From f21806051f192827b588e132c2469675a9765af7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 21 Sep 2026 19:52:40 +0000 Subject: [PATCH] Update SDK to version v4.51.0 - Generated from OpenAPI spec version v4.51.0 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 193 +- build.gradle | 4 +- build.sbt | 2 +- docs/APIError.md | 2 +- docs/AgentApi.md | 3365 ++++++++- docs/AnalysesCoreApi.md | 331 +- docs/AnalysisBasicInfoOutputBody.md | 1 + docs/AnalysisConfig.md | 2 +- docs/AnalysisCreateRequest.md | 6 +- docs/AnalysisDetailResponse.md | 2 +- docs/AnalysisFunctionEntry.md | 2 +- docs/AnalysisLogs.md | 2 +- docs/AnalysisRecordBody.md | 3 +- docs/AnalysisReport.md | 30 +- docs/AnalysisRequirement.md | 15 + docs/AnalysisStringItem.md | 2 +- docs/ApiCombinationEvidence.md | 45 + docs/ArrayDataType.md | 3 +- docs/BaseDataType.md | 1 + docs/BaseResponseListDieMatch.md | 2 +- docs/BaseResponseProtocolsAgentResponse.md | 17 + docs/BaseResponseSecretsAgentResponse.md | 17 + docs/BatchFunctionSignatureEntry.md | 2 +- docs/BatchMatchingOutputBody.md | 2 +- docs/BatchRenameInputBody.md | 2 +- docs/BinariesApi.md | 316 + docs/BinaryConfig.md | 39 +- docs/BitfieldDataType.md | 1 + docs/BulkCreateUserResult.md | 2 +- docs/BulkCreateUsersOutputBody.md | 2 +- docs/BytesConstant.md | 25 + docs/CallChain.md | 13 + docs/CallChainEvidence.md | 45 + docs/CallEdgesOutputBody.md | 2 +- docs/CanonicalizeNamesOutputBody.md | 2 +- docs/CapabilitiesOutputBody.md | 2 +- docs/CapabilitiesResult.md | 13 + docs/Capability.md | 18 + docs/CommentsData.md | 2 +- docs/Config.md | 16 + docs/ConfigApi.md | 142 + docs/Connection.md | 4 +- docs/ConversationWithEvents.md | 2 +- docs/CopyFunctionSignaturesInputBody.md | 2 +- docs/CopyFunctionSignaturesOutputBody.md | 2 +- docs/CreateArrayDataType.md | 2 +- docs/CreateCollectionOutputBody.md | 2 +- docs/CreateConversationRequest.md | 2 +- docs/CreateDataTypeEntry.md | 2 +- docs/CreateEnumDataType.md | 2 +- docs/CreateFunctionDataType.md | 2 +- docs/CreateMetadata.md | 28 + docs/CreatePointerDataType.md | 2 +- docs/CreateRequest.md | 32 + docs/CreateResult.md | 14 + docs/CreateStructDataType.md | 2 +- docs/CreateTypedefDataType.md | 2 +- docs/CreateUnionDataType.md | 2 +- docs/CryptoCall.md | 60 + docs/CryptoDirectMatch.md | 59 + docs/CryptoExplainMetadata.md | 27 + docs/CryptoExplainResult.md | 18 + docs/CryptoExplainedFunction.md | 15 + docs/CryptoFinding.md | 64 + docs/CryptoScanMetadata.md | 27 + docs/CryptoScanResult.md | 15 + docs/DataTypeEntry.md | 3 +- docs/DataTypeVersion.md | 2 +- docs/DecompilerSummary.md | 15 + docs/DecompilerSummaryEvidence.md | 45 + docs/DieMatch.md | 8 +- docs/Display.md | 29 + docs/DnsQuery.md | 2 +- docs/DynamicExecutionStatusResponse.md | 2 +- docs/Endianness.md | 17 + docs/EnumDataType.md | 3 +- docs/EnumDefinition.md | 2 +- docs/ErrorBody.md | 9 +- docs/EventAttemptFailed.md | 2 +- docs/EventAttemptStarted.md | 2 +- docs/EventCONTEXTCOMPACTED.md | 2 +- docs/EventDecompFailed.md | 2 +- docs/EventDecompFinished.md | 2 +- docs/EventNamesFinished.md | 25 + docs/EventProse.md | 2 +- docs/EventRUNCANCELLED.md | 2 +- docs/EventRUNERROR.md | 2 +- docs/EventRUNFINISHED.md | 2 +- docs/EventRUNSTARTED.md | 2 +- docs/EventRenameApplied.md | 2 +- docs/EventSTEPFINISHED.md | 2 +- docs/EventSTEPSTARTED.md | 2 +- docs/EventSourceDelta.md | 2 +- docs/EventSourceReset.md | 2 +- docs/EventTEXTMESSAGECONTENT.md | 2 +- docs/EventTEXTMESSAGEEND.md | 2 +- docs/EventTEXTMESSAGESTART.md | 2 +- docs/EventTITLEUPDATED.md | 2 +- docs/EventTOOLCALLARGSDELTA.md | 2 +- docs/EventTOOLCALLEND.md | 2 +- docs/EventTOOLCALLPROGRESS.md | 2 +- docs/EventTOOLCALLRESULT.md | 2 +- docs/EventTOOLCALLSTART.md | 2 +- docs/EventTOOLCONFIRMATIONREQUIRED.md | 2 +- docs/EventTypesSuggested.md | 25 + docs/EventWarning.md | 2 +- docs/EvidenceEffect.md | 15 + docs/EvidenceInner.md | 59 + docs/EvidenceStrength.md | 15 + docs/ExecutionCall.md | 62 + docs/ExecutionDirectMatch.md | 61 + docs/ExecutionExplainMetadata.md | 27 + docs/ExecutionExplainResult.md | 22 + docs/ExecutionExplainedFunction.md | 15 + docs/ExecutionFinding.md | 67 + docs/ExecutionScanMetadata.md | 27 + docs/ExecutionScanResult.md | 15 + docs/ExtractedBinary.md | 15 + docs/ExtractedURL.md | 2 +- docs/ExtractionFailure.md | 14 + docs/FeedbackOutputBody.md | 24 + docs/FileActivityEntry.md | 2 +- docs/FilesystemAnalyseMetadata.md | 27 + docs/FilesystemAnalyseResult.md | 21 + docs/FilesystemCall.md | 67 + docs/FilesystemDirectMatch.md | 66 + docs/FilesystemExplainedFunction.md | 15 + docs/FilesystemFinding.md | 72 + docs/FilesystemScanMetadata.md | 27 + docs/FilesystemScanResult.md | 15 + docs/Finding.md | 15 + docs/FirmwareApi.md | 161 - docs/FunctionBoundary.md | 4 +- docs/FunctionCallEdges.md | 4 +- docs/FunctionDataType.md | 3 +- docs/FunctionMatch.md | 4 +- docs/FunctionSignatureBody.md | 2 +- docs/FunctionSignatureEntry.md | 2 +- docs/FunctionSignatureVersion.md | 4 +- docs/FunctionSimilarity.md | 15 + docs/FunctionSimilarityEvidence.md | 45 + docs/FunctionTypeDefinition.md | 2 +- docs/FunctionsAiDecompilationApi.md | 93 +- docs/FunctionsProgressOutputBody.md | 15 + docs/FunctionsRenamingHistoryApi.md | 2 +- docs/GetAnalysisLogsOutputBody.md | 2 +- docs/GetCollectionOutputBody.md | 2 +- docs/GetConfigOutputBody.md | 14 + docs/GetDataTypeHistoryBody.md | 2 +- docs/GetDieInfoOutputBody.md | 13 + docs/GetFunctionSignatureHistoryBody.md | 2 +- docs/GetMatchesOutputBody.md | 2 +- docs/GetMatchesStatusOutputBody.md | 7 +- docs/GetModelsOutputBody.md | 13 + docs/GetProductsOutputBody.md | 2 +- docs/GetRelatedBinariesOutputBody.md | 14 + docs/GetRelatedStatusOutputBody.md | 26 + docs/GetSubscriptionOutputBody.md | 4 +- docs/GetTokensResponse.md | 4 +- docs/HardcodedSecretEvidence.md | 51 + docs/HttpRequest.md | 6 +- docs/IOC.md | 43 +- docs/ImportedApi.md | 14 + docs/ImportedApiCall.md | 15 + docs/ImportedApiCallEvidence.md | 45 + docs/ImportedFunctionDetailOutputBody.md | 2 +- docs/IndirectCallSitesOutputBody.md | 2 +- docs/InputBody.md | 13 + docs/KnownConstantEvidence.md | 45 + docs/ListAnalysesOutputBody.md | 2 +- docs/ListAnalysisFunctionsOutputBody.md | 2 +- docs/ListAnalysisStringsOutputBody.md | 2 +- docs/ListArchiveContentsOutputBody.md | 2 +- docs/ListCollectionsOutputBody.md | 2 +- docs/ListDataTypeFunctionsBody.md | 2 +- docs/ListExampleAnalysesOutputBody.md | 2 +- docs/ListFunctionSignaturesOutputBody.md | 4 +- docs/ListFunctionStringsOutputBody.md | 2 +- docs/ListImportedFunctionsOutputBody.md | 2 +- docs/ListTeamsOutputBody.md | 2 +- docs/ListUsersOutputBody.md | 2 +- docs/Meta.md | 13 + docs/Metadata.md | 27 + docs/ModelInterpretation.md | 13 + docs/ModelInterpretationEvidence.md | 36 + docs/MutexEntry.md | 2 +- docs/NamesFinishedEvent.md | 16 + docs/NetworkActivity.md | 8 +- docs/NetworkingCall.md | 66 + docs/NetworkingDirectMatch.md | 65 + docs/NetworkingExplainMetadata.md | 27 + docs/NetworkingExplainResult.md | 23 + docs/NetworkingExplainedFunction.md | 15 + docs/NetworkingFinding.md | 71 + docs/NetworkingScanMetadata.md | 27 + docs/NetworkingScanResult.md | 15 + docs/OperationCreateMetadataCreateResult.md | 17 + ...ryptoExplainMetadataCryptoExplainResult.md | 17 + ...ationCryptoScanMetadataCryptoScanResult.md | 17 + ...onExplainMetadataExecutionExplainResult.md | 17 + ...xecutionScanMetadataExecutionScanResult.md | 17 + ...mAnalyseMetadataFilesystemAnalyseResult.md | 17 + ...esystemScanMetadataFilesystemScanResult.md | 17 + docs/OperationMetadataCapabilitiesResult.md | 17 + docs/OperationMetadataRemediationResult.md | 17 + docs/OperationMetadataReportResult.md | 17 + docs/OperationMetadataThreatReportResult.md | 17 + docs/OperationMetadataTriageResult.md | 17 + ...gExplainMetadataNetworkingExplainResult.md | 17 + ...workingScanMetadataNetworkingScanResult.md | 17 + ...nSecurityScanMetadataSecurityScanResult.md | 17 + docs/OperationWorkflowProgressResultBody.md | 17 + docs/PatchCollectionBinariesOutputBody.md | 2 +- docs/PointerDataType.md | 3 +- docs/ProcessActivityEntry.md | 2 +- docs/ProcessMemdumps.md | 2 +- docs/ProcessNode.md | 2 +- docs/ProcessTree.md | 2 +- docs/ProductOutput.md | 2 +- docs/ProtocolsAgentResponse.md | 15 + docs/ReferencedConstant.md | 15 + docs/ReferencedConstantEvidence.md | 45 + docs/RegistryOperation.md | 2 +- docs/RelatedBinary.md | 16 + docs/RemediationResult.md | 15 + docs/RenameInputBody.md | 16 +- docs/ReportAnalysisResponse.md | 2 +- docs/ReportEvent.md | 2 +- docs/ReportInfo.md | 4 +- docs/ReportReachabilityStatus.md | 17 + docs/ReportResult.md | 14 + docs/ResolvedEntity.md | 2 + docs/ResultBody.md | 16 + docs/RuleKind.md | 29 + docs/SSOProvidersOutputBody.md | 2 +- docs/SandboxConfig.md | 41 + docs/ScheduledTaskEntry.md | 2 +- docs/ScreenshotEntry.md | 13 + docs/ScreenshotsIndex.md | 14 + docs/SecretsAgentResponse.md | 15 + docs/SecurityFinding.md | 58 + docs/SecurityScanMetadata.md | 27 + docs/SecurityScanResult.md | 18 + docs/SegmentInfo.md | 2 +- docs/SendMessageRequest.md | 2 +- docs/ServerSentEventsInner.md | 2 +- docs/ServerSentEventsInner1.md | 2 +- docs/ServiceEntry.md | 2 +- docs/SignatureParameterEntry.md | 2 +- docs/SignatureParameterInput.md | 2 +- docs/StartBatchMatchingInputBody.md | 1 + docs/StartMatchingForAnalysisInputBody.md | 2 +- docs/StartMatchingForFunctionsInputBody.md | 2 +- docs/StartMatchingOutputBody.md | 7 +- docs/Status.md | 73 + docs/StructDataType.md | 3 +- docs/StructDefinition.md | 2 +- docs/Subject.md | 17 + docs/SubjectAnyOf.md | 13 + docs/SubjectAnyOf1.md | 13 + docs/SubjectAnyOf2.md | 13 + docs/SubjectAnyOf3.md | 13 + docs/SubmitFeedbackInputBody.md | 24 + docs/SuggestedHole.md | 14 + docs/SuggestedMemberView.md | 45 + docs/SuggestedTypeView.md | 20 + docs/SummaryData.md | 1 + docs/SuspiciousString.md | 14 + docs/SuspiciousStringEvidence.md | 45 + docs/Symbols.md | 4 +- docs/Technique.md | 22 + docs/ThreatReportResult.md | 20 + docs/TokenisedData.md | 2 +- docs/TriageFunction.md | 17 + docs/TriageResult.md | 15 + docs/TriggerCryptoScanInputBody.md | 47 + docs/TriggerExecutionExplainInputBody.md | 31 + docs/TriggerExecutionScanInputBody.md | 49 + docs/TriggerFilesystemAnalyseInputBody.md | 37 + docs/TriggerFilesystemScanInputBody.md | 54 + docs/TriggerNetworkingExplainInputBody.md | 33 + docs/TriggerNetworkingScanInputBody.md | 53 + docs/TriggerSecurityScanInputBody.md | 13 + docs/TypeSuggestionsData.md | 28 + docs/TypedefDataType.md | 3 +- docs/TypesSuggestedEvent.md | 17 + docs/UnionDataType.md | 3 +- docs/UnionDefinition.md | 2 +- docs/UnknownDataType.md | 1 + docs/UpdateArrayDataType.md | 2 +- docs/UpdateDataTypeEntry.md | 2 +- docs/UpdateEnumDataType.md | 2 +- docs/UpdateFunctionDataType.md | 2 +- docs/UpdateFunctionSignatureInputBody.md | 2 +- docs/UpdatePointerDataType.md | 2 +- docs/UpdateStructDataType.md | 2 +- docs/UpdateTypedefDataType.md | 2 +- docs/UpdateUnionDataType.md | 2 +- docs/UpgradeAnalysisModelOutputBody.md | 15 + docs/UploadOutputBody.md | 32 + docs/UploadResponse.md | 1 + docs/UpsertOverridesData.md | 2 +- docs/UpsertOverridesInputBody.md | 2 +- docs/User.md | 2 +- docs/WorkflowProgress.md | 7 +- pom.xml | 2 +- src/main/java/ai/reveng/api/AgentApi.java | 6649 ++++++++++++++++- .../java/ai/reveng/api/AnalysesCoreApi.java | 999 ++- src/main/java/ai/reveng/api/BinariesApi.java | 601 ++ src/main/java/ai/reveng/api/ConfigApi.java | 245 + src/main/java/ai/reveng/api/FirmwareApi.java | 353 - .../api/FunctionsAiDecompilationApi.java | 200 +- .../api/FunctionsRenamingHistoryApi.java | 6 +- .../java/ai/reveng/invoker/ApiClient.java | 2 +- .../java/ai/reveng/invoker/Configuration.java | 2 +- src/main/java/ai/reveng/invoker/JSON.java | 150 + src/main/java/ai/reveng/model/APIError.java | 105 +- .../ai/reveng/model/AddCalleeInputBody.java | 103 +- .../model/AddCollectionBinariesInputBody.java | 103 +- .../reveng/model/AddUserStringInputBody.java | 103 +- .../AddUserStringToFunctionInputBody.java | 103 +- .../model/AnalysisBasicInfoOutputBody.java | 133 +- .../java/ai/reveng/model/AnalysisConfig.java | 4 - .../reveng/model/AnalysisCreateRequest.java | 12 - .../reveng/model/AnalysisDataTypesGroup.java | 103 +- .../model/AnalysisDataTypesOutputBody.java | 103 +- .../reveng/model/AnalysisDetailResponse.java | 2 - .../reveng/model/AnalysisFunctionEntry.java | 14 +- .../ai/reveng/model/AnalysisLogEntry.java | 103 +- .../ai/reveng/model/AnalysisLogMessage.java | 103 +- .../java/ai/reveng/model/AnalysisLogs.java | 117 +- .../ai/reveng/model/AnalysisRecordBody.java | 46 +- .../java/ai/reveng/model/AnalysisReport.java | 293 +- .../ai/reveng/model/AnalysisRequirement.java | 367 + .../reveng/model/AnalysisStringFunction.java | 103 +- .../ai/reveng/model/AnalysisStringItem.java | 117 +- .../java/ai/reveng/model/AnalysisTagBody.java | 103 +- src/main/java/ai/reveng/model/ApiCall.java | 103 +- .../reveng/model/ApiCombinationEvidence.java | 591 ++ .../java/ai/reveng/model/ArrayDataType.java | 135 +- .../java/ai/reveng/model/ArrayDefinition.java | 103 +- src/main/java/ai/reveng/model/Artifact.java | 103 +- .../ai/reveng/model/AttemptFailedEvent.java | 103 +- .../ai/reveng/model/AttemptStartedEvent.java | 103 +- .../java/ai/reveng/model/AutoRunAgents.java | 2 +- .../model/AutoUnstripStatusOutputBody.java | 103 +- .../java/ai/reveng/model/BaseDataType.java | 131 +- .../model/BaseResponseListDieMatch.java | 16 +- .../BaseResponseProtocolsAgentResponse.java | 429 ++ .../BaseResponseSecretsAgentResponse.java | 429 ++ .../model/BatchFunctionSignatureEntry.java | 117 +- .../reveng/model/BatchMatchingOutputBody.java | 14 +- .../ai/reveng/model/BatchRenameInputBody.java | 117 +- .../java/ai/reveng/model/BatchRenameItem.java | 103 +- .../reveng/model/BatchRenameOutputBody.java | 103 +- src/main/java/ai/reveng/model/Binary.java | 103 +- .../java/ai/reveng/model/BinaryConfig.java | 278 +- .../reveng/model/BinaryDetailsResponse.java | 66 +- .../ai/reveng/model/BitfieldDataType.java | 131 +- .../ai/reveng/model/BulkCreateUserResult.java | 4 - .../model/BulkCreateUsersOutputBody.java | 14 +- .../java/ai/reveng/model/BytesConstant.java | 405 + src/main/java/ai/reveng/model/CallChain.java | 302 + .../ai/reveng/model/CallChainEvidence.java | 586 ++ src/main/java/ai/reveng/model/CallEdge.java | 103 +- .../ai/reveng/model/CallEdgesOutputBody.java | 117 +- .../java/ai/reveng/model/CanonicalName.java | 103 +- .../model/CanonicalizeNamesInputBody.java | 103 +- .../model/CanonicalizeNamesOutputBody.java | 117 +- .../reveng/model/CapabilitiesOutputBody.java | 117 +- .../ai/reveng/model/CapabilitiesResult.java | 303 + src/main/java/ai/reveng/model/Capability.java | 431 ++ .../java/ai/reveng/model/CapabilityEntry.java | 103 +- .../reveng/model/CollectionListItemBody.java | 103 +- .../java/ai/reveng/model/CommentsData.java | 117 +- src/main/java/ai/reveng/model/Config.java | 359 + .../ai/reveng/model/ConfirmToolInputBody.java | 103 +- src/main/java/ai/reveng/model/Connection.java | 135 +- .../ai/reveng/model/ConsoleOutputEntry.java | 103 +- .../java/ai/reveng/model/Conversation.java | 103 +- .../ai/reveng/model/ConversationContext.java | 103 +- .../reveng/model/ConversationWithEvents.java | 117 +- .../CopyFunctionSignaturesInputBody.java | 117 +- .../CopyFunctionSignaturesOutputBody.java | 117 +- .../ai/reveng/model/CopySignatureItem.java | 103 +- .../model/CreateAIDecompOutputBody.java | 103 +- .../CreateAnalysisDataTypesInputBody.java | 103 +- .../ai/reveng/model/CreateArrayDataType.java | 105 +- .../ai/reveng/model/CreateBaseDataType.java | 103 +- .../reveng/model/CreateBitfieldDataType.java | 103 +- .../model/CreateCollectionInputBody.java | 103 +- .../model/CreateCollectionOutputBody.java | 119 +- .../model/CreateConversationRequest.java | 107 +- .../ai/reveng/model/CreateEnumDataType.java | 105 +- .../reveng/model/CreateFunctionDataType.java | 105 +- .../java/ai/reveng/model/CreateMetadata.java | 403 + .../reveng/model/CreatePointerDataType.java | 105 +- .../java/ai/reveng/model/CreateRequest.java | 596 ++ .../java/ai/reveng/model/CreateResult.java | 312 + .../ai/reveng/model/CreateStructDataType.java | 105 +- .../reveng/model/CreateTypedefDataType.java | 105 +- .../ai/reveng/model/CreateUnionDataType.java | 105 +- .../reveng/model/CreateUnknownDataType.java | 103 +- src/main/java/ai/reveng/model/CryptoCall.java | 599 ++ .../ai/reveng/model/CryptoDirectMatch.java | 570 ++ .../reveng/model/CryptoExplainMetadata.java | 403 + .../ai/reveng/model/CryptoExplainResult.java | 452 ++ .../reveng/model/CryptoExplainedFunction.java | 344 + .../java/ai/reveng/model/CryptoFinding.java | 785 ++ .../ai/reveng/model/CryptoScanMetadata.java | 403 + .../ai/reveng/model/CryptoScanResult.java | 365 + .../reveng/model/DataTypeEnumValueEntry.java | 103 +- .../reveng/model/DataTypeFunctionEntry.java | 103 +- .../model/DataTypeFunctionParameterEntry.java | 103 +- .../java/ai/reveng/model/DataTypeVersion.java | 107 +- .../ai/reveng/model/DecompFailedEvent.java | 103 +- .../ai/reveng/model/DecompFinishedEvent.java | 103 +- .../ai/reveng/model/DecompilationData.java | 103 +- .../ai/reveng/model/DecompilerSummary.java | 361 + .../model/DecompilerSummaryEvidence.java | 591 ++ src/main/java/ai/reveng/model/DieMatch.java | 72 +- src/main/java/ai/reveng/model/Display.java | 93 + src/main/java/ai/reveng/model/DnsQuery.java | 119 +- .../ai/reveng/model/DrakvufFileMetadata.java | 103 +- .../model/DynamicExecutionStatusResponse.java | 105 +- src/main/java/ai/reveng/model/Endianness.java | 81 + .../java/ai/reveng/model/EnumDataType.java | 135 +- .../java/ai/reveng/model/EnumDefinition.java | 117 +- src/main/java/ai/reveng/model/ErrorBody.java | 121 +- src/main/java/ai/reveng/model/Event.java | 103 +- .../ai/reveng/model/EventAttemptFailed.java | 2 - .../ai/reveng/model/EventAttemptStarted.java | 2 - .../reveng/model/EventCONTEXTCOMPACTED.java | 2 - .../ai/reveng/model/EventDecompFailed.java | 2 - .../ai/reveng/model/EventDecompFinished.java | 2 - .../ai/reveng/model/EventNamesFinished.java | 422 ++ src/main/java/ai/reveng/model/EventProse.java | 2 - .../ai/reveng/model/EventRUNCANCELLED.java | 2 - .../java/ai/reveng/model/EventRUNERROR.java | 2 - .../ai/reveng/model/EventRUNFINISHED.java | 2 - .../java/ai/reveng/model/EventRUNSTARTED.java | 2 - .../ai/reveng/model/EventRenameApplied.java | 2 - .../ai/reveng/model/EventSTEPFINISHED.java | 2 - .../ai/reveng/model/EventSTEPSTARTED.java | 2 - .../ai/reveng/model/EventSourceDelta.java | 2 - .../ai/reveng/model/EventSourceReset.java | 2 - .../reveng/model/EventTEXTMESSAGECONTENT.java | 2 - .../ai/reveng/model/EventTEXTMESSAGEEND.java | 2 - .../reveng/model/EventTEXTMESSAGESTART.java | 2 - .../ai/reveng/model/EventTITLEUPDATED.java | 2 - .../reveng/model/EventTOOLCALLARGSDELTA.java | 2 - .../ai/reveng/model/EventTOOLCALLEND.java | 2 - .../reveng/model/EventTOOLCALLPROGRESS.java | 2 - .../ai/reveng/model/EventTOOLCALLRESULT.java | 2 - .../ai/reveng/model/EventTOOLCALLSTART.java | 2 - .../model/EventTOOLCONFIRMATIONREQUIRED.java | 2 - .../ai/reveng/model/EventTypesSuggested.java | 422 ++ .../java/ai/reveng/model/EventWarning.java | 2 - .../java/ai/reveng/model/EvidenceEffect.java | 79 + .../java/ai/reveng/model/EvidenceInner.java | 657 ++ .../ai/reveng/model/EvidenceStrength.java | 79 + .../java/ai/reveng/model/ExecutionCall.java | 603 ++ .../ai/reveng/model/ExecutionDirectMatch.java | 574 ++ .../model/ExecutionExplainMetadata.java | 403 + .../reveng/model/ExecutionExplainResult.java | 577 ++ .../model/ExecutionExplainedFunction.java | 344 + .../ai/reveng/model/ExecutionFinding.java | 815 ++ .../reveng/model/ExecutionScanMetadata.java | 403 + .../ai/reveng/model/ExecutionScanResult.java | 365 + .../java/ai/reveng/model/ExtractedBinary.java | 344 + .../java/ai/reveng/model/ExtractedURL.java | 119 +- .../ai/reveng/model/ExtractionFailure.java | 315 + .../ai/reveng/model/FeedbackOutputBody.java | 349 + .../ai/reveng/model/FileActivityEntry.java | 119 +- .../model/FilesystemAnalyseMetadata.java | 403 + .../reveng/model/FilesystemAnalyseResult.java | 548 ++ .../java/ai/reveng/model/FilesystemCall.java | 613 ++ .../reveng/model/FilesystemDirectMatch.java | 584 ++ .../model/FilesystemExplainedFunction.java | 344 + .../ai/reveng/model/FilesystemFinding.java | 825 ++ .../reveng/model/FilesystemScanMetadata.java | 403 + .../ai/reveng/model/FilesystemScanResult.java | 365 + src/main/java/ai/reveng/model/Finding.java | 364 + .../ai/reveng/model/FunctionBoundary.java | 120 +- .../ai/reveng/model/FunctionCallEdges.java | 131 +- .../ai/reveng/model/FunctionDataType.java | 135 +- .../model/FunctionDetailsOutputBody.java | 103 +- .../java/ai/reveng/model/FunctionMatch.java | 133 +- .../reveng/model/FunctionSignatureBody.java | 14 +- .../reveng/model/FunctionSignatureEntry.java | 117 +- .../model/FunctionSignatureVersion.java | 109 +- .../ai/reveng/model/FunctionSimilarity.java | 347 + .../model/FunctionSimilarityEvidence.java | 591 ++ .../ai/reveng/model/FunctionStringItem.java | 103 +- .../reveng/model/FunctionTypeDefinition.java | 117 +- .../model/FunctionsProgressOutputBody.java | 338 + .../reveng/model/GeneratePDFOutputBody.java | 103 +- .../model/GetAdditionalDetailsOutputBody.java | 103 +- .../GetAdditionalDetailsStatusOutputBody.java | 103 +- .../model/GetAnalysisLogsOutputBody.java | 117 +- .../GetAnalysisStringsStatusOutputBody.java | 103 +- .../reveng/model/GetCollectionOutputBody.java | 119 +- .../ai/reveng/model/GetConfigOutputBody.java | 328 + .../reveng/model/GetDataTypeHistoryBody.java | 117 +- .../ai/reveng/model/GetDieInfoOutputBody.java | 303 + .../GetFunctionSignatureHistoryBody.java | 117 +- .../ai/reveng/model/GetMatchesOutputBody.java | 119 +- .../model/GetMatchesStatusOutputBody.java | 254 +- .../ai/reveng/model/GetModelsOutputBody.java | 302 + .../reveng/model/GetProductsOutputBody.java | 14 +- .../model/GetRelatedBinariesOutputBody.java | 329 + .../model/GetRelatedStatusOutputBody.java | 351 + .../model/GetSubscriptionOutputBody.java | 8 - .../ai/reveng/model/GetTokensResponse.java | 103 +- .../reveng/model/HardcodedSecretEvidence.java | 758 ++ .../java/ai/reveng/model/HistoryActor.java | 103 +- .../java/ai/reveng/model/HistoryEntry.java | 103 +- .../java/ai/reveng/model/HttpRequest.java | 127 +- src/main/java/ai/reveng/model/IOC.java | 270 +- .../java/ai/reveng/model/ImportedApi.java | 330 + .../java/ai/reveng/model/ImportedApiCall.java | 361 + .../reveng/model/ImportedApiCallEvidence.java | 591 ++ .../model/ImportedFunctionCallerEntry.java | 103 +- .../ImportedFunctionDetailOutputBody.java | 117 +- .../ai/reveng/model/IndirectCallSite.java | 103 +- .../model/IndirectCallSitesOutputBody.java | 117 +- .../java/ai/reveng/model/InlineComment.java | 103 +- src/main/java/ai/reveng/model/InputBody.java | 282 + .../reveng/model/KnownConstantEvidence.java | 587 ++ .../ai/reveng/model/LineAttributionsData.java | 103 +- .../reveng/model/ListAnalysesOutputBody.java | 117 +- .../ListAnalysisDataTypesOutputBody.java | 103 +- .../ListAnalysisFunctionsOutputBody.java | 117 +- .../model/ListAnalysisStringsOutputBody.java | 117 +- .../model/ListArchiveContentsOutputBody.java | 14 +- .../model/ListCollectionsOutputBody.java | 117 +- .../model/ListDataTypeFunctionsBody.java | 117 +- .../model/ListExampleAnalysesOutputBody.java | 117 +- .../ListFunctionSignaturesOutputBody.java | 133 +- .../model/ListFunctionStringsOutputBody.java | 117 +- .../ListImportedFunctionsOutputBody.java | 117 +- .../ai/reveng/model/ListTeamsOutputBody.java | 14 +- .../ai/reveng/model/ListUsersOutputBody.java | 14 +- .../java/ai/reveng/model/MemdumpEntry.java | 103 +- src/main/java/ai/reveng/model/Meta.java | 284 + src/main/java/ai/reveng/model/Metadata.java | 393 + .../ai/reveng/model/ModelInterpretation.java | 294 + .../model/ModelInterpretationEvidence.java | 537 ++ .../java/ai/reveng/model/ModuleLoadEntry.java | 103 +- src/main/java/ai/reveng/model/MutexEntry.java | 119 +- .../java/ai/reveng/model/NameConfidence.java | 103 +- .../ai/reveng/model/NamesFinishedEvent.java | 367 + .../java/ai/reveng/model/NetworkActivity.java | 167 +- .../java/ai/reveng/model/NetworkingCall.java | 611 ++ .../reveng/model/NetworkingDirectMatch.java | 582 ++ .../model/NetworkingExplainMetadata.java | 403 + .../reveng/model/NetworkingExplainResult.java | 606 ++ .../model/NetworkingExplainedFunction.java | 344 + .../ai/reveng/model/NetworkingFinding.java | 823 ++ .../reveng/model/NetworkingScanMetadata.java | 403 + .../ai/reveng/model/NetworkingScanResult.java | 365 + .../OperationCreateMetadataCreateResult.java | 396 + ...ptoExplainMetadataCryptoExplainResult.java | 396 + ...ionCryptoScanMetadataCryptoScanResult.java | 396 + ...ExplainMetadataExecutionExplainResult.java | 396 + ...cutionScanMetadataExecutionScanResult.java | 396 + ...nalyseMetadataFilesystemAnalyseResult.java | 396 + ...ystemScanMetadataFilesystemScanResult.java | 396 + .../OperationMetadataCapabilitiesResult.java | 396 + .../OperationMetadataRemediationResult.java | 396 + .../model/OperationMetadataReportResult.java | 396 + .../OperationMetadataThreatReportResult.java | 396 + .../model/OperationMetadataTriageResult.java | 396 + ...xplainMetadataNetworkingExplainResult.java | 396 + ...rkingScanMetadataNetworkingScanResult.java | 396 + ...ecurityScanMetadataSecurityScanResult.java | 396 + .../OperationWorkflowProgressResultBody.java | 396 + .../PatchCollectionBinariesInputBody.java | 103 +- .../PatchCollectionBinariesOutputBody.java | 117 +- .../model/PatchCollectionInputBody.java | 103 +- .../model/PatchCollectionOutputBody.java | 103 +- .../model/PatchCollectionTagsInputBody.java | 103 +- .../model/PatchCollectionTagsOutputBody.java | 103 +- .../ai/reveng/model/PatchCommentBody.java | 103 +- .../java/ai/reveng/model/PcapBodyInfo.java | 103 +- .../java/ai/reveng/model/Permissions.java | 103 +- .../java/ai/reveng/model/PointerDataType.java | 135 +- .../ai/reveng/model/PointerDefinition.java | 103 +- .../java/ai/reveng/model/PriceOutput.java | 103 +- .../java/ai/reveng/model/PriceSummary.java | 103 +- .../ai/reveng/model/ProcessActivityEntry.java | 119 +- .../java/ai/reveng/model/ProcessMemdumps.java | 119 +- .../java/ai/reveng/model/ProcessNode.java | 119 +- .../java/ai/reveng/model/ProcessTree.java | 119 +- .../java/ai/reveng/model/ProductOutput.java | 117 +- .../java/ai/reveng/model/ProductSummary.java | 103 +- .../java/ai/reveng/model/ProgressMessage.java | 103 +- src/main/java/ai/reveng/model/ProseEvent.java | 103 +- .../reveng/model/ProtocolsAgentResponse.java | 321 + .../ai/reveng/model/ReferencedConstant.java | 359 + .../model/ReferencedConstantEvidence.java | 591 ++ .../ai/reveng/model/RegenerateOutputBody.java | 103 +- .../ai/reveng/model/RegistryOperation.java | 119 +- .../java/ai/reveng/model/RelatedBinary.java | 370 + .../ai/reveng/model/RemediationResult.java | 382 + .../RemoveCollectionBinariesInputBody.java | 103 +- .../ai/reveng/model/RenameAppliedEvent.java | 103 +- .../java/ai/reveng/model/RenameInputBody.java | 198 +- .../ai/reveng/model/RenameOutputBody.java | 103 +- .../model/RenameUnnamedFunctionsResult.java | 103 +- .../java/ai/reveng/model/RenderedToken.java | 103 +- .../reveng/model/ReportAnalysisResponse.java | 14 +- .../java/ai/reveng/model/ReportEvent.java | 119 +- src/main/java/ai/reveng/model/ReportInfo.java | 111 +- .../java/ai/reveng/model/ReportOptions.java | 103 +- .../model/ReportReachabilityStatus.java | 81 + .../java/ai/reveng/model/ReportResult.java | 312 + .../java/ai/reveng/model/ResolvedEntity.java | 47 +- src/main/java/ai/reveng/model/ResultBody.java | 392 + src/main/java/ai/reveng/model/RuleKind.java | 93 + .../reveng/model/SSOProvidersOutputBody.java | 14 +- .../java/ai/reveng/model/SandboxConfig.java | 570 ++ .../ai/reveng/model/ScheduledTaskEntry.java | 119 +- .../reveng/model/ScrapeThirdPartyConfig.java | 2 +- .../java/ai/reveng/model/ScreenshotEntry.java | 286 + .../ai/reveng/model/ScreenshotsIndex.java | 329 + .../ai/reveng/model/SecretsAgentResponse.java | 321 + .../java/ai/reveng/model/SecurityFinding.java | 803 ++ .../ai/reveng/model/SecurityScanMetadata.java | 403 + .../ai/reveng/model/SecurityScanResult.java | 443 ++ .../java/ai/reveng/model/SegmentInfo.java | 2 +- .../ai/reveng/model/SendMessageRequest.java | 107 +- .../reveng/model/ServerSentEventsInner1.java | 104 +- .../java/ai/reveng/model/ServiceEntry.java | 119 +- .../reveng/model/SignatureParameterEntry.java | 107 +- .../reveng/model/SignatureParameterInput.java | 107 +- .../reveng/model/SignatureStorageEntry.java | 103 +- .../reveng/model/SignatureStorageInput.java | 103 +- .../ai/reveng/model/SourceDeltaEvent.java | 103 +- .../ai/reveng/model/SourceResetEvent.java | 103 +- .../model/SseEventContextCompactedData.java | 103 +- .../model/SseEventRunCancelledData.java | 103 +- .../ai/reveng/model/SseEventRunErrorData.java | 103 +- .../reveng/model/SseEventRunFinishedData.java | 103 +- .../reveng/model/SseEventRunStartedData.java | 103 +- .../model/SseEventStepFinishedData.java | 103 +- .../reveng/model/SseEventStepStartedData.java | 103 +- .../model/SseEventTextMessageContentData.java | 103 +- .../model/SseEventTextMessageEndData.java | 103 +- .../model/SseEventTextMessageStartData.java | 103 +- .../model/SseEventTitleUpdatedData.java | 103 +- .../model/SseEventToolCallArgsDeltaData.java | 103 +- .../reveng/model/SseEventToolCallEndData.java | 103 +- .../model/SseEventToolCallProgressData.java | 103 +- .../model/SseEventToolCallResultData.java | 103 +- .../model/SseEventToolCallStartData.java | 103 +- .../SseEventToolConfirmationRequiredData.java | 103 +- .../model/StartBatchMatchingInputBody.java | 30 +- .../StartMatchingForAnalysisInputBody.java | 4 - .../StartMatchingForFunctionsInputBody.java | 4 - .../reveng/model/StartMatchingOutputBody.java | 254 +- .../java/ai/reveng/model/StartupInfo.java | 103 +- src/main/java/ai/reveng/model/Status.java | 550 ++ src/main/java/ai/reveng/model/StatusBody.java | 103 +- .../java/ai/reveng/model/StatusResponse.java | 103 +- .../java/ai/reveng/model/StructDataType.java | 34 +- .../ai/reveng/model/StructDefinition.java | 117 +- src/main/java/ai/reveng/model/Subject.java | 358 + .../java/ai/reveng/model/SubjectAnyOf.java | 287 + .../java/ai/reveng/model/SubjectAnyOf1.java | 287 + .../java/ai/reveng/model/SubjectAnyOf2.java | 287 + .../java/ai/reveng/model/SubjectAnyOf3.java | 287 + .../reveng/model/SubmitFeedbackInputBody.java | 347 + .../java/ai/reveng/model/SuggestedHole.java | 312 + .../ai/reveng/model/SuggestedMemberView.java | 658 ++ .../ai/reveng/model/SuggestedTypeView.java | 512 ++ .../java/ai/reveng/model/SummaryData.java | 134 +- .../ai/reveng/model/SuspiciousString.java | 332 + .../model/SuspiciousStringEvidence.java | 591 ++ src/main/java/ai/reveng/model/Symbols.java | 44 +- .../java/ai/reveng/model/TcpCarvedFile.java | 103 +- src/main/java/ai/reveng/model/Team.java | 103 +- src/main/java/ai/reveng/model/Technique.java | 547 ++ .../ai/reveng/model/ThreatReportResult.java | 512 ++ src/main/java/ai/reveng/model/Token.java | 103 +- .../java/ai/reveng/model/TokenisedData.java | 16 +- .../java/ai/reveng/model/TriageFunction.java | 409 + .../java/ai/reveng/model/TriageResult.java | 358 + .../model/TriggerCryptoScanInputBody.java | 501 ++ .../TriggerExecutionExplainInputBody.java | 361 + .../model/TriggerExecutionScanInputBody.java | 505 ++ .../TriggerFilesystemAnalyseInputBody.java | 373 + .../model/TriggerFilesystemScanInputBody.java | 515 ++ .../TriggerNetworkingExplainInputBody.java | 365 + .../model/TriggerNetworkingScanInputBody.java | 513 ++ ...riggerRenameUnnamedFunctionsInputBody.java | 103 +- .../model/TriggerSecurityScanInputBody.java | 280 + src/main/java/ai/reveng/model/Ttp.java | 103 +- .../ai/reveng/model/TypeSuggestionsData.java | 423 ++ .../java/ai/reveng/model/TypedefDataType.java | 135 +- .../ai/reveng/model/TypedefDefinition.java | 103 +- .../ai/reveng/model/TypesSuggestedEvent.java | 393 + .../java/ai/reveng/model/UnionDataType.java | 135 +- .../java/ai/reveng/model/UnionDefinition.java | 117 +- .../java/ai/reveng/model/UnknownDataType.java | 131 +- .../UpdateAnalysisDataTypesInputBody.java | 103 +- .../ai/reveng/model/UpdateArrayDataType.java | 105 +- .../ai/reveng/model/UpdateBaseDataType.java | 103 +- .../reveng/model/UpdateBitfieldDataType.java | 103 +- .../ai/reveng/model/UpdateEnumDataType.java | 105 +- .../reveng/model/UpdateFunctionDataType.java | 105 +- .../UpdateFunctionSignatureInputBody.java | 117 +- .../reveng/model/UpdatePointerDataType.java | 105 +- .../ai/reveng/model/UpdateStructDataType.java | 105 +- .../reveng/model/UpdateTypedefDataType.java | 105 +- .../ai/reveng/model/UpdateUnionDataType.java | 105 +- .../reveng/model/UpdateUnknownDataType.java | 103 +- .../model/UpgradeAnalysisModelOutputBody.java | 338 + .../ai/reveng/model/UploadOutputBody.java | 557 ++ .../java/ai/reveng/model/UploadResponse.java | 47 +- .../ai/reveng/model/UpsertOverridesData.java | 103 +- .../model/UpsertOverridesInputBody.java | 103 +- src/main/java/ai/reveng/model/User.java | 105 +- .../java/ai/reveng/model/UserProfile.java | 103 +- .../java/ai/reveng/model/WarningEvent.java | 103 +- .../ai/reveng/model/WorkflowProgress.java | 254 +- 727 files changed, 95730 insertions(+), 5413 deletions(-) create mode 100644 docs/AnalysisRequirement.md create mode 100644 docs/ApiCombinationEvidence.md create mode 100644 docs/BaseResponseProtocolsAgentResponse.md create mode 100644 docs/BaseResponseSecretsAgentResponse.md create mode 100644 docs/BytesConstant.md create mode 100644 docs/CallChain.md create mode 100644 docs/CallChainEvidence.md create mode 100644 docs/CapabilitiesResult.md create mode 100644 docs/Capability.md create mode 100644 docs/Config.md create mode 100644 docs/CreateMetadata.md create mode 100644 docs/CreateRequest.md create mode 100644 docs/CreateResult.md create mode 100644 docs/CryptoCall.md create mode 100644 docs/CryptoDirectMatch.md create mode 100644 docs/CryptoExplainMetadata.md create mode 100644 docs/CryptoExplainResult.md create mode 100644 docs/CryptoExplainedFunction.md create mode 100644 docs/CryptoFinding.md create mode 100644 docs/CryptoScanMetadata.md create mode 100644 docs/CryptoScanResult.md create mode 100644 docs/DecompilerSummary.md create mode 100644 docs/DecompilerSummaryEvidence.md create mode 100644 docs/Display.md create mode 100644 docs/Endianness.md create mode 100644 docs/EventNamesFinished.md create mode 100644 docs/EventTypesSuggested.md create mode 100644 docs/EvidenceEffect.md create mode 100644 docs/EvidenceInner.md create mode 100644 docs/EvidenceStrength.md create mode 100644 docs/ExecutionCall.md create mode 100644 docs/ExecutionDirectMatch.md create mode 100644 docs/ExecutionExplainMetadata.md create mode 100644 docs/ExecutionExplainResult.md create mode 100644 docs/ExecutionExplainedFunction.md create mode 100644 docs/ExecutionFinding.md create mode 100644 docs/ExecutionScanMetadata.md create mode 100644 docs/ExecutionScanResult.md create mode 100644 docs/ExtractedBinary.md create mode 100644 docs/ExtractionFailure.md create mode 100644 docs/FeedbackOutputBody.md create mode 100644 docs/FilesystemAnalyseMetadata.md create mode 100644 docs/FilesystemAnalyseResult.md create mode 100644 docs/FilesystemCall.md create mode 100644 docs/FilesystemDirectMatch.md create mode 100644 docs/FilesystemExplainedFunction.md create mode 100644 docs/FilesystemFinding.md create mode 100644 docs/FilesystemScanMetadata.md create mode 100644 docs/FilesystemScanResult.md create mode 100644 docs/Finding.md delete mode 100644 docs/FirmwareApi.md create mode 100644 docs/FunctionSimilarity.md create mode 100644 docs/FunctionSimilarityEvidence.md create mode 100644 docs/FunctionsProgressOutputBody.md create mode 100644 docs/GetConfigOutputBody.md create mode 100644 docs/GetDieInfoOutputBody.md create mode 100644 docs/GetModelsOutputBody.md create mode 100644 docs/GetRelatedBinariesOutputBody.md create mode 100644 docs/GetRelatedStatusOutputBody.md create mode 100644 docs/HardcodedSecretEvidence.md create mode 100644 docs/ImportedApi.md create mode 100644 docs/ImportedApiCall.md create mode 100644 docs/ImportedApiCallEvidence.md create mode 100644 docs/InputBody.md create mode 100644 docs/KnownConstantEvidence.md create mode 100644 docs/Meta.md create mode 100644 docs/Metadata.md create mode 100644 docs/ModelInterpretation.md create mode 100644 docs/ModelInterpretationEvidence.md create mode 100644 docs/NamesFinishedEvent.md create mode 100644 docs/NetworkingCall.md create mode 100644 docs/NetworkingDirectMatch.md create mode 100644 docs/NetworkingExplainMetadata.md create mode 100644 docs/NetworkingExplainResult.md create mode 100644 docs/NetworkingExplainedFunction.md create mode 100644 docs/NetworkingFinding.md create mode 100644 docs/NetworkingScanMetadata.md create mode 100644 docs/NetworkingScanResult.md create mode 100644 docs/OperationCreateMetadataCreateResult.md create mode 100644 docs/OperationCryptoExplainMetadataCryptoExplainResult.md create mode 100644 docs/OperationCryptoScanMetadataCryptoScanResult.md create mode 100644 docs/OperationExecutionExplainMetadataExecutionExplainResult.md create mode 100644 docs/OperationExecutionScanMetadataExecutionScanResult.md create mode 100644 docs/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.md create mode 100644 docs/OperationFilesystemScanMetadataFilesystemScanResult.md create mode 100644 docs/OperationMetadataCapabilitiesResult.md create mode 100644 docs/OperationMetadataRemediationResult.md create mode 100644 docs/OperationMetadataReportResult.md create mode 100644 docs/OperationMetadataThreatReportResult.md create mode 100644 docs/OperationMetadataTriageResult.md create mode 100644 docs/OperationNetworkingExplainMetadataNetworkingExplainResult.md create mode 100644 docs/OperationNetworkingScanMetadataNetworkingScanResult.md create mode 100644 docs/OperationSecurityScanMetadataSecurityScanResult.md create mode 100644 docs/OperationWorkflowProgressResultBody.md create mode 100644 docs/ProtocolsAgentResponse.md create mode 100644 docs/ReferencedConstant.md create mode 100644 docs/ReferencedConstantEvidence.md create mode 100644 docs/RelatedBinary.md create mode 100644 docs/RemediationResult.md create mode 100644 docs/ReportReachabilityStatus.md create mode 100644 docs/ReportResult.md create mode 100644 docs/ResultBody.md create mode 100644 docs/RuleKind.md create mode 100644 docs/SandboxConfig.md create mode 100644 docs/ScreenshotEntry.md create mode 100644 docs/ScreenshotsIndex.md create mode 100644 docs/SecretsAgentResponse.md create mode 100644 docs/SecurityFinding.md create mode 100644 docs/SecurityScanMetadata.md create mode 100644 docs/SecurityScanResult.md create mode 100644 docs/Status.md create mode 100644 docs/Subject.md create mode 100644 docs/SubjectAnyOf.md create mode 100644 docs/SubjectAnyOf1.md create mode 100644 docs/SubjectAnyOf2.md create mode 100644 docs/SubjectAnyOf3.md create mode 100644 docs/SubmitFeedbackInputBody.md create mode 100644 docs/SuggestedHole.md create mode 100644 docs/SuggestedMemberView.md create mode 100644 docs/SuggestedTypeView.md create mode 100644 docs/SuspiciousString.md create mode 100644 docs/SuspiciousStringEvidence.md create mode 100644 docs/Technique.md create mode 100644 docs/ThreatReportResult.md create mode 100644 docs/TriageFunction.md create mode 100644 docs/TriageResult.md create mode 100644 docs/TriggerCryptoScanInputBody.md create mode 100644 docs/TriggerExecutionExplainInputBody.md create mode 100644 docs/TriggerExecutionScanInputBody.md create mode 100644 docs/TriggerFilesystemAnalyseInputBody.md create mode 100644 docs/TriggerFilesystemScanInputBody.md create mode 100644 docs/TriggerNetworkingExplainInputBody.md create mode 100644 docs/TriggerNetworkingScanInputBody.md create mode 100644 docs/TriggerSecurityScanInputBody.md create mode 100644 docs/TypeSuggestionsData.md create mode 100644 docs/TypesSuggestedEvent.md create mode 100644 docs/UpgradeAnalysisModelOutputBody.md create mode 100644 docs/UploadOutputBody.md delete mode 100644 src/main/java/ai/reveng/api/FirmwareApi.java create mode 100644 src/main/java/ai/reveng/model/AnalysisRequirement.java create mode 100644 src/main/java/ai/reveng/model/ApiCombinationEvidence.java create mode 100644 src/main/java/ai/reveng/model/BaseResponseProtocolsAgentResponse.java create mode 100644 src/main/java/ai/reveng/model/BaseResponseSecretsAgentResponse.java create mode 100644 src/main/java/ai/reveng/model/BytesConstant.java create mode 100644 src/main/java/ai/reveng/model/CallChain.java create mode 100644 src/main/java/ai/reveng/model/CallChainEvidence.java create mode 100644 src/main/java/ai/reveng/model/CapabilitiesResult.java create mode 100644 src/main/java/ai/reveng/model/Capability.java create mode 100644 src/main/java/ai/reveng/model/Config.java create mode 100644 src/main/java/ai/reveng/model/CreateMetadata.java create mode 100644 src/main/java/ai/reveng/model/CreateRequest.java create mode 100644 src/main/java/ai/reveng/model/CreateResult.java create mode 100644 src/main/java/ai/reveng/model/CryptoCall.java create mode 100644 src/main/java/ai/reveng/model/CryptoDirectMatch.java create mode 100644 src/main/java/ai/reveng/model/CryptoExplainMetadata.java create mode 100644 src/main/java/ai/reveng/model/CryptoExplainResult.java create mode 100644 src/main/java/ai/reveng/model/CryptoExplainedFunction.java create mode 100644 src/main/java/ai/reveng/model/CryptoFinding.java create mode 100644 src/main/java/ai/reveng/model/CryptoScanMetadata.java create mode 100644 src/main/java/ai/reveng/model/CryptoScanResult.java create mode 100644 src/main/java/ai/reveng/model/DecompilerSummary.java create mode 100644 src/main/java/ai/reveng/model/DecompilerSummaryEvidence.java create mode 100644 src/main/java/ai/reveng/model/Display.java create mode 100644 src/main/java/ai/reveng/model/Endianness.java create mode 100644 src/main/java/ai/reveng/model/EventNamesFinished.java create mode 100644 src/main/java/ai/reveng/model/EventTypesSuggested.java create mode 100644 src/main/java/ai/reveng/model/EvidenceEffect.java create mode 100644 src/main/java/ai/reveng/model/EvidenceInner.java create mode 100644 src/main/java/ai/reveng/model/EvidenceStrength.java create mode 100644 src/main/java/ai/reveng/model/ExecutionCall.java create mode 100644 src/main/java/ai/reveng/model/ExecutionDirectMatch.java create mode 100644 src/main/java/ai/reveng/model/ExecutionExplainMetadata.java create mode 100644 src/main/java/ai/reveng/model/ExecutionExplainResult.java create mode 100644 src/main/java/ai/reveng/model/ExecutionExplainedFunction.java create mode 100644 src/main/java/ai/reveng/model/ExecutionFinding.java create mode 100644 src/main/java/ai/reveng/model/ExecutionScanMetadata.java create mode 100644 src/main/java/ai/reveng/model/ExecutionScanResult.java create mode 100644 src/main/java/ai/reveng/model/ExtractedBinary.java create mode 100644 src/main/java/ai/reveng/model/ExtractionFailure.java create mode 100644 src/main/java/ai/reveng/model/FeedbackOutputBody.java create mode 100644 src/main/java/ai/reveng/model/FilesystemAnalyseMetadata.java create mode 100644 src/main/java/ai/reveng/model/FilesystemAnalyseResult.java create mode 100644 src/main/java/ai/reveng/model/FilesystemCall.java create mode 100644 src/main/java/ai/reveng/model/FilesystemDirectMatch.java create mode 100644 src/main/java/ai/reveng/model/FilesystemExplainedFunction.java create mode 100644 src/main/java/ai/reveng/model/FilesystemFinding.java create mode 100644 src/main/java/ai/reveng/model/FilesystemScanMetadata.java create mode 100644 src/main/java/ai/reveng/model/FilesystemScanResult.java create mode 100644 src/main/java/ai/reveng/model/Finding.java create mode 100644 src/main/java/ai/reveng/model/FunctionSimilarity.java create mode 100644 src/main/java/ai/reveng/model/FunctionSimilarityEvidence.java create mode 100644 src/main/java/ai/reveng/model/FunctionsProgressOutputBody.java create mode 100644 src/main/java/ai/reveng/model/GetConfigOutputBody.java create mode 100644 src/main/java/ai/reveng/model/GetDieInfoOutputBody.java create mode 100644 src/main/java/ai/reveng/model/GetModelsOutputBody.java create mode 100644 src/main/java/ai/reveng/model/GetRelatedBinariesOutputBody.java create mode 100644 src/main/java/ai/reveng/model/GetRelatedStatusOutputBody.java create mode 100644 src/main/java/ai/reveng/model/HardcodedSecretEvidence.java create mode 100644 src/main/java/ai/reveng/model/ImportedApi.java create mode 100644 src/main/java/ai/reveng/model/ImportedApiCall.java create mode 100644 src/main/java/ai/reveng/model/ImportedApiCallEvidence.java create mode 100644 src/main/java/ai/reveng/model/InputBody.java create mode 100644 src/main/java/ai/reveng/model/KnownConstantEvidence.java create mode 100644 src/main/java/ai/reveng/model/Meta.java create mode 100644 src/main/java/ai/reveng/model/Metadata.java create mode 100644 src/main/java/ai/reveng/model/ModelInterpretation.java create mode 100644 src/main/java/ai/reveng/model/ModelInterpretationEvidence.java create mode 100644 src/main/java/ai/reveng/model/NamesFinishedEvent.java create mode 100644 src/main/java/ai/reveng/model/NetworkingCall.java create mode 100644 src/main/java/ai/reveng/model/NetworkingDirectMatch.java create mode 100644 src/main/java/ai/reveng/model/NetworkingExplainMetadata.java create mode 100644 src/main/java/ai/reveng/model/NetworkingExplainResult.java create mode 100644 src/main/java/ai/reveng/model/NetworkingExplainedFunction.java create mode 100644 src/main/java/ai/reveng/model/NetworkingFinding.java create mode 100644 src/main/java/ai/reveng/model/NetworkingScanMetadata.java create mode 100644 src/main/java/ai/reveng/model/NetworkingScanResult.java create mode 100644 src/main/java/ai/reveng/model/OperationCreateMetadataCreateResult.java create mode 100644 src/main/java/ai/reveng/model/OperationCryptoExplainMetadataCryptoExplainResult.java create mode 100644 src/main/java/ai/reveng/model/OperationCryptoScanMetadataCryptoScanResult.java create mode 100644 src/main/java/ai/reveng/model/OperationExecutionExplainMetadataExecutionExplainResult.java create mode 100644 src/main/java/ai/reveng/model/OperationExecutionScanMetadataExecutionScanResult.java create mode 100644 src/main/java/ai/reveng/model/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.java create mode 100644 src/main/java/ai/reveng/model/OperationFilesystemScanMetadataFilesystemScanResult.java create mode 100644 src/main/java/ai/reveng/model/OperationMetadataCapabilitiesResult.java create mode 100644 src/main/java/ai/reveng/model/OperationMetadataRemediationResult.java create mode 100644 src/main/java/ai/reveng/model/OperationMetadataReportResult.java create mode 100644 src/main/java/ai/reveng/model/OperationMetadataThreatReportResult.java create mode 100644 src/main/java/ai/reveng/model/OperationMetadataTriageResult.java create mode 100644 src/main/java/ai/reveng/model/OperationNetworkingExplainMetadataNetworkingExplainResult.java create mode 100644 src/main/java/ai/reveng/model/OperationNetworkingScanMetadataNetworkingScanResult.java create mode 100644 src/main/java/ai/reveng/model/OperationSecurityScanMetadataSecurityScanResult.java create mode 100644 src/main/java/ai/reveng/model/OperationWorkflowProgressResultBody.java create mode 100644 src/main/java/ai/reveng/model/ProtocolsAgentResponse.java create mode 100644 src/main/java/ai/reveng/model/ReferencedConstant.java create mode 100644 src/main/java/ai/reveng/model/ReferencedConstantEvidence.java create mode 100644 src/main/java/ai/reveng/model/RelatedBinary.java create mode 100644 src/main/java/ai/reveng/model/RemediationResult.java create mode 100644 src/main/java/ai/reveng/model/ReportReachabilityStatus.java create mode 100644 src/main/java/ai/reveng/model/ReportResult.java create mode 100644 src/main/java/ai/reveng/model/ResultBody.java create mode 100644 src/main/java/ai/reveng/model/RuleKind.java create mode 100644 src/main/java/ai/reveng/model/SandboxConfig.java create mode 100644 src/main/java/ai/reveng/model/ScreenshotEntry.java create mode 100644 src/main/java/ai/reveng/model/ScreenshotsIndex.java create mode 100644 src/main/java/ai/reveng/model/SecretsAgentResponse.java create mode 100644 src/main/java/ai/reveng/model/SecurityFinding.java create mode 100644 src/main/java/ai/reveng/model/SecurityScanMetadata.java create mode 100644 src/main/java/ai/reveng/model/SecurityScanResult.java create mode 100644 src/main/java/ai/reveng/model/Status.java create mode 100644 src/main/java/ai/reveng/model/Subject.java create mode 100644 src/main/java/ai/reveng/model/SubjectAnyOf.java create mode 100644 src/main/java/ai/reveng/model/SubjectAnyOf1.java create mode 100644 src/main/java/ai/reveng/model/SubjectAnyOf2.java create mode 100644 src/main/java/ai/reveng/model/SubjectAnyOf3.java create mode 100644 src/main/java/ai/reveng/model/SubmitFeedbackInputBody.java create mode 100644 src/main/java/ai/reveng/model/SuggestedHole.java create mode 100644 src/main/java/ai/reveng/model/SuggestedMemberView.java create mode 100644 src/main/java/ai/reveng/model/SuggestedTypeView.java create mode 100644 src/main/java/ai/reveng/model/SuspiciousString.java create mode 100644 src/main/java/ai/reveng/model/SuspiciousStringEvidence.java create mode 100644 src/main/java/ai/reveng/model/Technique.java create mode 100644 src/main/java/ai/reveng/model/ThreatReportResult.java create mode 100644 src/main/java/ai/reveng/model/TriageFunction.java create mode 100644 src/main/java/ai/reveng/model/TriageResult.java create mode 100644 src/main/java/ai/reveng/model/TriggerCryptoScanInputBody.java create mode 100644 src/main/java/ai/reveng/model/TriggerExecutionExplainInputBody.java create mode 100644 src/main/java/ai/reveng/model/TriggerExecutionScanInputBody.java create mode 100644 src/main/java/ai/reveng/model/TriggerFilesystemAnalyseInputBody.java create mode 100644 src/main/java/ai/reveng/model/TriggerFilesystemScanInputBody.java create mode 100644 src/main/java/ai/reveng/model/TriggerNetworkingExplainInputBody.java create mode 100644 src/main/java/ai/reveng/model/TriggerNetworkingScanInputBody.java create mode 100644 src/main/java/ai/reveng/model/TriggerSecurityScanInputBody.java create mode 100644 src/main/java/ai/reveng/model/TypeSuggestionsData.java create mode 100644 src/main/java/ai/reveng/model/TypesSuggestedEvent.java create mode 100644 src/main/java/ai/reveng/model/UpgradeAnalysisModelOutputBody.java create mode 100644 src/main/java/ai/reveng/model/UploadOutputBody.java diff --git a/.sdk-version b/.sdk-version index 37c93bef..79477607 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v4.4.0 +v4.51.0 diff --git a/README.md b/README.md index b049f7e7..ce1d8b1d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add this dependency to your project's POM: ai.reveng sdk - 4.4.0 + 4.51.0 compile ``` @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation "ai.reveng:sdk:4.4.0" + implementation "ai.reveng:sdk:4.51.0" } ``` @@ -77,21 +77,60 @@ All URIs are relative to *https://api.reveng.ai* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AgentApi* | [**checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGet**](docs/AgentApi.md#checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/capabilities/status | Check the status of a capabilities analysis workflow +*AgentApi* | [**checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet**](docs/AgentApi.md#checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/protocols/status | Check the status of a protocols discovery workflow *AgentApi* | [**checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet**](docs/AgentApi.md#checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/remediation/status | Check the status of a remediation analysis workflow *AgentApi* | [**checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet**](docs/AgentApi.md#checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/report-analysis/status | Check the status of a report analysis workflow +*AgentApi* | [**checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet**](docs/AgentApi.md#checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/secrets/status | Check the status of a secrets discovery workflow *AgentApi* | [**checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet**](docs/AgentApi.md#checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/triage/status | Check the status of a triage analysis workflow *AgentApi* | [**createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost**](docs/AgentApi.md#createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost) | **POST** /v2/analyses/{analysis_id}/agent/capabilities | Queues a capabilities analysis workflow process +*AgentApi* | [**createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost**](docs/AgentApi.md#createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost) | **POST** /v2/analyses/{analysis_id}/agent/protocols | Queues a protocols discovery workflow process *AgentApi* | [**createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost**](docs/AgentApi.md#createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost) | **POST** /v2/analyses/{analysis_id}/agent/remediation | Queues a remediation analysis workflow process *AgentApi* | [**createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost**](docs/AgentApi.md#createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost) | **POST** /v2/analyses/{analysis_id}/agent/report-analysis | Queues a combined report analysis workflow process +*AgentApi* | [**createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost**](docs/AgentApi.md#createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost) | **POST** /v2/analyses/{analysis_id}/agent/secrets | Queues a secrets discovery workflow process *AgentApi* | [**createTriageTaskV2AnalysesAnalysisIdAgentTriagePost**](docs/AgentApi.md#createTriageTaskV2AnalysesAnalysisIdAgentTriagePost) | **POST** /v2/analyses/{analysis_id}/agent/triage | Queues a triage analysis workflow process *AgentApi* | [**getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet**](docs/AgentApi.md#getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet) | **GET** /v2/analyses/{analysis_id}/agent/capabilities | Get Capabilities Result +*AgentApi* | [**getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet**](docs/AgentApi.md#getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet) | **GET** /v2/analyses/{analysis_id}/agent/protocols | Get Protocols Result *AgentApi* | [**getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet**](docs/AgentApi.md#getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet) | **GET** /v2/analyses/{analysis_id}/agent/remediation | Get Remediation Result *AgentApi* | [**getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet**](docs/AgentApi.md#getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet) | **GET** /v2/analyses/{analysis_id}/agent/report-analysis | Get Report Analysis Result +*AgentApi* | [**getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet**](docs/AgentApi.md#getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet) | **GET** /v2/analyses/{analysis_id}/agent/secrets | Get Secrets Result *AgentApi* | [**getTriageResultV2AnalysesAnalysisIdAgentTriageGet**](docs/AgentApi.md#getTriageResultV2AnalysesAnalysisIdAgentTriageGet) | **GET** /v2/analyses/{analysis_id}/agent/triage | Get Triage Result *AgentApi* | [**v3CancelRenameUnnamedFunctions**](docs/AgentApi.md#v3CancelRenameUnnamedFunctions) | **POST** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions/cancel | Cancel the rename-unnamed-functions agent. +*AgentApi* | [**v3CancelSecurityScanOperation**](docs/AgentApi.md#v3CancelSecurityScanOperation) | **POST** /v3/operations/security-scan/{analysis_id}:cancel | Cancel a security-scan operation. +*AgentApi* | [**v3GetBinaryAgentFeedback**](docs/AgentApi.md#v3GetBinaryAgentFeedback) | **GET** /v3/analyses/{analysis_id}/agents/{agent}/feedback | Get the caller's feedback on an agent's output. +*AgentApi* | [**v3GetCapabilitiesOperation**](docs/AgentApi.md#v3GetCapabilitiesOperation) | **GET** /v3/operations/capabilities/{analysis_id} | Get a capabilities operation. +*AgentApi* | [**v3GetCryptoExplainOperation**](docs/AgentApi.md#v3GetCryptoExplainOperation) | **GET** /v3/operations/crypto-explain/{function_id} | Get a crypto-explain operation. +*AgentApi* | [**v3GetCryptoScanOperation**](docs/AgentApi.md#v3GetCryptoScanOperation) | **GET** /v3/operations/crypto-scan/{analysis_id} | Get a crypto-scan operation. +*AgentApi* | [**v3GetExecutionExplainOperation**](docs/AgentApi.md#v3GetExecutionExplainOperation) | **GET** /v3/operations/execution-explain/{function_id} | Get an execution-explain operation. +*AgentApi* | [**v3GetExecutionScanOperation**](docs/AgentApi.md#v3GetExecutionScanOperation) | **GET** /v3/operations/execution-scan/{analysis_id} | Get an execution-scan operation. +*AgentApi* | [**v3GetFilesystemAnalyseOperation**](docs/AgentApi.md#v3GetFilesystemAnalyseOperation) | **GET** /v3/operations/filesystem-analyse/{function_id} | Get a filesystem-analyse operation. +*AgentApi* | [**v3GetFilesystemScanOperation**](docs/AgentApi.md#v3GetFilesystemScanOperation) | **GET** /v3/operations/filesystem-scan/{analysis_id} | Get a filesystem-scan operation. +*AgentApi* | [**v3GetNetworkingExplainOperation**](docs/AgentApi.md#v3GetNetworkingExplainOperation) | **GET** /v3/operations/networking-explain/{function_id} | Get a networking-explain operation. +*AgentApi* | [**v3GetNetworkingScanOperation**](docs/AgentApi.md#v3GetNetworkingScanOperation) | **GET** /v3/operations/networking-scan/{analysis_id} | Get a networking-scan operation. +*AgentApi* | [**v3GetProtocolsOperation**](docs/AgentApi.md#v3GetProtocolsOperation) | **GET** /v3/operations/protocols/{analysis_id} | Get a protocols operation. +*AgentApi* | [**v3GetRemediationOperation**](docs/AgentApi.md#v3GetRemediationOperation) | **GET** /v3/operations/remediation/{analysis_id} | Get a remediation operation. *AgentApi* | [**v3GetRenameUnnamedFunctionsResult**](docs/AgentApi.md#v3GetRenameUnnamedFunctionsResult) | **GET** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions | Get rename-unnamed-functions agent result. *AgentApi* | [**v3GetRenameUnnamedFunctionsStatus**](docs/AgentApi.md#v3GetRenameUnnamedFunctionsStatus) | **GET** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions/status | Get rename-unnamed-functions agent status. +*AgentApi* | [**v3GetReportAnalysisOperation**](docs/AgentApi.md#v3GetReportAnalysisOperation) | **GET** /v3/operations/report-analysis/{analysis_id} | Get a report-analysis operation. +*AgentApi* | [**v3GetSecretsOperation**](docs/AgentApi.md#v3GetSecretsOperation) | **GET** /v3/operations/secrets/{analysis_id} | Get a secrets operation. +*AgentApi* | [**v3GetSecurityScanOperation**](docs/AgentApi.md#v3GetSecurityScanOperation) | **GET** /v3/operations/security-scan/{analysis_id} | Get a security-scan operation. +*AgentApi* | [**v3GetTriageOperation**](docs/AgentApi.md#v3GetTriageOperation) | **GET** /v3/operations/triage/{analysis_id} | Get a triage operation. +*AgentApi* | [**v3RunCapabilities**](docs/AgentApi.md#v3RunCapabilities) | **POST** /v3/analyses/{analysis_id}/capabilities:run | Run the capabilities agent. +*AgentApi* | [**v3RunCryptoExplain**](docs/AgentApi.md#v3RunCryptoExplain) | **POST** /v3/functions/{function_id}/crypto-explain:run | Run the crypto-explain agent. +*AgentApi* | [**v3RunCryptoScan**](docs/AgentApi.md#v3RunCryptoScan) | **POST** /v3/analyses/{analysis_id}/crypto-scan:run | Run the crypto-scan agent. +*AgentApi* | [**v3RunExecutionExplain**](docs/AgentApi.md#v3RunExecutionExplain) | **POST** /v3/functions/{function_id}/execution-explain:run | Run the execution-explain agent. +*AgentApi* | [**v3RunExecutionScan**](docs/AgentApi.md#v3RunExecutionScan) | **POST** /v3/analyses/{analysis_id}/execution-scan:run | Run the execution-scan agent. +*AgentApi* | [**v3RunFilesystemAnalyse**](docs/AgentApi.md#v3RunFilesystemAnalyse) | **POST** /v3/functions/{function_id}/filesystem-analyse:run | Run the filesystem-analyse agent. +*AgentApi* | [**v3RunFilesystemScan**](docs/AgentApi.md#v3RunFilesystemScan) | **POST** /v3/analyses/{analysis_id}/filesystem-scan:run | Run the filesystem-scan agent. +*AgentApi* | [**v3RunNetworkingExplain**](docs/AgentApi.md#v3RunNetworkingExplain) | **POST** /v3/functions/{function_id}/networking-explain:run | Run the networking-explain agent. +*AgentApi* | [**v3RunNetworkingScan**](docs/AgentApi.md#v3RunNetworkingScan) | **POST** /v3/analyses/{analysis_id}/networking-scan:run | Run the networking-scan agent. +*AgentApi* | [**v3RunProtocols**](docs/AgentApi.md#v3RunProtocols) | **POST** /v3/analyses/{analysis_id}/protocols:run | Run the protocols agent. +*AgentApi* | [**v3RunRemediation**](docs/AgentApi.md#v3RunRemediation) | **POST** /v3/analyses/{analysis_id}/remediation:run | Run the remediation agent. +*AgentApi* | [**v3RunReportAnalysis**](docs/AgentApi.md#v3RunReportAnalysis) | **POST** /v3/analyses/{analysis_id}/report-analysis:run | Run the report-analysis agent. +*AgentApi* | [**v3RunSecrets**](docs/AgentApi.md#v3RunSecrets) | **POST** /v3/analyses/{analysis_id}/secrets:run | Run the secrets agent. +*AgentApi* | [**v3RunSecurityScan**](docs/AgentApi.md#v3RunSecurityScan) | **POST** /v3/analyses/{analysis_id}/security-scan:run | Run the security-scan agent. +*AgentApi* | [**v3RunTriage**](docs/AgentApi.md#v3RunTriage) | **POST** /v3/analyses/{analysis_id}/triage:run | Run the triage agent. *AgentApi* | [**v3TriggerRenameUnnamedFunctions**](docs/AgentApi.md#v3TriggerRenameUnnamedFunctions) | **POST** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions | Run the rename-unnamed-functions agent. +*AgentApi* | [**v3UpsertBinaryAgentFeedback**](docs/AgentApi.md#v3UpsertBinaryAgentFeedback) | **PUT** /v3/analyses/{analysis_id}/agents/{agent}/feedback | Record feedback on an agent's output. *AnalysesBulkActionsApi* | [**bulkAddAnalysisTags**](docs/AnalysesBulkActionsApi.md#bulkAddAnalysisTags) | **PATCH** /v2/analyses/tags/add | Bulk Add Analysis Tags *AnalysesBulkActionsApi* | [**bulkDeleteAnalyses**](docs/AnalysesBulkActionsApi.md#bulkDeleteAnalyses) | **PATCH** /v2/analyses/delete | Bulk Delete Analyses *AnalysesCommentsApi* | [**createAnalysisComment**](docs/AnalysesCommentsApi.md#createAnalysisComment) | **POST** /v2/analyses/{analysis_id}/comments | Create a comment for this analysis @@ -121,12 +160,16 @@ Class | Method | HTTP request | Description *AnalysesCoreApi* | [**updateAnalysis**](docs/AnalysesCoreApi.md#updateAnalysis) | **PATCH** /v2/analyses/{analysis_id} | Update Analysis *AnalysesCoreApi* | [**updateAnalysisTags**](docs/AnalysesCoreApi.md#updateAnalysisTags) | **PATCH** /v2/analyses/{analysis_id}/tags | Update Analysis Tags *AnalysesCoreApi* | [**uploadFile**](docs/AnalysesCoreApi.md#uploadFile) | **POST** /v2/upload | Upload File +*AnalysesCoreApi* | [**v3CreateAnalysis**](docs/AnalysesCoreApi.md#v3CreateAnalysis) | **POST** /v3/analyses | Create an analysis *AnalysesCoreApi* | [**v3GetAnalysisAutoUnstripStatus**](docs/AnalysesCoreApi.md#v3GetAnalysisAutoUnstripStatus) | **GET** /v3/analyses/{analysis_id}/auto-unstrip/status | Get the auto-unstrip status for an analysis. +*AnalysesCoreApi* | [**v3GetAnalysisFunctionsProgress**](docs/AnalysesCoreApi.md#v3GetAnalysisFunctionsProgress) | **GET** /v3/analyses/{analysis_id}/progress/functions | Get function embedding progress for an analysis. *AnalysesCoreApi* | [**v3GetAnalysisLogs**](docs/AnalysesCoreApi.md#v3GetAnalysisLogs) | **GET** /v3/analyses/{analysis_id}/logs | Get the Analysis log +*AnalysesCoreApi* | [**v3GetAnalysisOperation**](docs/AnalysesCoreApi.md#v3GetAnalysisOperation) | **GET** /v3/operations/analyses/{analysis_id} | Get an Analysis-creation operation *AnalysesCoreApi* | [**v3GetAnalysisStrings**](docs/AnalysesCoreApi.md#v3GetAnalysisStrings) | **GET** /v3/analyses/{analysis_id}/functions/strings | List strings for an analysis. *AnalysesCoreApi* | [**v3GetAnalysisStringsStatus**](docs/AnalysesCoreApi.md#v3GetAnalysisStringsStatus) | **GET** /v3/analyses/{analysis_id}/functions/strings/status | Get the string-extraction status for an analysis. *AnalysesCoreApi* | [**v3ListAnalyses**](docs/AnalysesCoreApi.md#v3ListAnalyses) | **GET** /v3/analyses | List analyses *AnalysesCoreApi* | [**v3ListExampleAnalyses**](docs/AnalysesCoreApi.md#v3ListExampleAnalyses) | **GET** /v3/analyses/examples | List example analyses +*AnalysesCoreApi* | [**v3UpgradeAnalysisModel**](docs/AnalysesCoreApi.md#v3UpgradeAnalysisModel) | **POST** /v3/analyses/{analysis_id}/upgrade-model | Re-analyse on the latest model *AnalysesResultsMetadataApi* | [**getAnalysisFunctionsPaginated**](docs/AnalysesResultsMetadataApi.md#getAnalysisFunctionsPaginated) | **GET** /v2/analyses/{analysis_id}/functions | Get functions from analysis *AnalysesResultsMetadataApi* | [**getCapabilities**](docs/AnalysesResultsMetadataApi.md#getCapabilities) | **GET** /v2/analyses/{analysis_id}/capabilities | Gets the capabilities from the analysis *AnalysesResultsMetadataApi* | [**getFunctionsList**](docs/AnalysesResultsMetadataApi.md#getFunctionsList) | **GET** /v2/analyses/{analysis_id}/functions/list | Gets functions from analysis @@ -145,6 +188,10 @@ Class | Method | HTTP request | Description *BinariesApi* | [**getBinaryExternals**](docs/BinariesApi.md#getBinaryExternals) | **GET** /v2/binaries/{binary_id}/externals | Gets the external details of a binary *BinariesApi* | [**getBinaryRelatedStatus**](docs/BinariesApi.md#getBinaryRelatedStatus) | **GET** /v2/binaries/{binary_id}/related/status | Gets the status of the unpack binary task for a binary *BinariesApi* | [**getRelatedBinaries**](docs/BinariesApi.md#getRelatedBinaries) | **GET** /v2/binaries/{binary_id}/related | Gets the related binaries of a binary. +*BinariesApi* | [**v3GetBinaryDieInfo**](docs/BinariesApi.md#v3GetBinaryDieInfo) | **GET** /v3/binaries/{binary_id}/die-info | Get Detect It Easy matches for a binary. +*BinariesApi* | [**v3GetBinaryRelated**](docs/BinariesApi.md#v3GetBinaryRelated) | **GET** /v3/binaries/{binary_id}/related | Get the binaries related to this one by unpacking. +*BinariesApi* | [**v3GetBinaryRelatedStatus**](docs/BinariesApi.md#v3GetBinaryRelatedStatus) | **GET** /v3/binaries/{binary_id}/related/status | Get the archive-unpacking status for a binary. +*BinariesApi* | [**v3UploadFile**](docs/BinariesApi.md#v3UploadFile) | **POST** /v3/upload | Upload a file. *CollectionsApi* | [**createCollection**](docs/CollectionsApi.md#createCollection) | **POST** /v2/collections | Creates new collection information *CollectionsApi* | [**deleteCollection**](docs/CollectionsApi.md#deleteCollection) | **DELETE** /v2/collections/{collection_id} | Deletes a collection *CollectionsApi* | [**getCollection**](docs/CollectionsApi.md#getCollection) | **GET** /v2/collections/{collection_id} | Returns a collection @@ -162,6 +209,8 @@ Class | Method | HTTP request | Description *CollectionsApi* | [**v3PatchCollectionTags**](docs/CollectionsApi.md#v3PatchCollectionTags) | **PATCH** /v3/collections/{collection_id}/tags | Replace the tags on a collection. *CollectionsApi* | [**v3RemoveCollectionBinaries**](docs/CollectionsApi.md#v3RemoveCollectionBinaries) | **DELETE** /v3/collections/{collection_id}/binaries | Remove binaries from a collection. *ConfigApi* | [**getConfig**](docs/ConfigApi.md#getConfig) | **GET** /v2/config | Get Config +*ConfigApi* | [**v3GetConfig**](docs/ConfigApi.md#v3GetConfig) | **GET** /v3/config | Get client configuration. +*ConfigApi* | [**v3GetModels**](docs/ConfigApi.md#v3GetModels) | **GET** /v3/models | Get the models available for analysis. *ConversationsApi* | [**cancelRun**](docs/ConversationsApi.md#cancelRun) | **POST** /v2/conversations/{id}/cancel | Cancel an active run *ConversationsApi* | [**confirmTool**](docs/ConversationsApi.md#confirmTool) | **POST** /v2/conversations/{id}/confirm | Approve or reject a pending tool confirmation *ConversationsApi* | [**createConversation**](docs/ConversationsApi.md#createConversation) | **POST** /v2/conversations | Create a new conversation @@ -183,8 +232,6 @@ Class | Method | HTTP request | Description *ExternalSourcesApi* | [**createExternalTaskVt**](docs/ExternalSourcesApi.md#createExternalTaskVt) | **POST** /v2/analysis/{analysis_id}/external/vt | Pulls data from VirusTotal *ExternalSourcesApi* | [**getVtData**](docs/ExternalSourcesApi.md#getVtData) | **GET** /v2/analysis/{analysis_id}/external/vt | Get VirusTotal data *ExternalSourcesApi* | [**getVtTaskStatus**](docs/ExternalSourcesApi.md#getVtTaskStatus) | **GET** /v2/analysis/{analysis_id}/external/vt/status | Check the status of VirusTotal data retrieval -*FirmwareApi* | [**getBinariesForFirmwareTask**](docs/FirmwareApi.md#getBinariesForFirmwareTask) | **GET** /v2/firmware/get-binaries/{task_id} | Upload firmware for unpacking -*FirmwareApi* | [**uploadFirmware**](docs/FirmwareApi.md#uploadFirmware) | **POST** /v2/firmware | Upload firmware for unpacking *FunctionsAiDecompilationApi* | [**createAiDecompilation**](docs/FunctionsAiDecompilationApi.md#createAiDecompilation) | **POST** /v3/functions/{function_id}/ai-decompilation | Start AI decompilation *FunctionsAiDecompilationApi* | [**deleteAiDecompilationInlineComment**](docs/FunctionsAiDecompilationApi.md#deleteAiDecompilationInlineComment) | **DELETE** /v3/functions/{function_id}/ai-decompilation/inline-comments/{line} | Delete a single inline comment *FunctionsAiDecompilationApi* | [**getAiDecompilation**](docs/FunctionsAiDecompilationApi.md#getAiDecompilation) | **GET** /v3/functions/{function_id}/ai-decompilation | Get AI decompilation result @@ -201,6 +248,7 @@ Class | Method | HTTP request | Description *FunctionsAiDecompilationApi* | [**upsertAiDecompilationRating**](docs/FunctionsAiDecompilationApi.md#upsertAiDecompilationRating) | **PATCH** /v2/functions/{function_id}/ai-decompilation/rating | Upsert rating for AI decompilation *FunctionsAiDecompilationApi* | [**v3GetAiDecompilationLineAttributions**](docs/FunctionsAiDecompilationApi.md#v3GetAiDecompilationLineAttributions) | **GET** /v3/functions/{function_id}/ai-decompilation/line-attributions | Get AI decompilation line attributions *FunctionsAiDecompilationApi* | [**v3GetAiDecompilationTokens**](docs/FunctionsAiDecompilationApi.md#v3GetAiDecompilationTokens) | **GET** /v3/functions/{function_id}/ai-decompilation/tokens | Get AI decompilation tokens and user overrides +*FunctionsAiDecompilationApi* | [**v3GetAiDecompilationTypeSuggestions**](docs/FunctionsAiDecompilationApi.md#v3GetAiDecompilationTypeSuggestions) | **GET** /v3/functions/{function_id}/ai-decompilation/type-suggestions | Get AI decompilation type suggestions *FunctionsAiDecompilationApi* | [**v3UpsertAiDecompilationOverrides**](docs/FunctionsAiDecompilationApi.md#v3UpsertAiDecompilationOverrides) | **PATCH** /v3/functions/{function_id}/ai-decompilation/overrides | Upsert variable/function name overrides *FunctionsCoreApi* | [**addFunctionCallee**](docs/FunctionsCoreApi.md#addFunctionCallee) | **POST** /v3/functions/{function_id}/callees | Add a callee to a function *FunctionsCoreApi* | [**addUserStringToFunction**](docs/FunctionsCoreApi.md#addUserStringToFunction) | **POST** /v3/functions/{function_id}/user-provided-strings | Add a user-provided string to a function. @@ -280,6 +328,7 @@ Class | Method | HTTP request | Description - [AnalysisRecord](docs/AnalysisRecord.md) - [AnalysisRecordBody](docs/AnalysisRecordBody.md) - [AnalysisReport](docs/AnalysisReport.md) + - [AnalysisRequirement](docs/AnalysisRequirement.md) - [AnalysisScope](docs/AnalysisScope.md) - [AnalysisStringFunction](docs/AnalysisStringFunction.md) - [AnalysisStringInput](docs/AnalysisStringInput.md) @@ -292,6 +341,7 @@ Class | Method | HTTP request | Description - [AnalysisUpdateTagsRequest](docs/AnalysisUpdateTagsRequest.md) - [AnalysisUpdateTagsResponse](docs/AnalysisUpdateTagsResponse.md) - [ApiCall](docs/ApiCall.md) + - [ApiCombinationEvidence](docs/ApiCombinationEvidence.md) - [AppApiRestV2AgentSchemaCapability](docs/AppApiRestV2AgentSchemaCapability.md) - [AppApiRestV2AnalysesEnumsOrderBy](docs/AppApiRestV2AnalysesEnumsOrderBy.md) - [AppApiRestV2CollectionsEnumsOrderBy](docs/AppApiRestV2CollectionsEnumsOrderBy.md) @@ -354,10 +404,12 @@ Class | Method | HTTP request | Description - [BaseResponseLogs](docs/BaseResponseLogs.md) - [BaseResponseModelsResponse](docs/BaseResponseModelsResponse.md) - [BaseResponseParams](docs/BaseResponseParams.md) + - [BaseResponseProtocolsAgentResponse](docs/BaseResponseProtocolsAgentResponse.md) - [BaseResponseQueuedWorkflowTaskResponse](docs/BaseResponseQueuedWorkflowTaskResponse.md) - [BaseResponseRecent](docs/BaseResponseRecent.md) - [BaseResponseRemediationAgentResponse](docs/BaseResponseRemediationAgentResponse.md) - [BaseResponseReportAnalysisResponse](docs/BaseResponseReportAnalysisResponse.md) + - [BaseResponseSecretsAgentResponse](docs/BaseResponseSecretsAgentResponse.md) - [BaseResponseStatus](docs/BaseResponseStatus.md) - [BaseResponseStr](docs/BaseResponseStr.md) - [BaseResponseTagSearchResponse](docs/BaseResponseTagSearchResponse.md) @@ -389,6 +441,9 @@ Class | Method | HTTP request | Description - [BulkCreateUserResult](docs/BulkCreateUserResult.md) - [BulkCreateUsersOutputBody](docs/BulkCreateUsersOutputBody.md) - [BulkDeleteAnalysesRequest](docs/BulkDeleteAnalysesRequest.md) + - [BytesConstant](docs/BytesConstant.md) + - [CallChain](docs/CallChain.md) + - [CallChainEvidence](docs/CallChainEvidence.md) - [CallEdge](docs/CallEdge.md) - [CallEdgesOutputBody](docs/CallEdgesOutputBody.md) - [CalleeFunctionInfo](docs/CalleeFunctionInfo.md) @@ -400,6 +455,8 @@ Class | Method | HTTP request | Description - [Capabilities](docs/Capabilities.md) - [CapabilitiesAgentResponse](docs/CapabilitiesAgentResponse.md) - [CapabilitiesOutputBody](docs/CapabilitiesOutputBody.md) + - [CapabilitiesResult](docs/CapabilitiesResult.md) + - [Capability](docs/Capability.md) - [CapabilityEntry](docs/CapabilityEntry.md) - [ChildBinariesResponse](docs/ChildBinariesResponse.md) - [CodeSignatureModel](docs/CodeSignatureModel.md) @@ -421,6 +478,7 @@ Class | Method | HTTP request | Description - [CommentResponse](docs/CommentResponse.md) - [CommentUpdateRequest](docs/CommentUpdateRequest.md) - [CommentsData](docs/CommentsData.md) + - [Config](docs/Config.md) - [ConfigResponse](docs/ConfigResponse.md) - [ConfirmToolInputBody](docs/ConfirmToolInputBody.md) - [Connection](docs/Connection.md) @@ -447,9 +505,12 @@ Class | Method | HTTP request | Description - [CreateGroupInputBody](docs/CreateGroupInputBody.md) - [CreateIdentityInputBody](docs/CreateIdentityInputBody.md) - [CreateIssuerInputBody](docs/CreateIssuerInputBody.md) + - [CreateMetadata](docs/CreateMetadata.md) - [CreateOrganisationInputBody](docs/CreateOrganisationInputBody.md) - [CreatePointerDataType](docs/CreatePointerDataType.md) - [CreatePortalSessionInputBody](docs/CreatePortalSessionInputBody.md) + - [CreateRequest](docs/CreateRequest.md) + - [CreateResult](docs/CreateResult.md) - [CreateStructDataType](docs/CreateStructDataType.md) - [CreateTeamInputBody](docs/CreateTeamInputBody.md) - [CreateTypedefDataType](docs/CreateTypedefDataType.md) @@ -457,6 +518,14 @@ Class | Method | HTTP request | Description - [CreateUnknownDataType](docs/CreateUnknownDataType.md) - [CreateUserInputBody](docs/CreateUserInputBody.md) - [Created](docs/Created.md) + - [CryptoCall](docs/CryptoCall.md) + - [CryptoDirectMatch](docs/CryptoDirectMatch.md) + - [CryptoExplainMetadata](docs/CryptoExplainMetadata.md) + - [CryptoExplainResult](docs/CryptoExplainResult.md) + - [CryptoExplainedFunction](docs/CryptoExplainedFunction.md) + - [CryptoFinding](docs/CryptoFinding.md) + - [CryptoScanMetadata](docs/CryptoScanMetadata.md) + - [CryptoScanResult](docs/CryptoScanResult.md) - [DataTypeEntry](docs/DataTypeEntry.md) - [DataTypeEnumValueEntry](docs/DataTypeEnumValueEntry.md) - [DataTypeFunctionEntry](docs/DataTypeFunctionEntry.md) @@ -467,8 +536,11 @@ Class | Method | HTTP request | Description - [DecompFinishedEvent](docs/DecompFinishedEvent.md) - [DecompilationCommentContext](docs/DecompilationCommentContext.md) - [DecompilationData](docs/DecompilationData.md) + - [DecompilerSummary](docs/DecompilerSummary.md) + - [DecompilerSummaryEvidence](docs/DecompilerSummaryEvidence.md) - [DieMatch](docs/DieMatch.md) - [DisassemblyOutputBody](docs/DisassemblyOutputBody.md) + - [Display](docs/Display.md) - [DnsQuery](docs/DnsQuery.md) - [DrakvufFileMetadata](docs/DrakvufFileMetadata.md) - [DynamicExecutionStatus](docs/DynamicExecutionStatus.md) @@ -481,6 +553,7 @@ Class | Method | HTTP request | Description - [ELFSegment](docs/ELFSegment.md) - [ELFSymbol](docs/ELFSymbol.md) - [ElfDynamicEntry](docs/ElfDynamicEntry.md) + - [Endianness](docs/Endianness.md) - [EntrypointModel](docs/EntrypointModel.md) - [EnumDataType](docs/EnumDataType.md) - [EnumDefinition](docs/EnumDefinition.md) @@ -492,6 +565,7 @@ Class | Method | HTTP request | Description - [EventCONTEXTCOMPACTED](docs/EventCONTEXTCOMPACTED.md) - [EventDecompFailed](docs/EventDecompFailed.md) - [EventDecompFinished](docs/EventDecompFinished.md) + - [EventNamesFinished](docs/EventNamesFinished.md) - [EventProse](docs/EventProse.md) - [EventRUNCANCELLED](docs/EventRUNCANCELLED.md) - [EventRUNERROR](docs/EventRUNERROR.md) @@ -512,16 +586,40 @@ Class | Method | HTTP request | Description - [EventTOOLCALLRESULT](docs/EventTOOLCALLRESULT.md) - [EventTOOLCALLSTART](docs/EventTOOLCALLSTART.md) - [EventTOOLCONFIRMATIONREQUIRED](docs/EventTOOLCONFIRMATIONREQUIRED.md) + - [EventTypesSuggested](docs/EventTypesSuggested.md) - [EventWarning](docs/EventWarning.md) + - [EvidenceEffect](docs/EvidenceEffect.md) + - [EvidenceInner](docs/EvidenceInner.md) + - [EvidenceStrength](docs/EvidenceStrength.md) - [Example](docs/Example.md) + - [ExecutionCall](docs/ExecutionCall.md) + - [ExecutionDirectMatch](docs/ExecutionDirectMatch.md) + - [ExecutionExplainMetadata](docs/ExecutionExplainMetadata.md) + - [ExecutionExplainResult](docs/ExecutionExplainResult.md) + - [ExecutionExplainedFunction](docs/ExecutionExplainedFunction.md) + - [ExecutionFinding](docs/ExecutionFinding.md) + - [ExecutionScanMetadata](docs/ExecutionScanMetadata.md) + - [ExecutionScanResult](docs/ExecutionScanResult.md) - [ExportModel](docs/ExportModel.md) - [ExternalResponse](docs/ExternalResponse.md) + - [ExtractedBinary](docs/ExtractedBinary.md) - [ExtractedURL](docs/ExtractedURL.md) + - [ExtractionFailure](docs/ExtractionFailure.md) + - [FeedbackOutputBody](docs/FeedbackOutputBody.md) - [FileActivityEntry](docs/FileActivityEntry.md) - [FileFormat](docs/FileFormat.md) - [FileHashes](docs/FileHashes.md) - [FileMetadata](docs/FileMetadata.md) + - [FilesystemAnalyseMetadata](docs/FilesystemAnalyseMetadata.md) + - [FilesystemAnalyseResult](docs/FilesystemAnalyseResult.md) + - [FilesystemCall](docs/FilesystemCall.md) + - [FilesystemDirectMatch](docs/FilesystemDirectMatch.md) + - [FilesystemExplainedFunction](docs/FilesystemExplainedFunction.md) + - [FilesystemFinding](docs/FilesystemFinding.md) + - [FilesystemScanMetadata](docs/FilesystemScanMetadata.md) + - [FilesystemScanResult](docs/FilesystemScanResult.md) - [Filters](docs/Filters.md) + - [Finding](docs/Finding.md) - [FormFile](docs/FormFile.md) - [FunctionBlockDestinationResponse](docs/FunctionBlockDestinationResponse.md) - [FunctionBlockResponse](docs/FunctionBlockResponse.md) @@ -544,6 +642,8 @@ Class | Method | HTTP request | Description - [FunctionSignatureBody](docs/FunctionSignatureBody.md) - [FunctionSignatureEntry](docs/FunctionSignatureEntry.md) - [FunctionSignatureVersion](docs/FunctionSignatureVersion.md) + - [FunctionSimilarity](docs/FunctionSimilarity.md) + - [FunctionSimilarityEvidence](docs/FunctionSimilarityEvidence.md) - [FunctionSourceType](docs/FunctionSourceType.md) - [FunctionString](docs/FunctionString.md) - [FunctionStringItem](docs/FunctionStringItem.md) @@ -551,6 +651,7 @@ Class | Method | HTTP request | Description - [FunctionTypeDefinition](docs/FunctionTypeDefinition.md) - [FunctionsDetailResponse](docs/FunctionsDetailResponse.md) - [FunctionsListRename](docs/FunctionsListRename.md) + - [FunctionsProgressOutputBody](docs/FunctionsProgressOutputBody.md) - [GeneratePDFOutputBody](docs/GeneratePDFOutputBody.md) - [GetAdditionalDetailsOutputBody](docs/GetAdditionalDetailsOutputBody.md) - [GetAdditionalDetailsStatusOutputBody](docs/GetAdditionalDetailsStatusOutputBody.md) @@ -558,14 +659,20 @@ Class | Method | HTTP request | Description - [GetAnalysisLogsOutputBody](docs/GetAnalysisLogsOutputBody.md) - [GetAnalysisStringsStatusOutputBody](docs/GetAnalysisStringsStatusOutputBody.md) - [GetCollectionOutputBody](docs/GetCollectionOutputBody.md) + - [GetConfigOutputBody](docs/GetConfigOutputBody.md) - [GetDataTypeHistoryBody](docs/GetDataTypeHistoryBody.md) + - [GetDieInfoOutputBody](docs/GetDieInfoOutputBody.md) - [GetFunctionSignatureHistoryBody](docs/GetFunctionSignatureHistoryBody.md) - [GetMatchesOutputBody](docs/GetMatchesOutputBody.md) - [GetMatchesStatusOutputBody](docs/GetMatchesStatusOutputBody.md) + - [GetModelsOutputBody](docs/GetModelsOutputBody.md) - [GetProductsOutputBody](docs/GetProductsOutputBody.md) - [GetPublicUserResponse](docs/GetPublicUserResponse.md) + - [GetRelatedBinariesOutputBody](docs/GetRelatedBinariesOutputBody.md) + - [GetRelatedStatusOutputBody](docs/GetRelatedStatusOutputBody.md) - [GetSubscriptionOutputBody](docs/GetSubscriptionOutputBody.md) - [GetTokensResponse](docs/GetTokensResponse.md) + - [HardcodedSecretEvidence](docs/HardcodedSecretEvidence.md) - [HistoryActor](docs/HistoryActor.md) - [HistoryEntry](docs/HistoryEntry.md) - [HttpRequest](docs/HttpRequest.md) @@ -573,15 +680,20 @@ Class | Method | HTTP request | Description - [ISA](docs/ISA.md) - [IconModel](docs/IconModel.md) - [ImportModel](docs/ImportModel.md) + - [ImportedApi](docs/ImportedApi.md) + - [ImportedApiCall](docs/ImportedApiCall.md) + - [ImportedApiCallEvidence](docs/ImportedApiCallEvidence.md) - [ImportedFunctionCallerEntry](docs/ImportedFunctionCallerEntry.md) - [ImportedFunctionDetailOutputBody](docs/ImportedFunctionDetailOutputBody.md) - [ImportedFunctionEntry](docs/ImportedFunctionEntry.md) - [IndirectCallSite](docs/IndirectCallSite.md) - [IndirectCallSitesOutputBody](docs/IndirectCallSitesOutputBody.md) - [InlineComment](docs/InlineComment.md) + - [InputBody](docs/InputBody.md) - [InsertAnalysisLogRequest](docs/InsertAnalysisLogRequest.md) - [InviteUserInputBody](docs/InviteUserInputBody.md) - [IssuerAllowedDomain](docs/IssuerAllowedDomain.md) + - [KnownConstantEvidence](docs/KnownConstantEvidence.md) - [LineAttributionsData](docs/LineAttributionsData.md) - [ListAnalysesOutputBody](docs/ListAnalysesOutputBody.md) - [ListAnalysisDataTypesOutputBody](docs/ListAnalysisDataTypesOutputBody.md) @@ -604,15 +716,44 @@ Class | Method | HTTP request | Description - [MatchedFunction](docs/MatchedFunction.md) - [MemdumpEntry](docs/MemdumpEntry.md) - [MessageBody](docs/MessageBody.md) + - [Meta](docs/Meta.md) - [MetaModel](docs/MetaModel.md) + - [Metadata](docs/Metadata.md) + - [ModelInterpretation](docs/ModelInterpretation.md) + - [ModelInterpretationEvidence](docs/ModelInterpretationEvidence.md) - [ModelName](docs/ModelName.md) - [ModelsResponse](docs/ModelsResponse.md) - [ModuleLoadEntry](docs/ModuleLoadEntry.md) - [MutexEntry](docs/MutexEntry.md) - [NameConfidence](docs/NameConfidence.md) - [NameSourceType](docs/NameSourceType.md) + - [NamesFinishedEvent](docs/NamesFinishedEvent.md) - [NetworkActivity](docs/NetworkActivity.md) + - [NetworkingCall](docs/NetworkingCall.md) + - [NetworkingDirectMatch](docs/NetworkingDirectMatch.md) + - [NetworkingExplainMetadata](docs/NetworkingExplainMetadata.md) + - [NetworkingExplainResult](docs/NetworkingExplainResult.md) + - [NetworkingExplainedFunction](docs/NetworkingExplainedFunction.md) + - [NetworkingFinding](docs/NetworkingFinding.md) + - [NetworkingScanMetadata](docs/NetworkingScanMetadata.md) + - [NetworkingScanResult](docs/NetworkingScanResult.md) - [OIDCCallbackInputBody](docs/OIDCCallbackInputBody.md) + - [OperationCreateMetadataCreateResult](docs/OperationCreateMetadataCreateResult.md) + - [OperationCryptoExplainMetadataCryptoExplainResult](docs/OperationCryptoExplainMetadataCryptoExplainResult.md) + - [OperationCryptoScanMetadataCryptoScanResult](docs/OperationCryptoScanMetadataCryptoScanResult.md) + - [OperationExecutionExplainMetadataExecutionExplainResult](docs/OperationExecutionExplainMetadataExecutionExplainResult.md) + - [OperationExecutionScanMetadataExecutionScanResult](docs/OperationExecutionScanMetadataExecutionScanResult.md) + - [OperationFilesystemAnalyseMetadataFilesystemAnalyseResult](docs/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.md) + - [OperationFilesystemScanMetadataFilesystemScanResult](docs/OperationFilesystemScanMetadataFilesystemScanResult.md) + - [OperationMetadataCapabilitiesResult](docs/OperationMetadataCapabilitiesResult.md) + - [OperationMetadataRemediationResult](docs/OperationMetadataRemediationResult.md) + - [OperationMetadataReportResult](docs/OperationMetadataReportResult.md) + - [OperationMetadataThreatReportResult](docs/OperationMetadataThreatReportResult.md) + - [OperationMetadataTriageResult](docs/OperationMetadataTriageResult.md) + - [OperationNetworkingExplainMetadataNetworkingExplainResult](docs/OperationNetworkingExplainMetadataNetworkingExplainResult.md) + - [OperationNetworkingScanMetadataNetworkingScanResult](docs/OperationNetworkingScanMetadataNetworkingScanResult.md) + - [OperationSecurityScanMetadataSecurityScanResult](docs/OperationSecurityScanMetadataSecurityScanResult.md) + - [OperationWorkflowProgressResultBody](docs/OperationWorkflowProgressResultBody.md) - [Order](docs/Order.md) - [Organisation](docs/Organisation.md) - [OrganisationGroup](docs/OrganisationGroup.md) @@ -645,16 +786,21 @@ Class | Method | HTTP request | Description - [ProductSummary](docs/ProductSummary.md) - [ProgressMessage](docs/ProgressMessage.md) - [ProseEvent](docs/ProseEvent.md) + - [ProtocolsAgentResponse](docs/ProtocolsAgentResponse.md) - [PutAnalysisStringsRequest](docs/PutAnalysisStringsRequest.md) - [QueuedWorkflowTaskResponse](docs/QueuedWorkflowTaskResponse.md) - [ReAnalysisForm](docs/ReAnalysisForm.md) - [Recent](docs/Recent.md) + - [ReferencedConstant](docs/ReferencedConstant.md) + - [ReferencedConstantEvidence](docs/ReferencedConstantEvidence.md) - [RefreshBody](docs/RefreshBody.md) - [RegenerateOutputBody](docs/RegenerateOutputBody.md) - [RegisterUserInputBody](docs/RegisterUserInputBody.md) - [RegistryOperation](docs/RegistryOperation.md) + - [RelatedBinary](docs/RelatedBinary.md) - [RelativeBinaryResponse](docs/RelativeBinaryResponse.md) - [RemediationAgentResponse](docs/RemediationAgentResponse.md) + - [RemediationResult](docs/RemediationResult.md) - [RemoveCollectionBinariesInputBody](docs/RemoveCollectionBinariesInputBody.md) - [RenameAppliedEvent](docs/RenameAppliedEvent.md) - [RenameInputBody](docs/RenameInputBody.md) @@ -665,17 +811,28 @@ Class | Method | HTTP request | Description - [ReportEvent](docs/ReportEvent.md) - [ReportInfo](docs/ReportInfo.md) - [ReportOptions](docs/ReportOptions.md) + - [ReportReachabilityStatus](docs/ReportReachabilityStatus.md) + - [ReportResult](docs/ReportResult.md) - [ResolvedEntity](docs/ResolvedEntity.md) + - [ResultBody](docs/ResultBody.md) - [RevokeBody](docs/RevokeBody.md) + - [RuleKind](docs/RuleKind.md) - [SSOProvider](docs/SSOProvider.md) - [SSOProvidersOutputBody](docs/SSOProvidersOutputBody.md) + - [SandboxConfig](docs/SandboxConfig.md) - [SandboxOptions](docs/SandboxOptions.md) - [SandboxStartMethod](docs/SandboxStartMethod.md) - [SandboxTimeout](docs/SandboxTimeout.md) - [ScheduledTaskEntry](docs/ScheduledTaskEntry.md) - [ScrapeThirdPartyConfig](docs/ScrapeThirdPartyConfig.md) + - [ScreenshotEntry](docs/ScreenshotEntry.md) + - [ScreenshotsIndex](docs/ScreenshotsIndex.md) + - [SecretsAgentResponse](docs/SecretsAgentResponse.md) - [SectionModel](docs/SectionModel.md) + - [SecurityFinding](docs/SecurityFinding.md) - [SecurityModel](docs/SecurityModel.md) + - [SecurityScanMetadata](docs/SecurityScanMetadata.md) + - [SecurityScanResult](docs/SecurityScanResult.md) - [SegmentInfo](docs/SegmentInfo.md) - [SendMessageRequest](docs/SendMessageRequest.md) - [ServerSentEventsInner](docs/ServerSentEventsInner.md) @@ -714,6 +871,7 @@ Class | Method | HTTP request | Description - [StartMatchingForFunctionsInputBody](docs/StartMatchingForFunctionsInputBody.md) - [StartMatchingOutputBody](docs/StartMatchingOutputBody.md) - [StartupInfo](docs/StartupInfo.md) + - [Status](docs/Status.md) - [StatusBody](docs/StatusBody.md) - [StatusInput](docs/StatusInput.md) - [StatusOutput](docs/StatusOutput.md) @@ -722,8 +880,19 @@ Class | Method | HTTP request | Description - [StringSource](docs/StringSource.md) - [StructDataType](docs/StructDataType.md) - [StructDefinition](docs/StructDefinition.md) + - [Subject](docs/Subject.md) + - [SubjectAnyOf](docs/SubjectAnyOf.md) + - [SubjectAnyOf1](docs/SubjectAnyOf1.md) + - [SubjectAnyOf2](docs/SubjectAnyOf2.md) + - [SubjectAnyOf3](docs/SubjectAnyOf3.md) + - [SubmitFeedbackInputBody](docs/SubmitFeedbackInputBody.md) - [SubmitUserFeedbackRequest](docs/SubmitUserFeedbackRequest.md) + - [SuggestedHole](docs/SuggestedHole.md) + - [SuggestedMemberView](docs/SuggestedMemberView.md) + - [SuggestedTypeView](docs/SuggestedTypeView.md) - [SummaryData](docs/SummaryData.md) + - [SuspiciousString](docs/SuspiciousString.md) + - [SuspiciousStringEvidence](docs/SuspiciousStringEvidence.md) - [Symbols](docs/Symbols.md) - [Tag](docs/Tag.md) - [TagItem](docs/TagItem.md) @@ -736,18 +905,32 @@ Class | Method | HTTP request | Description - [TcpCarvedFile](docs/TcpCarvedFile.md) - [Team](docs/Team.md) - [TeamMember](docs/TeamMember.md) + - [Technique](docs/Technique.md) + - [ThreatReportResult](docs/ThreatReportResult.md) - [TimestampModel](docs/TimestampModel.md) - [Token](docs/Token.md) - [TokenInputBody](docs/TokenInputBody.md) - [TokenResponse](docs/TokenResponse.md) - [TokenisedData](docs/TokenisedData.md) + - [TriageFunction](docs/TriageFunction.md) - [TriageFunctionResponse](docs/TriageFunctionResponse.md) - [TriageReportResponse](docs/TriageReportResponse.md) + - [TriageResult](docs/TriageResult.md) + - [TriggerCryptoScanInputBody](docs/TriggerCryptoScanInputBody.md) - [TriggerDynamicExecutionInputBody](docs/TriggerDynamicExecutionInputBody.md) + - [TriggerExecutionExplainInputBody](docs/TriggerExecutionExplainInputBody.md) + - [TriggerExecutionScanInputBody](docs/TriggerExecutionScanInputBody.md) + - [TriggerFilesystemAnalyseInputBody](docs/TriggerFilesystemAnalyseInputBody.md) + - [TriggerFilesystemScanInputBody](docs/TriggerFilesystemScanInputBody.md) + - [TriggerNetworkingExplainInputBody](docs/TriggerNetworkingExplainInputBody.md) + - [TriggerNetworkingScanInputBody](docs/TriggerNetworkingScanInputBody.md) - [TriggerRenameUnnamedFunctionsInputBody](docs/TriggerRenameUnnamedFunctionsInputBody.md) + - [TriggerSecurityScanInputBody](docs/TriggerSecurityScanInputBody.md) - [Ttp](docs/Ttp.md) + - [TypeSuggestionsData](docs/TypeSuggestionsData.md) - [TypedefDataType](docs/TypedefDataType.md) - [TypedefDefinition](docs/TypedefDefinition.md) + - [TypesSuggestedEvent](docs/TypesSuggestedEvent.md) - [UnionDataType](docs/UnionDataType.md) - [UnionDefinition](docs/UnionDefinition.md) - [UnknownDataType](docs/UnknownDataType.md) @@ -772,7 +955,9 @@ Class | Method | HTTP request | Description - [UpdateUserCreditsInputBody](docs/UpdateUserCreditsInputBody.md) - [UpdateUserInputBody](docs/UpdateUserInputBody.md) - [UpdateUserPasswordInputBody](docs/UpdateUserPasswordInputBody.md) + - [UpgradeAnalysisModelOutputBody](docs/UpgradeAnalysisModelOutputBody.md) - [UploadFileType](docs/UploadFileType.md) + - [UploadOutputBody](docs/UploadOutputBody.md) - [UploadResponse](docs/UploadResponse.md) - [UpsertAiDecomplationRatingRequest](docs/UpsertAiDecomplationRatingRequest.md) - [UpsertOverridesData](docs/UpsertOverridesData.md) diff --git a/build.gradle b/build.gradle index 89717108..fdc51341 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'ai.reveng' -version = '4.4.0' +version = '4.51.0' @@ -174,7 +174,7 @@ mavenPublishing { // key, and signing without one fails the build. if (project.hasProperty("signingInMemoryKey")) signAllPublications() - coordinates("ai.reveng", "sdk", "4.4.0") + coordinates("ai.reveng", "sdk", "4.51.0") pom { name = "sdk" diff --git a/build.sbt b/build.sbt index 3b6200e1..ea32e9e4 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ai.reveng", name := "sdk", - version := "4.4.0", + version := "4.51.0", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), diff --git a/docs/APIError.md b/docs/APIError.md index ef1aadbd..55b5b075 100644 --- a/docs/APIError.md +++ b/docs/APIError.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**error** | [**ErrorBody**](ErrorBody.md) | | | +|**error** | **ErrorBody** | | | diff --git a/docs/AgentApi.md b/docs/AgentApi.md index 6d604fba..062c9813 100644 --- a/docs/AgentApi.md +++ b/docs/AgentApi.md @@ -5,21 +5,60 @@ All URIs are relative to *https://api.reveng.ai* | Method | HTTP request | Description | |------------- | ------------- | -------------| | [**checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGet**](AgentApi.md#checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/capabilities/status | Check the status of a capabilities analysis workflow | +| [**checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet**](AgentApi.md#checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/protocols/status | Check the status of a protocols discovery workflow | | [**checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet**](AgentApi.md#checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/remediation/status | Check the status of a remediation analysis workflow | | [**checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet**](AgentApi.md#checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/report-analysis/status | Check the status of a report analysis workflow | +| [**checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet**](AgentApi.md#checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/secrets/status | Check the status of a secrets discovery workflow | | [**checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet**](AgentApi.md#checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet) | **GET** /v2/analyses/{analysis_id}/agent/triage/status | Check the status of a triage analysis workflow | | [**createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost**](AgentApi.md#createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost) | **POST** /v2/analyses/{analysis_id}/agent/capabilities | Queues a capabilities analysis workflow process | +| [**createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost**](AgentApi.md#createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost) | **POST** /v2/analyses/{analysis_id}/agent/protocols | Queues a protocols discovery workflow process | | [**createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost**](AgentApi.md#createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost) | **POST** /v2/analyses/{analysis_id}/agent/remediation | Queues a remediation analysis workflow process | | [**createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost**](AgentApi.md#createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost) | **POST** /v2/analyses/{analysis_id}/agent/report-analysis | Queues a combined report analysis workflow process | +| [**createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost**](AgentApi.md#createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost) | **POST** /v2/analyses/{analysis_id}/agent/secrets | Queues a secrets discovery workflow process | | [**createTriageTaskV2AnalysesAnalysisIdAgentTriagePost**](AgentApi.md#createTriageTaskV2AnalysesAnalysisIdAgentTriagePost) | **POST** /v2/analyses/{analysis_id}/agent/triage | Queues a triage analysis workflow process | | [**getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet**](AgentApi.md#getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet) | **GET** /v2/analyses/{analysis_id}/agent/capabilities | Get Capabilities Result | +| [**getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet**](AgentApi.md#getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet) | **GET** /v2/analyses/{analysis_id}/agent/protocols | Get Protocols Result | | [**getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet**](AgentApi.md#getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet) | **GET** /v2/analyses/{analysis_id}/agent/remediation | Get Remediation Result | | [**getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet**](AgentApi.md#getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet) | **GET** /v2/analyses/{analysis_id}/agent/report-analysis | Get Report Analysis Result | +| [**getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet**](AgentApi.md#getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet) | **GET** /v2/analyses/{analysis_id}/agent/secrets | Get Secrets Result | | [**getTriageResultV2AnalysesAnalysisIdAgentTriageGet**](AgentApi.md#getTriageResultV2AnalysesAnalysisIdAgentTriageGet) | **GET** /v2/analyses/{analysis_id}/agent/triage | Get Triage Result | | [**v3CancelRenameUnnamedFunctions**](AgentApi.md#v3CancelRenameUnnamedFunctions) | **POST** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions/cancel | Cancel the rename-unnamed-functions agent. | +| [**v3CancelSecurityScanOperation**](AgentApi.md#v3CancelSecurityScanOperation) | **POST** /v3/operations/security-scan/{analysis_id}:cancel | Cancel a security-scan operation. | +| [**v3GetBinaryAgentFeedback**](AgentApi.md#v3GetBinaryAgentFeedback) | **GET** /v3/analyses/{analysis_id}/agents/{agent}/feedback | Get the caller's feedback on an agent's output. | +| [**v3GetCapabilitiesOperation**](AgentApi.md#v3GetCapabilitiesOperation) | **GET** /v3/operations/capabilities/{analysis_id} | Get a capabilities operation. | +| [**v3GetCryptoExplainOperation**](AgentApi.md#v3GetCryptoExplainOperation) | **GET** /v3/operations/crypto-explain/{function_id} | Get a crypto-explain operation. | +| [**v3GetCryptoScanOperation**](AgentApi.md#v3GetCryptoScanOperation) | **GET** /v3/operations/crypto-scan/{analysis_id} | Get a crypto-scan operation. | +| [**v3GetExecutionExplainOperation**](AgentApi.md#v3GetExecutionExplainOperation) | **GET** /v3/operations/execution-explain/{function_id} | Get an execution-explain operation. | +| [**v3GetExecutionScanOperation**](AgentApi.md#v3GetExecutionScanOperation) | **GET** /v3/operations/execution-scan/{analysis_id} | Get an execution-scan operation. | +| [**v3GetFilesystemAnalyseOperation**](AgentApi.md#v3GetFilesystemAnalyseOperation) | **GET** /v3/operations/filesystem-analyse/{function_id} | Get a filesystem-analyse operation. | +| [**v3GetFilesystemScanOperation**](AgentApi.md#v3GetFilesystemScanOperation) | **GET** /v3/operations/filesystem-scan/{analysis_id} | Get a filesystem-scan operation. | +| [**v3GetNetworkingExplainOperation**](AgentApi.md#v3GetNetworkingExplainOperation) | **GET** /v3/operations/networking-explain/{function_id} | Get a networking-explain operation. | +| [**v3GetNetworkingScanOperation**](AgentApi.md#v3GetNetworkingScanOperation) | **GET** /v3/operations/networking-scan/{analysis_id} | Get a networking-scan operation. | +| [**v3GetProtocolsOperation**](AgentApi.md#v3GetProtocolsOperation) | **GET** /v3/operations/protocols/{analysis_id} | Get a protocols operation. | +| [**v3GetRemediationOperation**](AgentApi.md#v3GetRemediationOperation) | **GET** /v3/operations/remediation/{analysis_id} | Get a remediation operation. | | [**v3GetRenameUnnamedFunctionsResult**](AgentApi.md#v3GetRenameUnnamedFunctionsResult) | **GET** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions | Get rename-unnamed-functions agent result. | | [**v3GetRenameUnnamedFunctionsStatus**](AgentApi.md#v3GetRenameUnnamedFunctionsStatus) | **GET** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions/status | Get rename-unnamed-functions agent status. | +| [**v3GetReportAnalysisOperation**](AgentApi.md#v3GetReportAnalysisOperation) | **GET** /v3/operations/report-analysis/{analysis_id} | Get a report-analysis operation. | +| [**v3GetSecretsOperation**](AgentApi.md#v3GetSecretsOperation) | **GET** /v3/operations/secrets/{analysis_id} | Get a secrets operation. | +| [**v3GetSecurityScanOperation**](AgentApi.md#v3GetSecurityScanOperation) | **GET** /v3/operations/security-scan/{analysis_id} | Get a security-scan operation. | +| [**v3GetTriageOperation**](AgentApi.md#v3GetTriageOperation) | **GET** /v3/operations/triage/{analysis_id} | Get a triage operation. | +| [**v3RunCapabilities**](AgentApi.md#v3RunCapabilities) | **POST** /v3/analyses/{analysis_id}/capabilities:run | Run the capabilities agent. | +| [**v3RunCryptoExplain**](AgentApi.md#v3RunCryptoExplain) | **POST** /v3/functions/{function_id}/crypto-explain:run | Run the crypto-explain agent. | +| [**v3RunCryptoScan**](AgentApi.md#v3RunCryptoScan) | **POST** /v3/analyses/{analysis_id}/crypto-scan:run | Run the crypto-scan agent. | +| [**v3RunExecutionExplain**](AgentApi.md#v3RunExecutionExplain) | **POST** /v3/functions/{function_id}/execution-explain:run | Run the execution-explain agent. | +| [**v3RunExecutionScan**](AgentApi.md#v3RunExecutionScan) | **POST** /v3/analyses/{analysis_id}/execution-scan:run | Run the execution-scan agent. | +| [**v3RunFilesystemAnalyse**](AgentApi.md#v3RunFilesystemAnalyse) | **POST** /v3/functions/{function_id}/filesystem-analyse:run | Run the filesystem-analyse agent. | +| [**v3RunFilesystemScan**](AgentApi.md#v3RunFilesystemScan) | **POST** /v3/analyses/{analysis_id}/filesystem-scan:run | Run the filesystem-scan agent. | +| [**v3RunNetworkingExplain**](AgentApi.md#v3RunNetworkingExplain) | **POST** /v3/functions/{function_id}/networking-explain:run | Run the networking-explain agent. | +| [**v3RunNetworkingScan**](AgentApi.md#v3RunNetworkingScan) | **POST** /v3/analyses/{analysis_id}/networking-scan:run | Run the networking-scan agent. | +| [**v3RunProtocols**](AgentApi.md#v3RunProtocols) | **POST** /v3/analyses/{analysis_id}/protocols:run | Run the protocols agent. | +| [**v3RunRemediation**](AgentApi.md#v3RunRemediation) | **POST** /v3/analyses/{analysis_id}/remediation:run | Run the remediation agent. | +| [**v3RunReportAnalysis**](AgentApi.md#v3RunReportAnalysis) | **POST** /v3/analyses/{analysis_id}/report-analysis:run | Run the report-analysis agent. | +| [**v3RunSecrets**](AgentApi.md#v3RunSecrets) | **POST** /v3/analyses/{analysis_id}/secrets:run | Run the secrets agent. | +| [**v3RunSecurityScan**](AgentApi.md#v3RunSecurityScan) | **POST** /v3/analyses/{analysis_id}/security-scan:run | Run the security-scan agent. | +| [**v3RunTriage**](AgentApi.md#v3RunTriage) | **POST** /v3/analyses/{analysis_id}/triage:run | Run the triage agent. | | [**v3TriggerRenameUnnamedFunctions**](AgentApi.md#v3TriggerRenameUnnamedFunctions) | **POST** /v3/analyses/{analysis_id}/agents/rename-unnamed-functions | Run the rename-unnamed-functions agent. | +| [**v3UpsertBinaryAgentFeedback**](AgentApi.md#v3UpsertBinaryAgentFeedback) | **PUT** /v3/analyses/{analysis_id}/agents/{agent}/feedback | Record feedback on an agent's output. | @@ -94,11 +133,11 @@ public class Example { | **200** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet** -> TaskStatusResponse checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(analysisId) + +# **checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet** +> TaskStatusResponse checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet(analysisId) -Check the status of a remediation analysis workflow +Check the status of a protocols discovery workflow ### Example ```java @@ -128,10 +167,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - TaskStatusResponse result = apiInstance.checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(analysisId); + TaskStatusResponse result = apiInstance.checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet"); + System.err.println("Exception when calling AgentApi#checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -166,11 +205,11 @@ public class Example { | **200** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet** -> TaskStatusResponse checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(analysisId) + +# **checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet** +> TaskStatusResponse checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(analysisId) -Check the status of a report analysis workflow +Check the status of a remediation analysis workflow ### Example ```java @@ -200,10 +239,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - TaskStatusResponse result = apiInstance.checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(analysisId); + TaskStatusResponse result = apiInstance.checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet"); + System.err.println("Exception when calling AgentApi#checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -238,11 +277,11 @@ public class Example { | **200** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet** -> TaskStatusResponse checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(analysisId) + +# **checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet** +> TaskStatusResponse checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(analysisId) -Check the status of a triage analysis workflow +Check the status of a report analysis workflow ### Example ```java @@ -272,10 +311,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - TaskStatusResponse result = apiInstance.checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(analysisId); + TaskStatusResponse result = apiInstance.checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet"); + System.err.println("Exception when calling AgentApi#checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -310,11 +349,11 @@ public class Example { | **200** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost** -> BaseResponseQueuedWorkflowTaskResponse createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(analysisId) + +# **checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet** +> TaskStatusResponse checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet(analysisId) -Queues a capabilities analysis workflow process +Check the status of a secrets discovery workflow ### Example ```java @@ -344,10 +383,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(analysisId); + TaskStatusResponse result = apiInstance.checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost"); + System.err.println("Exception when calling AgentApi#checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -365,7 +404,7 @@ public class Example { ### Return type -[**BaseResponseQueuedWorkflowTaskResponse**](BaseResponseQueuedWorkflowTaskResponse.md) +[**TaskStatusResponse**](TaskStatusResponse.md) ### Authorization @@ -379,14 +418,14 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **202** | Successful Response | - | +| **200** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost** -> BaseResponseQueuedWorkflowTaskResponse createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(analysisId) + +# **checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet** +> TaskStatusResponse checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(analysisId) -Queues a remediation analysis workflow process +Check the status of a triage analysis workflow ### Example ```java @@ -416,10 +455,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(analysisId); + TaskStatusResponse result = apiInstance.checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost"); + System.err.println("Exception when calling AgentApi#checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -437,7 +476,7 @@ public class Example { ### Return type -[**BaseResponseQueuedWorkflowTaskResponse**](BaseResponseQueuedWorkflowTaskResponse.md) +[**TaskStatusResponse**](TaskStatusResponse.md) ### Authorization @@ -451,14 +490,14 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **202** | Successful Response | - | +| **200** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost** -> QueuedWorkflowTaskResponse createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(analysisId) + +# **createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost** +> BaseResponseQueuedWorkflowTaskResponse createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(analysisId) -Queues a combined report analysis workflow process +Queues a capabilities analysis workflow process ### Example ```java @@ -488,10 +527,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - QueuedWorkflowTaskResponse result = apiInstance.createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(analysisId); + BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost"); + System.err.println("Exception when calling AgentApi#createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -509,7 +548,7 @@ public class Example { ### Return type -[**QueuedWorkflowTaskResponse**](QueuedWorkflowTaskResponse.md) +[**BaseResponseQueuedWorkflowTaskResponse**](BaseResponseQueuedWorkflowTaskResponse.md) ### Authorization @@ -525,13 +564,12 @@ public class Example { |-------------|-------------|------------------| | **202** | Successful Response | - | | **422** | Invalid request parameters | - | -| **409** | Task already completed or queued | - | - -# **createTriageTaskV2AnalysesAnalysisIdAgentTriagePost** -> BaseResponseQueuedWorkflowTaskResponse createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(analysisId) + +# **createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost** +> BaseResponseQueuedWorkflowTaskResponse createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost(analysisId) -Queues a triage analysis workflow process +Queues a protocols discovery workflow process ### Example ```java @@ -561,10 +599,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(analysisId); + BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#createTriageTaskV2AnalysesAnalysisIdAgentTriagePost"); + System.err.println("Exception when calling AgentApi#createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -599,11 +637,11 @@ public class Example { | **202** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet** -> BaseResponseCapabilitiesAgentResponse getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(analysisId) + +# **createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost** +> BaseResponseQueuedWorkflowTaskResponse createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(analysisId) -Get Capabilities Result +Queues a remediation analysis workflow process ### Example ```java @@ -633,10 +671,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - BaseResponseCapabilitiesAgentResponse result = apiInstance.getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(analysisId); + BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet"); + System.err.println("Exception when calling AgentApi#createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -654,7 +692,7 @@ public class Example { ### Return type -[**BaseResponseCapabilitiesAgentResponse**](BaseResponseCapabilitiesAgentResponse.md) +[**BaseResponseQueuedWorkflowTaskResponse**](BaseResponseQueuedWorkflowTaskResponse.md) ### Authorization @@ -668,16 +706,14 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **200** | Successful Response | - | +| **202** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet** -> BaseResponseRemediationAgentResponse getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(analysisId) - -Get Remediation Result + +# **createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost** +> QueuedWorkflowTaskResponse createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(analysisId) -Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules +Queues a combined report analysis workflow process ### Example ```java @@ -707,10 +743,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - BaseResponseRemediationAgentResponse result = apiInstance.getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(analysisId); + QueuedWorkflowTaskResponse result = apiInstance.createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet"); + System.err.println("Exception when calling AgentApi#createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -728,7 +764,7 @@ public class Example { ### Return type -[**BaseResponseRemediationAgentResponse**](BaseResponseRemediationAgentResponse.md) +[**QueuedWorkflowTaskResponse**](QueuedWorkflowTaskResponse.md) ### Authorization @@ -742,16 +778,15 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **200** | Successful Response | - | +| **202** | Successful Response | - | | **422** | Invalid request parameters | - | +| **409** | Task already completed or queued | - | - -# **getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet** -> BaseResponseReportAnalysisResponse getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(analysisId) - -Get Report Analysis Result + +# **createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost** +> BaseResponseQueuedWorkflowTaskResponse createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost(analysisId) -Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule +Queues a secrets discovery workflow process ### Example ```java @@ -781,10 +816,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - BaseResponseReportAnalysisResponse result = apiInstance.getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(analysisId); + BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet"); + System.err.println("Exception when calling AgentApi#createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -802,7 +837,7 @@ public class Example { ### Return type -[**BaseResponseReportAnalysisResponse**](BaseResponseReportAnalysisResponse.md) +[**BaseResponseQueuedWorkflowTaskResponse**](BaseResponseQueuedWorkflowTaskResponse.md) ### Authorization @@ -816,14 +851,14 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **200** | Successful Response | - | +| **202** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **getTriageResultV2AnalysesAnalysisIdAgentTriageGet** -> BaseResponseTriageReportResponse getTriageResultV2AnalysesAnalysisIdAgentTriageGet(analysisId) + +# **createTriageTaskV2AnalysesAnalysisIdAgentTriagePost** +> BaseResponseQueuedWorkflowTaskResponse createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(analysisId) -Get Triage Result +Queues a triage analysis workflow process ### Example ```java @@ -853,10 +888,10 @@ public class Example { AgentApi apiInstance = new AgentApi(defaultClient); Integer analysisId = 56; // Integer | try { - BaseResponseTriageReportResponse result = apiInstance.getTriageResultV2AnalysesAnalysisIdAgentTriageGet(analysisId); + BaseResponseQueuedWorkflowTaskResponse result = apiInstance.createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#getTriageResultV2AnalysesAnalysisIdAgentTriageGet"); + System.err.println("Exception when calling AgentApi#createTriageTaskV2AnalysesAnalysisIdAgentTriagePost"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -874,7 +909,7 @@ public class Example { ### Return type -[**BaseResponseTriageReportResponse**](BaseResponseTriageReportResponse.md) +[**BaseResponseQueuedWorkflowTaskResponse**](BaseResponseQueuedWorkflowTaskResponse.md) ### Authorization @@ -888,16 +923,14 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **200** | Successful Response | - | +| **202** | Successful Response | - | | **422** | Invalid request parameters | - | - -# **v3CancelRenameUnnamedFunctions** -> v3CancelRenameUnnamedFunctions(analysisId) - -Cancel the rename-unnamed-functions agent. + +# **getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet** +> BaseResponseCapabilitiesAgentResponse getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(analysisId) -Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run +Get Capabilities Result ### Example ```java @@ -925,11 +958,12 @@ public class Example { bearerAuth.setBearerToken("BEARER TOKEN"); AgentApi apiInstance = new AgentApi(defaultClient); - Long analysisId = 56L; // Long | Analysis ID + Integer analysisId = 56; // Integer | try { - apiInstance.v3CancelRenameUnnamedFunctions(analysisId); + BaseResponseCapabilitiesAgentResponse result = apiInstance.getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(analysisId); + System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#v3CancelRenameUnnamedFunctions"); + System.err.println("Exception when calling AgentApi#getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -943,11 +977,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **analysisId** | **Long**| Analysis ID | | +| **analysisId** | **Integer**| | | ### Return type -null (empty response body) +[**BaseResponseCapabilitiesAgentResponse**](BaseResponseCapabilitiesAgentResponse.md) ### Authorization @@ -961,19 +995,16 @@ null (empty response body) ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **204** | No Content | - | -| **403** | Forbidden | - | -| **404** | Not Found | - | -| **422** | Unprocessable Entity | - | -| **500** | Internal Server Error | - | +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | - -# **v3GetRenameUnnamedFunctionsResult** -> RenameUnnamedFunctionsResult v3GetRenameUnnamedFunctionsResult(analysisId) + +# **getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet** +> BaseResponseProtocolsAgentResponse getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet(analysisId) -Get rename-unnamed-functions agent result. +Get Protocols Result -Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready +Returns the protocols report, including metadata, findings, and evidence. ### Example ```java @@ -1001,12 +1032,12 @@ public class Example { bearerAuth.setBearerToken("BEARER TOKEN"); AgentApi apiInstance = new AgentApi(defaultClient); - Long analysisId = 56L; // Long | Analysis ID + Integer analysisId = 56; // Integer | try { - RenameUnnamedFunctionsResult result = apiInstance.v3GetRenameUnnamedFunctionsResult(analysisId); + BaseResponseProtocolsAgentResponse result = apiInstance.getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#v3GetRenameUnnamedFunctionsResult"); + System.err.println("Exception when calling AgentApi#getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -1020,11 +1051,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **analysisId** | **Long**| Analysis ID | | +| **analysisId** | **Integer**| | | ### Return type -[**RenameUnnamedFunctionsResult**](RenameUnnamedFunctionsResult.md) +[**BaseResponseProtocolsAgentResponse**](BaseResponseProtocolsAgentResponse.md) ### Authorization @@ -1038,20 +1069,16 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **200** | OK | - | -| **403** | Forbidden | - | -| **404** | Not Found | - | -| **409** | Conflict | - | -| **422** | Unprocessable Entity | - | -| **500** | Internal Server Error | - | +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | - -# **v3GetRenameUnnamedFunctionsStatus** -> StatusBody v3GetRenameUnnamedFunctionsStatus(analysisId) + +# **getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet** +> BaseResponseRemediationAgentResponse getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(analysisId) -Get rename-unnamed-functions agent status. +Get Remediation Result -Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied +Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules ### Example ```java @@ -1079,12 +1106,12 @@ public class Example { bearerAuth.setBearerToken("BEARER TOKEN"); AgentApi apiInstance = new AgentApi(defaultClient); - Long analysisId = 56L; // Long | Analysis ID + Integer analysisId = 56; // Integer | try { - StatusBody result = apiInstance.v3GetRenameUnnamedFunctionsStatus(analysisId); + BaseResponseRemediationAgentResponse result = apiInstance.getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#v3GetRenameUnnamedFunctionsStatus"); + System.err.println("Exception when calling AgentApi#getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -1098,11 +1125,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **analysisId** | **Long**| Analysis ID | | +| **analysisId** | **Integer**| | | ### Return type -[**StatusBody**](StatusBody.md) +[**BaseResponseRemediationAgentResponse**](BaseResponseRemediationAgentResponse.md) ### Authorization @@ -1116,19 +1143,16 @@ public class Example { ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **200** | OK | - | -| **403** | Forbidden | - | -| **404** | Not Found | - | -| **422** | Unprocessable Entity | - | -| **500** | Internal Server Error | - | +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | - -# **v3TriggerRenameUnnamedFunctions** -> StatusBody v3TriggerRenameUnnamedFunctions(analysisId, triggerRenameUnnamedFunctionsInputBody) + +# **getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet** +> BaseResponseReportAnalysisResponse getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(analysisId) -Run the rename-unnamed-functions agent. +Get Report Analysis Result -Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict +Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule ### Example ```java @@ -1156,13 +1180,12 @@ public class Example { bearerAuth.setBearerToken("BEARER TOKEN"); AgentApi apiInstance = new AgentApi(defaultClient); - Long analysisId = 56L; // Long | Analysis ID - TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody = new TriggerRenameUnnamedFunctionsInputBody(); // TriggerRenameUnnamedFunctionsInputBody | + Integer analysisId = 56; // Integer | try { - StatusBody result = apiInstance.v3TriggerRenameUnnamedFunctions(analysisId, triggerRenameUnnamedFunctionsInputBody); + BaseResponseReportAnalysisResponse result = apiInstance.getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(analysisId); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling AgentApi#v3TriggerRenameUnnamedFunctions"); + System.err.println("Exception when calling AgentApi#getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -1176,12 +1199,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **analysisId** | **Long**| Analysis ID | | -| **triggerRenameUnnamedFunctionsInputBody** | [**TriggerRenameUnnamedFunctionsInputBody**](TriggerRenameUnnamedFunctionsInputBody.md)| | | +| **analysisId** | **Integer**| | | ### Return type -[**StatusBody**](StatusBody.md) +[**BaseResponseReportAnalysisResponse**](BaseResponseReportAnalysisResponse.md) ### Authorization @@ -1189,16 +1211,3063 @@ public class Example { ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **202** | Accepted | - | -| **403** | Forbidden | - | -| **404** | Not Found | - | -| **409** | Conflict | - | +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | + + +# **getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet** +> BaseResponseSecretsAgentResponse getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet(analysisId) + +Get Secrets Result + +Returns the secrets report, including metadata, findings, and evidence. + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Integer analysisId = 56; // Integer | + try { + BaseResponseSecretsAgentResponse result = apiInstance.getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Integer**| | | + +### Return type + +[**BaseResponseSecretsAgentResponse**](BaseResponseSecretsAgentResponse.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | + + +# **getTriageResultV2AnalysesAnalysisIdAgentTriageGet** +> BaseResponseTriageReportResponse getTriageResultV2AnalysesAnalysisIdAgentTriageGet(analysisId) + +Get Triage Result + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Integer analysisId = 56; // Integer | + try { + BaseResponseTriageReportResponse result = apiInstance.getTriageResultV2AnalysesAnalysisIdAgentTriageGet(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#getTriageResultV2AnalysesAnalysisIdAgentTriageGet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Integer**| | | + +### Return type + +[**BaseResponseTriageReportResponse**](BaseResponseTriageReportResponse.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | + + +# **v3CancelRenameUnnamedFunctions** +> v3CancelRenameUnnamedFunctions(analysisId) + +Cancel the rename-unnamed-functions agent. + +Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + apiInstance.v3CancelRenameUnnamedFunctions(analysisId); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3CancelRenameUnnamedFunctions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +null (empty response body) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | No Content | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3CancelSecurityScanOperation** +> v3CancelSecurityScanOperation(analysisId) + +Cancel a security-scan operation. + +Requests cancellation of the currently running security-scan run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + apiInstance.v3CancelSecurityScanOperation(analysisId); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3CancelSecurityScanOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +null (empty response body) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | No Content | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetBinaryAgentFeedback** +> FeedbackOutputBody v3GetBinaryAgentFeedback(analysisId, agent) + +Get the caller's feedback on an agent's output. + +Returns the sentiment the caller recorded for one agent on this analysis, or a null sentiment when they have not recorded any. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + String agent = "triage"; // String | Which agent's output the feedback is about + try { + FeedbackOutputBody result = apiInstance.v3GetBinaryAgentFeedback(analysisId, agent); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetBinaryAgentFeedback"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **agent** | **String**| Which agent's output the feedback is about | [enum: triage, capabilities, report-analysis, remediation, protocols, secrets] | + +### Return type + +[**FeedbackOutputBody**](FeedbackOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetCapabilitiesOperation** +> OperationMetadataCapabilitiesResult v3GetCapabilitiesOperation(analysisId) + +Get a capabilities operation. + +Polls a capabilities run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataCapabilitiesResult result = apiInstance.v3GetCapabilitiesOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetCapabilitiesOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataCapabilitiesResult**](OperationMetadataCapabilitiesResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetCryptoExplainOperation** +> OperationCryptoExplainMetadataCryptoExplainResult v3GetCryptoExplainOperation(functionId) + +Get a crypto-explain operation. + +Returns the current state of the crypto-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + try { + OperationCryptoExplainMetadataCryptoExplainResult result = apiInstance.v3GetCryptoExplainOperation(functionId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetCryptoExplainOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | + +### Return type + +[**OperationCryptoExplainMetadataCryptoExplainResult**](OperationCryptoExplainMetadataCryptoExplainResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetCryptoScanOperation** +> OperationCryptoScanMetadataCryptoScanResult v3GetCryptoScanOperation(analysisId) + +Get a crypto-scan operation. + +Returns the current state of the crypto-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationCryptoScanMetadataCryptoScanResult result = apiInstance.v3GetCryptoScanOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetCryptoScanOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationCryptoScanMetadataCryptoScanResult**](OperationCryptoScanMetadataCryptoScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetExecutionExplainOperation** +> OperationExecutionExplainMetadataExecutionExplainResult v3GetExecutionExplainOperation(functionId) + +Get an execution-explain operation. + +Returns the current state of the execution-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + try { + OperationExecutionExplainMetadataExecutionExplainResult result = apiInstance.v3GetExecutionExplainOperation(functionId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetExecutionExplainOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | + +### Return type + +[**OperationExecutionExplainMetadataExecutionExplainResult**](OperationExecutionExplainMetadataExecutionExplainResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetExecutionScanOperation** +> OperationExecutionScanMetadataExecutionScanResult v3GetExecutionScanOperation(analysisId) + +Get an execution-scan operation. + +Returns the current state of the execution-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationExecutionScanMetadataExecutionScanResult result = apiInstance.v3GetExecutionScanOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetExecutionScanOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationExecutionScanMetadataExecutionScanResult**](OperationExecutionScanMetadataExecutionScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetFilesystemAnalyseOperation** +> OperationFilesystemAnalyseMetadataFilesystemAnalyseResult v3GetFilesystemAnalyseOperation(functionId) + +Get a filesystem-analyse operation. + +Returns the current state of the filesystem-analyse run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + try { + OperationFilesystemAnalyseMetadataFilesystemAnalyseResult result = apiInstance.v3GetFilesystemAnalyseOperation(functionId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetFilesystemAnalyseOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | + +### Return type + +[**OperationFilesystemAnalyseMetadataFilesystemAnalyseResult**](OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetFilesystemScanOperation** +> OperationFilesystemScanMetadataFilesystemScanResult v3GetFilesystemScanOperation(analysisId) + +Get a filesystem-scan operation. + +Returns the current state of the filesystem-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationFilesystemScanMetadataFilesystemScanResult result = apiInstance.v3GetFilesystemScanOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetFilesystemScanOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationFilesystemScanMetadataFilesystemScanResult**](OperationFilesystemScanMetadataFilesystemScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetNetworkingExplainOperation** +> OperationNetworkingExplainMetadataNetworkingExplainResult v3GetNetworkingExplainOperation(functionId) + +Get a networking-explain operation. + +Returns the current state of the networking-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + try { + OperationNetworkingExplainMetadataNetworkingExplainResult result = apiInstance.v3GetNetworkingExplainOperation(functionId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetNetworkingExplainOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | + +### Return type + +[**OperationNetworkingExplainMetadataNetworkingExplainResult**](OperationNetworkingExplainMetadataNetworkingExplainResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetNetworkingScanOperation** +> OperationNetworkingScanMetadataNetworkingScanResult v3GetNetworkingScanOperation(analysisId) + +Get a networking-scan operation. + +Returns the current state of the networking-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationNetworkingScanMetadataNetworkingScanResult result = apiInstance.v3GetNetworkingScanOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetNetworkingScanOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationNetworkingScanMetadataNetworkingScanResult**](OperationNetworkingScanMetadataNetworkingScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetProtocolsOperation** +> OperationMetadataReportResult v3GetProtocolsOperation(analysisId) + +Get a protocols operation. + +Polls a protocols run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataReportResult result = apiInstance.v3GetProtocolsOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetProtocolsOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataReportResult**](OperationMetadataReportResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetRemediationOperation** +> OperationMetadataRemediationResult v3GetRemediationOperation(analysisId) + +Get a remediation operation. + +Polls a remediation run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataRemediationResult result = apiInstance.v3GetRemediationOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetRemediationOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataRemediationResult**](OperationMetadataRemediationResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetRenameUnnamedFunctionsResult** +> RenameUnnamedFunctionsResult v3GetRenameUnnamedFunctionsResult(analysisId) + +Get rename-unnamed-functions agent result. + +Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + RenameUnnamedFunctionsResult result = apiInstance.v3GetRenameUnnamedFunctionsResult(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetRenameUnnamedFunctionsResult"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**RenameUnnamedFunctionsResult**](RenameUnnamedFunctionsResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetRenameUnnamedFunctionsStatus** +> StatusBody v3GetRenameUnnamedFunctionsStatus(analysisId) + +Get rename-unnamed-functions agent status. + +Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + StatusBody result = apiInstance.v3GetRenameUnnamedFunctionsStatus(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetRenameUnnamedFunctionsStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**StatusBody**](StatusBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetReportAnalysisOperation** +> OperationMetadataThreatReportResult v3GetReportAnalysisOperation(analysisId) + +Get a report-analysis operation. + +Polls a report-analysis run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataThreatReportResult result = apiInstance.v3GetReportAnalysisOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetReportAnalysisOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataThreatReportResult**](OperationMetadataThreatReportResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetSecretsOperation** +> OperationMetadataReportResult v3GetSecretsOperation(analysisId) + +Get a secrets operation. + +Polls a secrets run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataReportResult result = apiInstance.v3GetSecretsOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetSecretsOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataReportResult**](OperationMetadataReportResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetSecurityScanOperation** +> OperationSecurityScanMetadataSecurityScanResult v3GetSecurityScanOperation(analysisId) + +Get a security-scan operation. + +Returns the current state of the security-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationSecurityScanMetadataSecurityScanResult result = apiInstance.v3GetSecurityScanOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetSecurityScanOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationSecurityScanMetadataSecurityScanResult**](OperationSecurityScanMetadataSecurityScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetTriageOperation** +> OperationMetadataTriageResult v3GetTriageOperation(analysisId) + +Get a triage operation. + +Polls a triage run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataTriageResult result = apiInstance.v3GetTriageOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3GetTriageOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataTriageResult**](OperationMetadataTriageResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunCapabilities** +> OperationMetadataCapabilitiesResult v3RunCapabilities(analysisId) + +Run the capabilities agent. + +Starts the capabilities agent, which attributes behavioural capabilities to individual functions, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataCapabilitiesResult result = apiInstance.v3RunCapabilities(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunCapabilities"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataCapabilitiesResult**](OperationMetadataCapabilitiesResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunCryptoExplain** +> OperationCryptoExplainMetadataCryptoExplainResult v3RunCryptoExplain(functionId) + +Run the crypto-explain agent. + +Starts an agent that explains the cryptography the function implements, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + try { + OperationCryptoExplainMetadataCryptoExplainResult result = apiInstance.v3RunCryptoExplain(functionId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunCryptoExplain"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | + +### Return type + +[**OperationCryptoExplainMetadataCryptoExplainResult**](OperationCryptoExplainMetadataCryptoExplainResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunCryptoScan** +> OperationCryptoScanMetadataCryptoScanResult v3RunCryptoScan(analysisId, triggerCryptoScanInputBody) + +Run the crypto-scan agent. + +Starts an agent that name-matches the analysis' functions and their callees against known crypto-library APIs, and returns the operation to poll for its outcome. Purely name-based — never triggers AI decompilation, so it costs no credits and runs in seconds. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + TriggerCryptoScanInputBody triggerCryptoScanInputBody = new TriggerCryptoScanInputBody(); // TriggerCryptoScanInputBody | + try { + OperationCryptoScanMetadataCryptoScanResult result = apiInstance.v3RunCryptoScan(analysisId, triggerCryptoScanInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunCryptoScan"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **triggerCryptoScanInputBody** | [**TriggerCryptoScanInputBody**](TriggerCryptoScanInputBody.md)| | | + +### Return type + +[**OperationCryptoScanMetadataCryptoScanResult**](OperationCryptoScanMetadataCryptoScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunExecutionExplain** +> OperationExecutionExplainMetadataExecutionExplainResult v3RunExecutionExplain(functionId, triggerExecutionExplainInputBody) + +Run the execution-explain agent. + +Starts an agent that explains the code execution the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + TriggerExecutionExplainInputBody triggerExecutionExplainInputBody = new TriggerExecutionExplainInputBody(); // TriggerExecutionExplainInputBody | + try { + OperationExecutionExplainMetadataExecutionExplainResult result = apiInstance.v3RunExecutionExplain(functionId, triggerExecutionExplainInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunExecutionExplain"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | +| **triggerExecutionExplainInputBody** | [**TriggerExecutionExplainInputBody**](TriggerExecutionExplainInputBody.md)| | | + +### Return type + +[**OperationExecutionExplainMetadataExecutionExplainResult**](OperationExecutionExplainMetadataExecutionExplainResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunExecutionScan** +> OperationExecutionScanMetadataExecutionScanResult v3RunExecutionScan(analysisId, triggerExecutionScanInputBody) + +Run the execution-scan agent. + +Starts an agent that name-matches the analysis' functions and their callees against known code-execution APIs, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + TriggerExecutionScanInputBody triggerExecutionScanInputBody = new TriggerExecutionScanInputBody(); // TriggerExecutionScanInputBody | + try { + OperationExecutionScanMetadataExecutionScanResult result = apiInstance.v3RunExecutionScan(analysisId, triggerExecutionScanInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunExecutionScan"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **triggerExecutionScanInputBody** | [**TriggerExecutionScanInputBody**](TriggerExecutionScanInputBody.md)| | | + +### Return type + +[**OperationExecutionScanMetadataExecutionScanResult**](OperationExecutionScanMetadataExecutionScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunFilesystemAnalyse** +> OperationFilesystemAnalyseMetadataFilesystemAnalyseResult v3RunFilesystemAnalyse(functionId, triggerFilesystemAnalyseInputBody) + +Run the filesystem-analyse agent. + +Starts an agent that explains the filesystem/system access the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + TriggerFilesystemAnalyseInputBody triggerFilesystemAnalyseInputBody = new TriggerFilesystemAnalyseInputBody(); // TriggerFilesystemAnalyseInputBody | + try { + OperationFilesystemAnalyseMetadataFilesystemAnalyseResult result = apiInstance.v3RunFilesystemAnalyse(functionId, triggerFilesystemAnalyseInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunFilesystemAnalyse"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | +| **triggerFilesystemAnalyseInputBody** | [**TriggerFilesystemAnalyseInputBody**](TriggerFilesystemAnalyseInputBody.md)| | | + +### Return type + +[**OperationFilesystemAnalyseMetadataFilesystemAnalyseResult**](OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunFilesystemScan** +> OperationFilesystemScanMetadataFilesystemScanResult v3RunFilesystemScan(analysisId, triggerFilesystemScanInputBody) + +Run the filesystem-scan agent. + +Starts an agent that name-matches the analysis' functions and their callees against known filesystem/system APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + TriggerFilesystemScanInputBody triggerFilesystemScanInputBody = new TriggerFilesystemScanInputBody(); // TriggerFilesystemScanInputBody | + try { + OperationFilesystemScanMetadataFilesystemScanResult result = apiInstance.v3RunFilesystemScan(analysisId, triggerFilesystemScanInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunFilesystemScan"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **triggerFilesystemScanInputBody** | [**TriggerFilesystemScanInputBody**](TriggerFilesystemScanInputBody.md)| | | + +### Return type + +[**OperationFilesystemScanMetadataFilesystemScanResult**](OperationFilesystemScanMetadataFilesystemScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunNetworkingExplain** +> OperationNetworkingExplainMetadataNetworkingExplainResult v3RunNetworkingExplain(functionId, triggerNetworkingExplainInputBody) + +Run the networking-explain agent. + +Starts an agent that explains the network communication a function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long functionId = 56L; // Long | Function ID + TriggerNetworkingExplainInputBody triggerNetworkingExplainInputBody = new TriggerNetworkingExplainInputBody(); // TriggerNetworkingExplainInputBody | + try { + OperationNetworkingExplainMetadataNetworkingExplainResult result = apiInstance.v3RunNetworkingExplain(functionId, triggerNetworkingExplainInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunNetworkingExplain"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | +| **triggerNetworkingExplainInputBody** | [**TriggerNetworkingExplainInputBody**](TriggerNetworkingExplainInputBody.md)| | | + +### Return type + +[**OperationNetworkingExplainMetadataNetworkingExplainResult**](OperationNetworkingExplainMetadataNetworkingExplainResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunNetworkingScan** +> OperationNetworkingScanMetadataNetworkingScanResult v3RunNetworkingScan(analysisId, triggerNetworkingScanInputBody) + +Run the networking-scan agent. + +Starts an agent that name-matches the analysis' functions and their callees against known networking APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + TriggerNetworkingScanInputBody triggerNetworkingScanInputBody = new TriggerNetworkingScanInputBody(); // TriggerNetworkingScanInputBody | + try { + OperationNetworkingScanMetadataNetworkingScanResult result = apiInstance.v3RunNetworkingScan(analysisId, triggerNetworkingScanInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunNetworkingScan"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **triggerNetworkingScanInputBody** | [**TriggerNetworkingScanInputBody**](TriggerNetworkingScanInputBody.md)| | | + +### Return type + +[**OperationNetworkingScanMetadataNetworkingScanResult**](OperationNetworkingScanMetadataNetworkingScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunProtocols** +> OperationMetadataReportResult v3RunProtocols(analysisId) + +Run the protocols agent. + +Starts the protocols agent, which identifies the network and data protocols the binary implements, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataReportResult result = apiInstance.v3RunProtocols(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunProtocols"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataReportResult**](OperationMetadataReportResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunRemediation** +> OperationMetadataRemediationResult v3RunRemediation(analysisId) + +Run the remediation agent. + +Starts the remediation agent, which generates YARA, Snort and STIX detection rules for the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataRemediationResult result = apiInstance.v3RunRemediation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunRemediation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataRemediationResult**](OperationMetadataRemediationResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunReportAnalysis** +> OperationMetadataThreatReportResult v3RunReportAnalysis(analysisId) + +Run the report-analysis agent. + +Starts the report-analysis agent, which produces a combined threat report — summary, software type, attack flow, indicators of compromise, MITRE ATT&CK techniques and a YARA rule — and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataThreatReportResult result = apiInstance.v3RunReportAnalysis(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunReportAnalysis"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataThreatReportResult**](OperationMetadataThreatReportResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunSecrets** +> OperationMetadataReportResult v3RunSecrets(analysisId) + +Run the secrets agent. + +Starts the secrets agent, which finds credentials and other hardcoded secrets in the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataReportResult result = apiInstance.v3RunSecrets(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunSecrets"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataReportResult**](OperationMetadataReportResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunSecurityScan** +> OperationSecurityScanMetadataSecurityScanResult v3RunSecurityScan(analysisId, triggerSecurityScanInputBody) + +Run the security-scan agent. + +Starts an agent that decompiles the analysis' functions and runs a security scan over the decompiled source, and returns the operation to poll for its outcome. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `max_functions_to_scan` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + TriggerSecurityScanInputBody triggerSecurityScanInputBody = new TriggerSecurityScanInputBody(); // TriggerSecurityScanInputBody | + try { + OperationSecurityScanMetadataSecurityScanResult result = apiInstance.v3RunSecurityScan(analysisId, triggerSecurityScanInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunSecurityScan"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **triggerSecurityScanInputBody** | [**TriggerSecurityScanInputBody**](TriggerSecurityScanInputBody.md)| | | + +### Return type + +[**OperationSecurityScanMetadataSecurityScanResult**](OperationSecurityScanMetadataSecurityScanResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3RunTriage** +> OperationMetadataTriageResult v3RunTriage(analysisId) + +Run the triage agent. + +Starts the triage agent, which scores the binary and each of its functions for maliciousness, and returns the operation to poll for its outcome. Unlike the other binary agents this one is not gated on subscription tier. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationMetadataTriageResult result = apiInstance.v3RunTriage(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3RunTriage"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationMetadataTriageResult**](OperationMetadataTriageResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3TriggerRenameUnnamedFunctions** +> StatusBody v3TriggerRenameUnnamedFunctions(analysisId, triggerRenameUnnamedFunctionsInputBody) + +Run the rename-unnamed-functions agent. + +Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody = new TriggerRenameUnnamedFunctionsInputBody(); // TriggerRenameUnnamedFunctionsInputBody | + try { + StatusBody result = apiInstance.v3TriggerRenameUnnamedFunctions(analysisId, triggerRenameUnnamedFunctionsInputBody); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3TriggerRenameUnnamedFunctions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **triggerRenameUnnamedFunctionsInputBody** | [**TriggerRenameUnnamedFunctionsInputBody**](TriggerRenameUnnamedFunctionsInputBody.md)| | | + +### Return type + +[**StatusBody**](StatusBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **202** | Accepted | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3UpsertBinaryAgentFeedback** +> v3UpsertBinaryAgentFeedback(analysisId, agent, submitFeedbackInputBody) + +Record feedback on an agent's output. + +Records how useful the caller found one agent's output for this analysis. Replaces any sentiment they recorded previously. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AgentApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AgentApi apiInstance = new AgentApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + String agent = "triage"; // String | Which agent's output the feedback is about + SubmitFeedbackInputBody submitFeedbackInputBody = new SubmitFeedbackInputBody(); // SubmitFeedbackInputBody | + try { + apiInstance.v3UpsertBinaryAgentFeedback(analysisId, agent, submitFeedbackInputBody); + } catch (ApiException e) { + System.err.println("Exception when calling AgentApi#v3UpsertBinaryAgentFeedback"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | +| **agent** | **String**| Which agent's output the feedback is about | [enum: triage, capabilities, report-analysis, remediation, protocols, secrets] | +| **submitFeedbackInputBody** | [**SubmitFeedbackInputBody**](SubmitFeedbackInputBody.md)| | | + +### Return type + +null (empty response body) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | No Content | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | | **422** | Unprocessable Entity | - | | **500** | Internal Server Error | - | diff --git a/docs/AnalysesCoreApi.md b/docs/AnalysesCoreApi.md index ea53f1b5..cb0a7ca3 100644 --- a/docs/AnalysesCoreApi.md +++ b/docs/AnalysesCoreApi.md @@ -27,12 +27,16 @@ All URIs are relative to *https://api.reveng.ai* | [**updateAnalysis**](AnalysesCoreApi.md#updateAnalysis) | **PATCH** /v2/analyses/{analysis_id} | Update Analysis | | [**updateAnalysisTags**](AnalysesCoreApi.md#updateAnalysisTags) | **PATCH** /v2/analyses/{analysis_id}/tags | Update Analysis Tags | | [**uploadFile**](AnalysesCoreApi.md#uploadFile) | **POST** /v2/upload | Upload File | +| [**v3CreateAnalysis**](AnalysesCoreApi.md#v3CreateAnalysis) | **POST** /v3/analyses | Create an analysis | | [**v3GetAnalysisAutoUnstripStatus**](AnalysesCoreApi.md#v3GetAnalysisAutoUnstripStatus) | **GET** /v3/analyses/{analysis_id}/auto-unstrip/status | Get the auto-unstrip status for an analysis. | +| [**v3GetAnalysisFunctionsProgress**](AnalysesCoreApi.md#v3GetAnalysisFunctionsProgress) | **GET** /v3/analyses/{analysis_id}/progress/functions | Get function embedding progress for an analysis. | | [**v3GetAnalysisLogs**](AnalysesCoreApi.md#v3GetAnalysisLogs) | **GET** /v3/analyses/{analysis_id}/logs | Get the Analysis log | +| [**v3GetAnalysisOperation**](AnalysesCoreApi.md#v3GetAnalysisOperation) | **GET** /v3/operations/analyses/{analysis_id} | Get an Analysis-creation operation | | [**v3GetAnalysisStrings**](AnalysesCoreApi.md#v3GetAnalysisStrings) | **GET** /v3/analyses/{analysis_id}/functions/strings | List strings for an analysis. | | [**v3GetAnalysisStringsStatus**](AnalysesCoreApi.md#v3GetAnalysisStringsStatus) | **GET** /v3/analyses/{analysis_id}/functions/strings/status | Get the string-extraction status for an analysis. | | [**v3ListAnalyses**](AnalysesCoreApi.md#v3ListAnalyses) | **GET** /v3/analyses | List analyses | | [**v3ListExampleAnalyses**](AnalysesCoreApi.md#v3ListExampleAnalyses) | **GET** /v3/analyses/examples | List example analyses | +| [**v3UpgradeAnalysisModel**](AnalysesCoreApi.md#v3UpgradeAnalysisModel) | **POST** /v3/analyses/{analysis_id}/upgrade-model | Re-analyse on the latest model | @@ -1817,6 +1821,89 @@ public class Example { | **200** | Successful Response | - | | **422** | Invalid request parameters | - | + +# **v3CreateAnalysis** +> OperationCreateMetadataCreateResult v3CreateAnalysis(createRequest, xRevEngApplication) + +Create an analysis + +Queues a new Analysis for an uploaded Binary and returns the created Operation. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AnalysesCoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AnalysesCoreApi apiInstance = new AnalysesCoreApi(defaultClient); + CreateRequest createRequest = new CreateRequest(); // CreateRequest | + String xRevEngApplication = "xRevEngApplication_example"; // String | Identifies the calling RevEng application. Recorded on the Analysis log. + try { + OperationCreateMetadataCreateResult result = apiInstance.v3CreateAnalysis(createRequest, xRevEngApplication); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AnalysesCoreApi#v3CreateAnalysis"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **createRequest** | [**CreateRequest**](CreateRequest.md)| | | +| **xRevEngApplication** | **String**| Identifies the calling RevEng application. Recorded on the Analysis log. | [optional] | + +### Return type + +[**OperationCreateMetadataCreateResult**](OperationCreateMetadataCreateResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | Created | - | +| **400** | Bad Request | - | +| **402** | Payment Required | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **413** | Request Entity Too Large | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + # **v3GetAnalysisAutoUnstripStatus** > AutoUnstripStatusOutputBody v3GetAnalysisAutoUnstripStatus(analysisId) @@ -1894,6 +1981,83 @@ public class Example { | **422** | Unprocessable Entity | - | | **500** | Internal Server Error | - | + +# **v3GetAnalysisFunctionsProgress** +> FunctionsProgressOutputBody v3GetAnalysisFunctionsProgress(analysisId) + +Get function embedding progress for an analysis. + +Returns how many functions the analysis has and how many carry an embedding, with the percentage complete. Embeddings are counted from the unified store, so an analysis whose model predates the current multi-arch one reports zero. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AnalysesCoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AnalysesCoreApi apiInstance = new AnalysesCoreApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + FunctionsProgressOutputBody result = apiInstance.v3GetAnalysisFunctionsProgress(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AnalysesCoreApi#v3GetAnalysisFunctionsProgress"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**FunctionsProgressOutputBody**](FunctionsProgressOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + # **v3GetAnalysisLogs** > GetAnalysisLogsOutputBody v3GetAnalysisLogs(analysisId) @@ -1971,6 +2135,83 @@ public class Example { | **422** | Unprocessable Entity | - | | **500** | Internal Server Error | - | + +# **v3GetAnalysisOperation** +> OperationCreateMetadataCreateResult v3GetAnalysisOperation(analysisId) + +Get an Analysis-creation operation + +Polls the status of an Analysis-creation operation. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AnalysesCoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AnalysesCoreApi apiInstance = new AnalysesCoreApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + OperationCreateMetadataCreateResult result = apiInstance.v3GetAnalysisOperation(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AnalysesCoreApi#v3GetAnalysisOperation"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**OperationCreateMetadataCreateResult**](OperationCreateMetadataCreateResult.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + # **v3GetAnalysisStrings** > ListAnalysisStringsOutputBody v3GetAnalysisStrings(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder) @@ -2141,7 +2382,7 @@ public class Example { # **v3ListAnalyses** -> ListAnalysesOutputBody v3ListAnalyses(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, pageSize, nextPageToken, orderBy, order) +> ListAnalysesOutputBody v3ListAnalyses(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, platform, architecture, pageSize, nextPageToken, orderBy, order) List analyses @@ -2174,17 +2415,19 @@ public class Example { AnalysesCoreApi apiInstance = new AnalysesCoreApi(defaultClient); String searchTerm = "searchTerm_example"; // String | - List analysisScope = Arrays.asList(); // List | Leave empty for no filter + List analysisScope = Arrays.asList(); // List | Leave empty to search your own, your team's and all public analyses List status = Arrays.asList(); // List | List modelName = Arrays.asList(); // List | List usernames = Arrays.asList(); // List | String sha256Hash = "sha256Hash_example"; // String | + List platform = Arrays.asList(); // List | Restrict to binaries running on one of these operating-system platforms. Matches the uploader's override when they set one, the detected platform otherwise; a binary with neither is never matched. Leave empty for no filter + List architecture = Arrays.asList(); // List | Restrict to binaries built for one of these instruction-set architectures. Resolved the same way as platform. Leave empty for no filter Long pageSize = 20L; // Long | String nextPageToken = "nextPageToken_example"; // String | Forward-pagination cursor from a prior response. When set, order_by/order are taken from the token (the sort cannot change mid-pagination). String orderBy = "created"; // String | String order = "ASC"; // String | try { - ListAnalysesOutputBody result = apiInstance.v3ListAnalyses(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, pageSize, nextPageToken, orderBy, order); + ListAnalysesOutputBody result = apiInstance.v3ListAnalyses(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, platform, architecture, pageSize, nextPageToken, orderBy, order); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AnalysesCoreApi#v3ListAnalyses"); @@ -2202,11 +2445,13 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| | **searchTerm** | **String**| | [optional] | -| **analysisScope** | [**List<String>**](String.md)| Leave empty for no filter | [optional] [enum: PRIVATE, PUBLIC, TEAM] | +| **analysisScope** | [**List<String>**](String.md)| Leave empty to search your own, your team's and all public analyses | [optional] [enum: PRIVATE, PUBLIC, TEAM] | | **status** | [**List<String>**](String.md)| | [optional] [enum: Uploaded, Queued, Complete, Error, Processing] | | **modelName** | [**List<String>**](String.md)| | [optional] | | **usernames** | [**List<String>**](String.md)| | [optional] | | **sha256Hash** | **String**| | [optional] | +| **platform** | [**List<String>**](String.md)| Restrict to binaries running on one of these operating-system platforms. Matches the uploader's override when they set one, the detected platform otherwise; a binary with neither is never matched. Leave empty for no filter | [optional] [enum: windows, linux, android] | +| **architecture** | [**List<String>**](String.md)| Restrict to binaries built for one of these instruction-set architectures. Resolved the same way as platform. Leave empty for no filter | [optional] [enum: x86_64, x86_32, arm_64] | | **pageSize** | **Long**| | [optional] [default to 20] | | **nextPageToken** | **String**| Forward-pagination cursor from a prior response. When set, order_by/order are taken from the token (the sort cannot change mid-pagination). | [optional] | | **orderBy** | **String**| | [optional] [default to created] [enum: created, binary_name, binary_size] | @@ -2303,3 +2548,81 @@ This endpoint does not need any parameter. | **200** | OK | - | | **0** | Error | - | + +# **v3UpgradeAnalysisModel** +> UpgradeAnalysisModelOutputBody v3UpgradeAnalysisModel(analysisId) + +Re-analyse on the latest model + +Re-runs an analysis created on an older model against the current unified model, in place — the analysis ID does not change. No credits are consumed. Only the owner may call it, and only once the analysis has settled: the pipeline clears the binary's functions, names, data types and signatures before re-running. Returns 409 if the analysis is already on the latest model, or is still running. Poll `GET /v3/analyses/{analysis_id}/basic` for status, as with any other run. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AnalysesCoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + AnalysesCoreApi apiInstance = new AnalysesCoreApi(defaultClient); + Long analysisId = 56L; // Long | Analysis ID + try { + UpgradeAnalysisModelOutputBody result = apiInstance.v3UpgradeAnalysisModel(analysisId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AnalysesCoreApi#v3UpgradeAnalysisModel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **analysisId** | **Long**| Analysis ID | | + +### Return type + +[**UpgradeAnalysisModelOutputBody**](UpgradeAnalysisModelOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | Created | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **409** | Conflict | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + diff --git a/docs/AnalysisBasicInfoOutputBody.md b/docs/AnalysisBasicInfoOutputBody.md index f65c6410..d4614d68 100644 --- a/docs/AnalysisBasicInfoOutputBody.md +++ b/docs/AnalysisBasicInfoOutputBody.md @@ -24,6 +24,7 @@ |**isSystem** | **Boolean** | True when the analysis is owned by a system user | | |**modelId** | **Long** | Model ID | | |**modelName** | **String** | Model used for analysis | | +|**modelUpgradeAvailable** | **Boolean** | True when the analysis ran on a model older than the current one, so its owner can re-analyse it on the latest. Describes the analysis, not the caller's rights — only the owner may act on it | | |**ownerUsername** | **String** | Username of the analysis owner | | |**sequencerVersion** | **String** | Sequencer version, omitted when not set | [optional] | |**sha256Hash** | **String** | SHA-256 hash of the binary | | diff --git a/docs/AnalysisConfig.md b/docs/AnalysisConfig.md index 1631b67e..2660c0c3 100644 --- a/docs/AnalysisConfig.md +++ b/docs/AnalysisConfig.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**scrapeThirdPartyConfig** | [**ScrapeThirdPartyConfig**](ScrapeThirdPartyConfig.md) | Settings to scrape third party sources | [optional] | +|**scrapeThirdPartyConfig** | **ScrapeThirdPartyConfig** | Settings to scrape third party sources | [optional] | |**generateCapabilities** | **Boolean** | A configuration option for generating capabilities of a binary | [optional] | |**noCache** | **Boolean** | When enabled, skips using cached data within the processing. | [optional] | |**advancedAnalysis** | **Boolean** | Enables an advanced security analysis. | [optional] | diff --git a/docs/AnalysisCreateRequest.md b/docs/AnalysisCreateRequest.md index 212be48e..3affb01b 100644 --- a/docs/AnalysisCreateRequest.md +++ b/docs/AnalysisCreateRequest.md @@ -11,11 +11,11 @@ |**sha256Hash** | **String** | The sha256 hash of the file | | |**tags** | [**List<Tag>**](Tag.md) | List of tags to assign to an analysis | [optional] | |**analysisScope** | **AnalysisScope** | The scope of the analysis determines who can access it | [optional] | -|**symbols** | [**Symbols**](Symbols.md) | Symbols are user-defined properties which inform how the binary is decompiled | [optional] | +|**symbols** | **Symbols** | Symbols are user-defined properties which inform how the binary is decompiled | [optional] | |**debugHash** | **String** | Hash of the debug file | [optional] | |**analysisConfig** | [**AnalysisConfig**](AnalysisConfig.md) | The analysis config enables the configuration of optional analysis stages | [optional] | -|**binaryConfig** | [**BinaryConfig**](BinaryConfig.md) | The binary config can override automatically determined values such as ISA, Platform, File Format, etc | [optional] | -|**autoRunAgents** | [**AutoRunAgents**](AutoRunAgents.md) | | [optional] | +|**binaryConfig** | **BinaryConfig** | The binary config can override automatically determined values such as ISA, Platform, File Format, etc | [optional] | +|**autoRunAgents** | **AutoRunAgents** | | [optional] | diff --git a/docs/AnalysisDetailResponse.md b/docs/AnalysisDetailResponse.md index 2036dea0..323241da 100644 --- a/docs/AnalysisDetailResponse.md +++ b/docs/AnalysisDetailResponse.md @@ -21,7 +21,7 @@ |**debug** | **Boolean** | | | |**modelName** | **String** | | | |**sha256Hash** | **String** | | | -|**autoRunAgents** | [**AutoRunAgents**](AutoRunAgents.md) | | | +|**autoRunAgents** | **AutoRunAgents** | | | |**requestedConfig** | [**AnalysisConfigSnapshot**](AnalysisConfigSnapshot.md) | Snapshot of the configuration the analysis was submitted with. | | diff --git a/docs/AnalysisFunctionEntry.md b/docs/AnalysisFunctionEntry.md index 369a59c8..269499dd 100644 --- a/docs/AnalysisFunctionEntry.md +++ b/docs/AnalysisFunctionEntry.md @@ -13,7 +13,7 @@ |**functionName** | **String** | | | |**functionSize** | **Long** | | | |**functionVaddr** | **Long** | | | -|**mangledName** | **String** | Search is applied to string value | [optional] | +|**mangledName** | **String** | | [optional] | |**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, if any | [optional] | |**sourceBinaryId** | **Long** | | [optional] | |**sourceFunctionId** | **Long** | ID of the source function this name was transferred from, if any | [optional] | diff --git a/docs/AnalysisLogs.md b/docs/AnalysisLogs.md index 9b8d541b..f3bc5f5d 100644 --- a/docs/AnalysisLogs.md +++ b/docs/AnalysisLogs.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**messageCount** | **Long** | | | -|**messages** | [**List<AnalysisLogMessage>**](AnalysisLogMessage.md) | | | +|**messages** | **List<AnalysisLogMessage>** | | | diff --git a/docs/AnalysisRecordBody.md b/docs/AnalysisRecordBody.md index 951428a7..4009e5ed 100644 --- a/docs/AnalysisRecordBody.md +++ b/docs/AnalysisRecordBody.md @@ -21,12 +21,13 @@ |**isOwner** | **Boolean** | True when the caller owns the analysis | | |**modelId** | **Long** | Model ID | | |**modelName** | **String** | Model name | | +|**modelUpgradeAvailable** | **Boolean** | True when the analysis ran on a model older than the current one, so its owner can re-analyse it on the latest. Describes the analysis, not the caller's rights — only the owner may act on it | | |**sha256Hash** | **String** | SHA-256 hash of the binary | | |**status** | **String** | Analysis status | | |**suppliedArchitecture** | **String** | User-supplied instruction-set architecture; \"AUTO\" when not overridden | | |**suppliedBinaryFormat** | **String** | User-supplied binary container format; \"AUTO\" when not overridden | | |**suppliedBinaryType** | **String** | User-supplied operating-system platform; \"AUTO\" when not overridden | | -|**tags** | [**List<AnalysisTagBody>**](AnalysisTagBody.md) | Tags associated with the binary | | +|**tags** | **List<AnalysisTagBody>** | Tags associated with the binary | | |**username** | **String** | Username of the analysis owner | | diff --git a/docs/AnalysisReport.md b/docs/AnalysisReport.md index 8aa44f60..2bb6bb78 100644 --- a/docs/AnalysisReport.md +++ b/docs/AnalysisReport.md @@ -7,21 +7,21 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**artifacts** | [**List<Artifact>**](Artifact.md) | | [optional] | -|**consoleOutput** | [**List<ConsoleOutputEntry>**](ConsoleOutputEntry.md) | | [optional] | -|**fileActivity** | [**List<FileActivityEntry>**](FileActivityEntry.md) | | [optional] | -|**info** | [**ReportInfo**](ReportInfo.md) | | | -|**memdumps** | [**List<ProcessMemdumps>**](ProcessMemdumps.md) | | [optional] | -|**moduleLoadAddresses** | [**List<ModuleLoadEntry>**](ModuleLoadEntry.md) | | [optional] | -|**mutexes** | [**List<MutexEntry>**](MutexEntry.md) | | [optional] | -|**networkActivity** | [**NetworkActivity**](NetworkActivity.md) | | [optional] | -|**processActivity** | [**List<ProcessActivityEntry>**](ProcessActivityEntry.md) | | [optional] | -|**processTree** | [**ProcessTree**](ProcessTree.md) | | [optional] | -|**registryOperations** | [**List<RegistryOperation>**](RegistryOperation.md) | | [optional] | -|**scheduledTasks** | [**List<ScheduledTaskEntry>**](ScheduledTaskEntry.md) | | [optional] | -|**services** | [**List<ServiceEntry>**](ServiceEntry.md) | | [optional] | -|**startup** | [**StartupInfo**](StartupInfo.md) | | [optional] | -|**ttps** | [**List<Ttp>**](Ttp.md) | | [optional] | +|**artifacts** | **List<Artifact>** | | [optional] | +|**consoleOutput** | **List<ConsoleOutputEntry>** | | [optional] | +|**fileActivity** | **List<FileActivityEntry>** | | [optional] | +|**info** | **ReportInfo** | | | +|**memdumps** | **List<ProcessMemdumps>** | | [optional] | +|**moduleLoadAddresses** | **List<ModuleLoadEntry>** | | [optional] | +|**mutexes** | **List<MutexEntry>** | | [optional] | +|**networkActivity** | **NetworkActivity** | | [optional] | +|**processActivity** | **List<ProcessActivityEntry>** | | [optional] | +|**processTree** | **ProcessTree** | | [optional] | +|**registryOperations** | **List<RegistryOperation>** | | [optional] | +|**scheduledTasks** | **List<ScheduledTaskEntry>** | | [optional] | +|**services** | **List<ServiceEntry>** | | [optional] | +|**startup** | **StartupInfo** | | [optional] | +|**ttps** | **List<Ttp>** | | [optional] | diff --git a/docs/AnalysisRequirement.md b/docs/AnalysisRequirement.md new file mode 100644 index 00000000..9299a301 --- /dev/null +++ b/docs/AnalysisRequirement.md @@ -0,0 +1,15 @@ + + +# AnalysisRequirement + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**fields** | **List<String>** | CreateAnalysis field paths that must be provided or enabled to satisfy this requirement. | | +|**reason** | **String** | Why this requirement unblocks analysis. | | +|**values** | **Map<String, String>** | Field paths that must carry a specific value, keyed the same way as fields. | [optional] | + + + diff --git a/docs/AnalysisStringItem.md b/docs/AnalysisStringItem.md index b72632d9..43c049de 100644 --- a/docs/AnalysisStringItem.md +++ b/docs/AnalysisStringItem.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**functions** | [**List<AnalysisStringFunction>**](AnalysisStringFunction.md) | | | +|**functions** | **List<AnalysisStringFunction>** | | | |**source** | **String** | | | |**value** | **String** | | | diff --git a/docs/ApiCombinationEvidence.md b/docs/ApiCombinationEvidence.md new file mode 100644 index 00000000..b3eb030a --- /dev/null +++ b/docs/ApiCombinationEvidence.md @@ -0,0 +1,45 @@ + + +# ApiCombinationEvidence + +A known combination of APIs without a demonstrated semantic flow. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**apis** | [**List<ImportedApi>**](ImportedApi.md) | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| API_COMBINATION | "api_combination" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| INDIRECT | "indirect" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ArrayDataType.md b/docs/ArrayDataType.md index b354b38b..576d2a6f 100644 --- a/docs/ArrayDataType.md +++ b/docs/ArrayDataType.md @@ -9,12 +9,13 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**ArrayDefinition**](ArrayDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **ArrayDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/BaseDataType.md b/docs/BaseDataType.md index cce553fe..7c35c2ac 100644 --- a/docs/BaseDataType.md +++ b/docs/BaseDataType.md @@ -14,6 +14,7 @@ |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/BaseResponseListDieMatch.md b/docs/BaseResponseListDieMatch.md index b872a85e..0bbbf9b8 100644 --- a/docs/BaseResponseListDieMatch.md +++ b/docs/BaseResponseListDieMatch.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**List<DieMatch>**](DieMatch.md) | Response data | [optional] | +|**data** | **List<DieMatch>** | Response data | [optional] | |**message** | **String** | Response message | [optional] | |**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseProtocolsAgentResponse.md b/docs/BaseResponseProtocolsAgentResponse.md new file mode 100644 index 00000000..270855dd --- /dev/null +++ b/docs/BaseResponseProtocolsAgentResponse.md @@ -0,0 +1,17 @@ + + +# BaseResponseProtocolsAgentResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**status** | **Boolean** | Response status on whether the request succeeded | [optional] | +|**data** | **ProtocolsAgentResponse** | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | +|**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | + + + diff --git a/docs/BaseResponseSecretsAgentResponse.md b/docs/BaseResponseSecretsAgentResponse.md new file mode 100644 index 00000000..f0c06ccb --- /dev/null +++ b/docs/BaseResponseSecretsAgentResponse.md @@ -0,0 +1,17 @@ + + +# BaseResponseSecretsAgentResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**status** | **Boolean** | Response status on whether the request succeeded | [optional] | +|**data** | **SecretsAgentResponse** | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | +|**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | + + + diff --git a/docs/BatchFunctionSignatureEntry.md b/docs/BatchFunctionSignatureEntry.md index 09eca598..34002c37 100644 --- a/docs/BatchFunctionSignatureEntry.md +++ b/docs/BatchFunctionSignatureEntry.md @@ -13,7 +13,7 @@ |**functionId** | **Long** | | | |**functionName** | **String** | Current name of the function. | | |**hasSignature** | **Boolean** | Whether a signature was extracted for this function. False is a normal result: no signature is recorded unless data type extraction ran for the analysis, and thunks and external functions are skipped when it does. | | -|**parameters** | [**List<SignatureParameterEntry>**](SignatureParameterEntry.md) | Parameters in argument order. Empty with has_signature true means the function is known to take no arguments. | | +|**parameters** | **List<SignatureParameterEntry>** | Parameters in argument order. Empty with has_signature true means the function is known to take no arguments. | | |**returnDataTypeId** | **Long** | Return type, resolvable against the analysis data types list. Absent for an unresolved return type. | [optional] | |**sourceFunctionId** | **Long** | The function this signature was copied from, when it was transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this signature came from. | [optional] | diff --git a/docs/BatchMatchingOutputBody.md b/docs/BatchMatchingOutputBody.md index 20652ad5..4d57eb34 100644 --- a/docs/BatchMatchingOutputBody.md +++ b/docs/BatchMatchingOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**perBinary** | [**List<BatchBinaryMatchResult>**](BatchBinaryMatchResult.md) | Per-binary status (order matches the request). | | +|**perBinary** | **List<BatchBinaryMatchResult>** | Per-binary status (order matches the request). | | |**status** | [**StatusEnum**](#StatusEnum) | Aggregate status across the batch: COMPLETED when every binary is completed, FAILED if any failed, RUNNING/PENDING otherwise. | | diff --git a/docs/BatchRenameInputBody.md b/docs/BatchRenameInputBody.md index 54261089..4d7ac679 100644 --- a/docs/BatchRenameInputBody.md +++ b/docs/BatchRenameInputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**functions** | [**List<BatchRenameItem>**](BatchRenameItem.md) | List of functions to rename | | +|**functions** | **List<BatchRenameItem>** | List of functions to rename | | diff --git a/docs/BinariesApi.md b/docs/BinariesApi.md index 97ff5601..a2c4d1aa 100644 --- a/docs/BinariesApi.md +++ b/docs/BinariesApi.md @@ -14,6 +14,10 @@ All URIs are relative to *https://api.reveng.ai* | [**getBinaryExternals**](BinariesApi.md#getBinaryExternals) | **GET** /v2/binaries/{binary_id}/externals | Gets the external details of a binary | | [**getBinaryRelatedStatus**](BinariesApi.md#getBinaryRelatedStatus) | **GET** /v2/binaries/{binary_id}/related/status | Gets the status of the unpack binary task for a binary | | [**getRelatedBinaries**](BinariesApi.md#getRelatedBinaries) | **GET** /v2/binaries/{binary_id}/related | Gets the related binaries of a binary. | +| [**v3GetBinaryDieInfo**](BinariesApi.md#v3GetBinaryDieInfo) | **GET** /v3/binaries/{binary_id}/die-info | Get Detect It Easy matches for a binary. | +| [**v3GetBinaryRelated**](BinariesApi.md#v3GetBinaryRelated) | **GET** /v3/binaries/{binary_id}/related | Get the binaries related to this one by unpacking. | +| [**v3GetBinaryRelatedStatus**](BinariesApi.md#v3GetBinaryRelatedStatus) | **GET** /v3/binaries/{binary_id}/related/status | Get the archive-unpacking status for a binary. | +| [**v3UploadFile**](BinariesApi.md#v3UploadFile) | **POST** /v3/upload | Upload a file. | @@ -747,3 +751,315 @@ public class Example { | **422** | Invalid request parameters | - | | **403** | Forbidden | - | + +# **v3GetBinaryDieInfo** +> GetDieInfoOutputBody v3GetBinaryDieInfo(binaryId) + +Get Detect It Easy matches for a binary. + +Returns the signatures Detect It Easy recognised in the binary — packers, compilers and file types — with the version it could extract. Empty when detection has not run or recognised nothing. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.BinariesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + BinariesApi apiInstance = new BinariesApi(defaultClient); + Long binaryId = 56L; // Long | Binary ID + try { + GetDieInfoOutputBody result = apiInstance.v3GetBinaryDieInfo(binaryId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling BinariesApi#v3GetBinaryDieInfo"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **binaryId** | **Long**| Binary ID | | + +### Return type + +[**GetDieInfoOutputBody**](GetDieInfoOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetBinaryRelated** +> GetRelatedBinariesOutputBody v3GetBinaryRelated(binaryId) + +Get the binaries related to this one by unpacking. + +Returns the binaries unpacked out of this one, and the archive it came out of when it was not uploaded directly. A related binary that has never been analysed carries a null `analysis_id`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.BinariesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + BinariesApi apiInstance = new BinariesApi(defaultClient); + Long binaryId = 56L; // Long | Binary ID + try { + GetRelatedBinariesOutputBody result = apiInstance.v3GetBinaryRelated(binaryId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling BinariesApi#v3GetBinaryRelated"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **binaryId** | **Long**| Binary ID | | + +### Return type + +[**GetRelatedBinariesOutputBody**](GetRelatedBinariesOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3GetBinaryRelatedStatus** +> GetRelatedStatusOutputBody v3GetBinaryRelatedStatus(binaryId) + +Get the archive-unpacking status for a binary. + +Returns the status of the task that unpacks an archive into its contents, which is what decides whether the related-binary list is still filling up. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.BinariesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + BinariesApi apiInstance = new BinariesApi(defaultClient); + Long binaryId = 56L; // Long | Binary ID + try { + GetRelatedStatusOutputBody result = apiInstance.v3GetBinaryRelatedStatus(binaryId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling BinariesApi#v3GetBinaryRelatedStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **binaryId** | **Long**| Binary ID | | + +### Return type + +[**GetRelatedStatusOutputBody**](GetRelatedStatusOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + + +# **v3UploadFile** +> UploadOutputBody v3UploadFile(_file, uploadFileType, forceOverwrite) + +Upload a file. + +Uploads a binary, debug symbol, packed sample, or firmware image, keyed by its SHA-256 hash. A BINARY upload from a non-system caller also detects the file's architecture and OS so POST /v3/analyses knows whether it can run static analysis. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.BinariesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + BinariesApi apiInstance = new BinariesApi(defaultClient); + File _file = new File("/path/to/file"); // File | The file's raw bytes. + String uploadFileType = "BINARY"; // String | The kind of file being uploaded. + Boolean forceOverwrite = true; // Boolean | Re-upload and overwrite even if a file with this hash already exists. + try { + UploadOutputBody result = apiInstance.v3UploadFile(_file, uploadFileType, forceOverwrite); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling BinariesApi#v3UploadFile"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **_file** | **File**| The file's raw bytes. | | +| **uploadFileType** | **String**| The kind of file being uploaded. | [enum: BINARY, DEBUG, PACKED, FIRMWARE] | +| **forceOverwrite** | **Boolean**| Re-upload and overwrite even if a file with this hash already exists. | [optional] | + +### Return type + +[**UploadOutputBody**](UploadOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **400** | Bad Request | - | +| **413** | Request Entity Too Large | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + diff --git a/docs/BinaryConfig.md b/docs/BinaryConfig.md index ff69e9c1..e3e5adfc 100644 --- a/docs/BinaryConfig.md +++ b/docs/BinaryConfig.md @@ -7,9 +7,42 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**isa** | **ISA** | Instruction Set Architecture | [optional] | -|**platform** | **Platform** | | [optional] | -|**fileFormat** | **FileFormat** | | [optional] | +|**fileFormat** | [**FileFormatEnum**](#FileFormatEnum) | | [optional] | +|**isa** | [**IsaEnum**](#IsaEnum) | | [optional] | +|**platform** | [**PlatformEnum**](#PlatformEnum) | | [optional] | + + + +## Enum: FileFormatEnum + +| Name | Value | +|---- | -----| +| PE | "pe" | +| ELF | "elf" | +| BLOB | "blob" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: IsaEnum + +| Name | Value | +|---- | -----| +| X86 | "x86" | +| X86_64 | "x86_64" | +| ARM | "arm" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: PlatformEnum + +| Name | Value | +|---- | -----| +| LINUX | "linux" | +| WINDOWS | "windows" | +| ANDROID | "android" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/BitfieldDataType.md b/docs/BitfieldDataType.md index 19d9cc3a..3b2e8744 100644 --- a/docs/BitfieldDataType.md +++ b/docs/BitfieldDataType.md @@ -14,6 +14,7 @@ |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/BulkCreateUserResult.md b/docs/BulkCreateUserResult.md index 33201dc2..6ef39762 100644 --- a/docs/BulkCreateUserResult.md +++ b/docs/BulkCreateUserResult.md @@ -11,7 +11,7 @@ |**error** | **String** | Error description; present on failure | [optional] | |**index** | **Long** | 1-based row index in the CSV | | |**success** | **Boolean** | | | -|**user** | [**User**](User.md) | Created user; present on success | [optional] | +|**user** | **User** | Created user; present on success | [optional] | |**username** | **String** | Search is applied to string value | | diff --git a/docs/BulkCreateUsersOutputBody.md b/docs/BulkCreateUsersOutputBody.md index a8e6c6eb..70e62bbb 100644 --- a/docs/BulkCreateUsersOutputBody.md +++ b/docs/BulkCreateUsersOutputBody.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**failed** | **Long** | | | -|**results** | [**List<BulkCreateUserResult>**](BulkCreateUserResult.md) | | | +|**results** | **List<BulkCreateUserResult>** | | | |**succeeded** | **Long** | | | |**total** | **Long** | | | diff --git a/docs/BytesConstant.md b/docs/BytesConstant.md new file mode 100644 index 00000000..c82fbd1a --- /dev/null +++ b/docs/BytesConstant.md @@ -0,0 +1,25 @@ + + +# BytesConstant + +One exact, contiguous sequence of binary bytes. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**format** | [**FormatEnum**](#FormatEnum) | | [optional] | +|**value** | **String** | Hexadecimal byte pairs representing one exact, contiguous binary value. | | +|**display** | **Display** | | [optional] | + + + +## Enum: FormatEnum + +| Name | Value | +|---- | -----| +| BYTES | "bytes" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CallChain.md b/docs/CallChain.md new file mode 100644 index 00000000..ea59fe4b --- /dev/null +++ b/docs/CallChain.md @@ -0,0 +1,13 @@ + + +# CallChain + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**path** | **List<Integer>** | | | + + + diff --git a/docs/CallChainEvidence.md b/docs/CallChainEvidence.md new file mode 100644 index 00000000..a0b0663b --- /dev/null +++ b/docs/CallChainEvidence.md @@ -0,0 +1,45 @@ + + +# CallChainEvidence + +A concrete sequence of calls connecting program locations. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**callChain** | **List<Integer>** | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| CALL_CHAIN | "call_chain" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| DIRECT | "direct" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CallEdgesOutputBody.md b/docs/CallEdgesOutputBody.md index 2f306ad3..05426012 100644 --- a/docs/CallEdgesOutputBody.md +++ b/docs/CallEdgesOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**edges** | [**List<FunctionCallEdges>**](FunctionCallEdges.md) | | | +|**edges** | **List<FunctionCallEdges>** | | | diff --git a/docs/CanonicalizeNamesOutputBody.md b/docs/CanonicalizeNamesOutputBody.md index 756e4520..4a178449 100644 --- a/docs/CanonicalizeNamesOutputBody.md +++ b/docs/CanonicalizeNamesOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**results** | [**List<CanonicalName>**](CanonicalName.md) | Canonicalized names in the same order as the input. | | +|**results** | **List<CanonicalName>** | Canonicalized names in the same order as the input. | | diff --git a/docs/CapabilitiesOutputBody.md b/docs/CapabilitiesOutputBody.md index 1e074c8f..b369ccf8 100644 --- a/docs/CapabilitiesOutputBody.md +++ b/docs/CapabilitiesOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**capabilities** | [**List<CapabilityEntry>**](CapabilityEntry.md) | | | +|**capabilities** | **List<CapabilityEntry>** | | | diff --git a/docs/CapabilitiesResult.md b/docs/CapabilitiesResult.md new file mode 100644 index 00000000..7f58b937 --- /dev/null +++ b/docs/CapabilitiesResult.md @@ -0,0 +1,13 @@ + + +# CapabilitiesResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**capabilities** | **List<Capability>** | Capabilities found. A capability whose address no longer resolves within the analysis is omitted. | | + + + diff --git a/docs/Capability.md b/docs/Capability.md new file mode 100644 index 00000000..7f403039 --- /dev/null +++ b/docs/Capability.md @@ -0,0 +1,18 @@ + + +# Capability + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**capability** | **String** | The capability itself | | +|**description** | **String** | What the function does to exhibit the capability | | +|**functionId** | **Long** | ID of the function | | +|**functionName** | **String** | Name of the function | | +|**functionVaddr** | **String** | Virtual address of the function, hex-encoded | | +|**type** | **String** | Capability category | | + + + diff --git a/docs/CommentsData.md b/docs/CommentsData.md index 96254081..38f9136e 100644 --- a/docs/CommentsData.md +++ b/docs/CommentsData.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**inlineComments** | [**List<InlineComment>**](InlineComment.md) | Structured inline comments with line numbers | | +|**inlineComments** | **List<InlineComment>** | Structured inline comments with line numbers | | |**taskStatus** | [**TaskStatusEnum**](#TaskStatusEnum) | Task status | | diff --git a/docs/Config.md b/docs/Config.md new file mode 100644 index 00000000..c8774b14 --- /dev/null +++ b/docs/Config.md @@ -0,0 +1,16 @@ + + +# Config + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**generateCapabilities** | **Boolean** | | [optional] | +|**noCache** | **Boolean** | | [optional] | +|**sandboxConfig** | **SandboxConfig** | | [optional] | +|**scrapeThirdPartyConfig** | **ScrapeThirdPartyConfig** | | [optional] | + + + diff --git a/docs/ConfigApi.md b/docs/ConfigApi.md index 15cf4362..cd29a915 100644 --- a/docs/ConfigApi.md +++ b/docs/ConfigApi.md @@ -5,6 +5,8 @@ All URIs are relative to *https://api.reveng.ai* | Method | HTTP request | Description | |------------- | ------------- | -------------| | [**getConfig**](ConfigApi.md#getConfig) | **GET** /v2/config | Get Config | +| [**v3GetConfig**](ConfigApi.md#v3GetConfig) | **GET** /v3/config | Get client configuration. | +| [**v3GetModels**](ConfigApi.md#v3GetModels) | **GET** /v3/models | Get the models available for analysis. | @@ -77,3 +79,143 @@ This endpoint does not need any parameter. | **200** | Successful Response | - | | **422** | Invalid request parameters | - | + +# **v3GetConfig** +> GetConfigOutputBody v3GetConfig() + +Get client configuration. + +Returns the settings a client needs to configure itself: where to send users to view results, the largest binary the calling user may submit, and what AI decompilation supports. The size limit reflects the caller's own role and tier. + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.ConfigApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + ConfigApi apiInstance = new ConfigApi(defaultClient); + try { + GetConfigOutputBody result = apiInstance.v3GetConfig(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ConfigApi#v3GetConfig"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**GetConfigOutputBody**](GetConfigOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **0** | Error | - | + + +# **v3GetModels** +> GetModelsOutputBody v3GetModels() + +Get the models available for analysis. + +Returns the models a new analysis can be run on, by base name — the architecture and platform variants a model is built for are collapsed into one entry, and models no longer offered are omitted. **Error codes:** - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.ConfigApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + ConfigApi apiInstance = new ConfigApi(defaultClient); + try { + GetModelsOutputBody result = apiInstance.v3GetModels(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ConfigApi#v3GetModels"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**GetModelsOutputBody**](GetModelsOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **500** | Internal Server Error | - | + diff --git a/docs/Connection.md b/docs/Connection.md index b0b3643b..28064b67 100644 --- a/docs/Connection.md +++ b/docs/Connection.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**bytesReceived** | **Long** | | [optional] | |**bytesSent** | **Long** | | [optional] | -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**ja3** | **String** | | [optional] | |**ja3s** | **String** | | [optional] | |**localIp** | **String** | | | @@ -17,7 +17,7 @@ |**protocol** | **String** | | | |**remoteIp** | **String** | | | |**remotePort** | **Object** | | | -|**tcpCarvedFiles** | [**List<TcpCarvedFile>**](TcpCarvedFile.md) | | [optional] | +|**tcpCarvedFiles** | **List<TcpCarvedFile>** | | [optional] | diff --git a/docs/ConversationWithEvents.md b/docs/ConversationWithEvents.md index 22853f7b..d570b0ef 100644 --- a/docs/ConversationWithEvents.md +++ b/docs/ConversationWithEvents.md @@ -10,7 +10,7 @@ |**context** | **Object** | | [optional] | |**conversationUuid** | **String** | | | |**createdAt** | **OffsetDateTime** | | | -|**events** | [**List<Event>**](Event.md) | | | +|**events** | **List<Event>** | | | |**title** | **String** | | | |**updatedAt** | **OffsetDateTime** | | | |**userId** | **Long** | | | diff --git a/docs/CopyFunctionSignaturesInputBody.md b/docs/CopyFunctionSignaturesInputBody.md index ffc4e012..8eef3110 100644 --- a/docs/CopyFunctionSignaturesInputBody.md +++ b/docs/CopyFunctionSignaturesInputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**copies** | [**List<CopySignatureItem>**](CopySignatureItem.md) | Signatures to copy. No target may repeat, and no pair may name the same function twice. | | +|**copies** | **List<CopySignatureItem>** | Signatures to copy. No target may repeat, and no pair may name the same function twice. | | diff --git a/docs/CopyFunctionSignaturesOutputBody.md b/docs/CopyFunctionSignaturesOutputBody.md index b908b665..fda497b2 100644 --- a/docs/CopyFunctionSignaturesOutputBody.md +++ b/docs/CopyFunctionSignaturesOutputBody.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypes** | [**List<DataTypeEntry>**](DataTypeEntry.md) | The data types this analysis gained or had replaced, ordered by data_type_id. Empty when every type the copied signatures need was already stored unchanged. | | -|**signatures** | [**List<FunctionSignatureEntry>**](FunctionSignatureEntry.md) | The stored signatures of the target functions, in request order. | | +|**signatures** | **List<FunctionSignatureEntry>** | The stored signatures of the target functions, in request order. | | diff --git a/docs/CreateArrayDataType.md b/docs/CreateArrayDataType.md index 1d3b244f..3690339b 100644 --- a/docs/CreateArrayDataType.md +++ b/docs/CreateArrayDataType.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**ArrayDefinition**](ArrayDefinition.md) | | | +|**definition** | **ArrayDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CreateCollectionOutputBody.md b/docs/CreateCollectionOutputBody.md index 691a8e3d..dcfb6fc4 100644 --- a/docs/CreateCollectionOutputBody.md +++ b/docs/CreateCollectionOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**binaries** | [**List<Binary>**](Binary.md) | | [optional] | +|**binaries** | **List<Binary>** | | [optional] | |**collectionId** | **Long** | | | |**collectionName** | **String** | | | |**collectionScope** | **String** | | | diff --git a/docs/CreateConversationRequest.md b/docs/CreateConversationRequest.md index b05699d0..cdacf9ad 100644 --- a/docs/CreateConversationRequest.md +++ b/docs/CreateConversationRequest.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**context** | [**ConversationContext**](ConversationContext.md) | | [optional] | +|**context** | **ConversationContext** | | [optional] | |**title** | **String** | | [optional] | diff --git a/docs/CreateDataTypeEntry.md b/docs/CreateDataTypeEntry.md index 9af0dd00..9100c005 100644 --- a/docs/CreateDataTypeEntry.md +++ b/docs/CreateDataTypeEntry.md @@ -8,7 +8,7 @@ A data type to create. `kind` selects the variant and so which definition the ty | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**FunctionTypeDefinition**](FunctionTypeDefinition.md) | | | +|**definition** | **FunctionTypeDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CreateEnumDataType.md b/docs/CreateEnumDataType.md index 255cdfbf..7d8e9a93 100644 --- a/docs/CreateEnumDataType.md +++ b/docs/CreateEnumDataType.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**EnumDefinition**](EnumDefinition.md) | | | +|**definition** | **EnumDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CreateFunctionDataType.md b/docs/CreateFunctionDataType.md index efa478e1..cce69e24 100644 --- a/docs/CreateFunctionDataType.md +++ b/docs/CreateFunctionDataType.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**FunctionTypeDefinition**](FunctionTypeDefinition.md) | | | +|**definition** | **FunctionTypeDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CreateMetadata.md b/docs/CreateMetadata.md new file mode 100644 index 00000000..e9440eca --- /dev/null +++ b/docs/CreateMetadata.md @@ -0,0 +1,28 @@ + + +# CreateMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Analysis ID | | +|**binaryId** | **Long** | Binary ID | | +|**status** | [**StatusEnum**](#StatusEnum) | Analysis status | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UPLOADED | "Uploaded" | +| QUEUED | "Queued" | +| PROCESSING | "Processing" | +| COMPLETE | "Complete" | +| ERROR | "Error" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CreatePointerDataType.md b/docs/CreatePointerDataType.md index 67b32992..3475be2d 100644 --- a/docs/CreatePointerDataType.md +++ b/docs/CreatePointerDataType.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**PointerDefinition**](PointerDefinition.md) | | | +|**definition** | **PointerDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CreateRequest.md b/docs/CreateRequest.md new file mode 100644 index 00000000..2dce8d28 --- /dev/null +++ b/docs/CreateRequest.md @@ -0,0 +1,32 @@ + + +# CreateRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisConfig** | **Config** | | [optional] | +|**analysisScope** | [**AnalysisScopeEnum**](#AnalysisScopeEnum) | | [optional] | +|**autoRunAgents** | **AutoRunAgents** | | [optional] | +|**binaryConfig** | **BinaryConfig** | | [optional] | +|**debugHash** | **String** | | [optional] | +|**filename** | **String** | | | +|**sha256Hash** | **String** | | | +|**symbols** | **Symbols** | | [optional] | +|**tags** | **List<String>** | | [optional] | + + + +## Enum: AnalysisScopeEnum + +| Name | Value | +|---- | -----| +| PRIVATE | "PRIVATE" | +| PUBLIC | "PUBLIC" | +| TEAM | "TEAM" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CreateResult.md b/docs/CreateResult.md new file mode 100644 index 00000000..b103d29a --- /dev/null +++ b/docs/CreateResult.md @@ -0,0 +1,14 @@ + + +# CreateResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Analysis ID | | +|**binaryId** | **Long** | Binary ID | | + + + diff --git a/docs/CreateStructDataType.md b/docs/CreateStructDataType.md index 43cfe4ed..923854dd 100644 --- a/docs/CreateStructDataType.md +++ b/docs/CreateStructDataType.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**StructDefinition**](StructDefinition.md) | | | +|**definition** | **StructDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CreateTypedefDataType.md b/docs/CreateTypedefDataType.md index 4ed58d79..369f80c2 100644 --- a/docs/CreateTypedefDataType.md +++ b/docs/CreateTypedefDataType.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**TypedefDefinition**](TypedefDefinition.md) | | | +|**definition** | **TypedefDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CreateUnionDataType.md b/docs/CreateUnionDataType.md index 57e41415..951faa5d 100644 --- a/docs/CreateUnionDataType.md +++ b/docs/CreateUnionDataType.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**definition** | [**UnionDefinition**](UnionDefinition.md) | | | +|**definition** | **UnionDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/CryptoCall.md b/docs/CryptoCall.md new file mode 100644 index 00000000..b1b09597 --- /dev/null +++ b/docs/CryptoCall.md @@ -0,0 +1,60 @@ + + +# CryptoCall + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**calleeName** | **String** | Name of the called function | | +|**category** | [**CategoryEnum**](#CategoryEnum) | Crypto category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**library** | [**LibraryEnum**](#LibraryEnum) | Crypto library the match belongs to | | +|**matchedName** | **String** | Name or token that matched | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| SYMMETRIC | "symmetric" | +| ASYMMETRIC | "asymmetric" | +| HASHING | "hashing" | +| MAC | "mac" | +| KDF | "kdf" | +| RNG | "rng" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| LIBRARY_API | "library-api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: LibraryEnum + +| Name | Value | +|---- | -----| +| OPENSSL | "openssl" | +| MBEDTLS | "mbedtls" | +| WOLFSSL | "wolfssl" | +| LIBSODIUM | "libsodium" | +| LIBGCRYPT | "libgcrypt" | +| WINDOWS_CRYPTO_API | "windows_crypto_api" | +| CRYPTOPP | "cryptopp" | +| CPP_CRYPTO | "cpp-crypto" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CryptoDirectMatch.md b/docs/CryptoDirectMatch.md new file mode 100644 index 00000000..df777070 --- /dev/null +++ b/docs/CryptoDirectMatch.md @@ -0,0 +1,59 @@ + + +# CryptoDirectMatch + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**category** | [**CategoryEnum**](#CategoryEnum) | Crypto category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**library** | [**LibraryEnum**](#LibraryEnum) | Crypto library the match belongs to | | +|**matchedName** | **String** | Name or token that matched | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| SYMMETRIC | "symmetric" | +| ASYMMETRIC | "asymmetric" | +| HASHING | "hashing" | +| MAC | "mac" | +| KDF | "kdf" | +| RNG | "rng" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| LIBRARY_API | "library-api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: LibraryEnum + +| Name | Value | +|---- | -----| +| OPENSSL | "openssl" | +| MBEDTLS | "mbedtls" | +| WOLFSSL | "wolfssl" | +| LIBSODIUM | "libsodium" | +| LIBGCRYPT | "libgcrypt" | +| WINDOWS_CRYPTO_API | "windows_crypto_api" | +| CRYPTOPP | "cryptopp" | +| CPP_CRYPTO | "cpp-crypto" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CryptoExplainMetadata.md b/docs/CryptoExplainMetadata.md new file mode 100644 index 00000000..2dae8ebb --- /dev/null +++ b/docs/CryptoExplainMetadata.md @@ -0,0 +1,27 @@ + + +# CryptoExplainMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this function. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CryptoExplainResult.md b/docs/CryptoExplainResult.md new file mode 100644 index 00000000..3538975a --- /dev/null +++ b/docs/CryptoExplainResult.md @@ -0,0 +1,18 @@ + + +# CryptoExplainResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cancelled** | **Boolean** | Whether the run was cancelled | | +|**error** | **String** | Why no explanation could be produced. Empty when the run succeeded. | [optional] | +|**functionId** | **Long** | ID of the explained function | | +|**functionName** | **String** | Name of the explained function | [optional] | +|**functionsInvolved** | **List<CryptoExplainedFunction>** | Other functions involved in the cryptographic operation | [optional] | +|**summary** | **String** | Explanation of the cryptography the function performs | [optional] | + + + diff --git a/docs/CryptoExplainedFunction.md b/docs/CryptoExplainedFunction.md new file mode 100644 index 00000000..3385bb06 --- /dev/null +++ b/docs/CryptoExplainedFunction.md @@ -0,0 +1,15 @@ + + +# CryptoExplainedFunction + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**description** | **String** | Role this function plays in the cryptographic operation | | +|**functionId** | **Long** | ID of the function | | +|**functionName** | **String** | Name of the function | | + + + diff --git a/docs/CryptoFinding.md b/docs/CryptoFinding.md new file mode 100644 index 00000000..f4af2924 --- /dev/null +++ b/docs/CryptoFinding.md @@ -0,0 +1,64 @@ + + +# CryptoFinding + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**address** | **String** | Function's virtual address, hex-encoded | | +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Distinct crypto categories evidenced by this function | | +|**confidence** | [**ConfidenceEnum**](#ConfidenceEnum) | High when a direct name match was found, medium when the function only calls into crypto APIs | | +|**cryptoCalls** | **List<CryptoCall>** | Matches against names this function calls | [optional] | +|**directMatches** | **List<CryptoDirectMatch>** | Matches against the function's own name | [optional] | +|**evidenceCount** | **Long** | Total number of direct matches and crypto calls | | +|**functionId** | **Long** | ID of the function the finding was reported in | | +|**functionName** | **String** | Name of the function the finding was reported in | | +|**functionSize** | **Long** | Size of the function in bytes | | +|**libraries** | [**List<LibrariesEnum>**](#List<LibrariesEnum>) | Distinct crypto libraries evidenced by this function | | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| SYMMETRIC | "symmetric" | +| ASYMMETRIC | "asymmetric" | +| HASHING | "hashing" | +| MAC | "mac" | +| KDF | "kdf" | +| RNG | "rng" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: ConfidenceEnum + +| Name | Value | +|---- | -----| +| HIGH | "high" | +| MEDIUM | "medium" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<LibrariesEnum> + +| Name | Value | +|---- | -----| +| OPENSSL | "openssl" | +| MBEDTLS | "mbedtls" | +| WOLFSSL | "wolfssl" | +| LIBSODIUM | "libsodium" | +| LIBGCRYPT | "libgcrypt" | +| WINDOWS_CRYPTO_API | "windows_crypto_api" | +| CRYPTOPP | "cryptopp" | +| CPP_CRYPTO | "cpp-crypto" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CryptoScanMetadata.md b/docs/CryptoScanMetadata.md new file mode 100644 index 00000000..c6d107e6 --- /dev/null +++ b/docs/CryptoScanMetadata.md @@ -0,0 +1,27 @@ + + +# CryptoScanMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this analysis. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/CryptoScanResult.md b/docs/CryptoScanResult.md new file mode 100644 index 00000000..06d94d76 --- /dev/null +++ b/docs/CryptoScanResult.md @@ -0,0 +1,15 @@ + + +# CryptoScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Analysis the run was performed against | | +|**findings** | **List<CryptoFinding>** | Functions with crypto-related evidence, sorted by confidence then evidence count | [optional] | +|**totalFunctions** | **Long** | Functions the run considered | | + + + diff --git a/docs/DataTypeEntry.md b/docs/DataTypeEntry.md index eb591fba..833ba73d 100644 --- a/docs/DataTypeEntry.md +++ b/docs/DataTypeEntry.md @@ -10,12 +10,13 @@ A data type extracted from the binary. `kind` selects the variant and so which d |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**FunctionTypeDefinition**](FunctionTypeDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **FunctionTypeDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/DataTypeVersion.md b/docs/DataTypeVersion.md index 98ebbe6a..b44cd047 100644 --- a/docs/DataTypeVersion.md +++ b/docs/DataTypeVersion.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**updatedAt** | **OffsetDateTime** | When this version was written. Absent on a version that predates the recorded history. | [optional] | -|**updatedBy** | [**HistoryActor**](HistoryActor.md) | Who wrote this version. Absent on a version that predates the recorded history. | [optional] | +|**updatedBy** | **HistoryActor** | Who wrote this version. Absent on a version that predates the recorded history. | [optional] | |**value** | [**DataTypeEntry**](DataTypeEntry.md) | The type as it stood in this version. | | diff --git a/docs/DecompilerSummary.md b/docs/DecompilerSummary.md new file mode 100644 index 00000000..2c1d7705 --- /dev/null +++ b/docs/DecompilerSummary.md @@ -0,0 +1,15 @@ + + +# DecompilerSummary + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**subject** | [**Subject**](Subject.md) | | | +|**summary** | **String** | | | +|**reachability** | [**CallChain**](CallChain.md) | | [optional] | + + + diff --git a/docs/DecompilerSummaryEvidence.md b/docs/DecompilerSummaryEvidence.md new file mode 100644 index 00000000..f3d2d18b --- /dev/null +++ b/docs/DecompilerSummaryEvidence.md @@ -0,0 +1,45 @@ + + +# DecompilerSummaryEvidence + +Semantic summaries derived from decompiler output. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**summaries** | [**List<DecompilerSummary>**](DecompilerSummary.md) | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| DECOMPILER_SUMMARY | "decompiler_summary" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| MODEL_INTERPRETATION | "model_interpretation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| INDIRECT | "indirect" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/DieMatch.md b/docs/DieMatch.md index 9034d0f2..2661a112 100644 --- a/docs/DieMatch.md +++ b/docs/DieMatch.md @@ -7,10 +7,10 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**name** | **String** | Canonical name of the matched signature/technology (e.g., 'UPX', 'GCC', 'MSVC'). | | -|**type** | **String** | Category assigned by DIE for the match (e.g., 'compiler', 'packer', 'file'). | | -|**display** | **String** | Human-readable description from DIE's 'string' field; suitable for UI/logs, not for parsing. | | -|**version** | **String** | Extracted version string when available; may be empty/None if unknown. | | +|**display** | **String** | Human-readable description from DIE; suitable for display, not parsing | | +|**name** | **String** | Canonical name of the matched signature or technology | | +|**type** | **String** | Category DIE assigns the match, such as compiler, packer or file | | +|**version** | **String** | Version DIE extracted, empty when it could not determine one | | diff --git a/docs/Display.md b/docs/Display.md new file mode 100644 index 00000000..bffcff66 --- /dev/null +++ b/docs/Display.md @@ -0,0 +1,29 @@ + + +# Display + +## Enum + + +* `HEX` (value: `"hex"`) + +* `UINT8` (value: `"uint8"`) + +* `UINT16` (value: `"uint16"`) + +* `UINT32` (value: `"uint32"`) + +* `UINT64` (value: `"uint64"`) + +* `INT8` (value: `"int8"`) + +* `INT16` (value: `"int16"`) + +* `INT32` (value: `"int32"`) + +* `INT64` (value: `"int64"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/DnsQuery.md b/docs/DnsQuery.md index 1305ea42..5050a529 100644 --- a/docs/DnsQuery.md +++ b/docs/DnsQuery.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**cnameChain** | **List<String>** | | [optional] | |**domain** | **String** | | | -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**minTtl** | **Long** | | [optional] | |**resolvedIps** | **List<String>** | | [optional] | diff --git a/docs/DynamicExecutionStatusResponse.md b/docs/DynamicExecutionStatusResponse.md index 6a7cdb1c..39bada65 100644 --- a/docs/DynamicExecutionStatusResponse.md +++ b/docs/DynamicExecutionStatusResponse.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**errorMessage** | **String** | Error detail, set when status is FAILED | [optional] | -|**logs** | [**AnalysisLogs**](AnalysisLogs.md) | Sandbox status log messages captured during the run. Empty when none have been captured yet. | | +|**logs** | **AnalysisLogs** | Sandbox status log messages captured during the run. Empty when none have been captured yet. | | |**status** | [**StatusEnum**](#StatusEnum) | Task status | | diff --git a/docs/Endianness.md b/docs/Endianness.md new file mode 100644 index 00000000..0eea4397 --- /dev/null +++ b/docs/Endianness.md @@ -0,0 +1,17 @@ + + +# Endianness + +## Enum + + +* `UNSPECIFIED` (value: `"unspecified"`) + +* `LITTLE` (value: `"little"`) + +* `BIG` (value: `"big"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/EnumDataType.md b/docs/EnumDataType.md index 3f35b4e6..22205e01 100644 --- a/docs/EnumDataType.md +++ b/docs/EnumDataType.md @@ -9,12 +9,13 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**EnumDefinition**](EnumDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **EnumDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/EnumDefinition.md b/docs/EnumDefinition.md index 0c15972a..ad3fe7c1 100644 --- a/docs/EnumDefinition.md +++ b/docs/EnumDefinition.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**values** | [**List<DataTypeEnumValueEntry>**](DataTypeEnumValueEntry.md) | The type's constants. | | +|**values** | **List<DataTypeEnumValueEntry>** | The type's constants. | | diff --git a/docs/ErrorBody.md b/docs/ErrorBody.md index ddc8a0e1..fc480f14 100644 --- a/docs/ErrorBody.md +++ b/docs/ErrorBody.md @@ -20,14 +20,6 @@ | Name | Value | |---- | -----| | ACCESS_DENIED | "ACCESS_DENIED" | -| AGENT_BUDGET_EXCEEDED | "AGENT_BUDGET_EXCEEDED" | -| AGENT_DEFINITION_NOT_FOUND | "AGENT_DEFINITION_NOT_FOUND" | -| AGENT_INVALID_STARTING_INPUT | "AGENT_INVALID_STARTING_INPUT" | -| AGENT_MEMORY_INVALID_SCOPE | "AGENT_MEMORY_INVALID_SCOPE" | -| AGENT_MEMORY_NOT_FOUND | "AGENT_MEMORY_NOT_FOUND" | -| AGENT_MEMORY_VERSION_CONFLICT | "AGENT_MEMORY_VERSION_CONFLICT" | -| AGENT_NO_PENDING_QUESTION | "AGENT_NO_PENDING_QUESTION" | -| AGENT_RUN_NOT_FOUND | "AGENT_RUN_NOT_FOUND" | | ALREADY_EXISTS | "ALREADY_EXISTS" | | ANALYSIS_NOT_READY | "ANALYSIS_NOT_READY" | | BAD_REQUEST | "BAD_REQUEST" | @@ -56,6 +48,7 @@ | METHOD_NOT_ALLOWED | "METHOD_NOT_ALLOWED" | | NOT_ACCEPTABLE | "NOT_ACCEPTABLE" | | NOT_FOUND | "NOT_FOUND" | +| NOT_IMPLEMENTED | "NOT_IMPLEMENTED" | | NO_ACTIVE_RUN | "NO_ACTIVE_RUN" | | NO_PENDING_CONFIRMATION | "NO_PENDING_CONFIRMATION" | | OIDC_DISCOVERY_FAILED | "OIDC_DISCOVERY_FAILED" | diff --git a/docs/EventAttemptFailed.md b/docs/EventAttemptFailed.md index 0e762936..d0785f8d 100644 --- a/docs/EventAttemptFailed.md +++ b/docs/EventAttemptFailed.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**AttemptFailedEvent**](AttemptFailedEvent.md) | | | +|**data** | **AttemptFailedEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventAttemptStarted.md b/docs/EventAttemptStarted.md index dad1fe57..79bf23f5 100644 --- a/docs/EventAttemptStarted.md +++ b/docs/EventAttemptStarted.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**AttemptStartedEvent**](AttemptStartedEvent.md) | | | +|**data** | **AttemptStartedEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventCONTEXTCOMPACTED.md b/docs/EventCONTEXTCOMPACTED.md index bf346d62..1908eb58 100644 --- a/docs/EventCONTEXTCOMPACTED.md +++ b/docs/EventCONTEXTCOMPACTED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventContextCompactedData**](SseEventContextCompactedData.md) | | | +|**data** | **SseEventContextCompactedData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventDecompFailed.md b/docs/EventDecompFailed.md index 37cee435..b35cd520 100644 --- a/docs/EventDecompFailed.md +++ b/docs/EventDecompFailed.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**DecompFailedEvent**](DecompFailedEvent.md) | | | +|**data** | **DecompFailedEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventDecompFinished.md b/docs/EventDecompFinished.md index 53a89e2a..0a0d346f 100644 --- a/docs/EventDecompFinished.md +++ b/docs/EventDecompFinished.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**DecompFinishedEvent**](DecompFinishedEvent.md) | | | +|**data** | **DecompFinishedEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventNamesFinished.md b/docs/EventNamesFinished.md new file mode 100644 index 00000000..2f267fdc --- /dev/null +++ b/docs/EventNamesFinished.md @@ -0,0 +1,25 @@ + + +# EventNamesFinished + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**data** | **NamesFinishedEvent** | | | +|**event** | [**EventEnum**](#EventEnum) | The event name. | | +|**id** | **Integer** | The event ID. | [optional] | +|**retry** | **Integer** | The retry time in milliseconds. | [optional] | + + + +## Enum: EventEnum + +| Name | Value | +|---- | -----| +| NAMES_FINISHED | "names_finished" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/EventProse.md b/docs/EventProse.md index be636af9..d1259f78 100644 --- a/docs/EventProse.md +++ b/docs/EventProse.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**ProseEvent**](ProseEvent.md) | | | +|**data** | **ProseEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNCANCELLED.md b/docs/EventRUNCANCELLED.md index 5cf796d5..7885d32b 100644 --- a/docs/EventRUNCANCELLED.md +++ b/docs/EventRUNCANCELLED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventRunCancelledData**](SseEventRunCancelledData.md) | | | +|**data** | **SseEventRunCancelledData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNERROR.md b/docs/EventRUNERROR.md index ca39024c..98aa3d83 100644 --- a/docs/EventRUNERROR.md +++ b/docs/EventRUNERROR.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventRunErrorData**](SseEventRunErrorData.md) | | | +|**data** | **SseEventRunErrorData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNFINISHED.md b/docs/EventRUNFINISHED.md index 1632ea8a..73b8959a 100644 --- a/docs/EventRUNFINISHED.md +++ b/docs/EventRUNFINISHED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventRunFinishedData**](SseEventRunFinishedData.md) | | | +|**data** | **SseEventRunFinishedData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNSTARTED.md b/docs/EventRUNSTARTED.md index 8cef2498..e5feb036 100644 --- a/docs/EventRUNSTARTED.md +++ b/docs/EventRUNSTARTED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventRunStartedData**](SseEventRunStartedData.md) | | | +|**data** | **SseEventRunStartedData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRenameApplied.md b/docs/EventRenameApplied.md index c8005916..14272f71 100644 --- a/docs/EventRenameApplied.md +++ b/docs/EventRenameApplied.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**RenameAppliedEvent**](RenameAppliedEvent.md) | | | +|**data** | **RenameAppliedEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSTEPFINISHED.md b/docs/EventSTEPFINISHED.md index 90b815d0..a0274a7d 100644 --- a/docs/EventSTEPFINISHED.md +++ b/docs/EventSTEPFINISHED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventStepFinishedData**](SseEventStepFinishedData.md) | | | +|**data** | **SseEventStepFinishedData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSTEPSTARTED.md b/docs/EventSTEPSTARTED.md index 24c9d297..6cf63ead 100644 --- a/docs/EventSTEPSTARTED.md +++ b/docs/EventSTEPSTARTED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventStepStartedData**](SseEventStepStartedData.md) | | | +|**data** | **SseEventStepStartedData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSourceDelta.md b/docs/EventSourceDelta.md index c17af258..fd47d40e 100644 --- a/docs/EventSourceDelta.md +++ b/docs/EventSourceDelta.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SourceDeltaEvent**](SourceDeltaEvent.md) | | | +|**data** | **SourceDeltaEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSourceReset.md b/docs/EventSourceReset.md index d89f32f8..3771eab9 100644 --- a/docs/EventSourceReset.md +++ b/docs/EventSourceReset.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SourceResetEvent**](SourceResetEvent.md) | | | +|**data** | **SourceResetEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTEXTMESSAGECONTENT.md b/docs/EventTEXTMESSAGECONTENT.md index 628710a5..686a8151 100644 --- a/docs/EventTEXTMESSAGECONTENT.md +++ b/docs/EventTEXTMESSAGECONTENT.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventTextMessageContentData**](SseEventTextMessageContentData.md) | | | +|**data** | **SseEventTextMessageContentData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTEXTMESSAGEEND.md b/docs/EventTEXTMESSAGEEND.md index 62dda38b..fe89c0d2 100644 --- a/docs/EventTEXTMESSAGEEND.md +++ b/docs/EventTEXTMESSAGEEND.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventTextMessageEndData**](SseEventTextMessageEndData.md) | | | +|**data** | **SseEventTextMessageEndData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTEXTMESSAGESTART.md b/docs/EventTEXTMESSAGESTART.md index c73748a3..95d3c1f3 100644 --- a/docs/EventTEXTMESSAGESTART.md +++ b/docs/EventTEXTMESSAGESTART.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventTextMessageStartData**](SseEventTextMessageStartData.md) | | | +|**data** | **SseEventTextMessageStartData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTITLEUPDATED.md b/docs/EventTITLEUPDATED.md index 0a3f2b75..e649defb 100644 --- a/docs/EventTITLEUPDATED.md +++ b/docs/EventTITLEUPDATED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventTitleUpdatedData**](SseEventTitleUpdatedData.md) | | | +|**data** | **SseEventTitleUpdatedData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLARGSDELTA.md b/docs/EventTOOLCALLARGSDELTA.md index d0591f26..87771992 100644 --- a/docs/EventTOOLCALLARGSDELTA.md +++ b/docs/EventTOOLCALLARGSDELTA.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventToolCallArgsDeltaData**](SseEventToolCallArgsDeltaData.md) | | | +|**data** | **SseEventToolCallArgsDeltaData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLEND.md b/docs/EventTOOLCALLEND.md index db4cd41c..3a885fc9 100644 --- a/docs/EventTOOLCALLEND.md +++ b/docs/EventTOOLCALLEND.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventToolCallEndData**](SseEventToolCallEndData.md) | | | +|**data** | **SseEventToolCallEndData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLPROGRESS.md b/docs/EventTOOLCALLPROGRESS.md index 236a8690..5d5769d7 100644 --- a/docs/EventTOOLCALLPROGRESS.md +++ b/docs/EventTOOLCALLPROGRESS.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventToolCallProgressData**](SseEventToolCallProgressData.md) | | | +|**data** | **SseEventToolCallProgressData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLRESULT.md b/docs/EventTOOLCALLRESULT.md index 9d5595ca..e3721d52 100644 --- a/docs/EventTOOLCALLRESULT.md +++ b/docs/EventTOOLCALLRESULT.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventToolCallResultData**](SseEventToolCallResultData.md) | | | +|**data** | **SseEventToolCallResultData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLSTART.md b/docs/EventTOOLCALLSTART.md index bcb7fb57..9d296203 100644 --- a/docs/EventTOOLCALLSTART.md +++ b/docs/EventTOOLCALLSTART.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventToolCallStartData**](SseEventToolCallStartData.md) | | | +|**data** | **SseEventToolCallStartData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCONFIRMATIONREQUIRED.md b/docs/EventTOOLCONFIRMATIONREQUIRED.md index b38229c0..a5b57459 100644 --- a/docs/EventTOOLCONFIRMATIONREQUIRED.md +++ b/docs/EventTOOLCONFIRMATIONREQUIRED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventToolConfirmationRequiredData**](SseEventToolConfirmationRequiredData.md) | | | +|**data** | **SseEventToolConfirmationRequiredData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTypesSuggested.md b/docs/EventTypesSuggested.md new file mode 100644 index 00000000..c35254dd --- /dev/null +++ b/docs/EventTypesSuggested.md @@ -0,0 +1,25 @@ + + +# EventTypesSuggested + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**data** | **TypesSuggestedEvent** | | | +|**event** | [**EventEnum**](#EventEnum) | The event name. | | +|**id** | **Integer** | The event ID. | [optional] | +|**retry** | **Integer** | The retry time in milliseconds. | [optional] | + + + +## Enum: EventEnum + +| Name | Value | +|---- | -----| +| TYPES_SUGGESTED | "types_suggested" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/EventWarning.md b/docs/EventWarning.md index 2313d861..d7cd5cf0 100644 --- a/docs/EventWarning.md +++ b/docs/EventWarning.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**WarningEvent**](WarningEvent.md) | | | +|**data** | **WarningEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EvidenceEffect.md b/docs/EvidenceEffect.md new file mode 100644 index 00000000..691c041e --- /dev/null +++ b/docs/EvidenceEffect.md @@ -0,0 +1,15 @@ + + +# EvidenceEffect + +## Enum + + +* `SUPPORTS` (value: `"supports"`) + +* `REFUTES` (value: `"refutes"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/EvidenceInner.md b/docs/EvidenceInner.md new file mode 100644 index 00000000..bfe30f63 --- /dev/null +++ b/docs/EvidenceInner.md @@ -0,0 +1,59 @@ + + +# EvidenceInner + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | [**EffectEnum**](#EffectEnum) | | | +|**strength** | **EvidenceStrength** | | | +|**callChain** | **List<Integer>** | | | +|**constants** | [**List<ReferencedConstant>**](ReferencedConstant.md) | | | +|**calls** | [**List<ImportedApiCall>**](ImportedApiCall.md) | | | +|**strings** | [**List<SuspiciousString>**](SuspiciousString.md) | | | +|**similarities** | [**List<FunctionSimilarity>**](FunctionSimilarity.md) | | | +|**apis** | [**List<ImportedApi>**](ImportedApi.md) | | | +|**summaries** | [**List<DecompilerSummary>**](DecompilerSummary.md) | | | +|**interpretations** | [**List<ModelInterpretation>**](ModelInterpretation.md) | | | +|**values** | **List<BytesConstant>** | | | +|**ruleId** | **String** | | | +|**description** | **String** | | | +|**secretKind** | **RuleKind** | | | +|**secret** | **String** | | | +|**entropy** | **BigDecimal** | | | +|**size** | **Integer** | | | +|**references** | **List<Integer>** | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| HARDCODED_SECRET | "hardcoded_secret" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: EffectEnum + +| Name | Value | +|---- | -----| +| SUPPORTS | "supports" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/EvidenceStrength.md b/docs/EvidenceStrength.md new file mode 100644 index 00000000..87d06894 --- /dev/null +++ b/docs/EvidenceStrength.md @@ -0,0 +1,15 @@ + + +# EvidenceStrength + +## Enum + + +* `DIRECT` (value: `"direct"`) + +* `INDIRECT` (value: `"indirect"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/ExecutionCall.md b/docs/ExecutionCall.md new file mode 100644 index 00000000..923b463b --- /dev/null +++ b/docs/ExecutionCall.md @@ -0,0 +1,62 @@ + + +# ExecutionCall + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**calleeName** | **String** | Name of the called function | | +|**category** | [**CategoryEnum**](#CategoryEnum) | Execution category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**matchedName** | **String** | Name or token that matched | | +|**source** | [**SourceEnum**](#SourceEnum) | Execution source the match belongs to | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| DYNAMIC_RESOLVE | "dynamic-resolve" | +| HOOKING | "hooking" | +| INJECTION | "injection" | +| MEMORY_EXEC | "memory-exec" | +| MODULE_LOAD | "module-load" | +| PROCESS_CONTROL | "process-control" | +| PROCESS_CREATE | "process-create" | +| SCRIPT_EXEC | "script-exec" | +| SHELLCODE | "shellcode" | +| THREAD_CREATE | "thread-create" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| API | "api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: SourceEnum + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| SCRIPT_ENGINE | "script-engine" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ExecutionDirectMatch.md b/docs/ExecutionDirectMatch.md new file mode 100644 index 00000000..16cabe72 --- /dev/null +++ b/docs/ExecutionDirectMatch.md @@ -0,0 +1,61 @@ + + +# ExecutionDirectMatch + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**category** | [**CategoryEnum**](#CategoryEnum) | Execution category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**matchedName** | **String** | Name or token that matched | | +|**source** | [**SourceEnum**](#SourceEnum) | Execution source the match belongs to | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| DYNAMIC_RESOLVE | "dynamic-resolve" | +| HOOKING | "hooking" | +| INJECTION | "injection" | +| MEMORY_EXEC | "memory-exec" | +| MODULE_LOAD | "module-load" | +| PROCESS_CONTROL | "process-control" | +| PROCESS_CREATE | "process-create" | +| SCRIPT_EXEC | "script-exec" | +| SHELLCODE | "shellcode" | +| THREAD_CREATE | "thread-create" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| API | "api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: SourceEnum + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| SCRIPT_ENGINE | "script-engine" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ExecutionExplainMetadata.md b/docs/ExecutionExplainMetadata.md new file mode 100644 index 00000000..ab72f706 --- /dev/null +++ b/docs/ExecutionExplainMetadata.md @@ -0,0 +1,27 @@ + + +# ExecutionExplainMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this function. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ExecutionExplainResult.md b/docs/ExecutionExplainResult.md new file mode 100644 index 00000000..4db47f66 --- /dev/null +++ b/docs/ExecutionExplainResult.md @@ -0,0 +1,22 @@ + + +# ExecutionExplainResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cancelled** | **Boolean** | Whether the run was cancelled | | +|**codeOrigin** | **String** | Where the executed code originates from | [optional] | +|**executedTargets** | **List<String>** | Concrete targets that end up executed -- process names, module paths, or shellcode buffers | [optional] | +|**functionId** | **Long** | ID of the explained function | | +|**functionName** | **String** | Name of the explained function | [optional] | +|**functionsInvolved** | **List<ExecutionExplainedFunction>** | Other functions involved in the code execution | [optional] | +|**purpose** | **String** | Purpose of the code execution | [optional] | +|**summary** | **String** | Explanation of the code execution the function performs | [optional] | +|**trigger** | **String** | What triggers the execution | [optional] | +|**whatExecutes** | **String** | What code ends up executing | [optional] | + + + diff --git a/docs/ExecutionExplainedFunction.md b/docs/ExecutionExplainedFunction.md new file mode 100644 index 00000000..e693151d --- /dev/null +++ b/docs/ExecutionExplainedFunction.md @@ -0,0 +1,15 @@ + + +# ExecutionExplainedFunction + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**description** | **String** | Role this function plays in the code execution | | +|**functionId** | **Long** | ID of the function | | +|**functionName** | **String** | Name of the function | | + + + diff --git a/docs/ExecutionFinding.md b/docs/ExecutionFinding.md new file mode 100644 index 00000000..94fca008 --- /dev/null +++ b/docs/ExecutionFinding.md @@ -0,0 +1,67 @@ + + +# ExecutionFinding + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**address** | **String** | Function's virtual address, hex-encoded | | +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Distinct execution categories evidenced by this function | | +|**confidence** | [**ConfidenceEnum**](#ConfidenceEnum) | High when a direct name match was found, medium when the function only calls into execution APIs | | +|**directMatches** | **List<ExecutionDirectMatch>** | Matches against the function's own name | [optional] | +|**evidenceCount** | **Long** | Total number of direct matches and execution calls | | +|**executes** | **Boolean** | Whether this function evidences executing code rather than only supporting it | | +|**executionCalls** | **List<ExecutionCall>** | Matches against names this function calls | [optional] | +|**functionId** | **Long** | ID of the function the finding was reported in | | +|**functionName** | **String** | Name of the function the finding was reported in | | +|**functionSize** | **Long** | Size of the function in bytes | | +|**sources** | [**List<SourcesEnum>**](#List<SourcesEnum>) | Distinct execution sources evidenced by this function | | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| DYNAMIC_RESOLVE | "dynamic-resolve" | +| HOOKING | "hooking" | +| INJECTION | "injection" | +| MEMORY_EXEC | "memory-exec" | +| MODULE_LOAD | "module-load" | +| PROCESS_CONTROL | "process-control" | +| PROCESS_CREATE | "process-create" | +| SCRIPT_EXEC | "script-exec" | +| SHELLCODE | "shellcode" | +| THREAD_CREATE | "thread-create" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: ConfidenceEnum + +| Name | Value | +|---- | -----| +| HIGH | "high" | +| MEDIUM | "medium" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<SourcesEnum> + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| SCRIPT_ENGINE | "script-engine" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ExecutionScanMetadata.md b/docs/ExecutionScanMetadata.md new file mode 100644 index 00000000..bee454bf --- /dev/null +++ b/docs/ExecutionScanMetadata.md @@ -0,0 +1,27 @@ + + +# ExecutionScanMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this analysis. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ExecutionScanResult.md b/docs/ExecutionScanResult.md new file mode 100644 index 00000000..06f7f9a7 --- /dev/null +++ b/docs/ExecutionScanResult.md @@ -0,0 +1,15 @@ + + +# ExecutionScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Analysis the run was performed against | | +|**findings** | **List<ExecutionFinding>** | Functions with execution-related evidence, sorted by whether they execute code, then confidence, then evidence count | [optional] | +|**totalFunctions** | **Long** | Functions the run considered | | + + + diff --git a/docs/ExtractedBinary.md b/docs/ExtractedBinary.md new file mode 100644 index 00000000..5007c162 --- /dev/null +++ b/docs/ExtractedBinary.md @@ -0,0 +1,15 @@ + + +# ExtractedBinary + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**filename** | **String** | Original filename inside the upload | | +|**sha256Hash** | **String** | Content hash of the recovered binary | | +|**size** | **Long** | File size (in bytes) | | + + + diff --git a/docs/ExtractedURL.md b/docs/ExtractedURL.md index c02a2410..a4b464de 100644 --- a/docs/ExtractedURL.md +++ b/docs/ExtractedURL.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**url** | **String** | | | diff --git a/docs/ExtractionFailure.md b/docs/ExtractionFailure.md new file mode 100644 index 00000000..a2474714 --- /dev/null +++ b/docs/ExtractionFailure.md @@ -0,0 +1,14 @@ + + +# ExtractionFailure + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**message** | **String** | Why this file failed to extract. | | +|**retryable** | **Boolean** | Whether re-submitting the extraction might resolve this failure. | | + + + diff --git a/docs/FeedbackOutputBody.md b/docs/FeedbackOutputBody.md new file mode 100644 index 00000000..cffda59c --- /dev/null +++ b/docs/FeedbackOutputBody.md @@ -0,0 +1,24 @@ + + +# FeedbackOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**sentiment** | [**SentimentEnum**](#SentimentEnum) | The sentiment the caller recorded, or null when they have not left any | | + + + +## Enum: SentimentEnum + +| Name | Value | +|---- | -----| +| POSITIVE | "POSITIVE" | +| NEUTRAL | "NEUTRAL" | +| NEGATIVE | "NEGATIVE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/FileActivityEntry.md b/docs/FileActivityEntry.md index 14eade42..2b8edbe4 100644 --- a/docs/FileActivityEntry.md +++ b/docs/FileActivityEntry.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**path** | **String** | | | diff --git a/docs/FilesystemAnalyseMetadata.md b/docs/FilesystemAnalyseMetadata.md new file mode 100644 index 00000000..0eded2b0 --- /dev/null +++ b/docs/FilesystemAnalyseMetadata.md @@ -0,0 +1,27 @@ + + +# FilesystemAnalyseMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this function. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/FilesystemAnalyseResult.md b/docs/FilesystemAnalyseResult.md new file mode 100644 index 00000000..34069087 --- /dev/null +++ b/docs/FilesystemAnalyseResult.md @@ -0,0 +1,21 @@ + + +# FilesystemAnalyseResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cancelled** | **Boolean** | Whether the run was cancelled | | +|**dataDescription** | **String** | Description of the data read or written | [optional] | +|**dataDestination** | **String** | Where the data ends up | [optional] | +|**dataOrigin** | **String** | Where the data originates from | [optional] | +|**functionId** | **Long** | ID of the explained function | | +|**functionName** | **String** | Name of the explained function | [optional] | +|**functionsInvolved** | **List<FilesystemExplainedFunction>** | Other functions involved in the filesystem access | [optional] | +|**summary** | **String** | Explanation of the filesystem access the function performs | [optional] | +|**targets** | **List<String>** | Concrete filesystem targets identified -- paths, registry keys, or environment variables | [optional] | + + + diff --git a/docs/FilesystemCall.md b/docs/FilesystemCall.md new file mode 100644 index 00000000..853cea61 --- /dev/null +++ b/docs/FilesystemCall.md @@ -0,0 +1,67 @@ + + +# FilesystemCall + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**calleeName** | **String** | Name of the called function | | +|**category** | [**CategoryEnum**](#CategoryEnum) | Filesystem category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**matchedName** | **String** | Name or token that matched | | +|**source** | [**SourceEnum**](#SourceEnum) | Filesystem source the match belongs to | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| DIR_READ | "dir-read" | +| DIR_WRITE | "dir-write" | +| ENVIRONMENT | "environment" | +| FILE_DELETE | "file-delete" | +| FILE_OPEN | "file-open" | +| FILE_PERMS | "file-perms" | +| FILE_READ | "file-read" | +| FILE_STAT | "file-stat" | +| FILE_WRITE | "file-write" | +| MODULE | "module" | +| PATH_WRITE | "path-write" | +| PROCESS | "process" | +| REGISTRY_READ | "registry-read" | +| REGISTRY_WRITE | "registry-write" | +| SERVICE | "service" | +| SYSTEM | "system" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| API | "api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: SourceEnum + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/FilesystemDirectMatch.md b/docs/FilesystemDirectMatch.md new file mode 100644 index 00000000..885fa975 --- /dev/null +++ b/docs/FilesystemDirectMatch.md @@ -0,0 +1,66 @@ + + +# FilesystemDirectMatch + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**category** | [**CategoryEnum**](#CategoryEnum) | Filesystem category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**matchedName** | **String** | Name or token that matched | | +|**source** | [**SourceEnum**](#SourceEnum) | Filesystem source the match belongs to | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| DIR_READ | "dir-read" | +| DIR_WRITE | "dir-write" | +| ENVIRONMENT | "environment" | +| FILE_DELETE | "file-delete" | +| FILE_OPEN | "file-open" | +| FILE_PERMS | "file-perms" | +| FILE_READ | "file-read" | +| FILE_STAT | "file-stat" | +| FILE_WRITE | "file-write" | +| MODULE | "module" | +| PATH_WRITE | "path-write" | +| PROCESS | "process" | +| REGISTRY_READ | "registry-read" | +| REGISTRY_WRITE | "registry-write" | +| SERVICE | "service" | +| SYSTEM | "system" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| API | "api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: SourceEnum + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/FilesystemExplainedFunction.md b/docs/FilesystemExplainedFunction.md new file mode 100644 index 00000000..b504e298 --- /dev/null +++ b/docs/FilesystemExplainedFunction.md @@ -0,0 +1,15 @@ + + +# FilesystemExplainedFunction + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**description** | **String** | Role this function plays in the filesystem access | | +|**functionId** | **Long** | ID of the function | | +|**functionName** | **String** | Name of the function | | + + + diff --git a/docs/FilesystemFinding.md b/docs/FilesystemFinding.md new file mode 100644 index 00000000..0c9ef2ba --- /dev/null +++ b/docs/FilesystemFinding.md @@ -0,0 +1,72 @@ + + +# FilesystemFinding + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**address** | **String** | Function's virtual address, hex-encoded | | +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Distinct filesystem categories evidenced by this function | | +|**confidence** | [**ConfidenceEnum**](#ConfidenceEnum) | High when a direct name match was found, medium when the function only calls into filesystem APIs | | +|**directMatches** | **List<FilesystemDirectMatch>** | Matches against the function's own name | [optional] | +|**evidenceCount** | **Long** | Total number of direct matches and filesystem calls | | +|**filesystemCalls** | **List<FilesystemCall>** | Matches against names this function calls | [optional] | +|**functionId** | **Long** | ID of the function the finding was reported in | | +|**functionName** | **String** | Name of the function the finding was reported in | | +|**functionSize** | **Long** | Size of the function in bytes | | +|**modifies** | **Boolean** | Whether this function evidences modifying the filesystem rather than only observing it | | +|**sources** | [**List<SourcesEnum>**](#List<SourcesEnum>) | Distinct filesystem sources evidenced by this function | | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| DIR_READ | "dir-read" | +| DIR_WRITE | "dir-write" | +| ENVIRONMENT | "environment" | +| FILE_DELETE | "file-delete" | +| FILE_OPEN | "file-open" | +| FILE_PERMS | "file-perms" | +| FILE_READ | "file-read" | +| FILE_STAT | "file-stat" | +| FILE_WRITE | "file-write" | +| MODULE | "module" | +| PATH_WRITE | "path-write" | +| PROCESS | "process" | +| REGISTRY_READ | "registry-read" | +| REGISTRY_WRITE | "registry-write" | +| SERVICE | "service" | +| SYSTEM | "system" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: ConfidenceEnum + +| Name | Value | +|---- | -----| +| HIGH | "high" | +| MEDIUM | "medium" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<SourcesEnum> + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/FilesystemScanMetadata.md b/docs/FilesystemScanMetadata.md new file mode 100644 index 00000000..a15812d1 --- /dev/null +++ b/docs/FilesystemScanMetadata.md @@ -0,0 +1,27 @@ + + +# FilesystemScanMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this analysis. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/FilesystemScanResult.md b/docs/FilesystemScanResult.md new file mode 100644 index 00000000..087eff09 --- /dev/null +++ b/docs/FilesystemScanResult.md @@ -0,0 +1,15 @@ + + +# FilesystemScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Analysis the run was performed against | | +|**findings** | **List<FilesystemFinding>** | Functions with filesystem-related evidence, sorted by whether they modify the filesystem, then confidence, then evidence count | [optional] | +|**totalFunctions** | **Long** | Functions the run considered | | + + + diff --git a/docs/Finding.md b/docs/Finding.md new file mode 100644 index 00000000..b76dcf54 --- /dev/null +++ b/docs/Finding.md @@ -0,0 +1,15 @@ + + +# Finding + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**propertyId** | **String** | | [optional] | +|**reachability** | **ReportReachabilityStatus** | | [optional] | +|**evidence** | [**List<EvidenceInner>**](EvidenceInner.md) | | [optional] | + + + diff --git a/docs/FirmwareApi.md b/docs/FirmwareApi.md deleted file mode 100644 index 9a5df708..00000000 --- a/docs/FirmwareApi.md +++ /dev/null @@ -1,161 +0,0 @@ -# FirmwareApi - -All URIs are relative to *https://api.reveng.ai* - -| Method | HTTP request | Description | -|------------- | ------------- | -------------| -| [**getBinariesForFirmwareTask**](FirmwareApi.md#getBinariesForFirmwareTask) | **GET** /v2/firmware/get-binaries/{task_id} | Upload firmware for unpacking | -| [**uploadFirmware**](FirmwareApi.md#uploadFirmware) | **POST** /v2/firmware | Upload firmware for unpacking | - - - -# **getBinariesForFirmwareTask** -> Object getBinariesForFirmwareTask(taskId) - -Upload firmware for unpacking - -Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - -### Example -```java -// Import classes: -import ai.reveng.invoker.ApiClient; -import ai.reveng.invoker.ApiException; -import ai.reveng.invoker.Configuration; -import ai.reveng.invoker.auth.*; -import ai.reveng.invoker.models.*; -import ai.reveng.api.FirmwareApi; - -public class Example { - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - defaultClient.setBasePath("https://api.reveng.ai"); - - // Configure API key authorization: APIKey - ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); - APIKey.setApiKey("YOUR API KEY"); - // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) - //APIKey.setApiKeyPrefix("Token"); - - // Configure HTTP bearer authorization: bearerAuth - HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); - bearerAuth.setBearerToken("BEARER TOKEN"); - - FirmwareApi apiInstance = new FirmwareApi(defaultClient); - String taskId = "taskId_example"; // String | - try { - Object result = apiInstance.getBinariesForFirmwareTask(taskId); - System.out.println(result); - } catch (ApiException e) { - System.err.println("Exception when calling FirmwareApi#getBinariesForFirmwareTask"); - System.err.println("Status code: " + e.getCode()); - System.err.println("Reason: " + e.getResponseBody()); - System.err.println("Response headers: " + e.getResponseHeaders()); - e.printStackTrace(); - } - } -} -``` - -### Parameters - -| Name | Type | Description | Notes | -|------------- | ------------- | ------------- | -------------| -| **taskId** | **String**| | | - -### Return type - -**Object** - -### Authorization - -[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -| **200** | Successful Response | - | -| **422** | Invalid request parameters | - | - - -# **uploadFirmware** -> Object uploadFirmware(_file, password) - -Upload firmware for unpacking - -Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - -### Example -```java -// Import classes: -import ai.reveng.invoker.ApiClient; -import ai.reveng.invoker.ApiException; -import ai.reveng.invoker.Configuration; -import ai.reveng.invoker.auth.*; -import ai.reveng.invoker.models.*; -import ai.reveng.api.FirmwareApi; - -public class Example { - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - defaultClient.setBasePath("https://api.reveng.ai"); - - // Configure API key authorization: APIKey - ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); - APIKey.setApiKey("YOUR API KEY"); - // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) - //APIKey.setApiKeyPrefix("Token"); - - // Configure HTTP bearer authorization: bearerAuth - HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); - bearerAuth.setBearerToken("BEARER TOKEN"); - - FirmwareApi apiInstance = new FirmwareApi(defaultClient); - File _file = new File("/path/to/file"); // File | - String password = "password_example"; // String | - try { - Object result = apiInstance.uploadFirmware(_file, password); - System.out.println(result); - } catch (ApiException e) { - System.err.println("Exception when calling FirmwareApi#uploadFirmware"); - System.err.println("Status code: " + e.getCode()); - System.err.println("Reason: " + e.getResponseBody()); - System.err.println("Response headers: " + e.getResponseHeaders()); - e.printStackTrace(); - } - } -} -``` - -### Parameters - -| Name | Type | Description | Notes | -|------------- | ------------- | ------------- | -------------| -| **_file** | **File**| | | -| **password** | **String**| | [optional] | - -### Return type - -**Object** - -### Authorization - -[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - - - **Content-Type**: multipart/form-data - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -| **201** | Successful Response | - | -| **422** | Unprocessable Entity | - | -| **500** | Internal Server Error | - | - diff --git a/docs/FunctionBoundary.md b/docs/FunctionBoundary.md index 8ce1e713..43d4d479 100644 --- a/docs/FunctionBoundary.md +++ b/docs/FunctionBoundary.md @@ -7,10 +7,10 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| +|**endAddress** | **Long** | | | +|**includeInAnalysis** | **Boolean** | | [optional] | |**mangledName** | **String** | | | |**startAddress** | **Long** | | | -|**endAddress** | **Long** | | | -|**includeInAnalysis** | **Boolean** | Indicates whether the function should be included in the analysis | [optional] | diff --git a/docs/FunctionCallEdges.md b/docs/FunctionCallEdges.md index 7946e09f..d287bf06 100644 --- a/docs/FunctionCallEdges.md +++ b/docs/FunctionCallEdges.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**callees** | [**List<CallEdge>**](CallEdge.md) | | | -|**callers** | [**List<CallEdge>**](CallEdge.md) | | | +|**callees** | **List<CallEdge>** | | | +|**callers** | **List<CallEdge>** | | | |**functionId** | **Long** | | | diff --git a/docs/FunctionDataType.md b/docs/FunctionDataType.md index c0fc081a..17fa9cd2 100644 --- a/docs/FunctionDataType.md +++ b/docs/FunctionDataType.md @@ -9,12 +9,13 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**FunctionTypeDefinition**](FunctionTypeDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **FunctionTypeDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/FunctionMatch.md b/docs/FunctionMatch.md index fb4ade34..a8d6cd93 100644 --- a/docs/FunctionMatch.md +++ b/docs/FunctionMatch.md @@ -7,9 +7,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**confidences** | [**List<NameConfidence>**](NameConfidence.md) | Per-name confidences when canonify was requested | [optional] | +|**confidences** | **List<NameConfidence>** | Per-name confidences when canonify was requested | [optional] | |**functionId** | **Long** | Source function ID | | -|**matchedFunctions** | [**List<MatchedFunction>**](MatchedFunction.md) | Top candidate matches in similarity-descending order | | +|**matchedFunctions** | **List<MatchedFunction>** | Top candidate matches in similarity-descending order | | diff --git a/docs/FunctionSignatureBody.md b/docs/FunctionSignatureBody.md index 5a5b072f..d1f49bd2 100644 --- a/docs/FunctionSignatureBody.md +++ b/docs/FunctionSignatureBody.md @@ -13,7 +13,7 @@ |**functionId** | **Long** | | | |**functionName** | **String** | Current name of the function. | | |**hasSignature** | **Boolean** | Whether a signature was extracted for this function. False is a normal result: no signature is recorded unless data type extraction ran for the analysis, and thunks and external functions are skipped when it does. | | -|**parameters** | [**List<SignatureParameterEntry>**](SignatureParameterEntry.md) | Parameters in argument order. Empty with has_signature true means the function is known to take no arguments. | | +|**parameters** | **List<SignatureParameterEntry>** | Parameters in argument order. Empty with has_signature true means the function is known to take no arguments. | | |**returnDataTypeId** | **Long** | Return type, resolvable against the analysis data types list. Absent for an unresolved return type. | [optional] | |**sourceFunctionId** | **Long** | The function this signature was copied from, when it was transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this signature came from. | [optional] | diff --git a/docs/FunctionSignatureEntry.md b/docs/FunctionSignatureEntry.md index 81b6dd09..34f4e491 100644 --- a/docs/FunctionSignatureEntry.md +++ b/docs/FunctionSignatureEntry.md @@ -12,7 +12,7 @@ |**functionId** | **Long** | | | |**functionName** | **String** | Current name of the function. | | |**hasSignature** | **Boolean** | Whether a signature was extracted for this function. False is a normal result: no signature is recorded unless data type extraction ran for the analysis, and thunks and external functions are skipped when it does. | | -|**parameters** | [**List<SignatureParameterEntry>**](SignatureParameterEntry.md) | Parameters in argument order. Empty with has_signature true means the function is known to take no arguments. | | +|**parameters** | **List<SignatureParameterEntry>** | Parameters in argument order. Empty with has_signature true means the function is known to take no arguments. | | |**returnDataTypeId** | **Long** | Return type, resolvable against the analysis data types list. Absent for an unresolved return type. | [optional] | |**sourceFunctionId** | **Long** | The function this signature was copied from, when it was transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this signature came from. | [optional] | diff --git a/docs/FunctionSignatureVersion.md b/docs/FunctionSignatureVersion.md index c25eab90..0ffa34c2 100644 --- a/docs/FunctionSignatureVersion.md +++ b/docs/FunctionSignatureVersion.md @@ -8,8 +8,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**updatedAt** | **OffsetDateTime** | When this version was written. Absent on a version that predates the recorded history. | [optional] | -|**updatedBy** | [**HistoryActor**](HistoryActor.md) | Who wrote this version. Absent on a version that predates the recorded history. | [optional] | -|**value** | [**FunctionSignatureEntry**](FunctionSignatureEntry.md) | The signature as it stood in this version. | | +|**updatedBy** | **HistoryActor** | Who wrote this version. Absent on a version that predates the recorded history. | [optional] | +|**value** | **FunctionSignatureEntry** | The signature as it stood in this version. | | diff --git a/docs/FunctionSimilarity.md b/docs/FunctionSimilarity.md new file mode 100644 index 00000000..c342fa05 --- /dev/null +++ b/docs/FunctionSimilarity.md @@ -0,0 +1,15 @@ + + +# FunctionSimilarity + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | | +|**similarity** | **BigDecimal** | | | +|**subject** | [**Subject**](Subject.md) | | | + + + diff --git a/docs/FunctionSimilarityEvidence.md b/docs/FunctionSimilarityEvidence.md new file mode 100644 index 00000000..7a1f5650 --- /dev/null +++ b/docs/FunctionSimilarityEvidence.md @@ -0,0 +1,45 @@ + + +# FunctionSimilarityEvidence + +Function-similarity results suggestive of a capability. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**similarities** | [**List<FunctionSimilarity>**](FunctionSimilarity.md) | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| FUNCTION_SIMILARITY | "function_similarity" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| INDIRECT | "indirect" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/FunctionTypeDefinition.md b/docs/FunctionTypeDefinition.md index 6f236139..b57880fe 100644 --- a/docs/FunctionTypeDefinition.md +++ b/docs/FunctionTypeDefinition.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**parameters** | [**List<DataTypeFunctionParameterEntry>**](DataTypeFunctionParameterEntry.md) | The parameters, in argument order. | | +|**parameters** | **List<DataTypeFunctionParameterEntry>** | The parameters, in argument order. | | |**returnDataTypeId** | **Long** | The return type. | [optional] | diff --git a/docs/FunctionsAiDecompilationApi.md b/docs/FunctionsAiDecompilationApi.md index 5771f8d9..8b032053 100644 --- a/docs/FunctionsAiDecompilationApi.md +++ b/docs/FunctionsAiDecompilationApi.md @@ -20,12 +20,13 @@ All URIs are relative to *https://api.reveng.ai* | [**upsertAiDecompilationRating**](FunctionsAiDecompilationApi.md#upsertAiDecompilationRating) | **PATCH** /v2/functions/{function_id}/ai-decompilation/rating | Upsert rating for AI decompilation | | [**v3GetAiDecompilationLineAttributions**](FunctionsAiDecompilationApi.md#v3GetAiDecompilationLineAttributions) | **GET** /v3/functions/{function_id}/ai-decompilation/line-attributions | Get AI decompilation line attributions | | [**v3GetAiDecompilationTokens**](FunctionsAiDecompilationApi.md#v3GetAiDecompilationTokens) | **GET** /v3/functions/{function_id}/ai-decompilation/tokens | Get AI decompilation tokens and user overrides | +| [**v3GetAiDecompilationTypeSuggestions**](FunctionsAiDecompilationApi.md#v3GetAiDecompilationTypeSuggestions) | **GET** /v3/functions/{function_id}/ai-decompilation/type-suggestions | Get AI decompilation type suggestions | | [**v3UpsertAiDecompilationOverrides**](FunctionsAiDecompilationApi.md#v3UpsertAiDecompilationOverrides) | **PATCH** /v3/functions/{function_id}/ai-decompilation/overrides | Upsert variable/function name overrides | # **createAiDecompilation** -> CreateAIDecompOutputBody createAiDecompilation(functionId, temperature) +> CreateAIDecompOutputBody createAiDecompilation(functionId, temperature, typeSuggestions) Start AI decompilation @@ -59,8 +60,9 @@ public class Example { FunctionsAiDecompilationApi apiInstance = new FunctionsAiDecompilationApi(defaultClient); Long functionId = 56L; // Long | Function ID Double temperature = -1D; // Double | LLM temperature (0.0-1.0). Overrides the server default when set. Omit or set to -1 to use the server default. + Boolean typeSuggestions = true; // Boolean | Ask the language model to name the suggested types and their members. Set to false to skip the model call; the statically derived layouts are still computed and stored. Cannot re-enable the pass when the server has it off. try { - CreateAIDecompOutputBody result = apiInstance.createAiDecompilation(functionId, temperature); + CreateAIDecompOutputBody result = apiInstance.createAiDecompilation(functionId, temperature, typeSuggestions); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FunctionsAiDecompilationApi#createAiDecompilation"); @@ -79,6 +81,7 @@ public class Example { |------------- | ------------- | ------------- | -------------| | **functionId** | **Long**| Function ID | | | **temperature** | **Double**| LLM temperature (0.0-1.0). Overrides the server default when set. Omit or set to -1 to use the server default. | [optional] [default to -1] | +| **typeSuggestions** | **Boolean**| Ask the language model to name the suggested types and their members. Set to false to skip the model call; the statically derived layouts are still computed and stored. Cannot re-enable the pass when the server has it off. | [optional] [default to true] | ### Return type @@ -802,7 +805,7 @@ public class Example { Regenerate AI decompilation inline comments -Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found +Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers the comments would reference. Poll the inline comments status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict ### Example ```java @@ -868,8 +871,10 @@ public class Example { | Status code | Description | Response headers | |-------------|-------------|------------------| | **202** | Accepted | - | +| **400** | Bad Request | - | | **403** | Forbidden | - | | **404** | Not Found | - | +| **409** | Conflict | - | | **422** | Unprocessable Entity | - | | **500** | Internal Server Error | - | @@ -879,7 +884,7 @@ public class Example { Regenerate AI decompilation summary -Starts a new summary generation workflow for the function. Requires an existing decompilation. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found +Starts a new summary generation workflow for the function. Requires an existing decompilation. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers a summary would describe. Poll the summary status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict ### Example ```java @@ -947,6 +952,7 @@ public class Example { | **202** | Accepted | - | | **403** | Forbidden | - | | **404** | Not Found | - | +| **409** | Conflict | - | | **422** | Unprocessable Entity | - | | **500** | Internal Server Error | - | @@ -956,7 +962,7 @@ public class Example { Stream live AI decompilation output (SSE) -Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. Terminal events: `decomp_finished` (success) or `decomp_failed` (all retries exhausted). `attempt_failed` is per-attempt and non-terminal — Temporal may retry the activity. Clients should treat `attempt` changes as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. +Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. **Terminal events — the stream closes on these:** `names_finished` (success) and `decomp_failed` (all retries exhausted). `names_finished` is published on every success path, including when the naming pass is disabled, produces nothing, or fails, so a successful run always closes. **`decomp_finished` is NOT terminal.** It marks the end of the model call, not the end of the run: entity restore, the result write, the placeholder-naming pass and the type-suggestion pass all follow it, and the last two rewrite the identifiers the source renders with. Reading the decompilation at `decomp_finished` therefore returns names that are about to change — wait for `names_finished`. `attempt_failed` is per-attempt and non-terminal too: Temporal may retry, and clients disambiguate on `attempt`, which they should treat as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. ### Example ```java @@ -1252,6 +1258,83 @@ public class Example { | **422** | Unprocessable Entity | - | | **500** | Internal Server Error | - | + +# **v3GetAiDecompilationTypeSuggestions** +> TypeSuggestionsData v3GetAiDecompilationTypeSuggestions(functionId) + +Get AI decompilation type suggestions + +Returns the aggregate types the AI decompilation inferred for this function: a suggested name for each type and each of its members, the members' offsets and widths, and the gaps between them. Members revealed only by a caller or callee are included and marked by origin, as are members the model placed rather than observed. Nothing here is a data type row — these are proposals, and creating a row from one is the client's call. The list is empty until a run has produced suggestions, which is ordinary and not an error. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.FunctionsAiDecompilationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + FunctionsAiDecompilationApi apiInstance = new FunctionsAiDecompilationApi(defaultClient); + Long functionId = 56L; // Long | Function ID + try { + TypeSuggestionsData result = apiInstance.v3GetAiDecompilationTypeSuggestions(functionId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FunctionsAiDecompilationApi#v3GetAiDecompilationTypeSuggestions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **functionId** | **Long**| Function ID | | + +### Return type + +[**TypeSuggestionsData**](TypeSuggestionsData.md) + +### Authorization + +[APIKey](../README.md#APIKey), [bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **422** | Unprocessable Entity | - | +| **500** | Internal Server Error | - | + # **v3UpsertAiDecompilationOverrides** > UpsertOverridesData v3UpsertAiDecompilationOverrides(functionId, upsertOverridesInputBody) diff --git a/docs/FunctionsProgressOutputBody.md b/docs/FunctionsProgressOutputBody.md new file mode 100644 index 00000000..3ba8df1f --- /dev/null +++ b/docs/FunctionsProgressOutputBody.md @@ -0,0 +1,15 @@ + + +# FunctionsProgressOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**functionEmbeddingsCount** | **Long** | Functions whose embedding has been written back | | +|**functionsCount** | **Long** | Functions found in the analysis | | +|**percentageCompleted** | **Double** | Embeddings as a percentage of functions, to 2 decimal places. 0 when the analysis has no functions | | + + + diff --git a/docs/FunctionsRenamingHistoryApi.md b/docs/FunctionsRenamingHistoryApi.md index a7b73519..774c4773 100644 --- a/docs/FunctionsRenamingHistoryApi.md +++ b/docs/FunctionsRenamingHistoryApi.md @@ -322,7 +322,7 @@ public class Example { Rename a function -Renames a single function and records the change in history. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found +Renames a single function and records the change in history. `source_type` defaults to USER when omitted. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found ### Example ```java diff --git a/docs/GetAnalysisLogsOutputBody.md b/docs/GetAnalysisLogsOutputBody.md index a9d8d436..77238384 100644 --- a/docs/GetAnalysisLogsOutputBody.md +++ b/docs/GetAnalysisLogsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**entries** | [**List<AnalysisLogEntry>**](AnalysisLogEntry.md) | Analysis log lines, oldest first | | +|**entries** | **List<AnalysisLogEntry>** | Analysis log lines, oldest first | | diff --git a/docs/GetCollectionOutputBody.md b/docs/GetCollectionOutputBody.md index 480817fe..4782a23c 100644 --- a/docs/GetCollectionOutputBody.md +++ b/docs/GetCollectionOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**binaries** | [**List<Binary>**](Binary.md) | | [optional] | +|**binaries** | **List<Binary>** | | [optional] | |**collectionId** | **Long** | | | |**collectionName** | **String** | | | |**collectionScope** | **String** | | | diff --git a/docs/GetConfigOutputBody.md b/docs/GetConfigOutputBody.md new file mode 100644 index 00000000..a5c6665b --- /dev/null +++ b/docs/GetConfigOutputBody.md @@ -0,0 +1,14 @@ + + +# GetConfigOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**aiDecompilerUnsupportedLanguages** | **List<String>** | Source languages AI decompilation does not support | | +|**maxFileSizeBytes** | **Long** | Largest binary the calling user may submit for analysis, in bytes | | + + + diff --git a/docs/GetDataTypeHistoryBody.md b/docs/GetDataTypeHistoryBody.md index 8d8a4d0f..217e11e2 100644 --- a/docs/GetDataTypeHistoryBody.md +++ b/docs/GetDataTypeHistoryBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**versions** | [**List<DataTypeVersion>**](DataTypeVersion.md) | Every version of the type, newest first. The first element is the current value, so the list is never empty; a type that has never been edited has that one element only. | | +|**versions** | **List<DataTypeVersion>** | Every version of the type, newest first. The first element is the current value, so the list is never empty; a type that has never been edited has that one element only. | | diff --git a/docs/GetDieInfoOutputBody.md b/docs/GetDieInfoOutputBody.md new file mode 100644 index 00000000..c67fc482 --- /dev/null +++ b/docs/GetDieInfoOutputBody.md @@ -0,0 +1,13 @@ + + +# GetDieInfoOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**matches** | **List<DieMatch>** | Signatures Detect It Easy recognised in the binary | | + + + diff --git a/docs/GetFunctionSignatureHistoryBody.md b/docs/GetFunctionSignatureHistoryBody.md index f497fce5..3fba9a2f 100644 --- a/docs/GetFunctionSignatureHistoryBody.md +++ b/docs/GetFunctionSignatureHistoryBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**versions** | [**List<FunctionSignatureVersion>**](FunctionSignatureVersion.md) | Every version of the signature, newest first. The first element is the current value, so the list is never empty; a signature that has never been edited has that one element only. | | +|**versions** | **List<FunctionSignatureVersion>** | Every version of the signature, newest first. The first element is the current value, so the list is never empty; a signature that has never been edited has that one element only. | | diff --git a/docs/GetMatchesOutputBody.md b/docs/GetMatchesOutputBody.md index 1e0350f9..2da43c67 100644 --- a/docs/GetMatchesOutputBody.md +++ b/docs/GetMatchesOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**matches** | [**List<FunctionMatch>**](FunctionMatch.md) | Per-source-function matches. Populated when status=COMPLETED; empty otherwise. | [optional] | +|**matches** | **List<FunctionMatch>** | Per-source-function matches. Populated when status=COMPLETED; empty otherwise. | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Current workflow status | | diff --git a/docs/GetMatchesStatusOutputBody.md b/docs/GetMatchesStatusOutputBody.md index 4ec42795..abad88e2 100644 --- a/docs/GetMatchesStatusOutputBody.md +++ b/docs/GetMatchesStatusOutputBody.md @@ -7,11 +7,16 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**messages** | [**List<ProgressMessage>**](ProgressMessage.md) | Log messages emitted during execution | | +|**messages** | **List<ProgressMessage>** | Log messages emitted during execution | | +|**percent** | **Long** | Overall completion as a percentage, weighted by step duration | | |**status** | [**StatusEnum**](#StatusEnum) | Current workflow status | | |**step** | **String** | Name of the current step | | |**stepIndex** | **Long** | Zero-based index of the current step | | +|**stepShare** | **Long** | Percentage points the current step contributes when it completes | | |**stepsTotal** | **Long** | Total number of steps in the workflow | | +|**subStep** | **String** | Phase within the current step, when the step reports one | [optional] | +|**subStepDone** | **Long** | Items completed in the current phase | [optional] | +|**subStepTotal** | **Long** | Items the current phase will process, 0 when unknown | [optional] | diff --git a/docs/GetModelsOutputBody.md b/docs/GetModelsOutputBody.md new file mode 100644 index 00000000..89b1f521 --- /dev/null +++ b/docs/GetModelsOutputBody.md @@ -0,0 +1,13 @@ + + +# GetModelsOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**models** | **List<String>** | Models a new analysis may be run on | | + + + diff --git a/docs/GetProductsOutputBody.md b/docs/GetProductsOutputBody.md index 9683ddd7..d15aa7bd 100644 --- a/docs/GetProductsOutputBody.md +++ b/docs/GetProductsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**products** | [**List<ProductOutput>**](ProductOutput.md) | List of available products | | +|**products** | **List<ProductOutput>** | List of available products | | diff --git a/docs/GetRelatedBinariesOutputBody.md b/docs/GetRelatedBinariesOutputBody.md new file mode 100644 index 00000000..ec757e6b --- /dev/null +++ b/docs/GetRelatedBinariesOutputBody.md @@ -0,0 +1,14 @@ + + +# GetRelatedBinariesOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**children** | **List<RelatedBinary>** | Binaries unpacked out of this one | | +|**parent** | **RelatedBinary** | Archive this binary was unpacked from, null when it was uploaded directly | | + + + diff --git a/docs/GetRelatedStatusOutputBody.md b/docs/GetRelatedStatusOutputBody.md new file mode 100644 index 00000000..52e5301d --- /dev/null +++ b/docs/GetRelatedStatusOutputBody.md @@ -0,0 +1,26 @@ + + +# GetRelatedStatusOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**status** | [**StatusEnum**](#StatusEnum) | Status of the task that unpacks an archive into its contents | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/GetSubscriptionOutputBody.md b/docs/GetSubscriptionOutputBody.md index a542f03c..506d9694 100644 --- a/docs/GetSubscriptionOutputBody.md +++ b/docs/GetSubscriptionOutputBody.md @@ -8,8 +8,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**endsAt** | **OffsetDateTime** | Date access ends (CANCELING only). | [optional] | -|**price** | [**PriceSummary**](PriceSummary.md) | Current price (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | -|**product** | [**ProductSummary**](ProductSummary.md) | Subscribed product (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | +|**price** | **PriceSummary** | Current price (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | +|**product** | **ProductSummary** | Subscribed product (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | |**renewsAt** | **OffsetDateTime** | Next billing date (ACTIVE only). | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Subscription state. | | |**tier** | [**TierEnum**](#TierEnum) | User's effective tier. | | diff --git a/docs/GetTokensResponse.md b/docs/GetTokensResponse.md index 13bdf7ec..6ebcd3ff 100644 --- a/docs/GetTokensResponse.md +++ b/docs/GetTokensResponse.md @@ -9,8 +9,8 @@ |------------ | ------------- | ------------- | -------------| |**aiDecomp** | **String** | Tokenised AI-decompilation. Includes generated comments. Empty until a run has succeeded. | | |**analysisId** | **Long** | Analysis the function belongs to. Scopes every data_type_id below. | | -|**placeholderToRenderedToken** | [**Map<String, RenderedToken>**](RenderedToken.md) | Each placeholder token mapped to the value the server would render in its place, and the record it refers to. Null until a run has succeeded. | | -|**placeholderToUserOverride** | [**Map<String, Token>**](Token.md) | The caller's own overrides, keyed by token. Null until a run has succeeded. | | +|**placeholderToRenderedToken** | **Map<String, RenderedToken>** | Each placeholder token mapped to the value the server would render in its place, and the record it refers to. Null until a run has succeeded. | | +|**placeholderToUserOverride** | **Map<String, Token>** | The caller's own overrides, keyed by token. Null until a run has succeeded. | | diff --git a/docs/HardcodedSecretEvidence.md b/docs/HardcodedSecretEvidence.md new file mode 100644 index 00000000..7dbe0496 --- /dev/null +++ b/docs/HardcodedSecretEvidence.md @@ -0,0 +1,51 @@ + + +# HardcodedSecretEvidence + +A hard-coded secret identified in the binary's data. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | [**EffectEnum**](#EffectEnum) | | [optional] | +|**strength** | **EvidenceStrength** | | | +|**ruleId** | **String** | | | +|**description** | **String** | | | +|**secretKind** | **RuleKind** | | | +|**secret** | **String** | | | +|**entropy** | **BigDecimal** | | | +|**size** | **Integer** | | | +|**references** | **List<Integer>** | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| HARDCODED_SECRET | "hardcoded_secret" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: EffectEnum + +| Name | Value | +|---- | -----| +| SUPPORTS | "supports" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/HttpRequest.md b/docs/HttpRequest.md index f70b1ccf..fb765a93 100644 --- a/docs/HttpRequest.md +++ b/docs/HttpRequest.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**bytesReceived** | **Long** | | [optional] | |**bytesSent** | **Long** | | [optional] | -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**extraHeaders** | **List<String>** | | [optional] | |**flags** | **Long** | | [optional] | |**password** | **String** | | [optional] | @@ -19,8 +19,8 @@ |**proxy** | **String** | | [optional] | |**proxyBypass** | **String** | | [optional] | |**referer** | **String** | | [optional] | -|**requestBody** | [**PcapBodyInfo**](PcapBodyInfo.md) | | [optional] | -|**responseBody** | [**PcapBodyInfo**](PcapBodyInfo.md) | | [optional] | +|**requestBody** | **PcapBodyInfo** | | [optional] | +|**responseBody** | **PcapBodyInfo** | | [optional] | |**responseStatus** | **Long** | | [optional] | |**serverIp** | **String** | | [optional] | |**serverName** | **String** | | [optional] | diff --git a/docs/IOC.md b/docs/IOC.md index 4b5ac0c1..30fcce97 100644 --- a/docs/IOC.md +++ b/docs/IOC.md @@ -7,43 +7,12 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**type** | [**TypeEnum**](#TypeEnum) | Type of the IOC | | -|**value** | **String** | Value of the IOC | | -|**description** | **String** | Description of the IOC | | -|**source** | **String** | The source address where the IOC can be found in the binary if possible. | [optional] | -|**functionId** | **Integer** | Unique identifier of the function containing the IOC | [optional] | -|**functionName** | **String** | Name of the function containing the IOC | [optional] | - - - -## Enum: TypeEnum - -| Name | Value | -|---- | -----| -| IP | "ip" | -| DOMAIN | "domain" | -| URL | "url" | -| USERNAMES | "usernames" | -| PASSWORDS | "passwords" | -| FILE_HASH | "file_hash" | -| MUTEX | "mutex" | -| REGISTRY_KEY | "registry_key" | -| FILENAME | "filename" | -| EMAIL | "email" | -| C2_ENDPOINT | "c2_endpoint" | -| USER_AGENT | "user_agent" | -| PEM_KEY | "pem_key" | -| SSH_KEY | "ssh_key" | -| NETWORK_PORT | "network_port" | -| JA3 | "ja3" | -| SSL_CERT_FINGERPRINT | "ssl_cert_fingerprint" | -| HTTP_HEADER | "http_header" | -| SERVICE | "service" | -| SCHEDULED_TASK | "scheduled_task" | -| PE_HEADER | "pe_header" | -| ENTROPY | "entropy" | -| OTHER | "other" | -| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | +|**description** | **String** | What the indicator means | | +|**functionId** | **Long** | ID of the function it was found in. Null when the source does not resolve to one. | | +|**functionName** | **String** | Name of the function it was found in. Null when the source does not resolve to one. | | +|**source** | **String** | Where in the binary it was found, usually a hex address. Null when the agent did not report one. | | +|**type** | **String** | Indicator type | | +|**value** | **String** | The indicator itself | | diff --git a/docs/ImportedApi.md b/docs/ImportedApi.md new file mode 100644 index 00000000..545f9080 --- /dev/null +++ b/docs/ImportedApi.md @@ -0,0 +1,14 @@ + + +# ImportedApi + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**module** | **String** | | [optional] | +|**api** | **String** | | | + + + diff --git a/docs/ImportedApiCall.md b/docs/ImportedApiCall.md new file mode 100644 index 00000000..f079165c --- /dev/null +++ b/docs/ImportedApiCall.md @@ -0,0 +1,15 @@ + + +# ImportedApiCall + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**importedApi** | [**ImportedApi**](ImportedApi.md) | | | +|**subject** | [**Subject**](Subject.md) | | | +|**reachability** | [**CallChain**](CallChain.md) | | [optional] | + + + diff --git a/docs/ImportedApiCallEvidence.md b/docs/ImportedApiCallEvidence.md new file mode 100644 index 00000000..51eaf10f --- /dev/null +++ b/docs/ImportedApiCallEvidence.md @@ -0,0 +1,45 @@ + + +# ImportedApiCallEvidence + +Imported API calls observed in the program. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**calls** | [**List<ImportedApiCall>**](ImportedApiCall.md) | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| IMPORTED_API_CALL | "imported_api_call" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| DIRECT | "direct" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ImportedFunctionDetailOutputBody.md b/docs/ImportedFunctionDetailOutputBody.md index f1463bda..3967e957 100644 --- a/docs/ImportedFunctionDetailOutputBody.md +++ b/docs/ImportedFunctionDetailOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**callers** | [**List<ImportedFunctionCallerEntry>**](ImportedFunctionCallerEntry.md) | Internal functions that call this import, resolved via its PLT/stub addresses. | | +|**callers** | **List<ImportedFunctionCallerEntry>** | Internal functions that call this import, resolved via its PLT/stub addresses. | | |**importedFunctionId** | **Long** | | | |**isFunction** | **Boolean** | False for imported data symbols. | | |**libraryName** | **String** | Library the symbol is imported from. '<EXTERNAL>' for unattributed imports. | | diff --git a/docs/IndirectCallSitesOutputBody.md b/docs/IndirectCallSitesOutputBody.md index 0b9c3c72..c67ad82f 100644 --- a/docs/IndirectCallSitesOutputBody.md +++ b/docs/IndirectCallSitesOutputBody.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**functionId** | **Long** | | | -|**sites** | [**List<IndirectCallSite>**](IndirectCallSite.md) | | | +|**sites** | **List<IndirectCallSite>** | | | diff --git a/docs/InputBody.md b/docs/InputBody.md new file mode 100644 index 00000000..b7b87c7b --- /dev/null +++ b/docs/InputBody.md @@ -0,0 +1,13 @@ + + +# InputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**password** | **String** | Password to decrypt an encrypted archive. | [optional] | + + + diff --git a/docs/KnownConstantEvidence.md b/docs/KnownConstantEvidence.md new file mode 100644 index 00000000..165e18f1 --- /dev/null +++ b/docs/KnownConstantEvidence.md @@ -0,0 +1,45 @@ + + +# KnownConstantEvidence + +A known constant whose semantic use has not been demonstrated. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**values** | **List<BytesConstant>** | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| KNOWN_CONSTANT | "known_constant" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| INDIRECT | "indirect" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ListAnalysesOutputBody.md b/docs/ListAnalysesOutputBody.md index e63ca5a8..b2ff1d90 100644 --- a/docs/ListAnalysesOutputBody.md +++ b/docs/ListAnalysesOutputBody.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**nextPageToken** | **String** | Opaque cursor to fetch the next page; empty on the last page | [optional] | |**pageSize** | **Long** | Number of results in this page | | -|**results** | [**List<AnalysisRecordBody>**](AnalysisRecordBody.md) | The page of matching analyses | | +|**results** | **List<AnalysisRecordBody>** | The page of matching analyses | | diff --git a/docs/ListAnalysisFunctionsOutputBody.md b/docs/ListAnalysisFunctionsOutputBody.md index 5e11ad78..cd74c8d7 100644 --- a/docs/ListAnalysisFunctionsOutputBody.md +++ b/docs/ListAnalysisFunctionsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**functions** | [**List<AnalysisFunctionEntry>**](AnalysisFunctionEntry.md) | | | +|**functions** | **List<AnalysisFunctionEntry>** | | | |**totalCount** | **Long** | Total functions in the analysis, ignoring pagination. | | diff --git a/docs/ListAnalysisStringsOutputBody.md b/docs/ListAnalysisStringsOutputBody.md index 8877ae0f..3c7e8404 100644 --- a/docs/ListAnalysisStringsOutputBody.md +++ b/docs/ListAnalysisStringsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**strings** | [**List<AnalysisStringItem>**](AnalysisStringItem.md) | | | +|**strings** | **List<AnalysisStringItem>** | | | |**totalStrings** | **Long** | | | diff --git a/docs/ListArchiveContentsOutputBody.md b/docs/ListArchiveContentsOutputBody.md index 47cd52cf..2973a792 100644 --- a/docs/ListArchiveContentsOutputBody.md +++ b/docs/ListArchiveContentsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**entries** | [**List<ArchiveContentEntry>**](ArchiveContentEntry.md) | Files inside the archive, with paths relative to the archive root | | +|**entries** | **List<ArchiveContentEntry>** | Files inside the archive, with paths relative to the archive root | | |**hasNext** | **Boolean** | Whether a further page of entries follows this one. | | |**page** | **Long** | Page number of this response (1-indexed). | | |**pageSize** | **Long** | Number of entries per page. | | diff --git a/docs/ListCollectionsOutputBody.md b/docs/ListCollectionsOutputBody.md index 87f139a5..edbad9ba 100644 --- a/docs/ListCollectionsOutputBody.md +++ b/docs/ListCollectionsOutputBody.md @@ -10,7 +10,7 @@ |**hasNextPage** | **Boolean** | | | |**pageNumber** | **Long** | | | |**pageSize** | **Long** | | | -|**results** | [**List<CollectionListItemBody>**](CollectionListItemBody.md) | | | +|**results** | **List<CollectionListItemBody>** | | | diff --git a/docs/ListDataTypeFunctionsBody.md b/docs/ListDataTypeFunctionsBody.md index 467e4891..fd609bd4 100644 --- a/docs/ListDataTypeFunctionsBody.md +++ b/docs/ListDataTypeFunctionsBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**items** | [**List<DataTypeFunctionEntry>**](DataTypeFunctionEntry.md) | The page of matching functions, in ascending function ID order. Empty when no function uses the type. | | +|**items** | **List<DataTypeFunctionEntry>** | The page of matching functions, in ascending function ID order. Empty when no function uses the type. | | |**nextAfterFunctionId** | **Long** | Pass as after_function_id to fetch the next page. Absent on the last page. | [optional] | diff --git a/docs/ListExampleAnalysesOutputBody.md b/docs/ListExampleAnalysesOutputBody.md index 0f205f8e..3ef4fe14 100644 --- a/docs/ListExampleAnalysesOutputBody.md +++ b/docs/ListExampleAnalysesOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**analyses** | [**List<Example>**](Example.md) | List of example analyses | | +|**analyses** | **List<Example>** | List of example analyses | | diff --git a/docs/ListFunctionSignaturesOutputBody.md b/docs/ListFunctionSignaturesOutputBody.md index f50a50e2..6a9d87c1 100644 --- a/docs/ListFunctionSignaturesOutputBody.md +++ b/docs/ListFunctionSignaturesOutputBody.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**dataTypes** | [**List<AnalysisDataTypesGroup>**](AnalysisDataTypesGroup.md) | The types the returned signatures name, grouped by analysis and ordered by analysis_id. Returned only when include_data_types is true. | [optional] | -|**items** | [**List<BatchFunctionSignatureEntry>**](BatchFunctionSignatureEntry.md) | One entry per distinct requested function ID, in request order. A repeated ID yields one entry. | | +|**dataTypes** | **List<AnalysisDataTypesGroup>** | The types the returned signatures name, grouped by analysis and ordered by analysis_id. Returned only when include_data_types is true. | [optional] | +|**items** | **List<BatchFunctionSignatureEntry>** | One entry per distinct requested function ID, in request order. A repeated ID yields one entry. | | diff --git a/docs/ListFunctionStringsOutputBody.md b/docs/ListFunctionStringsOutputBody.md index ba483690..75e90ef0 100644 --- a/docs/ListFunctionStringsOutputBody.md +++ b/docs/ListFunctionStringsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**strings** | [**List<FunctionStringItem>**](FunctionStringItem.md) | | | +|**strings** | **List<FunctionStringItem>** | | | |**totalStrings** | **Long** | | | diff --git a/docs/ListImportedFunctionsOutputBody.md b/docs/ListImportedFunctionsOutputBody.md index 3f942b20..c8f716ac 100644 --- a/docs/ListImportedFunctionsOutputBody.md +++ b/docs/ListImportedFunctionsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**importedFunctions** | [**List<ImportedFunctionEntry>**](ImportedFunctionEntry.md) | | | +|**importedFunctions** | **List<ImportedFunctionEntry>** | | | |**totalCount** | **Long** | Total imported functions for the binary, ignoring pagination. | | diff --git a/docs/ListTeamsOutputBody.md b/docs/ListTeamsOutputBody.md index eacedc1e..c83a5d40 100644 --- a/docs/ListTeamsOutputBody.md +++ b/docs/ListTeamsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**teams** | [**List<Team>**](Team.md) | | | +|**teams** | **List<Team>** | | | |**total** | **Long** | | | diff --git a/docs/ListUsersOutputBody.md b/docs/ListUsersOutputBody.md index d66a4e9e..08f0c9bd 100644 --- a/docs/ListUsersOutputBody.md +++ b/docs/ListUsersOutputBody.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**total** | **Long** | | | -|**users** | [**List<User>**](User.md) | | | +|**users** | **List<User>** | | | diff --git a/docs/Meta.md b/docs/Meta.md new file mode 100644 index 00000000..4ad4ea2c --- /dev/null +++ b/docs/Meta.md @@ -0,0 +1,13 @@ + + +# Meta + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**endianness** | **Endianness** | | [optional] | + + + diff --git a/docs/Metadata.md b/docs/Metadata.md new file mode 100644 index 00000000..6b2bf314 --- /dev/null +++ b/docs/Metadata.md @@ -0,0 +1,27 @@ + + +# Metadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first, empty until the run logs anything. Each entry is a [timestamp, message] pair. | | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means this agent has never been triggered for the analysis, so it is safe to start one. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/ModelInterpretation.md b/docs/ModelInterpretation.md new file mode 100644 index 00000000..3685203c --- /dev/null +++ b/docs/ModelInterpretation.md @@ -0,0 +1,13 @@ + + +# ModelInterpretation + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**interpretation** | **String** | | [optional] | + + + diff --git a/docs/ModelInterpretationEvidence.md b/docs/ModelInterpretationEvidence.md new file mode 100644 index 00000000..6b33f7c7 --- /dev/null +++ b/docs/ModelInterpretationEvidence.md @@ -0,0 +1,36 @@ + + +# ModelInterpretationEvidence + +LLM interpretations of observations. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | **EvidenceStrength** | | [optional] | +|**interpretations** | [**List<ModelInterpretation>**](ModelInterpretation.md) | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| MODEL_INTERPRETATION | "model_interpretation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| MODEL_INTERPRETATION | "model_interpretation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/MutexEntry.md b/docs/MutexEntry.md index a664797b..5abc90dc 100644 --- a/docs/MutexEntry.md +++ b/docs/MutexEntry.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**name** | **String** | | | diff --git a/docs/NamesFinishedEvent.md b/docs/NamesFinishedEvent.md new file mode 100644 index 00000000..7bd82e13 --- /dev/null +++ b/docs/NamesFinishedEvent.md @@ -0,0 +1,16 @@ + + +# NamesFinishedEvent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**applied** | **Integer** | | | +|**attempt** | **Integer** | | | +|**seq** | **Integer** | | | +|**type** | **String** | | | + + + diff --git a/docs/NetworkActivity.md b/docs/NetworkActivity.md index 6df65e9b..398ade54 100644 --- a/docs/NetworkActivity.md +++ b/docs/NetworkActivity.md @@ -7,10 +7,10 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**connections** | [**List<Connection>**](Connection.md) | | [optional] | -|**dnsQueries** | [**List<DnsQuery>**](DnsQuery.md) | | [optional] | -|**extractedUrls** | [**List<ExtractedURL>**](ExtractedURL.md) | | [optional] | -|**httpRequests** | [**List<HttpRequest>**](HttpRequest.md) | | [optional] | +|**connections** | **List<Connection>** | | [optional] | +|**dnsQueries** | **List<DnsQuery>** | | [optional] | +|**extractedUrls** | **List<ExtractedURL>** | | [optional] | +|**httpRequests** | **List<HttpRequest>** | | [optional] | diff --git a/docs/NetworkingCall.md b/docs/NetworkingCall.md new file mode 100644 index 00000000..15412f38 --- /dev/null +++ b/docs/NetworkingCall.md @@ -0,0 +1,66 @@ + + +# NetworkingCall + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**calleeName** | **String** | Name of the called function | | +|**category** | [**CategoryEnum**](#CategoryEnum) | Networking category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**matchedName** | **String** | Name or token that matched | | +|**source** | [**SourceEnum**](#SourceEnum) | Networking source the match belongs to | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| ACCEPT | "accept" | +| ADDRESS | "address" | +| CONNECT | "connect" | +| DNS | "dns" | +| HTTP | "http" | +| NETINFO | "netinfo" | +| RAW_PACKET | "raw-packet" | +| RECV | "recv" | +| SEND | "send" | +| SOCKET | "socket" | +| TLS | "tls" | +| URL | "url" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| API | "api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: SourceEnum + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CURL | "curl" | +| GENERIC | "generic" | +| LIBC | "libc" | +| PCAP | "pcap" | +| POCO | "poco" | +| QT | "qt" | +| TLS | "tls" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/NetworkingDirectMatch.md b/docs/NetworkingDirectMatch.md new file mode 100644 index 00000000..efb86c60 --- /dev/null +++ b/docs/NetworkingDirectMatch.md @@ -0,0 +1,65 @@ + + +# NetworkingDirectMatch + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**category** | [**CategoryEnum**](#CategoryEnum) | Networking category of the match | | +|**how** | [**HowEnum**](#HowEnum) | Detection tier that produced the match | | +|**matchedName** | **String** | Name or token that matched | | +|**source** | [**SourceEnum**](#SourceEnum) | Networking source the match belongs to | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| ACCEPT | "accept" | +| ADDRESS | "address" | +| CONNECT | "connect" | +| DNS | "dns" | +| HTTP | "http" | +| NETINFO | "netinfo" | +| RAW_PACKET | "raw-packet" | +| RECV | "recv" | +| SEND | "send" | +| SOCKET | "socket" | +| TLS | "tls" | +| URL | "url" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: HowEnum + +| Name | Value | +|---- | -----| +| API | "api" | +| CPP_CLASS_TOKEN | "cpp-class-token" | +| GENERIC_KEYWORD | "generic-keyword" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: SourceEnum + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CURL | "curl" | +| GENERIC | "generic" | +| LIBC | "libc" | +| PCAP | "pcap" | +| POCO | "poco" | +| QT | "qt" | +| TLS | "tls" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/NetworkingExplainMetadata.md b/docs/NetworkingExplainMetadata.md new file mode 100644 index 00000000..ce47b9fa --- /dev/null +++ b/docs/NetworkingExplainMetadata.md @@ -0,0 +1,27 @@ + + +# NetworkingExplainMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this function. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/NetworkingExplainResult.md b/docs/NetworkingExplainResult.md new file mode 100644 index 00000000..c72e4bd5 --- /dev/null +++ b/docs/NetworkingExplainResult.md @@ -0,0 +1,23 @@ + + +# NetworkingExplainResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cancelled** | **Boolean** | Whether the run was cancelled | | +|**dataReceived** | **String** | Description of the data received | [optional] | +|**dataSent** | **String** | Description of the data sent | [optional] | +|**dataUsage** | **String** | How the sent or received data is used | [optional] | +|**endpoints** | **List<String>** | Concrete remote endpoints identified -- IPs, hostnames, or URLs | [optional] | +|**functionId** | **Long** | ID of the explained function | | +|**functionName** | **String** | Name of the explained function | [optional] | +|**functionsInvolved** | **List<NetworkingExplainedFunction>** | Other functions involved in the network communication | [optional] | +|**protocol** | **String** | Protocol used for the communication | [optional] | +|**purpose** | **String** | Purpose of the network communication | [optional] | +|**summary** | **String** | Explanation of the network communication the function performs | [optional] | + + + diff --git a/docs/NetworkingExplainedFunction.md b/docs/NetworkingExplainedFunction.md new file mode 100644 index 00000000..de2a426a --- /dev/null +++ b/docs/NetworkingExplainedFunction.md @@ -0,0 +1,15 @@ + + +# NetworkingExplainedFunction + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**description** | **String** | Role this function plays in the network communication | | +|**functionId** | **Long** | ID of the function | | +|**functionName** | **String** | Name of the function | | + + + diff --git a/docs/NetworkingFinding.md b/docs/NetworkingFinding.md new file mode 100644 index 00000000..acf3fd28 --- /dev/null +++ b/docs/NetworkingFinding.md @@ -0,0 +1,71 @@ + + +# NetworkingFinding + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**address** | **String** | Function's virtual address, hex-encoded | | +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Distinct networking categories evidenced by this function | | +|**confidence** | [**ConfidenceEnum**](#ConfidenceEnum) | High when a direct name match was found, medium when the function only calls into networking APIs | | +|**directMatches** | **List<NetworkingDirectMatch>** | Matches against the function's own name | [optional] | +|**evidenceCount** | **Long** | Total number of direct matches and network calls | | +|**functionId** | **Long** | ID of the function the finding was reported in | | +|**functionName** | **String** | Name of the function the finding was reported in | | +|**functionSize** | **Long** | Size of the function in bytes | | +|**networkCalls** | **List<NetworkingCall>** | Matches against names this function calls | [optional] | +|**remote** | **Boolean** | Whether this function evidences remote communication rather than only supporting it | | +|**sources** | [**List<SourcesEnum>**](#List<SourcesEnum>) | Distinct networking sources evidenced by this function | | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| ACCEPT | "accept" | +| ADDRESS | "address" | +| CONNECT | "connect" | +| DNS | "dns" | +| HTTP | "http" | +| NETINFO | "netinfo" | +| RAW_PACKET | "raw-packet" | +| RECV | "recv" | +| SEND | "send" | +| SOCKET | "socket" | +| TLS | "tls" | +| URL | "url" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: ConfidenceEnum + +| Name | Value | +|---- | -----| +| HIGH | "high" | +| MEDIUM | "medium" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<SourcesEnum> + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CURL | "curl" | +| GENERIC | "generic" | +| LIBC | "libc" | +| PCAP | "pcap" | +| POCO | "poco" | +| QT | "qt" | +| TLS | "tls" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/NetworkingScanMetadata.md b/docs/NetworkingScanMetadata.md new file mode 100644 index 00000000..9aa6902b --- /dev/null +++ b/docs/NetworkingScanMetadata.md @@ -0,0 +1,27 @@ + + +# NetworkingScanMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this analysis. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/NetworkingScanResult.md b/docs/NetworkingScanResult.md new file mode 100644 index 00000000..779e082b --- /dev/null +++ b/docs/NetworkingScanResult.md @@ -0,0 +1,15 @@ + + +# NetworkingScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Analysis the run was performed against | | +|**findings** | **List<NetworkingFinding>** | Functions with networking-related evidence, sorted by remoteness then confidence then evidence count | [optional] | +|**totalFunctions** | **Long** | Functions the run considered | | + + + diff --git a/docs/OperationCreateMetadataCreateResult.md b/docs/OperationCreateMetadataCreateResult.md new file mode 100644 index 00000000..1767ce72 --- /dev/null +++ b/docs/OperationCreateMetadataCreateResult.md @@ -0,0 +1,17 @@ + + +# OperationCreateMetadataCreateResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **CreateMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **CreateResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationCryptoExplainMetadataCryptoExplainResult.md b/docs/OperationCryptoExplainMetadataCryptoExplainResult.md new file mode 100644 index 00000000..fe710d2d --- /dev/null +++ b/docs/OperationCryptoExplainMetadataCryptoExplainResult.md @@ -0,0 +1,17 @@ + + +# OperationCryptoExplainMetadataCryptoExplainResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **CryptoExplainMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **CryptoExplainResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationCryptoScanMetadataCryptoScanResult.md b/docs/OperationCryptoScanMetadataCryptoScanResult.md new file mode 100644 index 00000000..89ca6b72 --- /dev/null +++ b/docs/OperationCryptoScanMetadataCryptoScanResult.md @@ -0,0 +1,17 @@ + + +# OperationCryptoScanMetadataCryptoScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **CryptoScanMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **CryptoScanResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationExecutionExplainMetadataExecutionExplainResult.md b/docs/OperationExecutionExplainMetadataExecutionExplainResult.md new file mode 100644 index 00000000..e903ccc5 --- /dev/null +++ b/docs/OperationExecutionExplainMetadataExecutionExplainResult.md @@ -0,0 +1,17 @@ + + +# OperationExecutionExplainMetadataExecutionExplainResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **ExecutionExplainMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **ExecutionExplainResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationExecutionScanMetadataExecutionScanResult.md b/docs/OperationExecutionScanMetadataExecutionScanResult.md new file mode 100644 index 00000000..e7d5bac3 --- /dev/null +++ b/docs/OperationExecutionScanMetadataExecutionScanResult.md @@ -0,0 +1,17 @@ + + +# OperationExecutionScanMetadataExecutionScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **ExecutionScanMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **ExecutionScanResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.md b/docs/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.md new file mode 100644 index 00000000..5d2bec23 --- /dev/null +++ b/docs/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.md @@ -0,0 +1,17 @@ + + +# OperationFilesystemAnalyseMetadataFilesystemAnalyseResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **FilesystemAnalyseMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **FilesystemAnalyseResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationFilesystemScanMetadataFilesystemScanResult.md b/docs/OperationFilesystemScanMetadataFilesystemScanResult.md new file mode 100644 index 00000000..e66a541d --- /dev/null +++ b/docs/OperationFilesystemScanMetadataFilesystemScanResult.md @@ -0,0 +1,17 @@ + + +# OperationFilesystemScanMetadataFilesystemScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **FilesystemScanMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **FilesystemScanResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationMetadataCapabilitiesResult.md b/docs/OperationMetadataCapabilitiesResult.md new file mode 100644 index 00000000..3828773c --- /dev/null +++ b/docs/OperationMetadataCapabilitiesResult.md @@ -0,0 +1,17 @@ + + +# OperationMetadataCapabilitiesResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **Metadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **CapabilitiesResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationMetadataRemediationResult.md b/docs/OperationMetadataRemediationResult.md new file mode 100644 index 00000000..b848d354 --- /dev/null +++ b/docs/OperationMetadataRemediationResult.md @@ -0,0 +1,17 @@ + + +# OperationMetadataRemediationResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **Metadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **RemediationResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationMetadataReportResult.md b/docs/OperationMetadataReportResult.md new file mode 100644 index 00000000..9641c110 --- /dev/null +++ b/docs/OperationMetadataReportResult.md @@ -0,0 +1,17 @@ + + +# OperationMetadataReportResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **Metadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **ReportResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationMetadataThreatReportResult.md b/docs/OperationMetadataThreatReportResult.md new file mode 100644 index 00000000..a13f21f7 --- /dev/null +++ b/docs/OperationMetadataThreatReportResult.md @@ -0,0 +1,17 @@ + + +# OperationMetadataThreatReportResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **Metadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **ThreatReportResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationMetadataTriageResult.md b/docs/OperationMetadataTriageResult.md new file mode 100644 index 00000000..0cb64aa2 --- /dev/null +++ b/docs/OperationMetadataTriageResult.md @@ -0,0 +1,17 @@ + + +# OperationMetadataTriageResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **Metadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **TriageResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationNetworkingExplainMetadataNetworkingExplainResult.md b/docs/OperationNetworkingExplainMetadataNetworkingExplainResult.md new file mode 100644 index 00000000..7574b77e --- /dev/null +++ b/docs/OperationNetworkingExplainMetadataNetworkingExplainResult.md @@ -0,0 +1,17 @@ + + +# OperationNetworkingExplainMetadataNetworkingExplainResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **NetworkingExplainMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **NetworkingExplainResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationNetworkingScanMetadataNetworkingScanResult.md b/docs/OperationNetworkingScanMetadataNetworkingScanResult.md new file mode 100644 index 00000000..bf5b5429 --- /dev/null +++ b/docs/OperationNetworkingScanMetadataNetworkingScanResult.md @@ -0,0 +1,17 @@ + + +# OperationNetworkingScanMetadataNetworkingScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **NetworkingScanMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **NetworkingScanResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationSecurityScanMetadataSecurityScanResult.md b/docs/OperationSecurityScanMetadataSecurityScanResult.md new file mode 100644 index 00000000..33c25dc8 --- /dev/null +++ b/docs/OperationSecurityScanMetadataSecurityScanResult.md @@ -0,0 +1,17 @@ + + +# OperationSecurityScanMetadataSecurityScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **SecurityScanMetadata** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **SecurityScanResult** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/OperationWorkflowProgressResultBody.md b/docs/OperationWorkflowProgressResultBody.md new file mode 100644 index 00000000..92d4e389 --- /dev/null +++ b/docs/OperationWorkflowProgressResultBody.md @@ -0,0 +1,17 @@ + + +# OperationWorkflowProgressResultBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**done** | **Boolean** | Whether the operation has reached a terminal state. | | +|**error** | **Status** | Failure detail, populated only when done is true and the operation failed. | [optional] | +|**metadata** | **WorkflowProgress** | In-flight information and details. | [optional] | +|**name** | **String** | API resource name. | | +|**response** | **ResultBody** | Result, set only when done is true and the operation succeeded. | [optional] | + + + diff --git a/docs/PatchCollectionBinariesOutputBody.md b/docs/PatchCollectionBinariesOutputBody.md index 6bb642f1..da1eec56 100644 --- a/docs/PatchCollectionBinariesOutputBody.md +++ b/docs/PatchCollectionBinariesOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**binaries** | [**List<Binary>**](Binary.md) | | | +|**binaries** | **List<Binary>** | | | diff --git a/docs/PointerDataType.md b/docs/PointerDataType.md index c52f2388..154deee4 100644 --- a/docs/PointerDataType.md +++ b/docs/PointerDataType.md @@ -9,12 +9,13 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**PointerDefinition**](PointerDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **PointerDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/ProcessActivityEntry.md b/docs/ProcessActivityEntry.md index fac0f3f8..730cfbb7 100644 --- a/docs/ProcessActivityEntry.md +++ b/docs/ProcessActivityEntry.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**args** | **List<String>** | | [optional] | |**childSeqid** | **Long** | | | -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**exitCode** | **Long** | | [optional] | |**exitCodeStr** | **String** | | [optional] | |**name** | **String** | | | diff --git a/docs/ProcessMemdumps.md b/docs/ProcessMemdumps.md index f4da9250..5c180f92 100644 --- a/docs/ProcessMemdumps.md +++ b/docs/ProcessMemdumps.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**dumps** | [**List<MemdumpEntry>**](MemdumpEntry.md) | | [optional] | +|**dumps** | **List<MemdumpEntry>** | | [optional] | |**processSeqid** | **Long** | | | diff --git a/docs/ProcessNode.md b/docs/ProcessNode.md index bbbaeb83..b2d2c0c7 100644 --- a/docs/ProcessNode.md +++ b/docs/ProcessNode.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**args** | **List<String>** | | [optional] | |**attributed** | **Boolean** | | | -|**children** | [**List<ProcessNode>**](ProcessNode.md) | | [optional] | +|**children** | **List<ProcessNode>** | | [optional] | |**exitCode** | **Long** | | [optional] | |**exitCodeStr** | **String** | | [optional] | |**exitedAt** | **Double** | | [optional] | diff --git a/docs/ProcessTree.md b/docs/ProcessTree.md index b73d3309..6df7d7e3 100644 --- a/docs/ProcessTree.md +++ b/docs/ProcessTree.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**nodes** | [**List<ProcessNode>**](ProcessNode.md) | | [optional] | +|**nodes** | **List<ProcessNode>** | | [optional] | |**sampleSeqid** | **Long** | | [optional] | diff --git a/docs/ProductOutput.md b/docs/ProductOutput.md index afdaf412..bf6cf52d 100644 --- a/docs/ProductOutput.md +++ b/docs/ProductOutput.md @@ -12,7 +12,7 @@ |**features** | **List<String>** | Marketing feature list for this product. | | |**id** | **String** | Product ID. | | |**name** | **String** | Human-readable product name. | | -|**prices** | [**List<PriceOutput>**](PriceOutput.md) | All active recurring prices for this product. | | +|**prices** | **List<PriceOutput>** | All active recurring prices for this product. | | |**salesOnly** | **Boolean** | When true, this product is not self-serve purchasable and must be bought via direct sales. | | |**tier** | **String** | User tier associated with this product, if any. | [optional] | diff --git a/docs/ProtocolsAgentResponse.md b/docs/ProtocolsAgentResponse.md new file mode 100644 index 00000000..3b90f5b0 --- /dev/null +++ b/docs/ProtocolsAgentResponse.md @@ -0,0 +1,15 @@ + + +# ProtocolsAgentResponse + +Full protocols report, including metadata, findings, and evidence. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**meta** | **Meta** | | [optional] | +|**findings** | **List<Finding>** | | [optional] | + + + diff --git a/docs/ReferencedConstant.md b/docs/ReferencedConstant.md new file mode 100644 index 00000000..fff4a79c --- /dev/null +++ b/docs/ReferencedConstant.md @@ -0,0 +1,15 @@ + + +# ReferencedConstant + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**subject** | [**Subject**](Subject.md) | | | +|**value** | **BytesConstant** | | | +|**display** | **Display** | | [optional] | + + + diff --git a/docs/ReferencedConstantEvidence.md b/docs/ReferencedConstantEvidence.md new file mode 100644 index 00000000..b97581cf --- /dev/null +++ b/docs/ReferencedConstantEvidence.md @@ -0,0 +1,45 @@ + + +# ReferencedConstantEvidence + +Constants and the instructions that reference them. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**constants** | [**List<ReferencedConstant>**](ReferencedConstant.md) | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| REFERENCED_CONSTANT | "referenced_constant" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| DIRECT | "direct" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/RegistryOperation.md b/docs/RegistryOperation.md index cf816c66..6545fe1d 100644 --- a/docs/RegistryOperation.md +++ b/docs/RegistryOperation.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**key** | **String** | | | diff --git a/docs/RelatedBinary.md b/docs/RelatedBinary.md new file mode 100644 index 00000000..6dc88f46 --- /dev/null +++ b/docs/RelatedBinary.md @@ -0,0 +1,16 @@ + + +# RelatedBinary + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Most recent analysis of the related binary, null when it has never been analysed | | +|**binaryId** | **Long** | ID of the related binary | | +|**name** | **String** | Name of the related binary | | +|**sha256** | **String** | SHA-256 of the related binary | | + + + diff --git a/docs/RemediationResult.md b/docs/RemediationResult.md new file mode 100644 index 00000000..14137363 --- /dev/null +++ b/docs/RemediationResult.md @@ -0,0 +1,15 @@ + + +# RemediationResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**snortRules** | **List<String>** | Generated Snort rules | | +|**stixRules** | **List<String>** | Generated STIX rules | | +|**yaraRules** | **List<String>** | Generated YARA rules | | + + + diff --git a/docs/RenameInputBody.md b/docs/RenameInputBody.md index a0b4358a..82b70af2 100644 --- a/docs/RenameInputBody.md +++ b/docs/RenameInputBody.md @@ -9,7 +9,21 @@ |------------ | ------------- | ------------- | -------------| |**newMangledName** | **String** | New mangled function name | [optional] | |**newName** | **String** | New function name | | -|**preserveAiDecompilation** | **Boolean** | Keep the cached AI decompilation, summary and inline comments. Set when the new name comes from the model's own prediction (e.g. Transfer Name) so existing AI output is not discarded and regenerated. | [optional] | +|**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Source that triggered the rename | [optional] | + + + +## Enum: SourceTypeEnum + +| Name | Value | +|---- | -----| +| SYSTEM | "SYSTEM" | +| USER | "USER" | +| EXTERNAL | "EXTERNAL" | +| AUTO_UNSTRIP | "AUTO_UNSTRIP" | +| AI_UNSTRIP | "AI_UNSTRIP" | +| AI_AGENT | "AI_AGENT" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/ReportAnalysisResponse.md b/docs/ReportAnalysisResponse.md index 258f3432..b4396cdb 100644 --- a/docs/ReportAnalysisResponse.md +++ b/docs/ReportAnalysisResponse.md @@ -12,7 +12,7 @@ |**totalNumberOfFunctions** | **Integer** | The total number of functions identified in the binary | | |**numberOfAnalysedFunctions** | **Integer** | The number of functions that were analyzed in the binary | | |**attackFlowSummary** | **String** | A summary in markdown format of the attack flow | | -|**ioCs** | [**List<IOC>**](IOC.md) | A list of IOCs (Indicators of Compromise) found in the analysis | | +|**ioCs** | **List<IOC>** | A list of IOCs (Indicators of Compromise) found in the analysis | | |**executableTechniques** | [**List<MITRETechnique>**](MITRETechnique.md) | A series of MITRE Techniques found | | |**yaraRule** | **String** | The YARA rule generated for the binary | | diff --git a/docs/ReportEvent.md b/docs/ReportEvent.md index ec32ed88..d84e9076 100644 --- a/docs/ReportEvent.md +++ b/docs/ReportEvent.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**apiCalls** | [**List<ApiCall>**](ApiCall.md) | | [optional] | +|**apiCalls** | **List<ApiCall>** | | [optional] | |**count** | **Long** | | [optional] | |**desiredAccess** | **List<String>** | | [optional] | |**processSeqid** | **Long** | | [optional] | diff --git a/docs/ReportInfo.md b/docs/ReportInfo.md index d343a34b..408758e6 100644 --- a/docs/ReportInfo.md +++ b/docs/ReportInfo.md @@ -7,9 +7,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**_file** | [**DrakvufFileMetadata**](DrakvufFileMetadata.md) | | [optional] | +|**_file** | **DrakvufFileMetadata** | | [optional] | |**id** | **String** | | | -|**options** | [**ReportOptions**](ReportOptions.md) | | [optional] | +|**options** | **ReportOptions** | | [optional] | |**osProfile** | **String** | | [optional] | |**status** | **String** | | [optional] | |**timeAnalysisFinished** | **String** | | [optional] | diff --git a/docs/ReportReachabilityStatus.md b/docs/ReportReachabilityStatus.md new file mode 100644 index 00000000..38869690 --- /dev/null +++ b/docs/ReportReachabilityStatus.md @@ -0,0 +1,17 @@ + + +# ReportReachabilityStatus + +## Enum + + +* `UNDETERMINED` (value: `"undetermined"`) + +* `REACHABLE` (value: `"reachable"`) + +* `UNREACHABLE` (value: `"unreachable"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/ReportResult.md b/docs/ReportResult.md new file mode 100644 index 00000000..384812af --- /dev/null +++ b/docs/ReportResult.md @@ -0,0 +1,14 @@ + + +# ReportResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**findings** | **Object** | | | +|**meta** | **Object** | | | + + + diff --git a/docs/ResolvedEntity.md b/docs/ResolvedEntity.md index 197077c5..20177192 100644 --- a/docs/ResolvedEntity.md +++ b/docs/ResolvedEntity.md @@ -23,6 +23,7 @@ |**needsNaming** | **Boolean** | | | |**provenance** | **String** | Search is applied to string value | | |**resolvedName** | **String** | | | +|**suggestedName** | **String** | Search is applied to string value | [optional] | |**suggestedType** | **String** | | | |**suggestionConfidence** | **String** | | | |**token** | **String** | Search is applied to string value | | @@ -54,6 +55,7 @@ | DATABASE | "database" | | FROZEN | "frozen" | | DEFAULT | "default" | +| SUGGESTED | "suggested" | | UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/ResultBody.md b/docs/ResultBody.md new file mode 100644 index 00000000..ec35c9e5 --- /dev/null +++ b/docs/ResultBody.md @@ -0,0 +1,16 @@ + + +# ResultBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**binaries** | **List<ExtractedBinary>** | Child binaries recovered from the extraction. | | +|**extractionDepth** | **Long** | Number of nested-archive extraction passes taken. | | +|**filenameToFailure** | **Map<String, ExtractionFailure>** | Per-file extraction failures, keyed by filename. | | +|**skippedFiles** | **Long** | Files skipped because they were not recognised as binaries. | | + + + diff --git a/docs/RuleKind.md b/docs/RuleKind.md new file mode 100644 index 00000000..3accb242 --- /dev/null +++ b/docs/RuleKind.md @@ -0,0 +1,29 @@ + + +# RuleKind + +## Enum + + +* `CREDENTIALS` (value: `"credentials"`) + +* `API_CREDENTIALS` (value: `"api-credentials"`) + +* `OAUTH_CREDENTIALS` (value: `"oauth-credentials"`) + +* `ENCRYPTION_KEY` (value: `"encryption-key"`) + +* `JWT_TOKEN` (value: `"jwt-token"`) + +* `WEBHOOK_URL` (value: `"webhook-url"`) + +* `PRIVATE_KEY` (value: `"private-key"`) + +* `SIGNED_URL` (value: `"signed-url"`) + +* `GENERIC` (value: `"generic"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/SSOProvidersOutputBody.md b/docs/SSOProvidersOutputBody.md index a3017518..2271e99b 100644 --- a/docs/SSOProvidersOutputBody.md +++ b/docs/SSOProvidersOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**providers** | [**List<SSOProvider>**](SSOProvider.md) | | | +|**providers** | **List<SSOProvider>** | | | diff --git a/docs/SandboxConfig.md b/docs/SandboxConfig.md new file mode 100644 index 00000000..6754f387 --- /dev/null +++ b/docs/SandboxConfig.md @@ -0,0 +1,41 @@ + + +# SandboxConfig + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**archiveEntryPath** | **String** | | [optional] | +|**archivePassword** | **String** | | [optional] | +|**archiveSha256Hash** | **String** | | [optional] | +|**commandLineArgs** | **String** | | [optional] | +|**enabled** | **Boolean** | | [optional] | +|**startMethod** | [**StartMethodEnum**](#StartMethodEnum) | | [optional] | +|**timeout** | [**TimeoutEnum**](#TimeoutEnum) | | [optional] | + + + +## Enum: StartMethodEnum + +| Name | Value | +|---- | -----| +| STANDARD_USER_PROCESS | "standard_user_process" | +| ADMINISTRATOR_PROCESS | "administrator_process" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: TimeoutEnum + +| Name | Value | +|---- | -----| +| NUMBER_120 | 120l | +| NUMBER_180 | 180l | +| NUMBER_300 | 300l | +| NUMBER_600 | 600l | +| NUMBER_unknown_default_open_api | 11184809l | + + + diff --git a/docs/ScheduledTaskEntry.md b/docs/ScheduledTaskEntry.md index 1f4883c1..385c366a 100644 --- a/docs/ScheduledTaskEntry.md +++ b/docs/ScheduledTaskEntry.md @@ -10,7 +10,7 @@ |**command** | **String** | | [optional] | |**day** | **String** | | [optional] | |**endDate** | **String** | | [optional] | -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**executable** | **String** | | [optional] | |**modifier** | **String** | | [optional] | |**runAs** | **String** | | [optional] | diff --git a/docs/ScreenshotEntry.md b/docs/ScreenshotEntry.md new file mode 100644 index 00000000..3affa3f5 --- /dev/null +++ b/docs/ScreenshotEntry.md @@ -0,0 +1,13 @@ + + +# ScreenshotEntry + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**index** | **Long** | | | + + + diff --git a/docs/ScreenshotsIndex.md b/docs/ScreenshotsIndex.md new file mode 100644 index 00000000..b0f2cec2 --- /dev/null +++ b/docs/ScreenshotsIndex.md @@ -0,0 +1,14 @@ + + +# ScreenshotsIndex + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**count** | **Long** | | | +|**screenshots** | **List<ScreenshotEntry>** | | | + + + diff --git a/docs/SecretsAgentResponse.md b/docs/SecretsAgentResponse.md new file mode 100644 index 00000000..22bd488c --- /dev/null +++ b/docs/SecretsAgentResponse.md @@ -0,0 +1,15 @@ + + +# SecretsAgentResponse + +Full secrets report, including metadata, findings, and evidence. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**meta** | **Meta** | | [optional] | +|**findings** | **List<Finding>** | | [optional] | + + + diff --git a/docs/SecurityFinding.md b/docs/SecurityFinding.md new file mode 100644 index 00000000..a2f499ca --- /dev/null +++ b/docs/SecurityFinding.md @@ -0,0 +1,58 @@ + + +# SecurityFinding + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**checkId** | **String** | Semgrep rule ID that matched | [optional] | +|**confidence** | [**ConfidenceEnum**](#ConfidenceEnum) | Semgrep's confidence in the finding | [optional] | +|**cwe** | **List<String>** | CWE identifiers associated with the finding | [optional] | +|**endLine** | **Long** | Line the finding ends on | [optional] | +|**functionId** | **Long** | ID of the function the finding was reported in | [optional] | +|**functionName** | **String** | Name of the function the finding was reported in | [optional] | +|**impact** | [**ImpactEnum**](#ImpactEnum) | Estimated impact of the finding | [optional] | +|**message** | **String** | Human-readable description of the finding | [optional] | +|**severity** | [**SeverityEnum**](#SeverityEnum) | Severity of the finding | [optional] | +|**snippetLines** | **List<String>** | Source lines making up the reported snippet | [optional] | +|**snippetStartLine** | **Long** | Line the reported snippet starts on | [optional] | +|**startLine** | **Long** | Line the finding starts on | [optional] | + + + +## Enum: ConfidenceEnum + +| Name | Value | +|---- | -----| +| LOW | "LOW" | +| MEDIUM | "MEDIUM" | +| HIGH | "HIGH" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: ImpactEnum + +| Name | Value | +|---- | -----| +| LOW | "LOW" | +| MEDIUM | "MEDIUM" | +| HIGH | "HIGH" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: SeverityEnum + +| Name | Value | +|---- | -----| +| LOW | "LOW" | +| MEDIUM | "MEDIUM" | +| HIGH | "HIGH" | +| CRITICAL | "CRITICAL" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/SecurityScanMetadata.md b/docs/SecurityScanMetadata.md new file mode 100644 index 00000000..a77a2a5a --- /dev/null +++ b/docs/SecurityScanMetadata.md @@ -0,0 +1,27 @@ + + +# SecurityScanMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**logHistory** | **List<List<Object>>** | Progress messages the run recorded, oldest first. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Run status. UNINITIALISED means the agent has never been triggered for this analysis. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/SecurityScanResult.md b/docs/SecurityScanResult.md new file mode 100644 index 00000000..68fa3443 --- /dev/null +++ b/docs/SecurityScanResult.md @@ -0,0 +1,18 @@ + + +# SecurityScanResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | Analysis the run was performed against | | +|**cancelled** | **Boolean** | Whether the run was cancelled before it covered every function | | +|**decompiled** | **Long** | Functions successfully decompiled and scanned | | +|**failed** | **Long** | Functions whose decompilation or scan attempt errored | | +|**securityScan** | **List<SecurityFinding>** | Shaped semgrep findings, one per result | [optional] | +|**total** | **Long** | Functions the run considered | | + + + diff --git a/docs/SegmentInfo.md b/docs/SegmentInfo.md index e3d85d4b..32b94c1f 100644 --- a/docs/SegmentInfo.md +++ b/docs/SegmentInfo.md @@ -2,7 +2,7 @@ # SegmentInfo -Represents the information about a segment. Attributes: name: The name of the segment. r: Determines if the segment has read permission. w: Determines if the segment has write permission. x: Determines if the segment has execute permission. start: The start address of the segment. end: The end address of the segment (inclusive). kind: Coarse classification of the segment: \"code\", \"data\", or \"other\". +Represents the information about a segment. This is the per-xref view, carried on :class:`XRef.segment`. The binary-wide ``AnalysisModel.segments`` list is written by a different producer with a different shape -- see :class:`MemorySegment`. Attributes: name: The name of the segment. r: Determines if the segment has read permission. w: Determines if the segment has write permission. x: Determines if the segment has execute permission. start: The start address of the segment. end: The end address of the segment (inclusive). kind: Coarse classification of the segment: \"code\", \"data\", or \"other\". ## Properties diff --git a/docs/SendMessageRequest.md b/docs/SendMessageRequest.md index b48f45ba..5994244d 100644 --- a/docs/SendMessageRequest.md +++ b/docs/SendMessageRequest.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**content** | **String** | | | -|**context** | [**ConversationContext**](ConversationContext.md) | | [optional] | +|**context** | **ConversationContext** | | [optional] | diff --git a/docs/ServerSentEventsInner.md b/docs/ServerSentEventsInner.md index 45012048..24911292 100644 --- a/docs/ServerSentEventsInner.md +++ b/docs/ServerSentEventsInner.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**SseEventToolConfirmationRequiredData**](SseEventToolConfirmationRequiredData.md) | | | +|**data** | **SseEventToolConfirmationRequiredData** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/ServerSentEventsInner1.md b/docs/ServerSentEventsInner1.md index 71b4fc7a..825223e5 100644 --- a/docs/ServerSentEventsInner1.md +++ b/docs/ServerSentEventsInner1.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**WarningEvent**](WarningEvent.md) | | | +|**data** | **WarningEvent** | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/ServiceEntry.md b/docs/ServiceEntry.md index df172a08..24dab9f1 100644 --- a/docs/ServiceEntry.md +++ b/docs/ServiceEntry.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**binaryPath** | **String** | | [optional] | |**displayName** | **String** | | [optional] | -|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**events** | **List<ReportEvent>** | | [optional] | |**name** | **String** | | [optional] | |**serviceType** | **String** | | [optional] | |**startType** | **String** | | [optional] | diff --git a/docs/SignatureParameterEntry.md b/docs/SignatureParameterEntry.md index 6659f8a4..c8ad41f4 100644 --- a/docs/SignatureParameterEntry.md +++ b/docs/SignatureParameterEntry.md @@ -11,7 +11,7 @@ |**dataTypeId** | **Long** | The parameter's type, resolvable against the analysis data types list. Absent when the type could not be resolved. | [optional] | |**name** | **String** | Parameter name, absent when the producer had none. | [optional] | |**ordinal** | **Long** | Zero-based argument position. | | -|**storage** | [**SignatureStorageEntry**](SignatureStorageEntry.md) | Where the parameter is passed. | [optional] | +|**storage** | **SignatureStorageEntry** | Where the parameter is passed. | [optional] | diff --git a/docs/SignatureParameterInput.md b/docs/SignatureParameterInput.md index c9137085..fa796220 100644 --- a/docs/SignatureParameterInput.md +++ b/docs/SignatureParameterInput.md @@ -11,7 +11,7 @@ |**dataTypeId** | **Long** | The parameter's type, which must belong to this analysis. Omit for an unresolved type. | [optional] | |**name** | **String** | Parameter name. Omit for an unnamed parameter. | [optional] | |**ordinal** | **Long** | Zero-based argument position. Must equal the parameter's index in the list. | | -|**storage** | [**SignatureStorageInput**](SignatureStorageInput.md) | Where the parameter is passed. | [optional] | +|**storage** | **SignatureStorageInput** | Where the parameter is passed. | [optional] | diff --git a/docs/StartBatchMatchingInputBody.md b/docs/StartBatchMatchingInputBody.md index a44c817b..a6f53f23 100644 --- a/docs/StartBatchMatchingInputBody.md +++ b/docs/StartBatchMatchingInputBody.md @@ -10,6 +10,7 @@ |**binaryIds** | **List<Long>** | Binary IDs to match the analysis against, one workflow per binary. | | |**debugTypes** | **List<String>** | Restrict matches to candidates with these debug source types. Defaults to [\"SYSTEM\"]. | [optional] | |**minSimilarity** | **Double** | Similarity floor as a percentage. Defaults to 90. | [optional] | +|**noCache** | **Boolean** | By default a completed matching run is reused per binary (that binary reports status=COMPLETED, no new run). Set true to force fresh runs for every binary. | [optional] | |**resultsPerFunction** | **Long** | Max matches returned per source function. Defaults to 1. | [optional] | diff --git a/docs/StartMatchingForAnalysisInputBody.md b/docs/StartMatchingForAnalysisInputBody.md index 5724ffac..20fc21e9 100644 --- a/docs/StartMatchingForAnalysisInputBody.md +++ b/docs/StartMatchingForAnalysisInputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**filters** | [**MatchFilters**](MatchFilters.md) | Narrow the candidate pool. | [optional] | +|**filters** | **MatchFilters** | Narrow the candidate pool. | [optional] | |**minSimilarity** | **Double** | Similarity floor as a percentage. Defaults to 90. | [optional] | |**noCache** | **Boolean** | By default a completed matching run for the same request is reused (response status=COMPLETED, no new run). Set true to force a fresh run. | [optional] | |**resultsPerFunction** | **Long** | Max matches returned per source function. Defaults to 1. | [optional] | diff --git a/docs/StartMatchingForFunctionsInputBody.md b/docs/StartMatchingForFunctionsInputBody.md index 8b68152a..433c7e6f 100644 --- a/docs/StartMatchingForFunctionsInputBody.md +++ b/docs/StartMatchingForFunctionsInputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**filters** | [**MatchFilters**](MatchFilters.md) | Narrow the candidate pool. | [optional] | +|**filters** | **MatchFilters** | Narrow the candidate pool. | [optional] | |**functionIds** | **List<Long>** | Source function IDs to match against the rest of the corpus. | | |**minSimilarity** | **Double** | Similarity floor as a percentage. Defaults to 90. | [optional] | |**noCache** | **Boolean** | By default a completed matching run for the same request is reused (response status=COMPLETED, no new run). Set true to force a fresh run. | [optional] | diff --git a/docs/StartMatchingOutputBody.md b/docs/StartMatchingOutputBody.md index dc9b9e7a..73e07f05 100644 --- a/docs/StartMatchingOutputBody.md +++ b/docs/StartMatchingOutputBody.md @@ -8,11 +8,16 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**matchId** | **String** | Opaque token for this matching run. Pass it to the GET/status endpoints' match_id query parameter to fetch this exact run. | | -|**messages** | [**List<ProgressMessage>**](ProgressMessage.md) | Log messages emitted during execution | | +|**messages** | **List<ProgressMessage>** | Log messages emitted during execution | | +|**percent** | **Long** | Overall completion as a percentage, weighted by step duration | | |**status** | [**StatusEnum**](#StatusEnum) | Current workflow status | | |**step** | **String** | Name of the current step | | |**stepIndex** | **Long** | Zero-based index of the current step | | +|**stepShare** | **Long** | Percentage points the current step contributes when it completes | | |**stepsTotal** | **Long** | Total number of steps in the workflow | | +|**subStep** | **String** | Phase within the current step, when the step reports one | [optional] | +|**subStepDone** | **Long** | Items completed in the current phase | [optional] | +|**subStepTotal** | **Long** | Items the current phase will process, 0 when unknown | [optional] | diff --git a/docs/Status.md b/docs/Status.md new file mode 100644 index 00000000..7bb874fb --- /dev/null +++ b/docs/Status.md @@ -0,0 +1,73 @@ + + +# Status + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | [**CodeEnum**](#CodeEnum) | Machine-readable error code, shared with synchronous API errors. | | +|**detail** | **String** | Additional context where helpful (quota numbers, validation specifics, etc.). | [optional] | +|**docUrl** | **String** | Link to documentation explaining this error and resolution steps. | | +|**message** | **String** | Brief description of the failure. | | +|**retryable** | **Boolean** | Whether retrying the operation might succeed. | | + + + +## Enum: CodeEnum + +| Name | Value | +|---- | -----| +| ACCESS_DENIED | "ACCESS_DENIED" | +| ALREADY_EXISTS | "ALREADY_EXISTS" | +| ANALYSIS_NOT_READY | "ANALYSIS_NOT_READY" | +| BAD_REQUEST | "BAD_REQUEST" | +| CLIENT_CLOSED_REQUEST | "CLIENT_CLOSED_REQUEST" | +| CONFLICT | "CONFLICT" | +| CONVERSATION_NOT_FOUND | "CONVERSATION_NOT_FOUND" | +| DOMAIN_ALREADY_CLAIMED | "DOMAIN_ALREADY_CLAIMED" | +| DOMAIN_VERIFICATION_PENDING | "DOMAIN_VERIFICATION_PENDING" | +| DYNAMIC_EXECUTION_INCOMPLETE | "DYNAMIC_EXECUTION_INCOMPLETE" | +| EMAIL_NOT_VERIFIED | "EMAIL_NOT_VERIFIED" | +| EXTERNAL_USER | "EXTERNAL_USER" | +| FORBIDDEN | "FORBIDDEN" | +| GATEWAY_TIMEOUT | "GATEWAY_TIMEOUT" | +| GROUP_HAS_MEMBERS | "GROUP_HAS_MEMBERS" | +| INSUFFICIENT_CREDITS | "INSUFFICIENT_CREDITS" | +| INTERNAL_ERROR | "INTERNAL_ERROR" | +| INTERNAL_ISSUER | "INTERNAL_ISSUER" | +| INVALID_CONVERSATION_ID | "INVALID_CONVERSATION_ID" | +| INVALID_CREDENTIALS | "INVALID_CREDENTIALS" | +| INVALID_INVITE_CODE | "INVALID_INVITE_CODE" | +| INVALID_RESET_CODE | "INVALID_RESET_CODE" | +| LAST_ORG_OWNER | "LAST_ORG_OWNER" | +| LAST_TEAM_ADMIN | "LAST_TEAM_ADMIN" | +| LAST_TEAM_MEMBER | "LAST_TEAM_MEMBER" | +| LINKED_TO_ORG | "LINKED_TO_ORG" | +| METHOD_NOT_ALLOWED | "METHOD_NOT_ALLOWED" | +| NOT_ACCEPTABLE | "NOT_ACCEPTABLE" | +| NOT_FOUND | "NOT_FOUND" | +| NOT_IMPLEMENTED | "NOT_IMPLEMENTED" | +| NO_ACTIVE_RUN | "NO_ACTIVE_RUN" | +| NO_PENDING_CONFIRMATION | "NO_PENDING_CONFIRMATION" | +| OIDC_DISCOVERY_FAILED | "OIDC_DISCOVERY_FAILED" | +| PASSWORD_RESET_REQUIRED | "PASSWORD_RESET_REQUIRED" | +| PAYMENT_REQUIRED | "PAYMENT_REQUIRED" | +| REPORT_RENDER_FAILED | "REPORT_RENDER_FAILED" | +| REQUEST_ENTITY_TOO_LARGE | "REQUEST_ENTITY_TOO_LARGE" | +| RUN_ALREADY_ACTIVE | "RUN_ALREADY_ACTIVE" | +| SELF_DELETION_NOT_ALLOWED | "SELF_DELETION_NOT_ALLOWED" | +| SERVICE_UNAVAILABLE | "SERVICE_UNAVAILABLE" | +| TOKEN_EXPIRED | "TOKEN_EXPIRED" | +| TOKEN_REUSED | "TOKEN_REUSED" | +| TOO_MANY_REQUESTS | "TOO_MANY_REQUESTS" | +| UNAUTHORIZED | "UNAUTHORIZED" | +| UNSUPPORTED_MEDIA_TYPE | "UNSUPPORTED_MEDIA_TYPE" | +| VALIDATION_FAILED | "VALIDATION_FAILED" | +| VERIFICATION_EXPIRED | "VERIFICATION_EXPIRED" | +| VERIFICATION_NOT_FOUND | "VERIFICATION_NOT_FOUND" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/StructDataType.md b/docs/StructDataType.md index fbd5aff8..bef39dea 100644 --- a/docs/StructDataType.md +++ b/docs/StructDataType.md @@ -9,12 +9,13 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**StructDefinition**](StructDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **StructDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/StructDefinition.md b/docs/StructDefinition.md index 7bdda77b..db6d7fc3 100644 --- a/docs/StructDefinition.md +++ b/docs/StructDefinition.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**members** | [**List<DataTypeMemberEntry>**](DataTypeMemberEntry.md) | The type's fields, in offset order. | | +|**members** | **List<DataTypeMemberEntry>** | The type's fields, in offset order. | | diff --git a/docs/Subject.md b/docs/Subject.md new file mode 100644 index 00000000..dbcf91e8 --- /dev/null +++ b/docs/Subject.md @@ -0,0 +1,17 @@ + + +# Subject + +Exactly one typed program entity described by an observation. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**function** | **Integer** | Function entry address. | | +|**callSite** | **Integer** | | | +|**instruction** | **Integer** | | | +|**data** | **Integer** | | | + + + diff --git a/docs/SubjectAnyOf.md b/docs/SubjectAnyOf.md new file mode 100644 index 00000000..57c30cea --- /dev/null +++ b/docs/SubjectAnyOf.md @@ -0,0 +1,13 @@ + + +# SubjectAnyOf + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**function** | **Integer** | Function entry address. | | + + + diff --git a/docs/SubjectAnyOf1.md b/docs/SubjectAnyOf1.md new file mode 100644 index 00000000..6351055e --- /dev/null +++ b/docs/SubjectAnyOf1.md @@ -0,0 +1,13 @@ + + +# SubjectAnyOf1 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**callSite** | **Integer** | | | + + + diff --git a/docs/SubjectAnyOf2.md b/docs/SubjectAnyOf2.md new file mode 100644 index 00000000..77e1a9da --- /dev/null +++ b/docs/SubjectAnyOf2.md @@ -0,0 +1,13 @@ + + +# SubjectAnyOf2 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**instruction** | **Integer** | | | + + + diff --git a/docs/SubjectAnyOf3.md b/docs/SubjectAnyOf3.md new file mode 100644 index 00000000..6f9ac277 --- /dev/null +++ b/docs/SubjectAnyOf3.md @@ -0,0 +1,13 @@ + + +# SubjectAnyOf3 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**data** | **Integer** | | | + + + diff --git a/docs/SubmitFeedbackInputBody.md b/docs/SubmitFeedbackInputBody.md new file mode 100644 index 00000000..88439b0f --- /dev/null +++ b/docs/SubmitFeedbackInputBody.md @@ -0,0 +1,24 @@ + + +# SubmitFeedbackInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**sentiment** | [**SentimentEnum**](#SentimentEnum) | How useful the caller found this agent's output | | + + + +## Enum: SentimentEnum + +| Name | Value | +|---- | -----| +| POSITIVE | "POSITIVE" | +| NEUTRAL | "NEUTRAL" | +| NEGATIVE | "NEGATIVE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/SuggestedHole.md b/docs/SuggestedHole.md new file mode 100644 index 00000000..74572f15 --- /dev/null +++ b/docs/SuggestedHole.md @@ -0,0 +1,14 @@ + + +# SuggestedHole + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**byteOffset** | **Long** | | | +|**byteSize** | **Long** | | | + + + diff --git a/docs/SuggestedMemberView.md b/docs/SuggestedMemberView.md new file mode 100644 index 00000000..43169cc9 --- /dev/null +++ b/docs/SuggestedMemberView.md @@ -0,0 +1,45 @@ + + +# SuggestedMemberView + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**bitOffset** | **Long** | Bit offset within the containing word for a bitfield member. | | +|**byteOffset** | **Long** | Offset within the type. Null when no placement could be established. | | +|**byteSize** | **Long** | Width of the access in bytes. | | +|**confidence** | [**ConfidenceEnum**](#ConfidenceEnum) | Where suggested_type came from. declared and inferred were observed; width knows only the access width; model is the language model's proposal. | | +|**name** | **String** | Name the member renders as: a database or frozen name where one exists, else the suggested one. | | +|**origin** | **String** | Which function revealed this member: self, caller:<function_id> or callee:<function_id>. | | +|**packed** | **Boolean** | The member sits at an offset its own width does not divide. | | +|**placement** | [**PlacementEnum**](#PlacementEnum) | observed means the offset was read off an access; guessed means the model proposed it; unplaced means the member has no offset. | | +|**suggestedType** | **String** | Type expression for the member. | | +|**token** | **String** | Placeholder this member renders as in the tokenised source. Absent for a member no access in this function revealed. | [optional] | + + + +## Enum: ConfidenceEnum + +| Name | Value | +|---- | -----| +| DECLARED | "declared" | +| INFERRED | "inferred" | +| WIDTH | "width" | +| MODEL | "model" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: PlacementEnum + +| Name | Value | +|---- | -----| +| OBSERVED | "observed" | +| GUESSED | "guessed" | +| UNPLACED | "unplaced" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/SuggestedTypeView.md b/docs/SuggestedTypeView.md new file mode 100644 index 00000000..d83a0473 --- /dev/null +++ b/docs/SuggestedTypeView.md @@ -0,0 +1,20 @@ + + +# SuggestedTypeView + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**dataTypeId** | **Long** | Existing data type the members were accessed through. Null when nothing resolved to a row; never minted for a suggestion. | [optional] | +|**holes** | **List<SuggestedHole>** | Gaps between consecutive placed members, in offset order. | | +|**impliedSize** | **Long** | Highest byte_offset+byte_size across the members. A lower bound on the type's size, not its size. | [optional] | +|**key** | **String** | Identity of the suggestion: index:<data_type_id> where the access named a row, else token:<type_token>. | | +|**members** | **List<SuggestedMemberView>** | Members in offset order, unplaced ones last. | | +|**name** | **String** | Name the type renders as: a database or frozen name where one exists, else the suggested one. | | +|**typeToken** | **String** | Placeholder the type renders as, when it appears in this function's source. | [optional] | +|**underlyingType** | **String** | Set only for a type with no observed members, where the suggestion is a name and a scalar type rather than a layout. | [optional] | + + + diff --git a/docs/SummaryData.md b/docs/SummaryData.md index 5363dff7..be03c493 100644 --- a/docs/SummaryData.md +++ b/docs/SummaryData.md @@ -8,6 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**aiSummary** | **String** | Summary with code tags removed | | +|**predictedFunctionName** | **String** | Name the model proposes for this function, produced alongside the summary. | [optional] | |**summary** | **String** | Raw summary from the model | | |**taskStatus** | [**TaskStatusEnum**](#TaskStatusEnum) | Task status | | diff --git a/docs/SuspiciousString.md b/docs/SuspiciousString.md new file mode 100644 index 00000000..b387c6e5 --- /dev/null +++ b/docs/SuspiciousString.md @@ -0,0 +1,14 @@ + + +# SuspiciousString + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**value** | **String** | | | +|**subject** | [**Subject**](Subject.md) | | [optional] | + + + diff --git a/docs/SuspiciousStringEvidence.md b/docs/SuspiciousStringEvidence.md new file mode 100644 index 00000000..8f7cffc7 --- /dev/null +++ b/docs/SuspiciousStringEvidence.md @@ -0,0 +1,45 @@ + + +# SuspiciousStringEvidence + +Suspicious strings without demonstrated semantic use. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**evidenceKind** | [**EvidenceKindEnum**](#EvidenceKindEnum) | | [optional] | +|**kind** | [**KindEnum**](#KindEnum) | | [optional] | +|**effect** | **EvidenceEffect** | | | +|**strength** | [**StrengthEnum**](#StrengthEnum) | | [optional] | +|**strings** | [**List<SuspiciousString>**](SuspiciousString.md) | | | + + + +## Enum: EvidenceKindEnum + +| Name | Value | +|---- | -----| +| SUSPICIOUS_STRING | "suspicious_string" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: KindEnum + +| Name | Value | +|---- | -----| +| DETERMINISTIC_DERIVATION | "deterministic_derivation" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: StrengthEnum + +| Name | Value | +|---- | -----| +| INDIRECT | "indirect" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/Symbols.md b/docs/Symbols.md index aa0f0dc1..f11e174a 100644 --- a/docs/Symbols.md +++ b/docs/Symbols.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**baseAddress** | **BigInteger** | The starting address of the execution | | -|**functionBoundaries** | [**List<FunctionBoundary>**](FunctionBoundary.md) | List of user defined function boundaries | [optional] | +|**baseAddress** | **Long** | | | +|**functionBoundaries** | **List<FunctionBoundary>** | | [optional] | diff --git a/docs/Technique.md b/docs/Technique.md new file mode 100644 index 00000000..7891349e --- /dev/null +++ b/docs/Technique.md @@ -0,0 +1,22 @@ + + +# Technique + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**description** | **String** | How the technique appears in this binary | | +|**endAddr** | **String** | End address of the containing function, hex-encoded | | +|**functionAddr** | **String** | Address of the containing function, hex-encoded | | +|**functionId** | **Long** | ID of the containing function | | +|**functionName** | **String** | Name of the containing function | | +|**startAddr** | **String** | Start address of the containing function, hex-encoded | | +|**techniqueDescription** | **String** | Full ATT&CK description of the technique | | +|**techniqueId** | **String** | MITRE ATT&CK technique ID | | +|**techniqueName** | **String** | MITRE ATT&CK technique name | | +|**techniqueUrl** | **String** | Link to the technique in the ATT&CK catalogue | | + + + diff --git a/docs/ThreatReportResult.md b/docs/ThreatReportResult.md new file mode 100644 index 00000000..577202fe --- /dev/null +++ b/docs/ThreatReportResult.md @@ -0,0 +1,20 @@ + + +# ThreatReportResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**ioCs** | **List<IOC>** | Indicators of compromise found. An indicator whose source does not resolve to a function is still listed, without function details. | | +|**attackFlowSummary** | **String** | Markdown summary of the attack flow | | +|**executableTechniques** | **List<Technique>** | MITRE ATT&CK techniques found. A technique is listed only when both its function and its ATT&CK catalogue entry resolve. | | +|**numberOfAnalysedFunctions** | **Long** | Functions the agent analysed | | +|**softwareType** | **String** | Classification of the binary | | +|**summary** | **String** | Summary of the analysis findings | | +|**totalNumberOfFunctions** | **Long** | Functions identified in the binary | | +|**yaraRule** | **String** | YARA rule generated for the binary | | + + + diff --git a/docs/TokenisedData.md b/docs/TokenisedData.md index bbb67ca8..4556048e 100644 --- a/docs/TokenisedData.md +++ b/docs/TokenisedData.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**entities** | [**List<ResolvedEntity>**](ResolvedEntity.md) | One entry per token in the tokenised source, with the name it resolves to and its hover metadata. | [optional] | +|**entities** | **List<ResolvedEntity>** | One entry per token in the tokenised source, with the name it resolves to and its hover metadata. | [optional] | |**lineAttribution** | **Object** | | [optional] | |**predictedFunctionName** | **String** | Predicted function name from the AI model | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Task status | | diff --git a/docs/TriageFunction.md b/docs/TriageFunction.md new file mode 100644 index 00000000..b35fa508 --- /dev/null +++ b/docs/TriageFunction.md @@ -0,0 +1,17 @@ + + +# TriageFunction + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**address** | **Long** | Virtual address of the function | | +|**capabilities** | **List<String>** | Capability categories the function exhibits | | +|**id** | **Long** | ID of the function | | +|**score** | **Double** | Maliciousness score for the function, 0 to 1 | | +|**summary** | **String** | What the function does | | + + + diff --git a/docs/TriageResult.md b/docs/TriageResult.md new file mode 100644 index 00000000..d8c9b189 --- /dev/null +++ b/docs/TriageResult.md @@ -0,0 +1,15 @@ + + +# TriageResult + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**functions** | **List<TriageFunction>** | Per-function assessments. A function whose address no longer resolves within the analysis is omitted. | | +|**softwareScore** | **Double** | Maliciousness score for the binary, 0 to 1 | | +|**summary** | **String** | Summary of the triage assessment | | + + + diff --git a/docs/TriggerCryptoScanInputBody.md b/docs/TriggerCryptoScanInputBody.md new file mode 100644 index 00000000..bf947dc9 --- /dev/null +++ b/docs/TriggerCryptoScanInputBody.md @@ -0,0 +1,47 @@ + + +# TriggerCryptoScanInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Restrict findings to these categories. Omit to scan every category. | [optional] | +|**directOnly** | **Boolean** | Only report functions whose own name matches a known crypto API; skips the calls-into-crypto pass, avoiding a bulk call-graph fetch. | [optional] | +|**libraries** | [**List<LibrariesEnum>**](#List<LibrariesEnum>) | Restrict findings to these libraries. Omit to scan every library. | [optional] | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| SYMMETRIC | "symmetric" | +| ASYMMETRIC | "asymmetric" | +| HASHING | "hashing" | +| MAC | "mac" | +| KDF | "kdf" | +| RNG | "rng" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<LibrariesEnum> + +| Name | Value | +|---- | -----| +| OPENSSL | "openssl" | +| MBEDTLS | "mbedtls" | +| WOLFSSL | "wolfssl" | +| LIBSODIUM | "libsodium" | +| LIBGCRYPT | "libgcrypt" | +| WINDOWS_CRYPTO_API | "windows_crypto_api" | +| CRYPTOPP | "cryptopp" | +| CPP_CRYPTO | "cpp-crypto" | +| GENERIC | "generic" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TriggerExecutionExplainInputBody.md b/docs/TriggerExecutionExplainInputBody.md new file mode 100644 index 00000000..9e9d6f74 --- /dev/null +++ b/docs/TriggerExecutionExplainInputBody.md @@ -0,0 +1,31 @@ + + +# TriggerExecutionExplainInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**category** | [**CategoryEnum**](#CategoryEnum) | Execution category to focus the explanation on. | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| DYNAMIC_RESOLVE | "dynamic-resolve" | +| HOOKING | "hooking" | +| INJECTION | "injection" | +| MEMORY_EXEC | "memory-exec" | +| MODULE_LOAD | "module-load" | +| PROCESS_CONTROL | "process-control" | +| PROCESS_CREATE | "process-create" | +| SCRIPT_EXEC | "script-exec" | +| SHELLCODE | "shellcode" | +| THREAD_CREATE | "thread-create" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TriggerExecutionScanInputBody.md b/docs/TriggerExecutionScanInputBody.md new file mode 100644 index 00000000..ea97a81e --- /dev/null +++ b/docs/TriggerExecutionScanInputBody.md @@ -0,0 +1,49 @@ + + +# TriggerExecutionScanInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Restrict findings to these categories. Omit to scan the default executes-code set. | [optional] | +|**directOnly** | **Boolean** | Only report functions whose own name matches a known execution API; skips the calls-into-execution pass, avoiding a bulk call-graph fetch. | [optional] | +|**sources** | [**List<SourcesEnum>**](#List<SourcesEnum>) | Restrict findings to these sources. Omit to scan every source. | [optional] | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| DYNAMIC_RESOLVE | "dynamic-resolve" | +| HOOKING | "hooking" | +| INJECTION | "injection" | +| MEMORY_EXEC | "memory-exec" | +| MODULE_LOAD | "module-load" | +| PROCESS_CONTROL | "process-control" | +| PROCESS_CREATE | "process-create" | +| SCRIPT_EXEC | "script-exec" | +| SHELLCODE | "shellcode" | +| THREAD_CREATE | "thread-create" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<SourcesEnum> + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| SCRIPT_ENGINE | "script-engine" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TriggerFilesystemAnalyseInputBody.md b/docs/TriggerFilesystemAnalyseInputBody.md new file mode 100644 index 00000000..bd787f4e --- /dev/null +++ b/docs/TriggerFilesystemAnalyseInputBody.md @@ -0,0 +1,37 @@ + + +# TriggerFilesystemAnalyseInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**category** | [**CategoryEnum**](#CategoryEnum) | Filesystem category to focus the explanation on. | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| DIR_READ | "dir-read" | +| DIR_WRITE | "dir-write" | +| ENVIRONMENT | "environment" | +| FILE_DELETE | "file-delete" | +| FILE_OPEN | "file-open" | +| FILE_PERMS | "file-perms" | +| FILE_READ | "file-read" | +| FILE_STAT | "file-stat" | +| FILE_WRITE | "file-write" | +| MODULE | "module" | +| PATH_WRITE | "path-write" | +| PROCESS | "process" | +| REGISTRY_READ | "registry-read" | +| REGISTRY_WRITE | "registry-write" | +| SERVICE | "service" | +| SYSTEM | "system" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TriggerFilesystemScanInputBody.md b/docs/TriggerFilesystemScanInputBody.md new file mode 100644 index 00000000..02f19e8c --- /dev/null +++ b/docs/TriggerFilesystemScanInputBody.md @@ -0,0 +1,54 @@ + + +# TriggerFilesystemScanInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Restrict findings to these categories. Omit to scan the default filesystem-modifying set. | [optional] | +|**directOnly** | **Boolean** | Only report functions whose own name matches a known filesystem API; skips the calls-into-filesystem pass, avoiding a bulk call-graph fetch. | [optional] | +|**sources** | [**List<SourcesEnum>**](#List<SourcesEnum>) | Restrict findings to these sources. Omit to scan every source. | [optional] | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| DIR_READ | "dir-read" | +| DIR_WRITE | "dir-write" | +| ENVIRONMENT | "environment" | +| FILE_DELETE | "file-delete" | +| FILE_OPEN | "file-open" | +| FILE_PERMS | "file-perms" | +| FILE_READ | "file-read" | +| FILE_STAT | "file-stat" | +| FILE_WRITE | "file-write" | +| MODULE | "module" | +| PATH_WRITE | "path-write" | +| PROCESS | "process" | +| REGISTRY_READ | "registry-read" | +| REGISTRY_WRITE | "registry-write" | +| SERVICE | "service" | +| SYSTEM | "system" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<SourcesEnum> + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CPP_STDLIB | "cpp-stdlib" | +| GENERIC | "generic" | +| LIBC | "libc" | +| QT | "qt" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TriggerNetworkingExplainInputBody.md b/docs/TriggerNetworkingExplainInputBody.md new file mode 100644 index 00000000..2ec7e853 --- /dev/null +++ b/docs/TriggerNetworkingExplainInputBody.md @@ -0,0 +1,33 @@ + + +# TriggerNetworkingExplainInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**category** | [**CategoryEnum**](#CategoryEnum) | Networking category to focus the explanation on. | | + + + +## Enum: CategoryEnum + +| Name | Value | +|---- | -----| +| ACCEPT | "accept" | +| ADDRESS | "address" | +| CONNECT | "connect" | +| DNS | "dns" | +| HTTP | "http" | +| NETINFO | "netinfo" | +| RAW_PACKET | "raw-packet" | +| RECV | "recv" | +| SEND | "send" | +| SOCKET | "socket" | +| TLS | "tls" | +| URL | "url" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TriggerNetworkingScanInputBody.md b/docs/TriggerNetworkingScanInputBody.md new file mode 100644 index 00000000..afb70b56 --- /dev/null +++ b/docs/TriggerNetworkingScanInputBody.md @@ -0,0 +1,53 @@ + + +# TriggerNetworkingScanInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**categories** | [**List<CategoriesEnum>**](#List<CategoriesEnum>) | Restrict findings to these categories. Omit to scan the default remote-communication set. | [optional] | +|**directOnly** | **Boolean** | Only report functions whose own name matches a known networking API; skips the calls-into-networking pass, avoiding a bulk call-graph fetch. | [optional] | +|**sources** | [**List<SourcesEnum>**](#List<SourcesEnum>) | Restrict findings to these sources. Omit to scan every source. | [optional] | + + + +## Enum: List<CategoriesEnum> + +| Name | Value | +|---- | -----| +| ACCEPT | "accept" | +| ADDRESS | "address" | +| CONNECT | "connect" | +| DNS | "dns" | +| HTTP | "http" | +| NETINFO | "netinfo" | +| RAW_PACKET | "raw-packet" | +| RECV | "recv" | +| SEND | "send" | +| SOCKET | "socket" | +| TLS | "tls" | +| URL | "url" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + +## Enum: List<SourcesEnum> + +| Name | Value | +|---- | -----| +| BOOST | "boost" | +| CPP | "cpp" | +| CURL | "curl" | +| GENERIC | "generic" | +| LIBC | "libc" | +| PCAP | "pcap" | +| POCO | "poco" | +| QT | "qt" | +| TLS | "tls" | +| WINDOWS | "windows" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TriggerSecurityScanInputBody.md b/docs/TriggerSecurityScanInputBody.md new file mode 100644 index 00000000..4b555068 --- /dev/null +++ b/docs/TriggerSecurityScanInputBody.md @@ -0,0 +1,13 @@ + + +# TriggerSecurityScanInputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**maxFunctionsToScan** | **Long** | Stop after decompiling and scanning this many functions. Omit to process every function in the analysis. | [optional] | + + + diff --git a/docs/TypeSuggestionsData.md b/docs/TypeSuggestionsData.md new file mode 100644 index 00000000..229936c2 --- /dev/null +++ b/docs/TypeSuggestionsData.md @@ -0,0 +1,28 @@ + + +# TypeSuggestionsData + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**model** | **String** | Language model that produced the suggestions. | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Status of the AI decompilation run that would have produced these suggestions. | | +|**types** | **List<SuggestedTypeView>** | One entry per suggested type. Empty for a run that produced none, and for a run that predates type suggestion — the two are not distinguished. | | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| UNINITIALISED | "UNINITIALISED" | +| PENDING | "PENDING" | +| RUNNING | "RUNNING" | +| COMPLETED | "COMPLETED" | +| FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/TypedefDataType.md b/docs/TypedefDataType.md index c5e6175b..fa65f0a8 100644 --- a/docs/TypedefDataType.md +++ b/docs/TypedefDataType.md @@ -9,12 +9,13 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**TypedefDefinition**](TypedefDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **TypedefDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/TypesSuggestedEvent.md b/docs/TypesSuggestedEvent.md new file mode 100644 index 00000000..7bbc3790 --- /dev/null +++ b/docs/TypesSuggestedEvent.md @@ -0,0 +1,17 @@ + + +# TypesSuggestedEvent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**attempt** | **Integer** | | | +|**members** | **Integer** | | | +|**seq** | **Integer** | | | +|**type** | **String** | | | +|**types** | **Integer** | | | + + + diff --git a/docs/UnionDataType.md b/docs/UnionDataType.md index 92cb5c64..8c7519e2 100644 --- a/docs/UnionDataType.md +++ b/docs/UnionDataType.md @@ -9,12 +9,13 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | When this type was extracted. | | |**dataTypeId** | **Long** | Identifies the type within its analysis. 0 is a valid id. | | -|**definition** | [**UnionDefinition**](UnionDefinition.md) | Absent only for a type referenced but never defined. | [optional] | +|**definition** | **UnionDefinition** | Absent only for a type referenced but never defined. | [optional] | |**hasDefinition** | **Boolean** | Whether this type carries a definition. False for the kinds that never have one and for a type referenced but never defined. | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/UnionDefinition.md b/docs/UnionDefinition.md index 580ec163..eec426b9 100644 --- a/docs/UnionDefinition.md +++ b/docs/UnionDefinition.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**members** | [**List<DataTypeMemberEntry>**](DataTypeMemberEntry.md) | The type's fields. Every member starts at offset 0. | | +|**members** | **List<DataTypeMemberEntry>** | The type's fields. Every member starts at offset 0. | | diff --git a/docs/UnknownDataType.md b/docs/UnknownDataType.md index cbc7e94e..e055033a 100644 --- a/docs/UnknownDataType.md +++ b/docs/UnknownDataType.md @@ -14,6 +14,7 @@ |**name** | **String** | Type name. | | |**namespace** | **String** | The scope qualifying the type name. Empty for a program-defined type. | | |**size** | **Long** | Size in bytes, absent when it could not be determined. | [optional] | +|**sourceAnalysisId** | **Long** | ID of the analysis the source function belongs to, when it could be resolved. | [optional] | |**sourceFunctionId** | **Long** | The function this type was copied from, when transferred rather than extracted. | [optional] | |**sourceType** | [**SourceTypeEnum**](#SourceTypeEnum) | Where this type came from. | | diff --git a/docs/UpdateArrayDataType.md b/docs/UpdateArrayDataType.md index 68d342bd..5815f3c4 100644 --- a/docs/UpdateArrayDataType.md +++ b/docs/UpdateArrayDataType.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**ArrayDefinition**](ArrayDefinition.md) | | | +|**definition** | **ArrayDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpdateDataTypeEntry.md b/docs/UpdateDataTypeEntry.md index 8d20b68b..0fb4da11 100644 --- a/docs/UpdateDataTypeEntry.md +++ b/docs/UpdateDataTypeEntry.md @@ -9,7 +9,7 @@ A replacement for the data type named by `data_type_id`. `kind` selects the vari | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**FunctionTypeDefinition**](FunctionTypeDefinition.md) | | | +|**definition** | **FunctionTypeDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpdateEnumDataType.md b/docs/UpdateEnumDataType.md index 3c673f3f..4edb3f86 100644 --- a/docs/UpdateEnumDataType.md +++ b/docs/UpdateEnumDataType.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**EnumDefinition**](EnumDefinition.md) | | | +|**definition** | **EnumDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpdateFunctionDataType.md b/docs/UpdateFunctionDataType.md index e065906d..290ceb49 100644 --- a/docs/UpdateFunctionDataType.md +++ b/docs/UpdateFunctionDataType.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**FunctionTypeDefinition**](FunctionTypeDefinition.md) | | | +|**definition** | **FunctionTypeDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpdateFunctionSignatureInputBody.md b/docs/UpdateFunctionSignatureInputBody.md index 1b280a63..a2035c22 100644 --- a/docs/UpdateFunctionSignatureInputBody.md +++ b/docs/UpdateFunctionSignatureInputBody.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**callingConvention** | **String** | Calling convention. Omit when there is none to record. | [optional] | -|**parameters** | [**List<SignatureParameterInput>**](SignatureParameterInput.md) | Parameters in argument order. An empty list records a function that takes no arguments. | | +|**parameters** | **List<SignatureParameterInput>** | Parameters in argument order. An empty list records a function that takes no arguments. | | |**returnDataTypeId** | **Long** | Return type, which must belong to this analysis. Omit for an unresolved return type. | [optional] | diff --git a/docs/UpdatePointerDataType.md b/docs/UpdatePointerDataType.md index 64778e4b..6ca34a24 100644 --- a/docs/UpdatePointerDataType.md +++ b/docs/UpdatePointerDataType.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**PointerDefinition**](PointerDefinition.md) | | | +|**definition** | **PointerDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpdateStructDataType.md b/docs/UpdateStructDataType.md index ed854311..b4ef1d28 100644 --- a/docs/UpdateStructDataType.md +++ b/docs/UpdateStructDataType.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**StructDefinition**](StructDefinition.md) | | | +|**definition** | **StructDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpdateTypedefDataType.md b/docs/UpdateTypedefDataType.md index a3037331..c6381e55 100644 --- a/docs/UpdateTypedefDataType.md +++ b/docs/UpdateTypedefDataType.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**TypedefDefinition**](TypedefDefinition.md) | | | +|**definition** | **TypedefDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpdateUnionDataType.md b/docs/UpdateUnionDataType.md index 32691b53..633513e4 100644 --- a/docs/UpdateUnionDataType.md +++ b/docs/UpdateUnionDataType.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**dataTypeId** | **Long** | The type to replace, as returned by the data types list for this analysis. | | -|**definition** | [**UnionDefinition**](UnionDefinition.md) | | | +|**definition** | **UnionDefinition** | | | |**kind** | [**KindEnum**](#KindEnum) | | | |**name** | **String** | Type name. Unique within the analysis for a given namespace and kind. | | |**namespace** | **String** | The scope qualifying the type name. Omit for a type of the binary's own. | [optional] | diff --git a/docs/UpgradeAnalysisModelOutputBody.md b/docs/UpgradeAnalysisModelOutputBody.md new file mode 100644 index 00000000..933ff475 --- /dev/null +++ b/docs/UpgradeAnalysisModelOutputBody.md @@ -0,0 +1,15 @@ + + +# UpgradeAnalysisModelOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisId** | **Long** | ID of the re-queued analysis. Unchanged — the upgrade moves the existing analysis rather than creating a new one. | | +|**binaryId** | **Long** | ID of the binary the analysis belongs to | | +|**modelId** | **Long** | Model the analysis is now queued against | | + + + diff --git a/docs/UploadOutputBody.md b/docs/UploadOutputBody.md new file mode 100644 index 00000000..9628f65e --- /dev/null +++ b/docs/UploadOutputBody.md @@ -0,0 +1,32 @@ + + +# UploadOutputBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisRequirements** | **List<AnalysisRequirement>** | Ways to unblock POST /v3/analyses for this file if it cannot be statically analysed as-is; empty if no requirement applies. | | +|**canExtract** | **Boolean** | Whether the firmware/extraction flow can accept this file. | | +|**canSandbox** | **Boolean** | Whether the file can be extracted and run in the Windows sandbox. | | +|**fileType** | [**FileTypeEnum**](#FileTypeEnum) | The kind of file that was uploaded. | | +|**filename** | **String** | The filename as given by the caller. | | +|**isArchive** | **Boolean** | Whether the detected format is a container/compression archive. | | +|**mime** | **String** | The MIME type detected from the file's contents, independent of upload_file_type. | | +|**sha256Hash** | **String** | SHA-256 hash of the uploaded file; the storage key for every subsequent reference to it. | | + + + +## Enum: FileTypeEnum + +| Name | Value | +|---- | -----| +| BINARY | "BINARY" | +| DEBUG | "DEBUG" | +| PACKED | "PACKED" | +| FIRMWARE | "FIRMWARE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/UploadResponse.md b/docs/UploadResponse.md index 9acab807..7ca50b71 100644 --- a/docs/UploadResponse.md +++ b/docs/UploadResponse.md @@ -14,6 +14,7 @@ |**isArchive** | **Boolean** | | | |**canSandbox** | **Boolean** | | | |**canExtract** | **Boolean** | | | +|**analysisRequirements** | **List<AnalysisRequirement>** | | [optional] | diff --git a/docs/UpsertOverridesData.md b/docs/UpsertOverridesData.md index 25ac7ad6..9fbffb1c 100644 --- a/docs/UpsertOverridesData.md +++ b/docs/UpsertOverridesData.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**placeholderToUserOverride** | [**Map<String, Token>**](Token.md) | Every override on the function after applying this request, keyed by placeholder token. | | +|**placeholderToUserOverride** | **Map<String, Token>** | Every override on the function after applying this request, keyed by placeholder token. | | diff --git a/docs/UpsertOverridesInputBody.md b/docs/UpsertOverridesInputBody.md index 1249eb85..40d4be34 100644 --- a/docs/UpsertOverridesInputBody.md +++ b/docs/UpsertOverridesInputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**overrides** | [**Map<String, Token>**](Token.md) | Overrides keyed by placeholder token. An entry whose value is an empty string removes that override. | | +|**overrides** | **Map<String, Token>** | Overrides keyed by placeholder token. An entry whose value is an empty string removes that override. | | diff --git a/docs/User.md b/docs/User.md index cbb79146..a389d682 100644 --- a/docs/User.md +++ b/docs/User.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**createdAt** | **OffsetDateTime** | | | |**email** | **String** | | | -|**profile** | [**UserProfile**](UserProfile.md) | | | +|**profile** | **UserProfile** | | | |**role** | [**RoleEnum**](#RoleEnum) | | | |**tier** | [**TierEnum**](#TierEnum) | | [optional] | |**userId** | **Long** | | | diff --git a/docs/WorkflowProgress.md b/docs/WorkflowProgress.md index 9ace5cb4..f355bdf3 100644 --- a/docs/WorkflowProgress.md +++ b/docs/WorkflowProgress.md @@ -7,11 +7,16 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**messages** | [**List<ProgressMessage>**](ProgressMessage.md) | Log messages emitted during execution | | +|**messages** | **List<ProgressMessage>** | Log messages emitted during execution | | +|**percent** | **Long** | Overall completion as a percentage, weighted by step duration | | |**status** | [**StatusEnum**](#StatusEnum) | Current workflow status | | |**step** | **String** | Name of the current step | | |**stepIndex** | **Long** | Zero-based index of the current step | | +|**stepShare** | **Long** | Percentage points the current step contributes when it completes | | |**stepsTotal** | **Long** | Total number of steps in the workflow | | +|**subStep** | **String** | Phase within the current step, when the step reports one | [optional] | +|**subStepDone** | **Long** | Items completed in the current phase | [optional] | +|**subStepTotal** | **Long** | Items the current phase will process, 0 when unknown | [optional] | diff --git a/pom.xml b/pom.xml index 693e1d50..99d0cc66 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ sdk jar sdk - 4.4.0 + 4.51.0 https://github.com/RevEngAI/sdk-java Java SDK for the RevEng.AI API diff --git a/src/main/java/ai/reveng/api/AgentApi.java b/src/main/java/ai/reveng/api/AgentApi.java index 7b7d2214..1fd7f49d 100644 --- a/src/main/java/ai/reveng/api/AgentApi.java +++ b/src/main/java/ai/reveng/api/AgentApi.java @@ -29,16 +29,42 @@ import ai.reveng.model.APIError; import ai.reveng.model.BaseResponse; import ai.reveng.model.BaseResponseCapabilitiesAgentResponse; +import ai.reveng.model.BaseResponseProtocolsAgentResponse; import ai.reveng.model.BaseResponseQueuedWorkflowTaskResponse; import ai.reveng.model.BaseResponseRemediationAgentResponse; import ai.reveng.model.BaseResponseReportAnalysisResponse; +import ai.reveng.model.BaseResponseSecretsAgentResponse; import ai.reveng.model.BaseResponseTriageReportResponse; import ai.reveng.model.ErrorModel; +import ai.reveng.model.FeedbackOutputBody; +import ai.reveng.model.OperationCryptoExplainMetadataCryptoExplainResult; +import ai.reveng.model.OperationCryptoScanMetadataCryptoScanResult; +import ai.reveng.model.OperationExecutionExplainMetadataExecutionExplainResult; +import ai.reveng.model.OperationExecutionScanMetadataExecutionScanResult; +import ai.reveng.model.OperationFilesystemAnalyseMetadataFilesystemAnalyseResult; +import ai.reveng.model.OperationFilesystemScanMetadataFilesystemScanResult; +import ai.reveng.model.OperationMetadataCapabilitiesResult; +import ai.reveng.model.OperationMetadataRemediationResult; +import ai.reveng.model.OperationMetadataReportResult; +import ai.reveng.model.OperationMetadataThreatReportResult; +import ai.reveng.model.OperationMetadataTriageResult; +import ai.reveng.model.OperationNetworkingExplainMetadataNetworkingExplainResult; +import ai.reveng.model.OperationNetworkingScanMetadataNetworkingScanResult; +import ai.reveng.model.OperationSecurityScanMetadataSecurityScanResult; import ai.reveng.model.QueuedWorkflowTaskResponse; import ai.reveng.model.RenameUnnamedFunctionsResult; import ai.reveng.model.StatusBody; +import ai.reveng.model.SubmitFeedbackInputBody; import ai.reveng.model.TaskStatusResponse; +import ai.reveng.model.TriggerCryptoScanInputBody; +import ai.reveng.model.TriggerExecutionExplainInputBody; +import ai.reveng.model.TriggerExecutionScanInputBody; +import ai.reveng.model.TriggerFilesystemAnalyseInputBody; +import ai.reveng.model.TriggerFilesystemScanInputBody; +import ai.reveng.model.TriggerNetworkingExplainInputBody; +import ai.reveng.model.TriggerNetworkingScanInputBody; import ai.reveng.model.TriggerRenameUnnamedFunctionsInputBody; +import ai.reveng.model.TriggerSecurityScanInputBody; import java.lang.reflect.Type; import java.util.ArrayList; @@ -96,7 +122,9 @@ public void setCustomBaseUrl(String customBaseUrl) { 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -142,6 +170,7 @@ public okhttp3.Call checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabili return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set @@ -166,7 +195,9 @@ private okhttp3.Call checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabil 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public TaskStatusResponse checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { ApiResponse localVarResp = checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGetWithHttpInfo(analysisId); return localVarResp.getData(); @@ -185,7 +216,9 @@ public TaskStatusResponse checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCa 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public ApiResponse checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { okhttp3.Call localVarCall = checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGetValidateBeforeCall(analysisId, null); Type localVarReturnType = new TypeToken(){}.getType(); @@ -206,7 +239,9 @@ public ApiResponse checkCapabilitiesTaskStatusV2AnalysesAnal 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabilitiesStatusGetValidateBeforeCall(analysisId, _callback); @@ -215,7 +250,7 @@ public okhttp3.Call checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabili return localVarCall; } /** - * Build call for checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet + * Build call for checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -227,8 +262,10 @@ public okhttp3.Call checkCapabilitiesTaskStatusV2AnalysesAnalysisIdAgentCapabili 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -245,7 +282,7 @@ public okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediati Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/remediation/status" + String localVarPath = "/v2/analyses/{analysis_id}/agent/protocols/status" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -273,19 +310,20 @@ public okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediati return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet(Async)"); } - return checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetCall(analysisId, _callback); + return checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetCall(analysisId, _callback); } /** - * Check the status of a remediation analysis workflow + * Check the status of a protocols discovery workflow * * @param analysisId (required) * @return TaskStatusResponse @@ -297,14 +335,16 @@ private okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediat 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public TaskStatusResponse checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetWithHttpInfo(analysisId); + @Deprecated + public TaskStatusResponse checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Check the status of a remediation analysis workflow + * Check the status of a protocols discovery workflow * * @param analysisId (required) * @return ApiResponse<TaskStatusResponse> @@ -316,15 +356,17 @@ public TaskStatusResponse checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRem 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public ApiResponse checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetValidateBeforeCall(analysisId, null); + @Deprecated + public ApiResponse checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetValidateBeforeCall(analysisId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Check the status of a remediation analysis workflow (asynchronously) + * Check the status of a protocols discovery workflow (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -337,16 +379,18 @@ public ApiResponse checkRemediationTaskStatusV2AnalysesAnaly 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetValidateBeforeCall(analysisId, _callback); + okhttp3.Call localVarCall = checkProtocolsTaskStatusV2AnalysesAnalysisIdAgentProtocolsStatusGetValidateBeforeCall(analysisId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet + * Build call for checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -358,8 +402,10 @@ public okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediati 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -376,7 +422,7 @@ public okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReport Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/report-analysis/status" + String localVarPath = "/v2/analyses/{analysis_id}/agent/remediation/status" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -404,19 +450,20 @@ public okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReport return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(Async)"); } - return checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetCall(analysisId, _callback); + return checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetCall(analysisId, _callback); } /** - * Check the status of a report analysis workflow + * Check the status of a remediation analysis workflow * * @param analysisId (required) * @return TaskStatusResponse @@ -428,14 +475,16 @@ private okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentRepor 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public TaskStatusResponse checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetWithHttpInfo(analysisId); + @Deprecated + public TaskStatusResponse checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Check the status of a report analysis workflow + * Check the status of a remediation analysis workflow * * @param analysisId (required) * @return ApiResponse<TaskStatusResponse> @@ -447,15 +496,17 @@ public TaskStatusResponse checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgent 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public ApiResponse checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetValidateBeforeCall(analysisId, null); + @Deprecated + public ApiResponse checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetValidateBeforeCall(analysisId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Check the status of a report analysis workflow (asynchronously) + * Check the status of a remediation analysis workflow (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -468,16 +519,18 @@ public ApiResponse checkReportAnalysisTaskStatusV2AnalysesAn 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetValidateBeforeCall(analysisId, _callback); + okhttp3.Call localVarCall = checkRemediationTaskStatusV2AnalysesAnalysisIdAgentRemediationStatusGetValidateBeforeCall(analysisId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet + * Build call for checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -489,8 +542,10 @@ public okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReport 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -507,7 +562,7 @@ public okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGe Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/triage/status" + String localVarPath = "/v2/analyses/{analysis_id}/agent/report-analysis/status" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -535,19 +590,20 @@ public okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGe return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(Async)"); } - return checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetCall(analysisId, _callback); + return checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetCall(analysisId, _callback); } /** - * Check the status of a triage analysis workflow + * Check the status of a report analysis workflow * * @param analysisId (required) * @return TaskStatusResponse @@ -559,14 +615,16 @@ private okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusG 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public TaskStatusResponse checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetWithHttpInfo(analysisId); + @Deprecated + public TaskStatusResponse checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Check the status of a triage analysis workflow + * Check the status of a report analysis workflow * * @param analysisId (required) * @return ApiResponse<TaskStatusResponse> @@ -578,15 +636,17 @@ public TaskStatusResponse checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageSt 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public ApiResponse checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetValidateBeforeCall(analysisId, null); + @Deprecated + public ApiResponse checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetValidateBeforeCall(analysisId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Check the status of a triage analysis workflow (asynchronously) + * Check the status of a report analysis workflow (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -599,16 +659,18 @@ public ApiResponse checkTriageTaskStatusV2AnalysesAnalysisId 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetValidateBeforeCall(analysisId, _callback); + okhttp3.Call localVarCall = checkReportAnalysisTaskStatusV2AnalysesAnalysisIdAgentReportAnalysisStatusGetValidateBeforeCall(analysisId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost + * Build call for checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -617,11 +679,13 @@ public okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGe - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -638,7 +702,7 @@ public okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesP Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/capabilities" + String localVarPath = "/v2/analyses/{analysis_id}/agent/secrets/status" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -663,61 +727,66 @@ public okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesP } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet(Async)"); } - return createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostCall(analysisId, _callback); + return checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetCall(analysisId, _callback); } /** - * Queues a capabilities analysis workflow process + * Check the status of a secrets discovery workflow * * @param analysisId (required) - * @return BaseResponseQueuedWorkflowTaskResponse + * @return TaskStatusResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public BaseResponseQueuedWorkflowTaskResponse createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostWithHttpInfo(analysisId); + @Deprecated + public TaskStatusResponse checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Queues a capabilities analysis workflow process + * Check the status of a secrets discovery workflow * * @param analysisId (required) - * @return ApiResponse<BaseResponseQueuedWorkflowTaskResponse> + * @return ApiResponse<TaskStatusResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public ApiResponse createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + @Deprecated + public ApiResponse checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Queues a capabilities analysis workflow process (asynchronously) + * Check the status of a secrets discovery workflow (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -727,19 +796,21 @@ public ApiResponse createCapabilitiesTas - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = checkSecretsTaskStatusV2AnalysesAnalysisIdAgentSecretsStatusGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost + * Build call for checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -748,11 +819,13 @@ public okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesP - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -769,7 +842,7 @@ public okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPos Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/remediation" + String localVarPath = "/v2/analyses/{analysis_id}/agent/triage/status" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -794,61 +867,66 @@ public okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPos } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(Async)"); } - return createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostCall(analysisId, _callback); + return checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetCall(analysisId, _callback); } /** - * Queues a remediation analysis workflow process + * Check the status of a triage analysis workflow * * @param analysisId (required) - * @return BaseResponseQueuedWorkflowTaskResponse + * @return TaskStatusResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public BaseResponseQueuedWorkflowTaskResponse createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostWithHttpInfo(analysisId); + @Deprecated + public TaskStatusResponse checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Queues a remediation analysis workflow process + * Check the status of a triage analysis workflow * * @param analysisId (required) - * @return ApiResponse<BaseResponseQueuedWorkflowTaskResponse> + * @return ApiResponse<TaskStatusResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public ApiResponse createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + @Deprecated + public ApiResponse checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Queues a remediation analysis workflow process (asynchronously) + * Check the status of a triage analysis workflow (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -858,19 +936,21 @@ public ApiResponse createRemediationTask - +
Response Details
Status Code Description Response Headers
202 Successful Response -
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = checkTriageTaskStatusV2AnalysesAnalysisIdAgentTriageStatusGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost + * Build call for createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -881,10 +961,11 @@ public okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPos Status Code Description Response Headers 202 Successful Response - 422 Invalid request parameters - - 409 Task already completed or queued - + * @deprecated */ - public okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -901,7 +982,7 @@ public okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnaly Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/report-analysis" + String localVarPath = "/v2/analyses/{analysis_id}/agent/capabilities" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -929,22 +1010,23 @@ public okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnaly return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(Async)"); } - return createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostCall(analysisId, _callback); + return createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostCall(analysisId, _callback); } /** - * Queues a combined report analysis workflow process + * Queues a capabilities analysis workflow process * * @param analysisId (required) - * @return QueuedWorkflowTaskResponse + * @return BaseResponseQueuedWorkflowTaskResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -952,19 +1034,20 @@ private okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnal -
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
409 Task already completed or queued -
+ * @deprecated */ - public QueuedWorkflowTaskResponse createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostWithHttpInfo(analysisId); + @Deprecated + public BaseResponseQueuedWorkflowTaskResponse createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Queues a combined report analysis workflow process + * Queues a capabilities analysis workflow process * * @param analysisId (required) - * @return ApiResponse<QueuedWorkflowTaskResponse> + * @return ApiResponse<BaseResponseQueuedWorkflowTaskResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -972,17 +1055,18 @@ public QueuedWorkflowTaskResponse createReportAnalysisTaskV2AnalysesAnalysisIdAg -
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
409 Task already completed or queued -
+ * @deprecated */ - public ApiResponse createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + @Deprecated + public ApiResponse createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Queues a combined report analysis workflow process (asynchronously) + * Queues a capabilities analysis workflow process (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -994,18 +1078,19 @@ public ApiResponse createReportAnalysisTaskV2Analyse Status Code Description Response Headers 202 Successful Response - 422 Invalid request parameters - - 409 Task already completed or queued - + * @deprecated */ - public okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = createCapabilitiesTaskV2AnalysesAnalysisIdAgentCapabilitiesPostValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for createTriageTaskV2AnalysesAnalysisIdAgentTriagePost + * Build call for createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -1017,8 +1102,10 @@ public okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnaly 202 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1035,7 +1122,7 @@ public okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostCall(@jav Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/triage" + String localVarPath = "/v2/analyses/{analysis_id}/agent/protocols" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1063,19 +1150,20 @@ public okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostCall(@jav return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost(Async)"); } - return createTriageTaskV2AnalysesAnalysisIdAgentTriagePostCall(analysisId, _callback); + return createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostCall(analysisId, _callback); } /** - * Queues a triage analysis workflow process + * Queues a protocols discovery workflow process * * @param analysisId (required) * @return BaseResponseQueuedWorkflowTaskResponse @@ -1087,14 +1175,16 @@ private okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostValidate 202 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public BaseResponseQueuedWorkflowTaskResponse createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = createTriageTaskV2AnalysesAnalysisIdAgentTriagePostWithHttpInfo(analysisId); + @Deprecated + public BaseResponseQueuedWorkflowTaskResponse createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Queues a triage analysis workflow process + * Queues a protocols discovery workflow process * * @param analysisId (required) * @return ApiResponse<BaseResponseQueuedWorkflowTaskResponse> @@ -1106,15 +1196,17 @@ public BaseResponseQueuedWorkflowTaskResponse createTriageTaskV2AnalysesAnalysis 202 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public ApiResponse createTriageTaskV2AnalysesAnalysisIdAgentTriagePostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = createTriageTaskV2AnalysesAnalysisIdAgentTriagePostValidateBeforeCall(analysisId, null); + @Deprecated + public ApiResponse createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostValidateBeforeCall(analysisId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Queues a triage analysis workflow process (asynchronously) + * Queues a protocols discovery workflow process (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -1127,16 +1219,18 @@ public ApiResponse createTriageTaskV2Ana 202 Successful Response - 422 Invalid request parameters - + * @deprecated */ - public okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createTriageTaskV2AnalysesAnalysisIdAgentTriagePostValidateBeforeCall(analysisId, _callback); + okhttp3.Call localVarCall = createProtocolsTaskV2AnalysesAnalysisIdAgentProtocolsPostValidateBeforeCall(analysisId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet + * Build call for createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -1145,11 +1239,13 @@ public okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostAsync(@ja - +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1166,7 +1262,7 @@ public okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGe Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/capabilities" + String localVarPath = "/v2/analyses/{analysis_id}/agent/remediation" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1191,61 +1287,66 @@ public okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGe } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(Async)"); } - return getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetCall(analysisId, _callback); + return createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostCall(analysisId, _callback); } /** - * Get Capabilities Result + * Queues a remediation analysis workflow process * * @param analysisId (required) - * @return BaseResponseCapabilitiesAgentResponse + * @return BaseResponseQueuedWorkflowTaskResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public BaseResponseCapabilitiesAgentResponse getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetWithHttpInfo(analysisId); + @Deprecated + public BaseResponseQueuedWorkflowTaskResponse createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Get Capabilities Result + * Queues a remediation analysis workflow process * * @param analysisId (required) - * @return ApiResponse<BaseResponseCapabilitiesAgentResponse> + * @return ApiResponse<BaseResponseQueuedWorkflowTaskResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public ApiResponse getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + @Deprecated + public ApiResponse createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get Capabilities Result (asynchronously) + * Queues a remediation analysis workflow process (asynchronously) * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes @@ -1255,19 +1356,21 @@ public ApiResponse getCapabilitiesResultV - +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = createRemediationTaskV2AnalysesAnalysisIdAgentRemediationPostValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet + * Build call for createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -1276,11 +1379,14 @@ public okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGe - + +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
409 Task already completed or queued -
+ * @deprecated */ - public okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1297,7 +1403,7 @@ public okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetC Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/remediation" + String localVarPath = "/v2/analyses/{analysis_id}/agent/report-analysis" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1322,62 +1428,69 @@ public okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetC } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(Async)"); } - return getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetCall(analysisId, _callback); + return createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostCall(analysisId, _callback); } /** - * Get Remediation Result - * Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules + * Queues a combined report analysis workflow process + * * @param analysisId (required) - * @return BaseResponseRemediationAgentResponse + * @return QueuedWorkflowTaskResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
409 Task already completed or queued -
+ * @deprecated */ - public BaseResponseRemediationAgentResponse getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetWithHttpInfo(analysisId); + @Deprecated + public QueuedWorkflowTaskResponse createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Get Remediation Result - * Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules + * Queues a combined report analysis workflow process + * * @param analysisId (required) - * @return ApiResponse<BaseResponseRemediationAgentResponse> + * @return ApiResponse<QueuedWorkflowTaskResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
409 Task already completed or queued -
+ * @deprecated */ - public ApiResponse getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + @Deprecated + public ApiResponse createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get Remediation Result (asynchronously) - * Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules + * Queues a combined report analysis workflow process (asynchronously) + * * @param analysisId (required) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -1386,19 +1499,22 @@ public ApiResponse getRemediationResultV2A - + +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
409 Task already completed or queued -
+ * @deprecated */ - public okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = createReportAnalysisTaskV2AnalysesAnalysisIdAgentReportAnalysisPostValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet + * Build call for createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost * @param analysisId (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -1407,11 +1523,13 @@ public okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetA - +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + @Deprecated + public okhttp3.Call createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1428,7 +1546,7 @@ public okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalys Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/report-analysis" + String localVarPath = "/v2/analyses/{analysis_id}/agent/secrets" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1453,63 +1571,5801 @@ public okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalys } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost(Async)"); } - return getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetCall(analysisId, _callback); + return createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostCall(analysisId, _callback); } /** - * Get Report Analysis Result - * Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule + * Queues a secrets discovery workflow process + * * @param analysisId (required) - * @return BaseResponseReportAnalysisResponse + * @return BaseResponseQueuedWorkflowTaskResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Response Details
Status Code Description Response Headers
200 Successful Response -
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated */ - public BaseResponseReportAnalysisResponse getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetWithHttpInfo(analysisId); + @Deprecated + public BaseResponseQueuedWorkflowTaskResponse createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Get Report Analysis Result - * Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule + * Queues a secrets discovery workflow process + * * @param analysisId (required) - * @return ApiResponse<BaseResponseReportAnalysisResponse> + * @return ApiResponse<BaseResponseQueuedWorkflowTaskResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Queues a secrets discovery workflow process (asynchronously) + * + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createSecretsTaskV2AnalysesAnalysisIdAgentSecretsPostValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for createTriageTaskV2AnalysesAnalysisIdAgentTriagePost + * @param analysisId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v2/analyses/{analysis_id}/agent/triage" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(Async)"); + } + + return createTriageTaskV2AnalysesAnalysisIdAgentTriagePostCall(analysisId, _callback); + + } + + /** + * Queues a triage analysis workflow process + * + * @param analysisId (required) + * @return BaseResponseQueuedWorkflowTaskResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public BaseResponseQueuedWorkflowTaskResponse createTriageTaskV2AnalysesAnalysisIdAgentTriagePost(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = createTriageTaskV2AnalysesAnalysisIdAgentTriagePostWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Queues a triage analysis workflow process + * + * @param analysisId (required) + * @return ApiResponse<BaseResponseQueuedWorkflowTaskResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse createTriageTaskV2AnalysesAnalysisIdAgentTriagePostWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = createTriageTaskV2AnalysesAnalysisIdAgentTriagePostValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Queues a triage analysis workflow process (asynchronously) + * + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call createTriageTaskV2AnalysesAnalysisIdAgentTriagePostAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createTriageTaskV2AnalysesAnalysisIdAgentTriagePostValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet + * @param analysisId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v2/analyses/{analysis_id}/agent/capabilities" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(Async)"); + } + + return getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetCall(analysisId, _callback); + + } + + /** + * Get Capabilities Result + * + * @param analysisId (required) + * @return BaseResponseCapabilitiesAgentResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public BaseResponseCapabilitiesAgentResponse getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get Capabilities Result + * + * @param analysisId (required) + * @return ApiResponse<BaseResponseCapabilitiesAgentResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Capabilities Result (asynchronously) + * + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getCapabilitiesResultV2AnalysesAnalysisIdAgentCapabilitiesGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet + * @param analysisId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v2/analyses/{analysis_id}/agent/protocols" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet(Async)"); + } + + return getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetCall(analysisId, _callback); + + } + + /** + * Get Protocols Result + * Returns the protocols report, including metadata, findings, and evidence. + * @param analysisId (required) + * @return BaseResponseProtocolsAgentResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public BaseResponseProtocolsAgentResponse getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get Protocols Result + * Returns the protocols report, including metadata, findings, and evidence. + * @param analysisId (required) + * @return ApiResponse<BaseResponseProtocolsAgentResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Protocols Result (asynchronously) + * Returns the protocols report, including metadata, findings, and evidence. + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getProtocolsResultV2AnalysesAnalysisIdAgentProtocolsGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet + * @param analysisId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v2/analyses/{analysis_id}/agent/remediation" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(Async)"); + } + + return getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetCall(analysisId, _callback); + + } + + /** + * Get Remediation Result + * Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules + * @param analysisId (required) + * @return BaseResponseRemediationAgentResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public BaseResponseRemediationAgentResponse getRemediationResultV2AnalysesAnalysisIdAgentRemediationGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get Remediation Result + * Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules + * @param analysisId (required) + * @return ApiResponse<BaseResponseRemediationAgentResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Remediation Result (asynchronously) + * Returns: - A list of generated YARA rules - A list of generated Snort rules - A list of generated STIX rules + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRemediationResultV2AnalysesAnalysisIdAgentRemediationGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet + * @param analysisId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v2/analyses/{analysis_id}/agent/report-analysis" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(Async)"); + } + + return getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetCall(analysisId, _callback); + + } + + /** + * Get Report Analysis Result + * Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule + * @param analysisId (required) + * @return BaseResponseReportAnalysisResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public BaseResponseReportAnalysisResponse getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get Report Analysis Result + * Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule + * @param analysisId (required) + * @return ApiResponse<BaseResponseReportAnalysisResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Report Analysis Result (asynchronously) + * Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet + * @param analysisId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v2/analyses/{analysis_id}/agent/secrets" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet(Async)"); + } + + return getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetCall(analysisId, _callback); + + } + + /** + * Get Secrets Result + * Returns the secrets report, including metadata, findings, and evidence. + * @param analysisId (required) + * @return BaseResponseSecretsAgentResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public BaseResponseSecretsAgentResponse getSecretsResultV2AnalysesAnalysisIdAgentSecretsGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get Secrets Result + * Returns the secrets report, including metadata, findings, and evidence. + * @param analysisId (required) + * @return ApiResponse<BaseResponseSecretsAgentResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Secrets Result (asynchronously) + * Returns the secrets report, including metadata, findings, and evidence. + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getSecretsResultV2AnalysesAnalysisIdAgentSecretsGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getTriageResultV2AnalysesAnalysisIdAgentTriageGet + * @param analysisId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v2/analyses/{analysis_id}/agent/triage" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling getTriageResultV2AnalysesAnalysisIdAgentTriageGet(Async)"); + } + + return getTriageResultV2AnalysesAnalysisIdAgentTriageGetCall(analysisId, _callback); + + } + + /** + * Get Triage Result + * + * @param analysisId (required) + * @return BaseResponseTriageReportResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public BaseResponseTriageReportResponse getTriageResultV2AnalysesAnalysisIdAgentTriageGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + ApiResponse localVarResp = getTriageResultV2AnalysesAnalysisIdAgentTriageGetWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get Triage Result + * + * @param analysisId (required) + * @return ApiResponse<BaseResponseTriageReportResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public ApiResponse getTriageResultV2AnalysesAnalysisIdAgentTriageGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { + okhttp3.Call localVarCall = getTriageResultV2AnalysesAnalysisIdAgentTriageGetValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Triage Result (asynchronously) + * + * @param analysisId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getTriageResultV2AnalysesAnalysisIdAgentTriageGetValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3CancelRenameUnnamedFunctions + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3CancelRenameUnnamedFunctionsCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions/cancel" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3CancelRenameUnnamedFunctionsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3CancelRenameUnnamedFunctions(Async)"); + } + + return v3CancelRenameUnnamedFunctionsCall(analysisId, _callback); + + } + + /** + * Cancel the rename-unnamed-functions agent. + * Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * @param analysisId Analysis ID (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public void v3CancelRenameUnnamedFunctions(@javax.annotation.Nonnull Long analysisId) throws ApiException { + v3CancelRenameUnnamedFunctionsWithHttpInfo(analysisId); + } + + /** + * Cancel the rename-unnamed-functions agent. + * Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * @param analysisId Analysis ID (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3CancelRenameUnnamedFunctionsWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3CancelRenameUnnamedFunctionsValidateBeforeCall(analysisId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Cancel the rename-unnamed-functions agent. (asynchronously) + * Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3CancelRenameUnnamedFunctionsAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3CancelRenameUnnamedFunctionsValidateBeforeCall(analysisId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for v3CancelSecurityScanOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3CancelSecurityScanOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/security-scan/{analysis_id}:cancel" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3CancelSecurityScanOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3CancelSecurityScanOperation(Async)"); + } + + return v3CancelSecurityScanOperationCall(analysisId, _callback); + + } + + /** + * Cancel a security-scan operation. + * Requests cancellation of the currently running security-scan run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * @param analysisId Analysis ID (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public void v3CancelSecurityScanOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + v3CancelSecurityScanOperationWithHttpInfo(analysisId); + } + + /** + * Cancel a security-scan operation. + * Requests cancellation of the currently running security-scan run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * @param analysisId Analysis ID (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3CancelSecurityScanOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3CancelSecurityScanOperationValidateBeforeCall(analysisId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Cancel a security-scan operation. (asynchronously) + * Requests cancellation of the currently running security-scan run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3CancelSecurityScanOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3CancelSecurityScanOperationValidateBeforeCall(analysisId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for v3GetBinaryAgentFeedback + * @param analysisId Analysis ID (required) + * @param agent Which agent's output the feedback is about (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryAgentFeedbackCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/agents/{agent}/feedback" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())) + .replace("{" + "agent" + "}", localVarApiClient.escapeString(agent.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetBinaryAgentFeedbackValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetBinaryAgentFeedback(Async)"); + } + + // verify the required parameter 'agent' is set + if (agent == null) { + throw new ApiException("Missing the required parameter 'agent' when calling v3GetBinaryAgentFeedback(Async)"); + } + + return v3GetBinaryAgentFeedbackCall(analysisId, agent, _callback); + + } + + /** + * Get the caller's feedback on an agent's output. + * Returns the sentiment the caller recorded for one agent on this analysis, or a null sentiment when they have not recorded any. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param agent Which agent's output the feedback is about (required) + * @return FeedbackOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public FeedbackOutputBody v3GetBinaryAgentFeedback(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent) throws ApiException { + ApiResponse localVarResp = v3GetBinaryAgentFeedbackWithHttpInfo(analysisId, agent); + return localVarResp.getData(); + } + + /** + * Get the caller's feedback on an agent's output. + * Returns the sentiment the caller recorded for one agent on this analysis, or a null sentiment when they have not recorded any. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param agent Which agent's output the feedback is about (required) + * @return ApiResponse<FeedbackOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetBinaryAgentFeedbackWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent) throws ApiException { + okhttp3.Call localVarCall = v3GetBinaryAgentFeedbackValidateBeforeCall(analysisId, agent, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get the caller's feedback on an agent's output. (asynchronously) + * Returns the sentiment the caller recorded for one agent on this analysis, or a null sentiment when they have not recorded any. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param agent Which agent's output the feedback is about (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryAgentFeedbackAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetBinaryAgentFeedbackValidateBeforeCall(analysisId, agent, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetCapabilitiesOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetCapabilitiesOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/capabilities/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetCapabilitiesOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetCapabilitiesOperation(Async)"); + } + + return v3GetCapabilitiesOperationCall(analysisId, _callback); + + } + + /** + * Get a capabilities operation. + * Polls a capabilities run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return OperationMetadataCapabilitiesResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataCapabilitiesResult v3GetCapabilitiesOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetCapabilitiesOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a capabilities operation. + * Polls a capabilities run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataCapabilitiesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetCapabilitiesOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetCapabilitiesOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a capabilities operation. (asynchronously) + * Polls a capabilities run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetCapabilitiesOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetCapabilitiesOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetCryptoExplainOperation + * @param functionId Function ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetCryptoExplainOperationCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/crypto-explain/{function_id}" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetCryptoExplainOperationValidateBeforeCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3GetCryptoExplainOperation(Async)"); + } + + return v3GetCryptoExplainOperationCall(functionId, _callback); + + } + + /** + * Get a crypto-explain operation. + * Returns the current state of the crypto-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return OperationCryptoExplainMetadataCryptoExplainResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationCryptoExplainMetadataCryptoExplainResult v3GetCryptoExplainOperation(@javax.annotation.Nonnull Long functionId) throws ApiException { + ApiResponse localVarResp = v3GetCryptoExplainOperationWithHttpInfo(functionId); + return localVarResp.getData(); + } + + /** + * Get a crypto-explain operation. + * Returns the current state of the crypto-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return ApiResponse<OperationCryptoExplainMetadataCryptoExplainResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetCryptoExplainOperationWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { + okhttp3.Call localVarCall = v3GetCryptoExplainOperationValidateBeforeCall(functionId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a crypto-explain operation. (asynchronously) + * Returns the current state of the crypto-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetCryptoExplainOperationAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetCryptoExplainOperationValidateBeforeCall(functionId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetCryptoScanOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetCryptoScanOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/crypto-scan/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetCryptoScanOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetCryptoScanOperation(Async)"); + } + + return v3GetCryptoScanOperationCall(analysisId, _callback); + + } + + /** + * Get a crypto-scan operation. + * Returns the current state of the crypto-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return OperationCryptoScanMetadataCryptoScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationCryptoScanMetadataCryptoScanResult v3GetCryptoScanOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetCryptoScanOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a crypto-scan operation. + * Returns the current state of the crypto-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationCryptoScanMetadataCryptoScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetCryptoScanOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetCryptoScanOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a crypto-scan operation. (asynchronously) + * Returns the current state of the crypto-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetCryptoScanOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetCryptoScanOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetExecutionExplainOperation + * @param functionId Function ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetExecutionExplainOperationCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/execution-explain/{function_id}" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetExecutionExplainOperationValidateBeforeCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3GetExecutionExplainOperation(Async)"); + } + + return v3GetExecutionExplainOperationCall(functionId, _callback); + + } + + /** + * Get an execution-explain operation. + * Returns the current state of the execution-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return OperationExecutionExplainMetadataExecutionExplainResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationExecutionExplainMetadataExecutionExplainResult v3GetExecutionExplainOperation(@javax.annotation.Nonnull Long functionId) throws ApiException { + ApiResponse localVarResp = v3GetExecutionExplainOperationWithHttpInfo(functionId); + return localVarResp.getData(); + } + + /** + * Get an execution-explain operation. + * Returns the current state of the execution-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return ApiResponse<OperationExecutionExplainMetadataExecutionExplainResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetExecutionExplainOperationWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { + okhttp3.Call localVarCall = v3GetExecutionExplainOperationValidateBeforeCall(functionId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get an execution-explain operation. (asynchronously) + * Returns the current state of the execution-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetExecutionExplainOperationAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetExecutionExplainOperationValidateBeforeCall(functionId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetExecutionScanOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetExecutionScanOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/execution-scan/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetExecutionScanOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetExecutionScanOperation(Async)"); + } + + return v3GetExecutionScanOperationCall(analysisId, _callback); + + } + + /** + * Get an execution-scan operation. + * Returns the current state of the execution-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return OperationExecutionScanMetadataExecutionScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationExecutionScanMetadataExecutionScanResult v3GetExecutionScanOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetExecutionScanOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get an execution-scan operation. + * Returns the current state of the execution-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationExecutionScanMetadataExecutionScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetExecutionScanOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetExecutionScanOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get an execution-scan operation. (asynchronously) + * Returns the current state of the execution-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetExecutionScanOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetExecutionScanOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetFilesystemAnalyseOperation + * @param functionId Function ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetFilesystemAnalyseOperationCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/filesystem-analyse/{function_id}" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetFilesystemAnalyseOperationValidateBeforeCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3GetFilesystemAnalyseOperation(Async)"); + } + + return v3GetFilesystemAnalyseOperationCall(functionId, _callback); + + } + + /** + * Get a filesystem-analyse operation. + * Returns the current state of the filesystem-analyse run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return OperationFilesystemAnalyseMetadataFilesystemAnalyseResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult v3GetFilesystemAnalyseOperation(@javax.annotation.Nonnull Long functionId) throws ApiException { + ApiResponse localVarResp = v3GetFilesystemAnalyseOperationWithHttpInfo(functionId); + return localVarResp.getData(); + } + + /** + * Get a filesystem-analyse operation. + * Returns the current state of the filesystem-analyse run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return ApiResponse<OperationFilesystemAnalyseMetadataFilesystemAnalyseResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetFilesystemAnalyseOperationWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { + okhttp3.Call localVarCall = v3GetFilesystemAnalyseOperationValidateBeforeCall(functionId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a filesystem-analyse operation. (asynchronously) + * Returns the current state of the filesystem-analyse run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetFilesystemAnalyseOperationAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetFilesystemAnalyseOperationValidateBeforeCall(functionId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetFilesystemScanOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetFilesystemScanOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/filesystem-scan/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetFilesystemScanOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetFilesystemScanOperation(Async)"); + } + + return v3GetFilesystemScanOperationCall(analysisId, _callback); + + } + + /** + * Get a filesystem-scan operation. + * Returns the current state of the filesystem-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return OperationFilesystemScanMetadataFilesystemScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationFilesystemScanMetadataFilesystemScanResult v3GetFilesystemScanOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetFilesystemScanOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a filesystem-scan operation. + * Returns the current state of the filesystem-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationFilesystemScanMetadataFilesystemScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetFilesystemScanOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetFilesystemScanOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a filesystem-scan operation. (asynchronously) + * Returns the current state of the filesystem-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetFilesystemScanOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetFilesystemScanOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetNetworkingExplainOperation + * @param functionId Function ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetNetworkingExplainOperationCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/networking-explain/{function_id}" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetNetworkingExplainOperationValidateBeforeCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3GetNetworkingExplainOperation(Async)"); + } + + return v3GetNetworkingExplainOperationCall(functionId, _callback); + + } + + /** + * Get a networking-explain operation. + * Returns the current state of the networking-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return OperationNetworkingExplainMetadataNetworkingExplainResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationNetworkingExplainMetadataNetworkingExplainResult v3GetNetworkingExplainOperation(@javax.annotation.Nonnull Long functionId) throws ApiException { + ApiResponse localVarResp = v3GetNetworkingExplainOperationWithHttpInfo(functionId); + return localVarResp.getData(); + } + + /** + * Get a networking-explain operation. + * Returns the current state of the networking-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @return ApiResponse<OperationNetworkingExplainMetadataNetworkingExplainResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetNetworkingExplainOperationWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { + okhttp3.Call localVarCall = v3GetNetworkingExplainOperationValidateBeforeCall(functionId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a networking-explain operation. (asynchronously) + * Returns the current state of the networking-explain run for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param functionId Function ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetNetworkingExplainOperationAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetNetworkingExplainOperationValidateBeforeCall(functionId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetNetworkingScanOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetNetworkingScanOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/networking-scan/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetNetworkingScanOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetNetworkingScanOperation(Async)"); + } + + return v3GetNetworkingScanOperationCall(analysisId, _callback); + + } + + /** + * Get a networking-scan operation. + * Returns the current state of the networking-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return OperationNetworkingScanMetadataNetworkingScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationNetworkingScanMetadataNetworkingScanResult v3GetNetworkingScanOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetNetworkingScanOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a networking-scan operation. + * Returns the current state of the networking-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationNetworkingScanMetadataNetworkingScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetNetworkingScanOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetNetworkingScanOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a networking-scan operation. (asynchronously) + * Returns the current state of the networking-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetNetworkingScanOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetNetworkingScanOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetProtocolsOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetProtocolsOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/protocols/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetProtocolsOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetProtocolsOperation(Async)"); + } + + return v3GetProtocolsOperationCall(analysisId, _callback); + + } + + /** + * Get a protocols operation. + * Polls a protocols run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return OperationMetadataReportResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataReportResult v3GetProtocolsOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetProtocolsOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a protocols operation. + * Polls a protocols run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataReportResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetProtocolsOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetProtocolsOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a protocols operation. (asynchronously) + * Polls a protocols run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetProtocolsOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetProtocolsOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetRemediationOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetRemediationOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/remediation/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetRemediationOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetRemediationOperation(Async)"); + } + + return v3GetRemediationOperationCall(analysisId, _callback); + + } + + /** + * Get a remediation operation. + * Polls a remediation run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return OperationMetadataRemediationResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataRemediationResult v3GetRemediationOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetRemediationOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a remediation operation. + * Polls a remediation run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataRemediationResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetRemediationOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetRemediationOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a remediation operation. (asynchronously) + * Polls a remediation run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetRemediationOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetRemediationOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetRenameUnnamedFunctionsResult + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetRenameUnnamedFunctionsResultCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetRenameUnnamedFunctionsResultValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetRenameUnnamedFunctionsResult(Async)"); + } + + return v3GetRenameUnnamedFunctionsResultCall(analysisId, _callback); + + } + + /** + * Get rename-unnamed-functions agent result. + * Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return RenameUnnamedFunctionsResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public RenameUnnamedFunctionsResult v3GetRenameUnnamedFunctionsResult(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetRenameUnnamedFunctionsResultWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get rename-unnamed-functions agent result. + * Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return ApiResponse<RenameUnnamedFunctionsResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetRenameUnnamedFunctionsResultWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsResultValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get rename-unnamed-functions agent result. (asynchronously) + * Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetRenameUnnamedFunctionsResultAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsResultValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetRenameUnnamedFunctionsStatus + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetRenameUnnamedFunctionsStatusCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions/status" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetRenameUnnamedFunctionsStatusValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetRenameUnnamedFunctionsStatus(Async)"); + } + + return v3GetRenameUnnamedFunctionsStatusCall(analysisId, _callback); + + } + + /** + * Get rename-unnamed-functions agent status. + * Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return StatusBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public StatusBody v3GetRenameUnnamedFunctionsStatus(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetRenameUnnamedFunctionsStatusWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get rename-unnamed-functions agent status. + * Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<StatusBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetRenameUnnamedFunctionsStatusWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsStatusValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get rename-unnamed-functions agent status. (asynchronously) + * Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetRenameUnnamedFunctionsStatusAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsStatusValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetReportAnalysisOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetReportAnalysisOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/report-analysis/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetReportAnalysisOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetReportAnalysisOperation(Async)"); + } + + return v3GetReportAnalysisOperationCall(analysisId, _callback); + + } + + /** + * Get a report-analysis operation. + * Polls a report-analysis run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return OperationMetadataThreatReportResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataThreatReportResult v3GetReportAnalysisOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetReportAnalysisOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a report-analysis operation. + * Polls a report-analysis run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataThreatReportResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetReportAnalysisOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetReportAnalysisOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a report-analysis operation. (asynchronously) + * Polls a report-analysis run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetReportAnalysisOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetReportAnalysisOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetSecretsOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetSecretsOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/secrets/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetSecretsOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetSecretsOperation(Async)"); + } + + return v3GetSecretsOperationCall(analysisId, _callback); + + } + + /** + * Get a secrets operation. + * Polls a secrets run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return OperationMetadataReportResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataReportResult v3GetSecretsOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetSecretsOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a secrets operation. + * Polls a secrets run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataReportResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetSecretsOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetSecretsOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a secrets operation. (asynchronously) + * Polls a secrets run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response.report` is set once the run has completed and carries the findings document as the agent produced it. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetSecretsOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetSecretsOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetSecurityScanOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetSecurityScanOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/security-scan/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetSecurityScanOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetSecurityScanOperation(Async)"); + } + + return v3GetSecurityScanOperationCall(analysisId, _callback); + + } + + /** + * Get a security-scan operation. + * Returns the current state of the security-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return OperationSecurityScanMetadataSecurityScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationSecurityScanMetadataSecurityScanResult v3GetSecurityScanOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetSecurityScanOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a security-scan operation. + * Returns the current state of the security-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationSecurityScanMetadataSecurityScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetSecurityScanOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetSecurityScanOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a security-scan operation. (asynchronously) + * Returns the current state of the security-scan run for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetSecurityScanOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetSecurityScanOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetTriageOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetTriageOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/triage/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetTriageOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetTriageOperation(Async)"); + } + + return v3GetTriageOperationCall(analysisId, _callback); + + } + + /** + * Get a triage operation. + * Polls a triage run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return OperationMetadataTriageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataTriageResult v3GetTriageOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetTriageOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get a triage operation. + * Polls a triage run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataTriageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetTriageOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetTriageOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a triage operation. (asynchronously) + * Polls a triage run. `metadata.status` tracks the run and `metadata.log_history` carries its progress messages; `response` is set once the run has completed. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetTriageOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetTriageOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunCapabilities + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunCapabilitiesCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/capabilities:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunCapabilitiesValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunCapabilities(Async)"); + } + + return v3RunCapabilitiesCall(analysisId, _callback); + + } + + /** + * Run the capabilities agent. + * Starts the capabilities agent, which attributes behavioural capabilities to individual functions, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return OperationMetadataCapabilitiesResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataCapabilitiesResult v3RunCapabilities(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3RunCapabilitiesWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Run the capabilities agent. + * Starts the capabilities agent, which attributes behavioural capabilities to individual functions, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataCapabilitiesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunCapabilitiesWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3RunCapabilitiesValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the capabilities agent. (asynchronously) + * Starts the capabilities agent, which attributes behavioural capabilities to individual functions, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunCapabilitiesAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunCapabilitiesValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunCryptoExplain + * @param functionId Function ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunCryptoExplainCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/functions/{function_id}/crypto-explain:run" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunCryptoExplainValidateBeforeCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3RunCryptoExplain(Async)"); + } + + return v3RunCryptoExplainCall(functionId, _callback); + + } + + /** + * Run the crypto-explain agent. + * Starts an agent that explains the cryptography the function implements, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @return OperationCryptoExplainMetadataCryptoExplainResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationCryptoExplainMetadataCryptoExplainResult v3RunCryptoExplain(@javax.annotation.Nonnull Long functionId) throws ApiException { + ApiResponse localVarResp = v3RunCryptoExplainWithHttpInfo(functionId); + return localVarResp.getData(); + } + + /** + * Run the crypto-explain agent. + * Starts an agent that explains the cryptography the function implements, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @return ApiResponse<OperationCryptoExplainMetadataCryptoExplainResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunCryptoExplainWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { + okhttp3.Call localVarCall = v3RunCryptoExplainValidateBeforeCall(functionId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the crypto-explain agent. (asynchronously) + * Starts an agent that explains the cryptography the function implements, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunCryptoExplainAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunCryptoExplainValidateBeforeCall(functionId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunCryptoScan + * @param analysisId Analysis ID (required) + * @param triggerCryptoScanInputBody (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunCryptoScanCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerCryptoScanInputBody triggerCryptoScanInputBody, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = triggerCryptoScanInputBody; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/crypto-scan:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunCryptoScanValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerCryptoScanInputBody triggerCryptoScanInputBody, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunCryptoScan(Async)"); + } + + // verify the required parameter 'triggerCryptoScanInputBody' is set + if (triggerCryptoScanInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerCryptoScanInputBody' when calling v3RunCryptoScan(Async)"); + } + + return v3RunCryptoScanCall(analysisId, triggerCryptoScanInputBody, _callback); + + } + + /** + * Run the crypto-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known crypto-library APIs, and returns the operation to poll for its outcome. Purely name-based — never triggers AI decompilation, so it costs no credits and runs in seconds. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerCryptoScanInputBody (required) + * @return OperationCryptoScanMetadataCryptoScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationCryptoScanMetadataCryptoScanResult v3RunCryptoScan(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerCryptoScanInputBody triggerCryptoScanInputBody) throws ApiException { + ApiResponse localVarResp = v3RunCryptoScanWithHttpInfo(analysisId, triggerCryptoScanInputBody); + return localVarResp.getData(); + } + + /** + * Run the crypto-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known crypto-library APIs, and returns the operation to poll for its outcome. Purely name-based — never triggers AI decompilation, so it costs no credits and runs in seconds. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerCryptoScanInputBody (required) + * @return ApiResponse<OperationCryptoScanMetadataCryptoScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunCryptoScanWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerCryptoScanInputBody triggerCryptoScanInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunCryptoScanValidateBeforeCall(analysisId, triggerCryptoScanInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the crypto-scan agent. (asynchronously) + * Starts an agent that name-matches the analysis' functions and their callees against known crypto-library APIs, and returns the operation to poll for its outcome. Purely name-based — never triggers AI decompilation, so it costs no credits and runs in seconds. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerCryptoScanInputBody (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunCryptoScanAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerCryptoScanInputBody triggerCryptoScanInputBody, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunCryptoScanValidateBeforeCall(analysisId, triggerCryptoScanInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunExecutionExplain + * @param functionId Function ID (required) + * @param triggerExecutionExplainInputBody (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunExecutionExplainCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerExecutionExplainInputBody triggerExecutionExplainInputBody, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = triggerExecutionExplainInputBody; + + // create path and map variables + String localVarPath = "/v3/functions/{function_id}/execution-explain:run" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunExecutionExplainValidateBeforeCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerExecutionExplainInputBody triggerExecutionExplainInputBody, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3RunExecutionExplain(Async)"); + } + + // verify the required parameter 'triggerExecutionExplainInputBody' is set + if (triggerExecutionExplainInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerExecutionExplainInputBody' when calling v3RunExecutionExplain(Async)"); + } + + return v3RunExecutionExplainCall(functionId, triggerExecutionExplainInputBody, _callback); + + } + + /** + * Run the execution-explain agent. + * Starts an agent that explains the code execution the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerExecutionExplainInputBody (required) + * @return OperationExecutionExplainMetadataExecutionExplainResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationExecutionExplainMetadataExecutionExplainResult v3RunExecutionExplain(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerExecutionExplainInputBody triggerExecutionExplainInputBody) throws ApiException { + ApiResponse localVarResp = v3RunExecutionExplainWithHttpInfo(functionId, triggerExecutionExplainInputBody); + return localVarResp.getData(); + } + + /** + * Run the execution-explain agent. + * Starts an agent that explains the code execution the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerExecutionExplainInputBody (required) + * @return ApiResponse<OperationExecutionExplainMetadataExecutionExplainResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunExecutionExplainWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerExecutionExplainInputBody triggerExecutionExplainInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunExecutionExplainValidateBeforeCall(functionId, triggerExecutionExplainInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the execution-explain agent. (asynchronously) + * Starts an agent that explains the code execution the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerExecutionExplainInputBody (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunExecutionExplainAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerExecutionExplainInputBody triggerExecutionExplainInputBody, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunExecutionExplainValidateBeforeCall(functionId, triggerExecutionExplainInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunExecutionScan + * @param analysisId Analysis ID (required) + * @param triggerExecutionScanInputBody (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunExecutionScanCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerExecutionScanInputBody triggerExecutionScanInputBody, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = triggerExecutionScanInputBody; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/execution-scan:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunExecutionScanValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerExecutionScanInputBody triggerExecutionScanInputBody, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunExecutionScan(Async)"); + } + + // verify the required parameter 'triggerExecutionScanInputBody' is set + if (triggerExecutionScanInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerExecutionScanInputBody' when calling v3RunExecutionScan(Async)"); + } + + return v3RunExecutionScanCall(analysisId, triggerExecutionScanInputBody, _callback); + + } + + /** + * Run the execution-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known code-execution APIs, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerExecutionScanInputBody (required) + * @return OperationExecutionScanMetadataExecutionScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationExecutionScanMetadataExecutionScanResult v3RunExecutionScan(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerExecutionScanInputBody triggerExecutionScanInputBody) throws ApiException { + ApiResponse localVarResp = v3RunExecutionScanWithHttpInfo(analysisId, triggerExecutionScanInputBody); + return localVarResp.getData(); + } + + /** + * Run the execution-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known code-execution APIs, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerExecutionScanInputBody (required) + * @return ApiResponse<OperationExecutionScanMetadataExecutionScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunExecutionScanWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerExecutionScanInputBody triggerExecutionScanInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunExecutionScanValidateBeforeCall(analysisId, triggerExecutionScanInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the execution-scan agent. (asynchronously) + * Starts an agent that name-matches the analysis' functions and their callees against known code-execution APIs, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerExecutionScanInputBody (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunExecutionScanAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerExecutionScanInputBody triggerExecutionScanInputBody, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunExecutionScanValidateBeforeCall(analysisId, triggerExecutionScanInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunFilesystemAnalyse + * @param functionId Function ID (required) + * @param triggerFilesystemAnalyseInputBody (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunFilesystemAnalyseCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerFilesystemAnalyseInputBody triggerFilesystemAnalyseInputBody, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = triggerFilesystemAnalyseInputBody; + + // create path and map variables + String localVarPath = "/v3/functions/{function_id}/filesystem-analyse:run" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunFilesystemAnalyseValidateBeforeCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerFilesystemAnalyseInputBody triggerFilesystemAnalyseInputBody, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3RunFilesystemAnalyse(Async)"); + } + + // verify the required parameter 'triggerFilesystemAnalyseInputBody' is set + if (triggerFilesystemAnalyseInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerFilesystemAnalyseInputBody' when calling v3RunFilesystemAnalyse(Async)"); + } + + return v3RunFilesystemAnalyseCall(functionId, triggerFilesystemAnalyseInputBody, _callback); + + } + + /** + * Run the filesystem-analyse agent. + * Starts an agent that explains the filesystem/system access the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerFilesystemAnalyseInputBody (required) + * @return OperationFilesystemAnalyseMetadataFilesystemAnalyseResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult v3RunFilesystemAnalyse(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerFilesystemAnalyseInputBody triggerFilesystemAnalyseInputBody) throws ApiException { + ApiResponse localVarResp = v3RunFilesystemAnalyseWithHttpInfo(functionId, triggerFilesystemAnalyseInputBody); + return localVarResp.getData(); + } + + /** + * Run the filesystem-analyse agent. + * Starts an agent that explains the filesystem/system access the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerFilesystemAnalyseInputBody (required) + * @return ApiResponse<OperationFilesystemAnalyseMetadataFilesystemAnalyseResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunFilesystemAnalyseWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerFilesystemAnalyseInputBody triggerFilesystemAnalyseInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunFilesystemAnalyseValidateBeforeCall(functionId, triggerFilesystemAnalyseInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the filesystem-analyse agent. (asynchronously) + * Starts an agent that explains the filesystem/system access the function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerFilesystemAnalyseInputBody (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunFilesystemAnalyseAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerFilesystemAnalyseInputBody triggerFilesystemAnalyseInputBody, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunFilesystemAnalyseValidateBeforeCall(functionId, triggerFilesystemAnalyseInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunFilesystemScan + * @param analysisId Analysis ID (required) + * @param triggerFilesystemScanInputBody (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunFilesystemScanCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerFilesystemScanInputBody triggerFilesystemScanInputBody, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = triggerFilesystemScanInputBody; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/filesystem-scan:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunFilesystemScanValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerFilesystemScanInputBody triggerFilesystemScanInputBody, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunFilesystemScan(Async)"); + } + + // verify the required parameter 'triggerFilesystemScanInputBody' is set + if (triggerFilesystemScanInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerFilesystemScanInputBody' when calling v3RunFilesystemScan(Async)"); + } + + return v3RunFilesystemScanCall(analysisId, triggerFilesystemScanInputBody, _callback); + + } + + /** + * Run the filesystem-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known filesystem/system APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerFilesystemScanInputBody (required) + * @return OperationFilesystemScanMetadataFilesystemScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationFilesystemScanMetadataFilesystemScanResult v3RunFilesystemScan(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerFilesystemScanInputBody triggerFilesystemScanInputBody) throws ApiException { + ApiResponse localVarResp = v3RunFilesystemScanWithHttpInfo(analysisId, triggerFilesystemScanInputBody); + return localVarResp.getData(); + } + + /** + * Run the filesystem-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known filesystem/system APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerFilesystemScanInputBody (required) + * @return ApiResponse<OperationFilesystemScanMetadataFilesystemScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunFilesystemScanWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerFilesystemScanInputBody triggerFilesystemScanInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunFilesystemScanValidateBeforeCall(analysisId, triggerFilesystemScanInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the filesystem-scan agent. (asynchronously) + * Starts an agent that name-matches the analysis' functions and their callees against known filesystem/system APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerFilesystemScanInputBody (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunFilesystemScanAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerFilesystemScanInputBody triggerFilesystemScanInputBody, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunFilesystemScanValidateBeforeCall(analysisId, triggerFilesystemScanInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunNetworkingExplain + * @param functionId Function ID (required) + * @param triggerNetworkingExplainInputBody (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunNetworkingExplainCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerNetworkingExplainInputBody triggerNetworkingExplainInputBody, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = triggerNetworkingExplainInputBody; + + // create path and map variables + String localVarPath = "/v3/functions/{function_id}/networking-explain:run" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunNetworkingExplainValidateBeforeCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerNetworkingExplainInputBody triggerNetworkingExplainInputBody, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3RunNetworkingExplain(Async)"); + } + + // verify the required parameter 'triggerNetworkingExplainInputBody' is set + if (triggerNetworkingExplainInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerNetworkingExplainInputBody' when calling v3RunNetworkingExplain(Async)"); + } + + return v3RunNetworkingExplainCall(functionId, triggerNetworkingExplainInputBody, _callback); + + } + + /** + * Run the networking-explain agent. + * Starts an agent that explains the network communication a function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerNetworkingExplainInputBody (required) + * @return OperationNetworkingExplainMetadataNetworkingExplainResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationNetworkingExplainMetadataNetworkingExplainResult v3RunNetworkingExplain(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerNetworkingExplainInputBody triggerNetworkingExplainInputBody) throws ApiException { + ApiResponse localVarResp = v3RunNetworkingExplainWithHttpInfo(functionId, triggerNetworkingExplainInputBody); + return localVarResp.getData(); + } + + /** + * Run the networking-explain agent. + * Starts an agent that explains the network communication a function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerNetworkingExplainInputBody (required) + * @return ApiResponse<OperationNetworkingExplainMetadataNetworkingExplainResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunNetworkingExplainWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerNetworkingExplainInputBody triggerNetworkingExplainInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunNetworkingExplainValidateBeforeCall(functionId, triggerNetworkingExplainInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the networking-explain agent. (asynchronously) + * Starts an agent that explains the network communication a function performs, and returns the operation to poll for its outcome. Requires credits. Returns 409 while a run is already in progress for this function. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param functionId Function ID (required) + * @param triggerNetworkingExplainInputBody (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunNetworkingExplainAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull TriggerNetworkingExplainInputBody triggerNetworkingExplainInputBody, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunNetworkingExplainValidateBeforeCall(functionId, triggerNetworkingExplainInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunNetworkingScan + * @param analysisId Analysis ID (required) + * @param triggerNetworkingScanInputBody (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunNetworkingScanCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerNetworkingScanInputBody triggerNetworkingScanInputBody, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = triggerNetworkingScanInputBody; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/networking-scan:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunNetworkingScanValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerNetworkingScanInputBody triggerNetworkingScanInputBody, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunNetworkingScan(Async)"); + } + + // verify the required parameter 'triggerNetworkingScanInputBody' is set + if (triggerNetworkingScanInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerNetworkingScanInputBody' when calling v3RunNetworkingScan(Async)"); + } + + return v3RunNetworkingScanCall(analysisId, triggerNetworkingScanInputBody, _callback); + + } + + /** + * Run the networking-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known networking APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerNetworkingScanInputBody (required) + * @return OperationNetworkingScanMetadataNetworkingScanResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationNetworkingScanMetadataNetworkingScanResult v3RunNetworkingScan(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerNetworkingScanInputBody triggerNetworkingScanInputBody) throws ApiException { + ApiResponse localVarResp = v3RunNetworkingScanWithHttpInfo(analysisId, triggerNetworkingScanInputBody); + return localVarResp.getData(); + } + + /** + * Run the networking-scan agent. + * Starts an agent that name-matches the analysis' functions and their callees against known networking APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerNetworkingScanInputBody (required) + * @return ApiResponse<OperationNetworkingScanMetadataNetworkingScanResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunNetworkingScanWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerNetworkingScanInputBody triggerNetworkingScanInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunNetworkingScanValidateBeforeCall(analysisId, triggerNetworkingScanInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the networking-scan agent. (asynchronously) + * Starts an agent that name-matches the analysis' functions and their callees against known networking APIs, and returns the operation to poll for its outcome. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param triggerNetworkingScanInputBody (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunNetworkingScanAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerNetworkingScanInputBody triggerNetworkingScanInputBody, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunNetworkingScanValidateBeforeCall(analysisId, triggerNetworkingScanInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunProtocols + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunProtocolsCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/protocols:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunProtocolsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunProtocols(Async)"); + } + + return v3RunProtocolsCall(analysisId, _callback); + + } + + /** + * Run the protocols agent. + * Starts the protocols agent, which identifies the network and data protocols the binary implements, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return OperationMetadataReportResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataReportResult v3RunProtocols(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3RunProtocolsWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Run the protocols agent. + * Starts the protocols agent, which identifies the network and data protocols the binary implements, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataReportResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunProtocolsWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3RunProtocolsValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the protocols agent. (asynchronously) + * Starts the protocols agent, which identifies the network and data protocols the binary implements, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunProtocolsAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunProtocolsValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunRemediation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunRemediationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/remediation:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunRemediationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunRemediation(Async)"); + } + + return v3RunRemediationCall(analysisId, _callback); + + } + + /** + * Run the remediation agent. + * Starts the remediation agent, which generates YARA, Snort and STIX detection rules for the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return OperationMetadataRemediationResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataRemediationResult v3RunRemediation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3RunRemediationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Run the remediation agent. + * Starts the remediation agent, which generates YARA, Snort and STIX detection rules for the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataRemediationResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3RunRemediationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3RunRemediationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Run the remediation agent. (asynchronously) + * Starts the remediation agent, which generates YARA, Snort and STIX detection rules for the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunRemediationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3RunRemediationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3RunReportAnalysis + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3RunReportAnalysisCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/report-analysis:run" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3RunReportAnalysisValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunReportAnalysis(Async)"); + } + + return v3RunReportAnalysisCall(analysisId, _callback); + + } + + /** + * Run the report-analysis agent. + * Starts the report-analysis agent, which produces a combined threat report — summary, software type, attack flow, indicators of compromise, MITRE ATT&CK techniques and a YARA rule — and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return OperationMetadataThreatReportResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationMetadataThreatReportResult v3RunReportAnalysis(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3RunReportAnalysisWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Run the report-analysis agent. + * Starts the report-analysis agent, which produces a combined threat report — summary, software type, attack flow, indicators of compromise, MITRE ATT&CK techniques and a YARA rule — and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataThreatReportResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public ApiResponse getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse v3RunReportAnalysisWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3RunReportAnalysisValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get Report Analysis Result (asynchronously) - * Returns: - A summary of the analysis - The software type of the binary - An attack flow summary - List of IOCs - List of MITRE executable techniques - A YARA rule - * @param analysisId (required) + * Run the report-analysis agent. (asynchronously) + * Starts the report-analysis agent, which produces a combined threat report — summary, software type, attack flow, indicators of compromise, MITRE ATT&CK techniques and a YARA rule — and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -1517,20 +7373,25 @@ public ApiResponse getReportAnalysisResultV2 - - + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3RunReportAnalysisAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalysisGetValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = v3RunReportAnalysisValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for getTriageResultV2AnalysesAnalysisIdAgentTriageGet - * @param analysisId (required) + * Build call for v3RunSecrets + * @param analysisId Analysis ID (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -1538,11 +7399,16 @@ public okhttp3.Call getReportAnalysisResultV2AnalysesAnalysisIdAgentReportAnalys - - + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3RunSecretsCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1559,7 +7425,7 @@ public okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetCall(@javax Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v2/analyses/{analysis_id}/agent/triage" + String localVarPath = "/v3/analyses/{analysis_id}/secrets:run" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1584,63 +7450,73 @@ public okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetCall(@javax } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3RunSecretsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling getTriageResultV2AnalysesAnalysisIdAgentTriageGet(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunSecrets(Async)"); } - return getTriageResultV2AnalysesAnalysisIdAgentTriageGetCall(analysisId, _callback); + return v3RunSecretsCall(analysisId, _callback); } /** - * Get Triage Result - * - * @param analysisId (required) - * @return BaseResponseTriageReportResponse + * Run the secrets agent. + * Starts the secrets agent, which finds credentials and other hardcoded secrets in the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return OperationMetadataReportResult * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - - + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public BaseResponseTriageReportResponse getTriageResultV2AnalysesAnalysisIdAgentTriageGet(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - ApiResponse localVarResp = getTriageResultV2AnalysesAnalysisIdAgentTriageGetWithHttpInfo(analysisId); + public OperationMetadataReportResult v3RunSecrets(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3RunSecretsWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Get Triage Result - * - * @param analysisId (required) - * @return ApiResponse<BaseResponseTriageReportResponse> + * Run the secrets agent. + * Starts the secrets agent, which finds credentials and other hardcoded secrets in the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationMetadataReportResult> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - - + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public ApiResponse getTriageResultV2AnalysesAnalysisIdAgentTriageGetWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { - okhttp3.Call localVarCall = getTriageResultV2AnalysesAnalysisIdAgentTriageGetValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse v3RunSecretsWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3RunSecretsValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get Triage Result (asynchronously) - * - * @param analysisId (required) + * Run the secrets agent. (asynchronously) + * Starts the secrets agent, which finds credentials and other hardcoded secrets in the binary, and returns the operation to poll for its outcome. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits + * @param analysisId Analysis ID (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -1648,20 +7524,26 @@ public ApiResponse getTriageResultV2AnalysesAn - - + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3RunSecretsAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getTriageResultV2AnalysesAnalysisIdAgentTriageGetValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = v3RunSecretsValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for v3CancelRenameUnnamedFunctions + * Build call for v3RunSecurityScan * @param analysisId Analysis ID (required) + * @param triggerSecurityScanInputBody (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -1669,14 +7551,16 @@ public okhttp3.Call getTriageResultV2AnalysesAnalysisIdAgentTriageGetAsync(@java - + + +
Response Details
Status Code Description Response Headers
204 No Content -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3CancelRenameUnnamedFunctionsCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3RunSecurityScanCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerSecurityScanInputBody triggerSecurityScanInputBody, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1690,10 +7574,10 @@ public okhttp3.Call v3CancelRenameUnnamedFunctionsCall(@javax.annotation.Nonnull basePath = null; } - Object localVarPostBody = null; + Object localVarPostBody = triggerSecurityScanInputBody; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions/cancel" + String localVarPath = "/v3/analyses/{analysis_id}/security-scan:run" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1711,6 +7595,7 @@ public okhttp3.Call v3CancelRenameUnnamedFunctionsCall(@javax.annotation.Nonnull } final String[] localVarContentTypes = { + "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -1722,62 +7607,77 @@ public okhttp3.Call v3CancelRenameUnnamedFunctionsCall(@javax.annotation.Nonnull } @SuppressWarnings("rawtypes") - private okhttp3.Call v3CancelRenameUnnamedFunctionsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3RunSecurityScanValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerSecurityScanInputBody triggerSecurityScanInputBody, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3CancelRenameUnnamedFunctions(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunSecurityScan(Async)"); } - return v3CancelRenameUnnamedFunctionsCall(analysisId, _callback); + // verify the required parameter 'triggerSecurityScanInputBody' is set + if (triggerSecurityScanInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerSecurityScanInputBody' when calling v3RunSecurityScan(Async)"); + } + + return v3RunSecurityScanCall(analysisId, triggerSecurityScanInputBody, _callback); } /** - * Cancel the rename-unnamed-functions agent. - * Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * Run the security-scan agent. + * Starts an agent that decompiles the analysis' functions and runs a security scan over the decompiled source, and returns the operation to poll for its outcome. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `max_functions_to_scan` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) + * @param triggerSecurityScanInputBody (required) + * @return OperationSecurityScanMetadataSecurityScanResult * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + +
Response Details
Status Code Description Response Headers
204 No Content -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public void v3CancelRenameUnnamedFunctions(@javax.annotation.Nonnull Long analysisId) throws ApiException { - v3CancelRenameUnnamedFunctionsWithHttpInfo(analysisId); + public OperationSecurityScanMetadataSecurityScanResult v3RunSecurityScan(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerSecurityScanInputBody triggerSecurityScanInputBody) throws ApiException { + ApiResponse localVarResp = v3RunSecurityScanWithHttpInfo(analysisId, triggerSecurityScanInputBody); + return localVarResp.getData(); } /** - * Cancel the rename-unnamed-functions agent. - * Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * Run the security-scan agent. + * Starts an agent that decompiles the analysis' functions and runs a security scan over the decompiled source, and returns the operation to poll for its outcome. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `max_functions_to_scan` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) - * @return ApiResponse<Void> + * @param triggerSecurityScanInputBody (required) + * @return ApiResponse<OperationSecurityScanMetadataSecurityScanResult> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + +
Response Details
Status Code Description Response Headers
204 No Content -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public ApiResponse v3CancelRenameUnnamedFunctionsWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { - okhttp3.Call localVarCall = v3CancelRenameUnnamedFunctionsValidateBeforeCall(analysisId, null); - return localVarApiClient.execute(localVarCall); + public ApiResponse v3RunSecurityScanWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerSecurityScanInputBody triggerSecurityScanInputBody) throws ApiException { + okhttp3.Call localVarCall = v3RunSecurityScanValidateBeforeCall(analysisId, triggerSecurityScanInputBody, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Cancel the rename-unnamed-functions agent. (asynchronously) - * Requests cancellation of the currently running rename-unnamed-functions run for the analysis. Returns 404 if no run is in progress. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NO_ACTIVE_RUN`](/errors/NO_ACTIVE_RUN) — No Active Run + * Run the security-scan agent. (asynchronously) + * Starts an agent that decompiles the analysis' functions and runs a security scan over the decompiled source, and returns the operation to poll for its outcome. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `max_functions_to_scan` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) + * @param triggerSecurityScanInputBody (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -1785,21 +7685,24 @@ public ApiResponse v3CancelRenameUnnamedFunctionsWithHttpInfo(@javax.annot - + + +
Response Details
Status Code Description Response Headers
204 No Content -
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3CancelRenameUnnamedFunctionsAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3RunSecurityScanAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerSecurityScanInputBody triggerSecurityScanInputBody, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3CancelRenameUnnamedFunctionsValidateBeforeCall(analysisId, _callback); - localVarApiClient.executeAsync(localVarCall, _callback); + okhttp3.Call localVarCall = v3RunSecurityScanValidateBeforeCall(analysisId, triggerSecurityScanInputBody, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for v3GetRenameUnnamedFunctionsResult + * Build call for v3RunTriage * @param analysisId Analysis ID (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -1809,6 +7712,7 @@ public okhttp3.Call v3CancelRenameUnnamedFunctionsAsync(@javax.annotation.Nonnul Response Details Status Code Description Response Headers 200 OK - + 402 Payment Required - 403 Forbidden - 404 Not Found - 409 Conflict - @@ -1816,7 +7720,7 @@ public okhttp3.Call v3CancelRenameUnnamedFunctionsAsync(@javax.annotation.Nonnul 500 Internal Server Error - */ - public okhttp3.Call v3GetRenameUnnamedFunctionsResultCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3RunTriageCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1833,7 +7737,7 @@ public okhttp3.Call v3GetRenameUnnamedFunctionsResultCall(@javax.annotation.Nonn Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions" + String localVarPath = "/v3/analyses/{analysis_id}/triage:run" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1858,31 +7762,32 @@ public okhttp3.Call v3GetRenameUnnamedFunctionsResultCall(@javax.annotation.Nonn } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call v3GetRenameUnnamedFunctionsResultValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3RunTriageValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetRenameUnnamedFunctionsResult(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3RunTriage(Async)"); } - return v3GetRenameUnnamedFunctionsResultCall(analysisId, _callback); + return v3RunTriageCall(analysisId, _callback); } /** - * Get rename-unnamed-functions agent result. - * Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * Run the triage agent. + * Starts the triage agent, which scores the binary and each of its functions for maliciousness, and returns the operation to poll for its outcome. Unlike the other binary agents this one is not gated on subscription tier. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) - * @return RenameUnnamedFunctionsResult + * @return OperationMetadataTriageResult * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details + @@ -1890,22 +7795,23 @@ private okhttp3.Call v3GetRenameUnnamedFunctionsResultValidateBeforeCall(@javax.
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
500 Internal Server Error -
*/ - public RenameUnnamedFunctionsResult v3GetRenameUnnamedFunctionsResult(@javax.annotation.Nonnull Long analysisId) throws ApiException { - ApiResponse localVarResp = v3GetRenameUnnamedFunctionsResultWithHttpInfo(analysisId); + public OperationMetadataTriageResult v3RunTriage(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3RunTriageWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Get rename-unnamed-functions agent result. - * Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * Run the triage agent. + * Starts the triage agent, which scores the binary and each of its functions for maliciousness, and returns the operation to poll for its outcome. Unlike the other binary agents this one is not gated on subscription tier. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) - * @return ApiResponse<RenameUnnamedFunctionsResult> + * @return ApiResponse<OperationMetadataTriageResult> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details + @@ -1913,15 +7819,15 @@ public RenameUnnamedFunctionsResult v3GetRenameUnnamedFunctionsResult(@javax.ann
Response Details
Status Code Description Response Headers
200 OK -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
500 Internal Server Error -
*/ - public ApiResponse v3GetRenameUnnamedFunctionsResultWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { - okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsResultValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse v3RunTriageWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3RunTriageValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get rename-unnamed-functions agent result. (asynchronously) - * Returns the summary of the most recent completed rename-unnamed-functions run. Returns 409 while a run is still in progress and 404 when the agent has never produced a result for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`ANALYSIS_NOT_READY`](/errors/ANALYSIS_NOT_READY) — Analysis Not Ready + * Run the triage agent. (asynchronously) + * Starts the triage agent, which scores the binary and each of its functions for maliciousness, and returns the operation to poll for its outcome. Unlike the other binary agents this one is not gated on subscription tier. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -1931,6 +7837,7 @@ public ApiResponse v3GetRenameUnnamedFunctionsResu Response Details Status Code Description Response Headers 200 OK - + 402 Payment Required - 403 Forbidden - 404 Not Found - 409 Conflict - @@ -1938,16 +7845,17 @@ public ApiResponse v3GetRenameUnnamedFunctionsResu 500 Internal Server Error - */ - public okhttp3.Call v3GetRenameUnnamedFunctionsResultAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3RunTriageAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsResultValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = v3RunTriageValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for v3GetRenameUnnamedFunctionsStatus + * Build call for v3TriggerRenameUnnamedFunctions * @param analysisId Analysis ID (required) + * @param triggerRenameUnnamedFunctionsInputBody (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -1955,14 +7863,16 @@ public okhttp3.Call v3GetRenameUnnamedFunctionsResultAsync(@javax.annotation.Non - + + +
Response Details
Status Code Description Response Headers
200 OK -
202 Accepted -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3GetRenameUnnamedFunctionsStatusCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3TriggerRenameUnnamedFunctionsCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1976,10 +7886,10 @@ public okhttp3.Call v3GetRenameUnnamedFunctionsStatusCall(@javax.annotation.Nonn basePath = null; } - Object localVarPostBody = null; + Object localVarPostBody = triggerRenameUnnamedFunctionsInputBody; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions/status" + String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -1997,6 +7907,7 @@ public okhttp3.Call v3GetRenameUnnamedFunctionsStatusCall(@javax.annotation.Nonn } final String[] localVarContentTypes = { + "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -2004,69 +7915,81 @@ public okhttp3.Call v3GetRenameUnnamedFunctionsStatusCall(@javax.annotation.Nonn } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call v3GetRenameUnnamedFunctionsStatusValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3TriggerRenameUnnamedFunctionsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetRenameUnnamedFunctionsStatus(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3TriggerRenameUnnamedFunctions(Async)"); } - return v3GetRenameUnnamedFunctionsStatusCall(analysisId, _callback); + // verify the required parameter 'triggerRenameUnnamedFunctionsInputBody' is set + if (triggerRenameUnnamedFunctionsInputBody == null) { + throw new ApiException("Missing the required parameter 'triggerRenameUnnamedFunctionsInputBody' when calling v3TriggerRenameUnnamedFunctions(Async)"); + } + + return v3TriggerRenameUnnamedFunctionsCall(analysisId, triggerRenameUnnamedFunctionsInputBody, _callback); } /** - * Get rename-unnamed-functions agent status. - * Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Run the rename-unnamed-functions agent. + * Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) + * @param triggerRenameUnnamedFunctionsInputBody (required) * @return StatusBody * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + +
Response Details
Status Code Description Response Headers
200 OK -
202 Accepted -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public StatusBody v3GetRenameUnnamedFunctionsStatus(@javax.annotation.Nonnull Long analysisId) throws ApiException { - ApiResponse localVarResp = v3GetRenameUnnamedFunctionsStatusWithHttpInfo(analysisId); + public StatusBody v3TriggerRenameUnnamedFunctions(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody) throws ApiException { + ApiResponse localVarResp = v3TriggerRenameUnnamedFunctionsWithHttpInfo(analysisId, triggerRenameUnnamedFunctionsInputBody); return localVarResp.getData(); } /** - * Get rename-unnamed-functions agent status. - * Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Run the rename-unnamed-functions agent. + * Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) + * @param triggerRenameUnnamedFunctionsInputBody (required) * @return ApiResponse<StatusBody> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + +
Response Details
Status Code Description Response Headers
200 OK -
202 Accepted -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public ApiResponse v3GetRenameUnnamedFunctionsStatusWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { - okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsStatusValidateBeforeCall(analysisId, null); + public ApiResponse v3TriggerRenameUnnamedFunctionsWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody) throws ApiException { + okhttp3.Call localVarCall = v3TriggerRenameUnnamedFunctionsValidateBeforeCall(analysisId, triggerRenameUnnamedFunctionsInputBody, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get rename-unnamed-functions agent status. (asynchronously) - * Returns the status of the most recent rename-unnamed-functions run for the analysis. `UNINITIALISED` means the agent has never been triggered, so it is safe to start one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Run the rename-unnamed-functions agent. (asynchronously) + * Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param analysisId Analysis ID (required) + * @param triggerRenameUnnamedFunctionsInputBody (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -2074,24 +7997,27 @@ public ApiResponse v3GetRenameUnnamedFunctionsStatusWithHttpInfo(@ja - + + +
Response Details
Status Code Description Response Headers
200 OK -
202 Accepted -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3GetRenameUnnamedFunctionsStatusAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3TriggerRenameUnnamedFunctionsAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3GetRenameUnnamedFunctionsStatusValidateBeforeCall(analysisId, _callback); + okhttp3.Call localVarCall = v3TriggerRenameUnnamedFunctionsValidateBeforeCall(analysisId, triggerRenameUnnamedFunctionsInputBody, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for v3TriggerRenameUnnamedFunctions + * Build call for v3UpsertBinaryAgentFeedback * @param analysisId Analysis ID (required) - * @param triggerRenameUnnamedFunctionsInputBody (required) + * @param agent Which agent's output the feedback is about (required) + * @param submitFeedbackInputBody (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -2099,15 +8025,14 @@ public okhttp3.Call v3GetRenameUnnamedFunctionsStatusAsync(@javax.annotation.Non - + -
Response Details
Status Code Description Response Headers
202 Accepted -
204 No Content -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3TriggerRenameUnnamedFunctionsCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3UpsertBinaryAgentFeedbackCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, @javax.annotation.Nonnull SubmitFeedbackInputBody submitFeedbackInputBody, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -2121,11 +8046,12 @@ public okhttp3.Call v3TriggerRenameUnnamedFunctionsCall(@javax.annotation.Nonnul basePath = null; } - Object localVarPostBody = triggerRenameUnnamedFunctionsInputBody; + Object localVarPostBody = submitFeedbackInputBody; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/agents/rename-unnamed-functions" - .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + String localVarPath = "/v3/analyses/{analysis_id}/agents/{agent}/feedback" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())) + .replace("{" + "agent" + "}", localVarApiClient.escapeString(agent.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -2150,79 +8076,82 @@ public okhttp3.Call v3TriggerRenameUnnamedFunctionsCall(@javax.annotation.Nonnul } String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call v3TriggerRenameUnnamedFunctionsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3UpsertBinaryAgentFeedbackValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, @javax.annotation.Nonnull SubmitFeedbackInputBody submitFeedbackInputBody, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3TriggerRenameUnnamedFunctions(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3UpsertBinaryAgentFeedback(Async)"); } - // verify the required parameter 'triggerRenameUnnamedFunctionsInputBody' is set - if (triggerRenameUnnamedFunctionsInputBody == null) { - throw new ApiException("Missing the required parameter 'triggerRenameUnnamedFunctionsInputBody' when calling v3TriggerRenameUnnamedFunctions(Async)"); + // verify the required parameter 'agent' is set + if (agent == null) { + throw new ApiException("Missing the required parameter 'agent' when calling v3UpsertBinaryAgentFeedback(Async)"); } - return v3TriggerRenameUnnamedFunctionsCall(analysisId, triggerRenameUnnamedFunctionsInputBody, _callback); + // verify the required parameter 'submitFeedbackInputBody' is set + if (submitFeedbackInputBody == null) { + throw new ApiException("Missing the required parameter 'submitFeedbackInputBody' when calling v3UpsertBinaryAgentFeedback(Async)"); + } + + return v3UpsertBinaryAgentFeedbackCall(analysisId, agent, submitFeedbackInputBody, _callback); } /** - * Run the rename-unnamed-functions agent. - * Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * Record feedback on an agent's output. + * Records how useful the caller found one agent's output for this analysis. Replaces any sentiment they recorded previously. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @param triggerRenameUnnamedFunctionsInputBody (required) - * @return StatusBody + * @param agent Which agent's output the feedback is about (required) + * @param submitFeedbackInputBody (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + -
Response Details
Status Code Description Response Headers
202 Accepted -
204 No Content -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public StatusBody v3TriggerRenameUnnamedFunctions(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody) throws ApiException { - ApiResponse localVarResp = v3TriggerRenameUnnamedFunctionsWithHttpInfo(analysisId, triggerRenameUnnamedFunctionsInputBody); - return localVarResp.getData(); + public void v3UpsertBinaryAgentFeedback(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, @javax.annotation.Nonnull SubmitFeedbackInputBody submitFeedbackInputBody) throws ApiException { + v3UpsertBinaryAgentFeedbackWithHttpInfo(analysisId, agent, submitFeedbackInputBody); } /** - * Run the rename-unnamed-functions agent. - * Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * Record feedback on an agent's output. + * Records how useful the caller found one agent's output for this analysis. Replaces any sentiment they recorded previously. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @param triggerRenameUnnamedFunctionsInputBody (required) - * @return ApiResponse<StatusBody> + * @param agent Which agent's output the feedback is about (required) + * @param submitFeedbackInputBody (required) + * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + -
Response Details
Status Code Description Response Headers
202 Accepted -
204 No Content -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public ApiResponse v3TriggerRenameUnnamedFunctionsWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody) throws ApiException { - okhttp3.Call localVarCall = v3TriggerRenameUnnamedFunctionsValidateBeforeCall(analysisId, triggerRenameUnnamedFunctionsInputBody, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); + public ApiResponse v3UpsertBinaryAgentFeedbackWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, @javax.annotation.Nonnull SubmitFeedbackInputBody submitFeedbackInputBody) throws ApiException { + okhttp3.Call localVarCall = v3UpsertBinaryAgentFeedbackValidateBeforeCall(analysisId, agent, submitFeedbackInputBody, null); + return localVarApiClient.execute(localVarCall); } /** - * Run the rename-unnamed-functions agent. (asynchronously) - * Starts an agent that renames the analysis' unnamed functions from their AI decompilations. Each function costs an AI decompilation, so a whole-analysis run can be expensive — use `limit` to bound it. Returns 409 while a run is already in progress for this analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * Record feedback on an agent's output. (asynchronously) + * Records how useful the caller found one agent's output for this analysis. Replaces any sentiment they recorded previously. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @param triggerRenameUnnamedFunctionsInputBody (required) + * @param agent Which agent's output the feedback is about (required) + * @param submitFeedbackInputBody (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -2230,19 +8159,17 @@ public ApiResponse v3TriggerRenameUnnamedFunctionsWithHttpInfo(@java - + -
Response Details
Status Code Description Response Headers
202 Accepted -
204 No Content -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3TriggerRenameUnnamedFunctionsAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3UpsertBinaryAgentFeedbackAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull String agent, @javax.annotation.Nonnull SubmitFeedbackInputBody submitFeedbackInputBody, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3TriggerRenameUnnamedFunctionsValidateBeforeCall(analysisId, triggerRenameUnnamedFunctionsInputBody, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + okhttp3.Call localVarCall = v3UpsertBinaryAgentFeedbackValidateBeforeCall(analysisId, agent, submitFeedbackInputBody, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } } diff --git a/src/main/java/ai/reveng/api/AnalysesCoreApi.java b/src/main/java/ai/reveng/api/AnalysesCoreApi.java index 399d549a..f14a485c 100644 --- a/src/main/java/ai/reveng/api/AnalysesCoreApi.java +++ b/src/main/java/ai/reveng/api/AnalysesCoreApi.java @@ -48,9 +48,11 @@ import ai.reveng.model.BaseResponseRecent; import ai.reveng.model.BaseResponseStatus; import ai.reveng.model.BaseResponseUploadResponse; +import ai.reveng.model.CreateRequest; import ai.reveng.model.DynamicExecutionStatus; import ai.reveng.model.DynamicExecutionStatusResponse; import java.io.File; +import ai.reveng.model.FunctionsProgressOutputBody; import ai.reveng.model.GetAnalysisLogsOutputBody; import ai.reveng.model.GetAnalysisStringsStatusOutputBody; import ai.reveng.model.GetMatchesOutputBody; @@ -60,12 +62,14 @@ import ai.reveng.model.ListAnalysisStringsOutputBody; import ai.reveng.model.ListExampleAnalysesOutputBody; import ai.reveng.model.ModelName; +import ai.reveng.model.OperationCreateMetadataCreateResult; import ai.reveng.model.Order; import ai.reveng.model.PutAnalysisStringsRequest; import ai.reveng.model.ReAnalysisForm; import ai.reveng.model.StartMatchingForAnalysisInputBody; import ai.reveng.model.StartMatchingOutputBody; import ai.reveng.model.StatusInput; +import ai.reveng.model.UpgradeAnalysisModelOutputBody; import ai.reveng.model.UploadFileType; import ai.reveng.model.Workspace; @@ -281,7 +285,9 @@ public okhttp3.Call addUserStringToAnalysisAsync(@javax.annotation.Nonnull Long 404 Not Found - 400 Bad Request - + * @deprecated */ + @Deprecated public okhttp3.Call createAnalysisCall(@javax.annotation.Nonnull AnalysisCreateRequest analysisCreateRequest, @javax.annotation.Nullable String xRevEngApplication, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -332,6 +338,7 @@ public okhttp3.Call createAnalysisCall(@javax.annotation.Nonnull AnalysisCreateR return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call createAnalysisValidateBeforeCall(@javax.annotation.Nonnull AnalysisCreateRequest analysisCreateRequest, @javax.annotation.Nullable String xRevEngApplication, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisCreateRequest' is set @@ -359,7 +366,9 @@ private okhttp3.Call createAnalysisValidateBeforeCall(@javax.annotation.Nonnull 404 Not Found - 400 Bad Request - + * @deprecated */ + @Deprecated public BaseResponseAnalysisCreateResponse createAnalysis(@javax.annotation.Nonnull AnalysisCreateRequest analysisCreateRequest, @javax.annotation.Nullable String xRevEngApplication) throws ApiException { ApiResponse localVarResp = createAnalysisWithHttpInfo(analysisCreateRequest, xRevEngApplication); return localVarResp.getData(); @@ -381,7 +390,9 @@ public BaseResponseAnalysisCreateResponse createAnalysis(@javax.annotation.Nonnu 404 Not Found - 400 Bad Request - + * @deprecated */ + @Deprecated public ApiResponse createAnalysisWithHttpInfo(@javax.annotation.Nonnull AnalysisCreateRequest analysisCreateRequest, @javax.annotation.Nullable String xRevEngApplication) throws ApiException { okhttp3.Call localVarCall = createAnalysisValidateBeforeCall(analysisCreateRequest, xRevEngApplication, null); Type localVarReturnType = new TypeToken(){}.getType(); @@ -405,7 +416,9 @@ public ApiResponse createAnalysisWithHttpInf 404 Not Found - 400 Bad Request - + * @deprecated */ + @Deprecated public okhttp3.Call createAnalysisAsync(@javax.annotation.Nonnull AnalysisCreateRequest analysisCreateRequest, @javax.annotation.Nullable String xRevEngApplication, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = createAnalysisValidateBeforeCall(analysisCreateRequest, xRevEngApplication, _callback); @@ -1580,7 +1593,9 @@ public okhttp3.Call getAnalysisLogsAsync(@javax.annotation.Nonnull Integer analy 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call getAnalysisParamsCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -1626,6 +1641,7 @@ public okhttp3.Call getAnalysisParamsCall(@javax.annotation.Nonnull Integer anal return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call getAnalysisParamsValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set @@ -1650,7 +1666,9 @@ private okhttp3.Call getAnalysisParamsValidateBeforeCall(@javax.annotation.Nonnu 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public BaseResponseParams getAnalysisParams(@javax.annotation.Nonnull Integer analysisId) throws ApiException { ApiResponse localVarResp = getAnalysisParamsWithHttpInfo(analysisId); return localVarResp.getData(); @@ -1669,7 +1687,9 @@ public BaseResponseParams getAnalysisParams(@javax.annotation.Nonnull Integer an 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public ApiResponse getAnalysisParamsWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { okhttp3.Call localVarCall = getAnalysisParamsValidateBeforeCall(analysisId, null); Type localVarReturnType = new TypeToken(){}.getType(); @@ -1690,7 +1710,9 @@ public ApiResponse getAnalysisParamsWithHttpInfo(@javax.anno 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call getAnalysisParamsAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getAnalysisParamsValidateBeforeCall(analysisId, _callback); @@ -1711,7 +1733,9 @@ public okhttp3.Call getAnalysisParamsAsync(@javax.annotation.Nonnull Integer ana 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call getAnalysisStatusCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -1757,6 +1781,7 @@ public okhttp3.Call getAnalysisStatusCall(@javax.annotation.Nonnull Integer anal return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call getAnalysisStatusValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set @@ -1781,7 +1806,9 @@ private okhttp3.Call getAnalysisStatusValidateBeforeCall(@javax.annotation.Nonnu 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public BaseResponseStatus getAnalysisStatus(@javax.annotation.Nonnull Integer analysisId) throws ApiException { ApiResponse localVarResp = getAnalysisStatusWithHttpInfo(analysisId); return localVarResp.getData(); @@ -1800,7 +1827,9 @@ public BaseResponseStatus getAnalysisStatus(@javax.annotation.Nonnull Integer an 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public ApiResponse getAnalysisStatusWithHttpInfo(@javax.annotation.Nonnull Integer analysisId) throws ApiException { okhttp3.Call localVarCall = getAnalysisStatusValidateBeforeCall(analysisId, null); Type localVarReturnType = new TypeToken(){}.getType(); @@ -1821,7 +1850,9 @@ public ApiResponse getAnalysisStatusWithHttpInfo(@javax.anno 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call getAnalysisStatusAsync(@javax.annotation.Nonnull Integer analysisId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getAnalysisStatusValidateBeforeCall(analysisId, _callback); @@ -2275,7 +2306,9 @@ public okhttp3.Call insertAnalysisLogAsync(@javax.annotation.Nonnull Integer ana 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call listAnalysesCall(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List workspace, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable DynamicExecutionStatus dynamicExecutionStatus, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Integer limit, @javax.annotation.Nullable Integer offset, @javax.annotation.Nullable AppApiRestV2AnalysesEnumsOrderBy orderBy, @javax.annotation.Nullable Order order, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -2364,6 +2397,7 @@ public okhttp3.Call listAnalysesCall(@javax.annotation.Nullable String searchTer return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call listAnalysesValidateBeforeCall(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List workspace, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable DynamicExecutionStatus dynamicExecutionStatus, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Integer limit, @javax.annotation.Nullable Integer offset, @javax.annotation.Nullable AppApiRestV2AnalysesEnumsOrderBy orderBy, @javax.annotation.Nullable Order order, final ApiCallback _callback) throws ApiException { return listAnalysesCall(searchTerm, workspace, status, modelName, dynamicExecutionStatus, usernames, sha256Hash, limit, offset, orderBy, order, _callback); @@ -2393,7 +2427,9 @@ private okhttp3.Call listAnalysesValidateBeforeCall(@javax.annotation.Nullable S 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public BaseResponseRecent listAnalyses(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List workspace, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable DynamicExecutionStatus dynamicExecutionStatus, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Integer limit, @javax.annotation.Nullable Integer offset, @javax.annotation.Nullable AppApiRestV2AnalysesEnumsOrderBy orderBy, @javax.annotation.Nullable Order order) throws ApiException { ApiResponse localVarResp = listAnalysesWithHttpInfo(searchTerm, workspace, status, modelName, dynamicExecutionStatus, usernames, sha256Hash, limit, offset, orderBy, order); return localVarResp.getData(); @@ -2422,7 +2458,9 @@ public BaseResponseRecent listAnalyses(@javax.annotation.Nullable String searchT 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public ApiResponse listAnalysesWithHttpInfo(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List workspace, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable DynamicExecutionStatus dynamicExecutionStatus, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Integer limit, @javax.annotation.Nullable Integer offset, @javax.annotation.Nullable AppApiRestV2AnalysesEnumsOrderBy orderBy, @javax.annotation.Nullable Order order) throws ApiException { okhttp3.Call localVarCall = listAnalysesValidateBeforeCall(searchTerm, workspace, status, modelName, dynamicExecutionStatus, usernames, sha256Hash, limit, offset, orderBy, order, null); Type localVarReturnType = new TypeToken(){}.getType(); @@ -2453,7 +2491,9 @@ public ApiResponse listAnalysesWithHttpInfo(@javax.annotatio 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call listAnalysesAsync(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List workspace, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable DynamicExecutionStatus dynamicExecutionStatus, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Integer limit, @javax.annotation.Nullable Integer offset, @javax.annotation.Nullable AppApiRestV2AnalysesEnumsOrderBy orderBy, @javax.annotation.Nullable Order order, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = listAnalysesValidateBeforeCall(searchTerm, workspace, status, modelName, dynamicExecutionStatus, usernames, sha256Hash, limit, offset, orderBy, order, _callback); @@ -2606,7 +2646,9 @@ public okhttp3.Call lookupBinaryIdAsync(@javax.annotation.Nonnull Integer binary 201 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call putAnalysisStringsCall(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull PutAnalysisStringsRequest putAnalysisStringsRequest, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -2653,6 +2695,7 @@ public okhttp3.Call putAnalysisStringsCall(@javax.annotation.Nonnull Integer ana return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call putAnalysisStringsValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull PutAnalysisStringsRequest putAnalysisStringsRequest, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set @@ -2683,7 +2726,9 @@ private okhttp3.Call putAnalysisStringsValidateBeforeCall(@javax.annotation.Nonn 201 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public BaseResponse putAnalysisStrings(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull PutAnalysisStringsRequest putAnalysisStringsRequest) throws ApiException { ApiResponse localVarResp = putAnalysisStringsWithHttpInfo(analysisId, putAnalysisStringsRequest); return localVarResp.getData(); @@ -2703,7 +2748,9 @@ public BaseResponse putAnalysisStrings(@javax.annotation.Nonnull Integer analysi 201 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public ApiResponse putAnalysisStringsWithHttpInfo(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull PutAnalysisStringsRequest putAnalysisStringsRequest) throws ApiException { okhttp3.Call localVarCall = putAnalysisStringsValidateBeforeCall(analysisId, putAnalysisStringsRequest, null); Type localVarReturnType = new TypeToken(){}.getType(); @@ -2725,7 +2772,9 @@ public ApiResponse putAnalysisStringsWithHttpInfo(@javax.annotatio 201 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call putAnalysisStringsAsync(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull PutAnalysisStringsRequest putAnalysisStringsRequest, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = putAnalysisStringsValidateBeforeCall(analysisId, putAnalysisStringsRequest, _callback); @@ -3346,7 +3395,9 @@ public okhttp3.Call updateAnalysisTagsAsync(@javax.annotation.Nonnull Integer an 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call uploadFileCall(@javax.annotation.Nonnull UploadFileType uploadFileType, @javax.annotation.Nonnull File _file, @javax.annotation.Nullable String packedPassword, @javax.annotation.Nullable Boolean forceOverwrite, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -3408,6 +3459,7 @@ public okhttp3.Call uploadFileCall(@javax.annotation.Nonnull UploadFileType uplo return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } + @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call uploadFileValidateBeforeCall(@javax.annotation.Nonnull UploadFileType uploadFileType, @javax.annotation.Nonnull File _file, @javax.annotation.Nullable String packedPassword, @javax.annotation.Nullable Boolean forceOverwrite, final ApiCallback _callback) throws ApiException { // verify the required parameter 'uploadFileType' is set @@ -3440,7 +3492,9 @@ private okhttp3.Call uploadFileValidateBeforeCall(@javax.annotation.Nonnull Uplo 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public BaseResponseUploadResponse uploadFile(@javax.annotation.Nonnull UploadFileType uploadFileType, @javax.annotation.Nonnull File _file, @javax.annotation.Nullable String packedPassword, @javax.annotation.Nullable Boolean forceOverwrite) throws ApiException { ApiResponse localVarResp = uploadFileWithHttpInfo(uploadFileType, _file, packedPassword, forceOverwrite); return localVarResp.getData(); @@ -3462,7 +3516,9 @@ public BaseResponseUploadResponse uploadFile(@javax.annotation.Nonnull UploadFil 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull UploadFileType uploadFileType, @javax.annotation.Nonnull File _file, @javax.annotation.Nullable String packedPassword, @javax.annotation.Nullable Boolean forceOverwrite) throws ApiException { okhttp3.Call localVarCall = uploadFileValidateBeforeCall(uploadFileType, _file, packedPassword, forceOverwrite, null); Type localVarReturnType = new TypeToken(){}.getType(); @@ -3486,7 +3542,9 @@ public ApiResponse uploadFileWithHttpInfo(@javax.ann 200 Successful Response - 422 Invalid request parameters - + * @deprecated */ + @Deprecated public okhttp3.Call uploadFileAsync(@javax.annotation.Nonnull UploadFileType uploadFileType, @javax.annotation.Nonnull File _file, @javax.annotation.Nullable String packedPassword, @javax.annotation.Nullable Boolean forceOverwrite, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = uploadFileValidateBeforeCall(uploadFileType, _file, packedPassword, forceOverwrite, _callback); @@ -3495,8 +3553,9 @@ public okhttp3.Call uploadFileAsync(@javax.annotation.Nonnull UploadFileType upl return localVarCall; } /** - * Build call for v3GetAnalysisAutoUnstripStatus - * @param analysisId Analysis ID (required) + * Build call for v3CreateAnalysis + * @param createRequest (required) + * @param xRevEngApplication Identifies the calling RevEng application. Recorded on the Analysis log. (optional) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -3504,14 +3563,18 @@ public okhttp3.Call uploadFileAsync(@javax.annotation.Nonnull UploadFileType upl - + + + + +
Response Details
Status Code Description Response Headers
200 OK -
201 Created -
400 Bad Request -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3GetAnalysisAutoUnstripStatusCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3CreateAnalysisCall(@javax.annotation.Nonnull CreateRequest createRequest, @javax.annotation.Nullable String xRevEngApplication, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -3525,11 +3588,10 @@ public okhttp3.Call v3GetAnalysisAutoUnstripStatusCall(@javax.annotation.Nonnull basePath = null; } - Object localVarPostBody = null; + Object localVarPostBody = createRequest; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/auto-unstrip/status" - .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + String localVarPath = "/v3/analyses"; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -3546,76 +3608,93 @@ public okhttp3.Call v3GetAnalysisAutoUnstripStatusCall(@javax.annotation.Nonnull } final String[] localVarContentTypes = { + "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } + if (xRevEngApplication != null) { + localVarHeaderParams.put("X-RevEng-Application", localVarApiClient.parameterToString(xRevEngApplication)); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call v3GetAnalysisAutoUnstripStatusValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'analysisId' is set - if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisAutoUnstripStatus(Async)"); + private okhttp3.Call v3CreateAnalysisValidateBeforeCall(@javax.annotation.Nonnull CreateRequest createRequest, @javax.annotation.Nullable String xRevEngApplication, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'createRequest' is set + if (createRequest == null) { + throw new ApiException("Missing the required parameter 'createRequest' when calling v3CreateAnalysis(Async)"); } - return v3GetAnalysisAutoUnstripStatusCall(analysisId, _callback); + return v3CreateAnalysisCall(createRequest, xRevEngApplication, _callback); } /** - * Get the auto-unstrip status for an analysis. - * Returns the status of the auto-unstrip task for the binary backing the analysis. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - * @param analysisId Analysis ID (required) - * @return AutoUnstripStatusOutputBody + * Create an analysis + * Queues a new Analysis for an uploaded Binary and returns the created Operation. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + * @param createRequest (required) + * @param xRevEngApplication Identifies the calling RevEng application. Recorded on the Analysis log. (optional) + * @return OperationCreateMetadataCreateResult * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + + + +
Response Details
Status Code Description Response Headers
200 OK -
201 Created -
400 Bad Request -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public AutoUnstripStatusOutputBody v3GetAnalysisAutoUnstripStatus(@javax.annotation.Nonnull Long analysisId) throws ApiException { - ApiResponse localVarResp = v3GetAnalysisAutoUnstripStatusWithHttpInfo(analysisId); + public OperationCreateMetadataCreateResult v3CreateAnalysis(@javax.annotation.Nonnull CreateRequest createRequest, @javax.annotation.Nullable String xRevEngApplication) throws ApiException { + ApiResponse localVarResp = v3CreateAnalysisWithHttpInfo(createRequest, xRevEngApplication); return localVarResp.getData(); } /** - * Get the auto-unstrip status for an analysis. - * Returns the status of the auto-unstrip task for the binary backing the analysis. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - * @param analysisId Analysis ID (required) - * @return ApiResponse<AutoUnstripStatusOutputBody> + * Create an analysis + * Queues a new Analysis for an uploaded Binary and returns the created Operation. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + * @param createRequest (required) + * @param xRevEngApplication Identifies the calling RevEng application. Recorded on the Analysis log. (optional) + * @return ApiResponse<OperationCreateMetadataCreateResult> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + + + +
Response Details
Status Code Description Response Headers
200 OK -
201 Created -
400 Bad Request -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public ApiResponse v3GetAnalysisAutoUnstripStatusWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { - okhttp3.Call localVarCall = v3GetAnalysisAutoUnstripStatusValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse v3CreateAnalysisWithHttpInfo(@javax.annotation.Nonnull CreateRequest createRequest, @javax.annotation.Nullable String xRevEngApplication) throws ApiException { + okhttp3.Call localVarCall = v3CreateAnalysisValidateBeforeCall(createRequest, xRevEngApplication, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get the auto-unstrip status for an analysis. (asynchronously) - * Returns the status of the auto-unstrip task for the binary backing the analysis. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - * @param analysisId Analysis ID (required) + * Create an analysis (asynchronously) + * Queues a new Analysis for an uploaded Binary and returns the created Operation. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + * @param createRequest (required) + * @param xRevEngApplication Identifies the calling RevEng application. Recorded on the Analysis log. (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -3623,22 +3702,26 @@ public ApiResponse v3GetAnalysisAutoUnstripStatusWi - + + + + +
Response Details
Status Code Description Response Headers
200 OK -
201 Created -
400 Bad Request -
402 Payment Required -
403 Forbidden -
404 Not Found -
409 Conflict -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
*/ - public okhttp3.Call v3GetAnalysisAutoUnstripStatusAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3CreateAnalysisAsync(@javax.annotation.Nonnull CreateRequest createRequest, @javax.annotation.Nullable String xRevEngApplication, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3GetAnalysisAutoUnstripStatusValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = v3CreateAnalysisValidateBeforeCall(createRequest, xRevEngApplication, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for v3GetAnalysisLogs + * Build call for v3GetAnalysisAutoUnstripStatus * @param analysisId Analysis ID (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -3654,7 +3737,7 @@ public okhttp3.Call v3GetAnalysisAutoUnstripStatusAsync(@javax.annotation.Nonnul 500 Internal Server Error - */ - public okhttp3.Call v3GetAnalysisLogsCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3GetAnalysisAutoUnstripStatusCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -3671,7 +3754,7 @@ public okhttp3.Call v3GetAnalysisLogsCall(@javax.annotation.Nonnull Long analysi Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/logs" + String localVarPath = "/v3/analyses/{analysis_id}/auto-unstrip/status" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -3700,21 +3783,21 @@ public okhttp3.Call v3GetAnalysisLogsCall(@javax.annotation.Nonnull Long analysi } @SuppressWarnings("rawtypes") - private okhttp3.Call v3GetAnalysisLogsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3GetAnalysisAutoUnstripStatusValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisLogs(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisAutoUnstripStatus(Async)"); } - return v3GetAnalysisLogsCall(analysisId, _callback); + return v3GetAnalysisAutoUnstripStatusCall(analysisId, _callback); } /** - * Get the Analysis log - * Returns every log line recorded for the Analysis, oldest first, merged from every source that has written one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Get the auto-unstrip status for an analysis. + * Returns the status of the auto-unstrip task for the binary backing the analysis. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @return GetAnalysisLogsOutputBody + * @return AutoUnstripStatusOutputBody * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -3727,16 +3810,16 @@ private okhttp3.Call v3GetAnalysisLogsValidateBeforeCall(@javax.annotation.Nonnu
500 Internal Server Error -
*/ - public GetAnalysisLogsOutputBody v3GetAnalysisLogs(@javax.annotation.Nonnull Long analysisId) throws ApiException { - ApiResponse localVarResp = v3GetAnalysisLogsWithHttpInfo(analysisId); + public AutoUnstripStatusOutputBody v3GetAnalysisAutoUnstripStatus(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetAnalysisAutoUnstripStatusWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Get the Analysis log - * Returns every log line recorded for the Analysis, oldest first, merged from every source that has written one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Get the auto-unstrip status for an analysis. + * Returns the status of the auto-unstrip task for the binary backing the analysis. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @return ApiResponse<GetAnalysisLogsOutputBody> + * @return ApiResponse<AutoUnstripStatusOutputBody> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -3749,15 +3832,15 @@ public GetAnalysisLogsOutputBody v3GetAnalysisLogs(@javax.annotation.Nonnull Lon
500 Internal Server Error -
*/ - public ApiResponse v3GetAnalysisLogsWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { - okhttp3.Call localVarCall = v3GetAnalysisLogsValidateBeforeCall(analysisId, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse v3GetAnalysisAutoUnstripStatusWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetAnalysisAutoUnstripStatusValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Get the Analysis log (asynchronously) - * Returns every log line recorded for the Analysis, oldest first, merged from every source that has written one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Get the auto-unstrip status for an analysis. (asynchronously) + * Returns the status of the auto-unstrip task for the binary backing the analysis. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -3773,23 +3856,16 @@ public ApiResponse v3GetAnalysisLogsWithHttpInfo(@jav 500 Internal Server Error - */ - public okhttp3.Call v3GetAnalysisLogsAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3GetAnalysisAutoUnstripStatusAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3GetAnalysisLogsValidateBeforeCall(analysisId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = v3GetAnalysisAutoUnstripStatusValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for v3GetAnalysisStrings + * Build call for v3GetAnalysisFunctionsProgress * @param analysisId Analysis ID (required) - * @param page Page number (1-indexed). (optional, default to 1) - * @param pageSize Number of results per page. (optional, default to 100) - * @param search Filter by string value (case-insensitive substring match). (optional) - * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) - * @param functionSearch Filter by function name (case-insensitive substring match). (optional) - * @param orderBy Field to order results by. (optional, default to value) - * @param sortOrder Sort direction. (optional, default to ASC) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -3804,7 +3880,7 @@ public okhttp3.Call v3GetAnalysisLogsAsync(@javax.annotation.Nonnull Long analys 500 Internal Server Error - */ - public okhttp3.Call v3GetAnalysisStringsCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3GetAnalysisFunctionsProgressCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -3821,7 +3897,7 @@ public okhttp3.Call v3GetAnalysisStringsCall(@javax.annotation.Nonnull Long anal Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/functions/strings" + String localVarPath = "/v3/analyses/{analysis_id}/progress/functions" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -3830,34 +3906,6 @@ public okhttp3.Call v3GetAnalysisStringsCall(@javax.annotation.Nonnull Long anal Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); - if (page != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("page", page)); - } - - if (pageSize != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("page_size", pageSize)); - } - - if (search != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("search", search)); - } - - if (searchOperator != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("search_operator", searchOperator)); - } - - if (functionSearch != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("function_search", functionSearch)); - } - - if (orderBy != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("order_by", orderBy)); - } - - if (sortOrder != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("sort_order", sortOrder)); - } - final String[] localVarAccepts = { "application/json" }; @@ -3878,28 +3926,21 @@ public okhttp3.Call v3GetAnalysisStringsCall(@javax.annotation.Nonnull Long anal } @SuppressWarnings("rawtypes") - private okhttp3.Call v3GetAnalysisStringsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3GetAnalysisFunctionsProgressValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisStrings(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisFunctionsProgress(Async)"); } - return v3GetAnalysisStringsCall(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder, _callback); + return v3GetAnalysisFunctionsProgressCall(analysisId, _callback); } /** - * List strings for an analysis. - * Returns the strings discovered in an analysis, combining function-level and analysis-level strings. Supports value/function-name search, sorting and pagination. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Get function embedding progress for an analysis. + * Returns how many functions the analysis has and how many carry an embedding, with the percentage complete. Embeddings are counted from the unified store, so an analysis whose model predates the current multi-arch one reports zero. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @param page Page number (1-indexed). (optional, default to 1) - * @param pageSize Number of results per page. (optional, default to 100) - * @param search Filter by string value (case-insensitive substring match). (optional) - * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) - * @param functionSearch Filter by function name (case-insensitive substring match). (optional) - * @param orderBy Field to order results by. (optional, default to value) - * @param sortOrder Sort direction. (optional, default to ASC) - * @return ListAnalysisStringsOutputBody + * @return FunctionsProgressOutputBody * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -3912,23 +3953,16 @@ private okhttp3.Call v3GetAnalysisStringsValidateBeforeCall(@javax.annotation.No
500 Internal Server Error -
*/ - public ListAnalysisStringsOutputBody v3GetAnalysisStrings(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder) throws ApiException { - ApiResponse localVarResp = v3GetAnalysisStringsWithHttpInfo(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder); + public FunctionsProgressOutputBody v3GetAnalysisFunctionsProgress(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetAnalysisFunctionsProgressWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * List strings for an analysis. - * Returns the strings discovered in an analysis, combining function-level and analysis-level strings. Supports value/function-name search, sorting and pagination. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Get function embedding progress for an analysis. + * Returns how many functions the analysis has and how many carry an embedding, with the percentage complete. Embeddings are counted from the unified store, so an analysis whose model predates the current multi-arch one reports zero. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @param page Page number (1-indexed). (optional, default to 1) - * @param pageSize Number of results per page. (optional, default to 100) - * @param search Filter by string value (case-insensitive substring match). (optional) - * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) - * @param functionSearch Filter by function name (case-insensitive substring match). (optional) - * @param orderBy Field to order results by. (optional, default to value) - * @param sortOrder Sort direction. (optional, default to ASC) - * @return ApiResponse<ListAnalysisStringsOutputBody> + * @return ApiResponse<FunctionsProgressOutputBody> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -3941,23 +3975,16 @@ public ListAnalysisStringsOutputBody v3GetAnalysisStrings(@javax.annotation.Nonn
500 Internal Server Error -
*/ - public ApiResponse v3GetAnalysisStringsWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder) throws ApiException { - okhttp3.Call localVarCall = v3GetAnalysisStringsValidateBeforeCall(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse v3GetAnalysisFunctionsProgressWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetAnalysisFunctionsProgressValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * List strings for an analysis. (asynchronously) - * Returns the strings discovered in an analysis, combining function-level and analysis-level strings. Supports value/function-name search, sorting and pagination. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Get function embedding progress for an analysis. (asynchronously) + * Returns how many functions the analysis has and how many carry an embedding, with the percentage complete. Embeddings are counted from the unified store, so an analysis whose model predates the current multi-arch one reports zero. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @param page Page number (1-indexed). (optional, default to 1) - * @param pageSize Number of results per page. (optional, default to 100) - * @param search Filter by string value (case-insensitive substring match). (optional) - * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) - * @param functionSearch Filter by function name (case-insensitive substring match). (optional) - * @param orderBy Field to order results by. (optional, default to value) - * @param sortOrder Sort direction. (optional, default to ASC) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -3972,15 +3999,15 @@ public ApiResponse v3GetAnalysisStringsWithHttpIn 500 Internal Server Error - */ - public okhttp3.Call v3GetAnalysisStringsAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3GetAnalysisFunctionsProgressAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3GetAnalysisStringsValidateBeforeCall(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = v3GetAnalysisFunctionsProgressValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** - * Build call for v3GetAnalysisStringsStatus + * Build call for v3GetAnalysisLogs * @param analysisId Analysis ID (required) * @param _callback Callback for upload/download progress * @return Call to execute @@ -3996,7 +4023,7 @@ public okhttp3.Call v3GetAnalysisStringsAsync(@javax.annotation.Nonnull Long ana 500 Internal Server Error - */ - public okhttp3.Call v3GetAnalysisStringsStatusCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3GetAnalysisLogsCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -4013,7 +4040,7 @@ public okhttp3.Call v3GetAnalysisStringsStatusCall(@javax.annotation.Nonnull Lon Object localVarPostBody = null; // create path and map variables - String localVarPath = "/v3/analyses/{analysis_id}/functions/strings/status" + String localVarPath = "/v3/analyses/{analysis_id}/logs" .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); List localVarQueryParams = new ArrayList(); @@ -4042,21 +4069,21 @@ public okhttp3.Call v3GetAnalysisStringsStatusCall(@javax.annotation.Nonnull Lon } @SuppressWarnings("rawtypes") - private okhttp3.Call v3GetAnalysisStringsStatusValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call v3GetAnalysisLogsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'analysisId' is set if (analysisId == null) { - throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisStringsStatus(Async)"); + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisLogs(Async)"); } - return v3GetAnalysisStringsStatusCall(analysisId, _callback); + return v3GetAnalysisLogsCall(analysisId, _callback); } /** - * Get the string-extraction status for an analysis. - * Returns the status of the string-extraction task for the binary backing the analysis. One of UNINITIALISED, PENDING, RUNNING, COMPLETED, FAILED. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * Get the Analysis log + * Returns every log line recorded for the Analysis, oldest first, merged from every source that has written one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) - * @return GetAnalysisStringsStatusOutputBody + * @return GetAnalysisLogsOutputBody * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -4069,15 +4096,500 @@ private okhttp3.Call v3GetAnalysisStringsStatusValidateBeforeCall(@javax.annotat
500 Internal Server Error -
*/ - public GetAnalysisStringsStatusOutputBody v3GetAnalysisStringsStatus(@javax.annotation.Nonnull Long analysisId) throws ApiException { - ApiResponse localVarResp = v3GetAnalysisStringsStatusWithHttpInfo(analysisId); + public GetAnalysisLogsOutputBody v3GetAnalysisLogs(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetAnalysisLogsWithHttpInfo(analysisId); return localVarResp.getData(); } /** - * Get the string-extraction status for an analysis. - * Returns the status of the string-extraction task for the binary backing the analysis. One of UNINITIALISED, PENDING, RUNNING, COMPLETED, FAILED. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - * @param analysisId Analysis ID (required) + * Get the Analysis log + * Returns every log line recorded for the Analysis, oldest first, merged from every source that has written one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<GetAnalysisLogsOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetAnalysisLogsWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetAnalysisLogsValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get the Analysis log (asynchronously) + * Returns every log line recorded for the Analysis, oldest first, merged from every source that has written one. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAnalysisLogsAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetAnalysisLogsValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetAnalysisOperation + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAnalysisOperationCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/operations/analyses/{analysis_id}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetAnalysisOperationValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisOperation(Async)"); + } + + return v3GetAnalysisOperationCall(analysisId, _callback); + + } + + /** + * Get an Analysis-creation operation + * Polls the status of an Analysis-creation operation. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return OperationCreateMetadataCreateResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public OperationCreateMetadataCreateResult v3GetAnalysisOperation(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetAnalysisOperationWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get an Analysis-creation operation + * Polls the status of an Analysis-creation operation. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return ApiResponse<OperationCreateMetadataCreateResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetAnalysisOperationWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3GetAnalysisOperationValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get an Analysis-creation operation (asynchronously) + * Polls the status of an Analysis-creation operation. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAnalysisOperationAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetAnalysisOperationValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetAnalysisStrings + * @param analysisId Analysis ID (required) + * @param page Page number (1-indexed). (optional, default to 1) + * @param pageSize Number of results per page. (optional, default to 100) + * @param search Filter by string value (case-insensitive substring match). (optional) + * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) + * @param functionSearch Filter by function name (case-insensitive substring match). (optional) + * @param orderBy Field to order results by. (optional, default to value) + * @param sortOrder Sort direction. (optional, default to ASC) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAnalysisStringsCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/functions/strings" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (page != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("page", page)); + } + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("page_size", pageSize)); + } + + if (search != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("search", search)); + } + + if (searchOperator != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("search_operator", searchOperator)); + } + + if (functionSearch != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("function_search", functionSearch)); + } + + if (orderBy != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("order_by", orderBy)); + } + + if (sortOrder != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sort_order", sortOrder)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetAnalysisStringsValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisStrings(Async)"); + } + + return v3GetAnalysisStringsCall(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder, _callback); + + } + + /** + * List strings for an analysis. + * Returns the strings discovered in an analysis, combining function-level and analysis-level strings. Supports value/function-name search, sorting and pagination. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param page Page number (1-indexed). (optional, default to 1) + * @param pageSize Number of results per page. (optional, default to 100) + * @param search Filter by string value (case-insensitive substring match). (optional) + * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) + * @param functionSearch Filter by function name (case-insensitive substring match). (optional) + * @param orderBy Field to order results by. (optional, default to value) + * @param sortOrder Sort direction. (optional, default to ASC) + * @return ListAnalysisStringsOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ListAnalysisStringsOutputBody v3GetAnalysisStrings(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder) throws ApiException { + ApiResponse localVarResp = v3GetAnalysisStringsWithHttpInfo(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder); + return localVarResp.getData(); + } + + /** + * List strings for an analysis. + * Returns the strings discovered in an analysis, combining function-level and analysis-level strings. Supports value/function-name search, sorting and pagination. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param page Page number (1-indexed). (optional, default to 1) + * @param pageSize Number of results per page. (optional, default to 100) + * @param search Filter by string value (case-insensitive substring match). (optional) + * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) + * @param functionSearch Filter by function name (case-insensitive substring match). (optional) + * @param orderBy Field to order results by. (optional, default to value) + * @param sortOrder Sort direction. (optional, default to ASC) + * @return ApiResponse<ListAnalysisStringsOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetAnalysisStringsWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder) throws ApiException { + okhttp3.Call localVarCall = v3GetAnalysisStringsValidateBeforeCall(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List strings for an analysis. (asynchronously) + * Returns the strings discovered in an analysis, combining function-level and analysis-level strings. Supports value/function-name search, sorting and pagination. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @param page Page number (1-indexed). (optional, default to 1) + * @param pageSize Number of results per page. (optional, default to 100) + * @param search Filter by string value (case-insensitive substring match). (optional) + * @param searchOperator How the search term matches string values. (optional, default to CONTAINS) + * @param functionSearch Filter by function name (case-insensitive substring match). (optional) + * @param orderBy Field to order results by. (optional, default to value) + * @param sortOrder Sort direction. (optional, default to ASC) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAnalysisStringsAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nullable Long page, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String search, @javax.annotation.Nullable String searchOperator, @javax.annotation.Nullable String functionSearch, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String sortOrder, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetAnalysisStringsValidateBeforeCall(analysisId, page, pageSize, search, searchOperator, functionSearch, orderBy, sortOrder, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetAnalysisStringsStatus + * @param analysisId Analysis ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAnalysisStringsStatusCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/functions/strings/status" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetAnalysisStringsStatusValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3GetAnalysisStringsStatus(Async)"); + } + + return v3GetAnalysisStringsStatusCall(analysisId, _callback); + + } + + /** + * Get the string-extraction status for an analysis. + * Returns the status of the string-extraction task for the binary backing the analysis. One of UNINITIALISED, PENDING, RUNNING, COMPLETED, FAILED. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) + * @return GetAnalysisStringsStatusOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public GetAnalysisStringsStatusOutputBody v3GetAnalysisStringsStatus(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3GetAnalysisStringsStatusWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Get the string-extraction status for an analysis. + * Returns the status of the string-extraction task for the binary backing the analysis. One of UNINITIALISED, PENDING, RUNNING, COMPLETED, FAILED. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param analysisId Analysis ID (required) * @return ApiResponse<GetAnalysisStringsStatusOutputBody> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -4125,11 +4637,13 @@ public okhttp3.Call v3GetAnalysisStringsStatusAsync(@javax.annotation.Nonnull Lo /** * Build call for v3ListAnalyses * @param searchTerm (optional) - * @param analysisScope Leave empty for no filter (optional) + * @param analysisScope Leave empty to search your own, your team's and all public analyses (optional) * @param status (optional) * @param modelName (optional) * @param usernames (optional) * @param sha256Hash (optional) + * @param platform Restrict to binaries running on one of these operating-system platforms. Matches the uploader's override when they set one, the detected platform otherwise; a binary with neither is never matched. Leave empty for no filter (optional) + * @param architecture Restrict to binaries built for one of these instruction-set architectures. Resolved the same way as platform. Leave empty for no filter (optional) * @param pageSize (optional, default to 20) * @param nextPageToken Forward-pagination cursor from a prior response. When set, order_by/order are taken from the token (the sort cannot change mid-pagination). (optional) * @param orderBy (optional, default to created) @@ -4147,7 +4661,7 @@ public okhttp3.Call v3GetAnalysisStringsStatusAsync(@javax.annotation.Nonnull Lo 500 Internal Server Error - */ - public okhttp3.Call v3ListAnalysesCall(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3ListAnalysesCall(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable List platform, @javax.annotation.Nullable List architecture, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -4196,6 +4710,14 @@ public okhttp3.Call v3ListAnalysesCall(@javax.annotation.Nullable String searchT localVarQueryParams.addAll(localVarApiClient.parameterToPair("sha256_hash", sha256Hash)); } + if (platform != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "platform", platform)); + } + + if (architecture != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "architecture", architecture)); + } + if (pageSize != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("page_size", pageSize)); } @@ -4232,8 +4754,8 @@ public okhttp3.Call v3ListAnalysesCall(@javax.annotation.Nullable String searchT } @SuppressWarnings("rawtypes") - private okhttp3.Call v3ListAnalysesValidateBeforeCall(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order, final ApiCallback _callback) throws ApiException { - return v3ListAnalysesCall(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, pageSize, nextPageToken, orderBy, order, _callback); + private okhttp3.Call v3ListAnalysesValidateBeforeCall(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable List platform, @javax.annotation.Nullable List architecture, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order, final ApiCallback _callback) throws ApiException { + return v3ListAnalysesCall(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, platform, architecture, pageSize, nextPageToken, orderBy, order, _callback); } @@ -4241,11 +4763,13 @@ private okhttp3.Call v3ListAnalysesValidateBeforeCall(@javax.annotation.Nullable * List analyses * Returns a page of analyses visible to the caller, filtered and ordered by the query parameters. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request * @param searchTerm (optional) - * @param analysisScope Leave empty for no filter (optional) + * @param analysisScope Leave empty to search your own, your team's and all public analyses (optional) * @param status (optional) * @param modelName (optional) * @param usernames (optional) * @param sha256Hash (optional) + * @param platform Restrict to binaries running on one of these operating-system platforms. Matches the uploader's override when they set one, the detected platform otherwise; a binary with neither is never matched. Leave empty for no filter (optional) + * @param architecture Restrict to binaries built for one of these instruction-set architectures. Resolved the same way as platform. Leave empty for no filter (optional) * @param pageSize (optional, default to 20) * @param nextPageToken Forward-pagination cursor from a prior response. When set, order_by/order are taken from the token (the sort cannot change mid-pagination). (optional) * @param orderBy (optional, default to created) @@ -4262,8 +4786,8 @@ private okhttp3.Call v3ListAnalysesValidateBeforeCall(@javax.annotation.Nullable 500 Internal Server Error - */ - public ListAnalysesOutputBody v3ListAnalyses(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order) throws ApiException { - ApiResponse localVarResp = v3ListAnalysesWithHttpInfo(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, pageSize, nextPageToken, orderBy, order); + public ListAnalysesOutputBody v3ListAnalyses(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable List platform, @javax.annotation.Nullable List architecture, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order) throws ApiException { + ApiResponse localVarResp = v3ListAnalysesWithHttpInfo(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, platform, architecture, pageSize, nextPageToken, orderBy, order); return localVarResp.getData(); } @@ -4271,11 +4795,13 @@ public ListAnalysesOutputBody v3ListAnalyses(@javax.annotation.Nullable String s * List analyses * Returns a page of analyses visible to the caller, filtered and ordered by the query parameters. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request * @param searchTerm (optional) - * @param analysisScope Leave empty for no filter (optional) + * @param analysisScope Leave empty to search your own, your team's and all public analyses (optional) * @param status (optional) * @param modelName (optional) * @param usernames (optional) * @param sha256Hash (optional) + * @param platform Restrict to binaries running on one of these operating-system platforms. Matches the uploader's override when they set one, the detected platform otherwise; a binary with neither is never matched. Leave empty for no filter (optional) + * @param architecture Restrict to binaries built for one of these instruction-set architectures. Resolved the same way as platform. Leave empty for no filter (optional) * @param pageSize (optional, default to 20) * @param nextPageToken Forward-pagination cursor from a prior response. When set, order_by/order are taken from the token (the sort cannot change mid-pagination). (optional) * @param orderBy (optional, default to created) @@ -4292,8 +4818,8 @@ public ListAnalysesOutputBody v3ListAnalyses(@javax.annotation.Nullable String s 500 Internal Server Error - */ - public ApiResponse v3ListAnalysesWithHttpInfo(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order) throws ApiException { - okhttp3.Call localVarCall = v3ListAnalysesValidateBeforeCall(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, pageSize, nextPageToken, orderBy, order, null); + public ApiResponse v3ListAnalysesWithHttpInfo(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable List platform, @javax.annotation.Nullable List architecture, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order) throws ApiException { + okhttp3.Call localVarCall = v3ListAnalysesValidateBeforeCall(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, platform, architecture, pageSize, nextPageToken, orderBy, order, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -4302,11 +4828,13 @@ public ApiResponse v3ListAnalysesWithHttpInfo(@javax.ann * List analyses (asynchronously) * Returns a page of analyses visible to the caller, filtered and ordered by the query parameters. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request * @param searchTerm (optional) - * @param analysisScope Leave empty for no filter (optional) + * @param analysisScope Leave empty to search your own, your team's and all public analyses (optional) * @param status (optional) * @param modelName (optional) * @param usernames (optional) * @param sha256Hash (optional) + * @param platform Restrict to binaries running on one of these operating-system platforms. Matches the uploader's override when they set one, the detected platform otherwise; a binary with neither is never matched. Leave empty for no filter (optional) + * @param architecture Restrict to binaries built for one of these instruction-set architectures. Resolved the same way as platform. Leave empty for no filter (optional) * @param pageSize (optional, default to 20) * @param nextPageToken Forward-pagination cursor from a prior response. When set, order_by/order are taken from the token (the sort cannot change mid-pagination). (optional) * @param orderBy (optional, default to created) @@ -4324,9 +4852,9 @@ public ApiResponse v3ListAnalysesWithHttpInfo(@javax.ann 500 Internal Server Error - */ - public okhttp3.Call v3ListAnalysesAsync(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order, final ApiCallback _callback) throws ApiException { + public okhttp3.Call v3ListAnalysesAsync(@javax.annotation.Nullable String searchTerm, @javax.annotation.Nullable List analysisScope, @javax.annotation.Nullable List status, @javax.annotation.Nullable List modelName, @javax.annotation.Nullable List usernames, @javax.annotation.Nullable String sha256Hash, @javax.annotation.Nullable List platform, @javax.annotation.Nullable List architecture, @javax.annotation.Nullable Long pageSize, @javax.annotation.Nullable String nextPageToken, @javax.annotation.Nullable String orderBy, @javax.annotation.Nullable String order, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = v3ListAnalysesValidateBeforeCall(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, pageSize, nextPageToken, orderBy, order, _callback); + okhttp3.Call localVarCall = v3ListAnalysesValidateBeforeCall(searchTerm, analysisScope, status, modelName, usernames, sha256Hash, platform, architecture, pageSize, nextPageToken, orderBy, order, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -4452,4 +4980,151 @@ public okhttp3.Call v3ListExampleAnalysesAsync(final ApiCallback + Response Details + Status Code Description Response Headers + 201 Created - + 403 Forbidden - + 404 Not Found - + 409 Conflict - + 422 Unprocessable Entity - + 500 Internal Server Error - + + */ + public okhttp3.Call v3UpgradeAnalysisModelCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/analyses/{analysis_id}/upgrade-model" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3UpgradeAnalysisModelValidateBeforeCall(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'analysisId' is set + if (analysisId == null) { + throw new ApiException("Missing the required parameter 'analysisId' when calling v3UpgradeAnalysisModel(Async)"); + } + + return v3UpgradeAnalysisModelCall(analysisId, _callback); + + } + + /** + * Re-analyse on the latest model + * Re-runs an analysis created on an older model against the current unified model, in place — the analysis ID does not change. No credits are consumed. Only the owner may call it, and only once the analysis has settled: the pipeline clears the binary's functions, names, data types and signatures before re-running. Returns 409 if the analysis is already on the latest model, or is still running. Poll `GET /v3/analyses/{analysis_id}/basic` for status, as with any other run. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @return UpgradeAnalysisModelOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public UpgradeAnalysisModelOutputBody v3UpgradeAnalysisModel(@javax.annotation.Nonnull Long analysisId) throws ApiException { + ApiResponse localVarResp = v3UpgradeAnalysisModelWithHttpInfo(analysisId); + return localVarResp.getData(); + } + + /** + * Re-analyse on the latest model + * Re-runs an analysis created on an older model against the current unified model, in place — the analysis ID does not change. No credits are consumed. Only the owner may call it, and only once the analysis has settled: the pipeline clears the binary's functions, names, data types and signatures before re-running. Returns 409 if the analysis is already on the latest model, or is still running. Poll `GET /v3/analyses/{analysis_id}/basic` for status, as with any other run. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @return ApiResponse<UpgradeAnalysisModelOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3UpgradeAnalysisModelWithHttpInfo(@javax.annotation.Nonnull Long analysisId) throws ApiException { + okhttp3.Call localVarCall = v3UpgradeAnalysisModelValidateBeforeCall(analysisId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Re-analyse on the latest model (asynchronously) + * Re-runs an analysis created on an older model against the current unified model, in place — the analysis ID does not change. No credits are consumed. Only the owner may call it, and only once the analysis has settled: the pipeline clears the binary's functions, names, data types and signatures before re-running. Returns 409 if the analysis is already on the latest model, or is still running. Poll `GET /v3/analyses/{analysis_id}/basic` for status, as with any other run. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict + * @param analysisId Analysis ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
403 Forbidden -
404 Not Found -
409 Conflict -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3UpgradeAnalysisModelAsync(@javax.annotation.Nonnull Long analysisId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3UpgradeAnalysisModelValidateBeforeCall(analysisId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } } diff --git a/src/main/java/ai/reveng/api/BinariesApi.java b/src/main/java/ai/reveng/api/BinariesApi.java index e532d650..ec3ad00f 100644 --- a/src/main/java/ai/reveng/api/BinariesApi.java +++ b/src/main/java/ai/reveng/api/BinariesApi.java @@ -38,6 +38,10 @@ import java.io.File; import ai.reveng.model.GetAdditionalDetailsOutputBody; import ai.reveng.model.GetAdditionalDetailsStatusOutputBody; +import ai.reveng.model.GetDieInfoOutputBody; +import ai.reveng.model.GetRelatedBinariesOutputBody; +import ai.reveng.model.GetRelatedStatusOutputBody; +import ai.reveng.model.UploadOutputBody; import java.lang.reflect.Type; import java.util.ArrayList; @@ -1439,4 +1443,601 @@ public okhttp3.Call getRelatedBinariesAsync(@javax.annotation.Nonnull Integer bi localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for v3GetBinaryDieInfo + * @param binaryId Binary ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryDieInfoCall(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/binaries/{binary_id}/die-info" + .replace("{" + "binary_id" + "}", localVarApiClient.escapeString(binaryId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetBinaryDieInfoValidateBeforeCall(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'binaryId' is set + if (binaryId == null) { + throw new ApiException("Missing the required parameter 'binaryId' when calling v3GetBinaryDieInfo(Async)"); + } + + return v3GetBinaryDieInfoCall(binaryId, _callback); + + } + + /** + * Get Detect It Easy matches for a binary. + * Returns the signatures Detect It Easy recognised in the binary — packers, compilers and file types — with the version it could extract. Empty when detection has not run or recognised nothing. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @return GetDieInfoOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public GetDieInfoOutputBody v3GetBinaryDieInfo(@javax.annotation.Nonnull Long binaryId) throws ApiException { + ApiResponse localVarResp = v3GetBinaryDieInfoWithHttpInfo(binaryId); + return localVarResp.getData(); + } + + /** + * Get Detect It Easy matches for a binary. + * Returns the signatures Detect It Easy recognised in the binary — packers, compilers and file types — with the version it could extract. Empty when detection has not run or recognised nothing. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @return ApiResponse<GetDieInfoOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetBinaryDieInfoWithHttpInfo(@javax.annotation.Nonnull Long binaryId) throws ApiException { + okhttp3.Call localVarCall = v3GetBinaryDieInfoValidateBeforeCall(binaryId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Detect It Easy matches for a binary. (asynchronously) + * Returns the signatures Detect It Easy recognised in the binary — packers, compilers and file types — with the version it could extract. Empty when detection has not run or recognised nothing. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryDieInfoAsync(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetBinaryDieInfoValidateBeforeCall(binaryId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetBinaryRelated + * @param binaryId Binary ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryRelatedCall(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/binaries/{binary_id}/related" + .replace("{" + "binary_id" + "}", localVarApiClient.escapeString(binaryId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetBinaryRelatedValidateBeforeCall(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'binaryId' is set + if (binaryId == null) { + throw new ApiException("Missing the required parameter 'binaryId' when calling v3GetBinaryRelated(Async)"); + } + + return v3GetBinaryRelatedCall(binaryId, _callback); + + } + + /** + * Get the binaries related to this one by unpacking. + * Returns the binaries unpacked out of this one, and the archive it came out of when it was not uploaded directly. A related binary that has never been analysed carries a null `analysis_id`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @return GetRelatedBinariesOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public GetRelatedBinariesOutputBody v3GetBinaryRelated(@javax.annotation.Nonnull Long binaryId) throws ApiException { + ApiResponse localVarResp = v3GetBinaryRelatedWithHttpInfo(binaryId); + return localVarResp.getData(); + } + + /** + * Get the binaries related to this one by unpacking. + * Returns the binaries unpacked out of this one, and the archive it came out of when it was not uploaded directly. A related binary that has never been analysed carries a null `analysis_id`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @return ApiResponse<GetRelatedBinariesOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetBinaryRelatedWithHttpInfo(@javax.annotation.Nonnull Long binaryId) throws ApiException { + okhttp3.Call localVarCall = v3GetBinaryRelatedValidateBeforeCall(binaryId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get the binaries related to this one by unpacking. (asynchronously) + * Returns the binaries unpacked out of this one, and the archive it came out of when it was not uploaded directly. A related binary that has never been analysed carries a null `analysis_id`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryRelatedAsync(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetBinaryRelatedValidateBeforeCall(binaryId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetBinaryRelatedStatus + * @param binaryId Binary ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryRelatedStatusCall(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/binaries/{binary_id}/related/status" + .replace("{" + "binary_id" + "}", localVarApiClient.escapeString(binaryId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetBinaryRelatedStatusValidateBeforeCall(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'binaryId' is set + if (binaryId == null) { + throw new ApiException("Missing the required parameter 'binaryId' when calling v3GetBinaryRelatedStatus(Async)"); + } + + return v3GetBinaryRelatedStatusCall(binaryId, _callback); + + } + + /** + * Get the archive-unpacking status for a binary. + * Returns the status of the task that unpacks an archive into its contents, which is what decides whether the related-binary list is still filling up. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @return GetRelatedStatusOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public GetRelatedStatusOutputBody v3GetBinaryRelatedStatus(@javax.annotation.Nonnull Long binaryId) throws ApiException { + ApiResponse localVarResp = v3GetBinaryRelatedStatusWithHttpInfo(binaryId); + return localVarResp.getData(); + } + + /** + * Get the archive-unpacking status for a binary. + * Returns the status of the task that unpacks an archive into its contents, which is what decides whether the related-binary list is still filling up. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @return ApiResponse<GetRelatedStatusOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetBinaryRelatedStatusWithHttpInfo(@javax.annotation.Nonnull Long binaryId) throws ApiException { + okhttp3.Call localVarCall = v3GetBinaryRelatedStatusValidateBeforeCall(binaryId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get the archive-unpacking status for a binary. (asynchronously) + * Returns the status of the task that unpacks an archive into its contents, which is what decides whether the related-binary list is still filling up. One of `UNINITIALISED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied + * @param binaryId Binary ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetBinaryRelatedStatusAsync(@javax.annotation.Nonnull Long binaryId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetBinaryRelatedStatusValidateBeforeCall(binaryId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3UploadFile + * @param _file The file's raw bytes. (required) + * @param uploadFileType The kind of file being uploaded. (required) + * @param forceOverwrite Re-upload and overwrite even if a file with this hash already exists. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3UploadFileCall(@javax.annotation.Nonnull File _file, @javax.annotation.Nonnull String uploadFileType, @javax.annotation.Nullable Boolean forceOverwrite, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/upload"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (_file != null) { + localVarFormParams.put("file", _file); + } + + if (forceOverwrite != null) { + localVarFormParams.put("force_overwrite", forceOverwrite); + } + + if (uploadFileType != null) { + localVarFormParams.put("upload_file_type", uploadFileType); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3UploadFileValidateBeforeCall(@javax.annotation.Nonnull File _file, @javax.annotation.Nonnull String uploadFileType, @javax.annotation.Nullable Boolean forceOverwrite, final ApiCallback _callback) throws ApiException { + // verify the required parameter '_file' is set + if (_file == null) { + throw new ApiException("Missing the required parameter '_file' when calling v3UploadFile(Async)"); + } + + // verify the required parameter 'uploadFileType' is set + if (uploadFileType == null) { + throw new ApiException("Missing the required parameter 'uploadFileType' when calling v3UploadFile(Async)"); + } + + return v3UploadFileCall(_file, uploadFileType, forceOverwrite, _callback); + + } + + /** + * Upload a file. + * Uploads a binary, debug symbol, packed sample, or firmware image, keyed by its SHA-256 hash. A BINARY upload from a non-system caller also detects the file's architecture and OS so POST /v3/analyses knows whether it can run static analysis. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + * @param _file The file's raw bytes. (required) + * @param uploadFileType The kind of file being uploaded. (required) + * @param forceOverwrite Re-upload and overwrite even if a file with this hash already exists. (optional) + * @return UploadOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public UploadOutputBody v3UploadFile(@javax.annotation.Nonnull File _file, @javax.annotation.Nonnull String uploadFileType, @javax.annotation.Nullable Boolean forceOverwrite) throws ApiException { + ApiResponse localVarResp = v3UploadFileWithHttpInfo(_file, uploadFileType, forceOverwrite); + return localVarResp.getData(); + } + + /** + * Upload a file. + * Uploads a binary, debug symbol, packed sample, or firmware image, keyed by its SHA-256 hash. A BINARY upload from a non-system caller also detects the file's architecture and OS so POST /v3/analyses knows whether it can run static analysis. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + * @param _file The file's raw bytes. (required) + * @param uploadFileType The kind of file being uploaded. (required) + * @param forceOverwrite Re-upload and overwrite even if a file with this hash already exists. (optional) + * @return ApiResponse<UploadOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3UploadFileWithHttpInfo(@javax.annotation.Nonnull File _file, @javax.annotation.Nonnull String uploadFileType, @javax.annotation.Nullable Boolean forceOverwrite) throws ApiException { + okhttp3.Call localVarCall = v3UploadFileValidateBeforeCall(_file, uploadFileType, forceOverwrite, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Upload a file. (asynchronously) + * Uploads a binary, debug symbol, packed sample, or firmware image, keyed by its SHA-256 hash. A BINARY upload from a non-system caller also detects the file's architecture and OS so POST /v3/analyses knows whether it can run static analysis. **Error codes:** - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `413` [`REQUEST_ENTITY_TOO_LARGE`](/errors/REQUEST_ENTITY_TOO_LARGE) — Request Entity Too Large + * @param _file The file's raw bytes. (required) + * @param uploadFileType The kind of file being uploaded. (required) + * @param forceOverwrite Re-upload and overwrite even if a file with this hash already exists. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
413 Request Entity Too Large -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3UploadFileAsync(@javax.annotation.Nonnull File _file, @javax.annotation.Nonnull String uploadFileType, @javax.annotation.Nullable Boolean forceOverwrite, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3UploadFileValidateBeforeCall(_file, uploadFileType, forceOverwrite, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } } diff --git a/src/main/java/ai/reveng/api/ConfigApi.java b/src/main/java/ai/reveng/api/ConfigApi.java index 207e5e17..861766e4 100644 --- a/src/main/java/ai/reveng/api/ConfigApi.java +++ b/src/main/java/ai/reveng/api/ConfigApi.java @@ -26,8 +26,11 @@ import java.io.IOException; +import ai.reveng.model.APIError; import ai.reveng.model.BaseResponse; import ai.reveng.model.BaseResponseConfigResponse; +import ai.reveng.model.GetConfigOutputBody; +import ai.reveng.model.GetModelsOutputBody; import java.lang.reflect.Type; import java.util.ArrayList; @@ -193,4 +196,246 @@ public okhttp3.Call getConfigAsync(final ApiCallback localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for v3GetConfig + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
0 Error -
+ */ + public okhttp3.Call v3GetConfigCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/config"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetConfigValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return v3GetConfigCall(_callback); + + } + + /** + * Get client configuration. + * Returns the settings a client needs to configure itself: where to send users to view results, the largest binary the calling user may submit, and what AI decompilation supports. The size limit reflects the caller's own role and tier. + * @return GetConfigOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
0 Error -
+ */ + public GetConfigOutputBody v3GetConfig() throws ApiException { + ApiResponse localVarResp = v3GetConfigWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * Get client configuration. + * Returns the settings a client needs to configure itself: where to send users to view results, the largest binary the calling user may submit, and what AI decompilation supports. The size limit reflects the caller's own role and tier. + * @return ApiResponse<GetConfigOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
0 Error -
+ */ + public ApiResponse v3GetConfigWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = v3GetConfigValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get client configuration. (asynchronously) + * Returns the settings a client needs to configure itself: where to send users to view results, the largest binary the calling user may submit, and what AI decompilation supports. The size limit reflects the caller's own role and tier. + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
0 Error -
+ */ + public okhttp3.Call v3GetConfigAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetConfigValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for v3GetModels + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetModelsCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/models"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetModelsValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return v3GetModelsCall(_callback); + + } + + /** + * Get the models available for analysis. + * Returns the models a new analysis can be run on, by base name — the architecture and platform variants a model is built for are collapsed into one entry, and models no longer offered are omitted. **Error codes:** - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + * @return GetModelsOutputBody + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
500 Internal Server Error -
+ */ + public GetModelsOutputBody v3GetModels() throws ApiException { + ApiResponse localVarResp = v3GetModelsWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * Get the models available for analysis. + * Returns the models a new analysis can be run on, by base name — the architecture and platform variants a model is built for are collapsed into one entry, and models no longer offered are omitted. **Error codes:** - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + * @return ApiResponse<GetModelsOutputBody> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
500 Internal Server Error -
+ */ + public ApiResponse v3GetModelsWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = v3GetModelsValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get the models available for analysis. (asynchronously) + * Returns the models a new analysis can be run on, by base name — the architecture and platform variants a model is built for are collapsed into one entry, and models no longer offered are omitted. **Error codes:** - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetModelsAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetModelsValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } } diff --git a/src/main/java/ai/reveng/api/FirmwareApi.java b/src/main/java/ai/reveng/api/FirmwareApi.java deleted file mode 100644 index f20d8d6e..00000000 --- a/src/main/java/ai/reveng/api/FirmwareApi.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.api; - -import ai.reveng.invoker.ApiCallback; -import ai.reveng.invoker.ApiClient; -import ai.reveng.invoker.ApiException; -import ai.reveng.invoker.ApiResponse; -import ai.reveng.invoker.Configuration; -import ai.reveng.invoker.Pair; -import ai.reveng.invoker.ProgressRequestBody; -import ai.reveng.invoker.ProgressResponseBody; - -import com.google.gson.reflect.TypeToken; - -import java.io.IOException; - - -import ai.reveng.model.BaseResponse; -import java.io.File; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class FirmwareApi { - private ApiClient localVarApiClient; - private int localHostIndex; - private String localCustomBaseUrl; - - public FirmwareApi() { - this(Configuration.getDefaultApiClient()); - } - - public FirmwareApi(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public ApiClient getApiClient() { - return localVarApiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public int getHostIndex() { - return localHostIndex; - } - - public void setHostIndex(int hostIndex) { - this.localHostIndex = hostIndex; - } - - public String getCustomBaseUrl() { - return localCustomBaseUrl; - } - - public void setCustomBaseUrl(String customBaseUrl) { - this.localCustomBaseUrl = customBaseUrl; - } - - /** - * Build call for getBinariesForFirmwareTask - * @param taskId (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - -
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
- */ - public okhttp3.Call getBinariesForFirmwareTaskCall(@javax.annotation.Nonnull String taskId, final ApiCallback _callback) throws ApiException { - String basePath = null; - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v2/firmware/get-binaries/{task_id}" - .replace("{" + "task_id" + "}", localVarApiClient.escapeString(taskId.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getBinariesForFirmwareTaskValidateBeforeCall(@javax.annotation.Nonnull String taskId, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'taskId' is set - if (taskId == null) { - throw new ApiException("Missing the required parameter 'taskId' when calling getBinariesForFirmwareTask(Async)"); - } - - return getBinariesForFirmwareTaskCall(taskId, _callback); - - } - - /** - * Upload firmware for unpacking - * Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - * @param taskId (required) - * @return Object - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
- */ - public Object getBinariesForFirmwareTask(@javax.annotation.Nonnull String taskId) throws ApiException { - ApiResponse localVarResp = getBinariesForFirmwareTaskWithHttpInfo(taskId); - return localVarResp.getData(); - } - - /** - * Upload firmware for unpacking - * Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - * @param taskId (required) - * @return ApiResponse<Object> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
- */ - public ApiResponse getBinariesForFirmwareTaskWithHttpInfo(@javax.annotation.Nonnull String taskId) throws ApiException { - okhttp3.Call localVarCall = getBinariesForFirmwareTaskValidateBeforeCall(taskId, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Upload firmware for unpacking (asynchronously) - * Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - * @param taskId (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - -
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
- */ - public okhttp3.Call getBinariesForFirmwareTaskAsync(@javax.annotation.Nonnull String taskId, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = getBinariesForFirmwareTaskValidateBeforeCall(taskId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - /** - * Build call for uploadFirmware - * @param _file (required) - * @param password (optional) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - - -
Response Details
Status Code Description Response Headers
201 Successful Response -
422 Unprocessable Entity -
500 Internal Server Error -
- */ - public okhttp3.Call uploadFirmwareCall(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { - String basePath = null; - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v2/firmware"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - if (_file != null) { - localVarFormParams.put("file", _file); - } - - if (password != null) { - localVarFormParams.put("password", password); - } - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - "multipart/form-data" - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFirmwareValidateBeforeCall(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { - // verify the required parameter '_file' is set - if (_file == null) { - throw new ApiException("Missing the required parameter '_file' when calling uploadFirmware(Async)"); - } - - return uploadFirmwareCall(_file, password, _callback); - - } - - /** - * Upload firmware for unpacking - * Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - * @param _file (required) - * @param password (optional) - * @return Object - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - - -
Response Details
Status Code Description Response Headers
201 Successful Response -
422 Unprocessable Entity -
500 Internal Server Error -
- */ - public Object uploadFirmware(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password) throws ApiException { - ApiResponse localVarResp = uploadFirmwareWithHttpInfo(_file, password); - return localVarResp.getData(); - } - - /** - * Upload firmware for unpacking - * Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - * @param _file (required) - * @param password (optional) - * @return ApiResponse<Object> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - - -
Response Details
Status Code Description Response Headers
201 Successful Response -
422 Unprocessable Entity -
500 Internal Server Error -
- */ - public ApiResponse uploadFirmwareWithHttpInfo(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password) throws ApiException { - okhttp3.Call localVarCall = uploadFirmwareValidateBeforeCall(_file, password, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Upload firmware for unpacking (asynchronously) - * Uploads a firmware file and begins a 'Firmware Unpacker' task. Returns a result identifier, which can be used to poll for the response. - * @param _file (required) - * @param password (optional) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - - -
Response Details
Status Code Description Response Headers
201 Successful Response -
422 Unprocessable Entity -
500 Internal Server Error -
- */ - public okhttp3.Call uploadFirmwareAsync(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = uploadFirmwareValidateBeforeCall(_file, password, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } -} diff --git a/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java b/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java index fdbbbf8e..064f45c2 100644 --- a/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java +++ b/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java @@ -38,6 +38,7 @@ import ai.reveng.model.RegenerateOutputBody; import ai.reveng.model.ServerSentEventsInner1; import ai.reveng.model.SummaryData; +import ai.reveng.model.TypeSuggestionsData; import ai.reveng.model.UpsertAiDecomplationRatingRequest; import ai.reveng.model.UpsertOverridesData; import ai.reveng.model.UpsertOverridesInputBody; @@ -90,6 +91,7 @@ public void setCustomBaseUrl(String customBaseUrl) { * Build call for createAiDecompilation * @param functionId Function ID (required) * @param temperature LLM temperature (0.0-1.0). Overrides the server default when set. Omit or set to -1 to use the server default. (optional, default to -1) + * @param typeSuggestions Ask the language model to name the suggested types and their members. Set to false to skip the model call; the statically derived layouts are still computed and stored. Cannot re-enable the pass when the server has it off. (optional, default to true) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -106,7 +108,7 @@ public void setCustomBaseUrl(String customBaseUrl) { 500 Internal Server Error - */ - public okhttp3.Call createAiDecompilationCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createAiDecompilationCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, @javax.annotation.Nullable Boolean typeSuggestions, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -136,6 +138,10 @@ public okhttp3.Call createAiDecompilationCall(@javax.annotation.Nonnull Long fun localVarQueryParams.addAll(localVarApiClient.parameterToPair("temperature", temperature)); } + if (typeSuggestions != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("type_suggestions", typeSuggestions)); + } + final String[] localVarAccepts = { "application/json" }; @@ -156,13 +162,13 @@ public okhttp3.Call createAiDecompilationCall(@javax.annotation.Nonnull Long fun } @SuppressWarnings("rawtypes") - private okhttp3.Call createAiDecompilationValidateBeforeCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, final ApiCallback _callback) throws ApiException { + private okhttp3.Call createAiDecompilationValidateBeforeCall(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, @javax.annotation.Nullable Boolean typeSuggestions, final ApiCallback _callback) throws ApiException { // verify the required parameter 'functionId' is set if (functionId == null) { throw new ApiException("Missing the required parameter 'functionId' when calling createAiDecompilation(Async)"); } - return createAiDecompilationCall(functionId, temperature, _callback); + return createAiDecompilationCall(functionId, temperature, typeSuggestions, _callback); } @@ -171,6 +177,7 @@ private okhttp3.Call createAiDecompilationValidateBeforeCall(@javax.annotation.N * Begins the AI decompilation process for a function. Charges team credits and starts the workflow. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param functionId Function ID (required) * @param temperature LLM temperature (0.0-1.0). Overrides the server default when set. Omit or set to -1 to use the server default. (optional, default to -1) + * @param typeSuggestions Ask the language model to name the suggested types and their members. Set to false to skip the model call; the statically derived layouts are still computed and stored. Cannot re-enable the pass when the server has it off. (optional, default to true) * @return CreateAIDecompOutputBody * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -186,8 +193,8 @@ private okhttp3.Call createAiDecompilationValidateBeforeCall(@javax.annotation.N 500 Internal Server Error - */ - public CreateAIDecompOutputBody createAiDecompilation(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature) throws ApiException { - ApiResponse localVarResp = createAiDecompilationWithHttpInfo(functionId, temperature); + public CreateAIDecompOutputBody createAiDecompilation(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, @javax.annotation.Nullable Boolean typeSuggestions) throws ApiException { + ApiResponse localVarResp = createAiDecompilationWithHttpInfo(functionId, temperature, typeSuggestions); return localVarResp.getData(); } @@ -196,6 +203,7 @@ public CreateAIDecompOutputBody createAiDecompilation(@javax.annotation.Nonnull * Begins the AI decompilation process for a function. Charges team credits and starts the workflow. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param functionId Function ID (required) * @param temperature LLM temperature (0.0-1.0). Overrides the server default when set. Omit or set to -1 to use the server default. (optional, default to -1) + * @param typeSuggestions Ask the language model to name the suggested types and their members. Set to false to skip the model call; the statically derived layouts are still computed and stored. Cannot re-enable the pass when the server has it off. (optional, default to true) * @return ApiResponse<CreateAIDecompOutputBody> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -211,8 +219,8 @@ public CreateAIDecompOutputBody createAiDecompilation(@javax.annotation.Nonnull 500 Internal Server Error - */ - public ApiResponse createAiDecompilationWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature) throws ApiException { - okhttp3.Call localVarCall = createAiDecompilationValidateBeforeCall(functionId, temperature, null); + public ApiResponse createAiDecompilationWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, @javax.annotation.Nullable Boolean typeSuggestions) throws ApiException { + okhttp3.Call localVarCall = createAiDecompilationValidateBeforeCall(functionId, temperature, typeSuggestions, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -222,6 +230,7 @@ public ApiResponse createAiDecompilationWithHttpInfo(@ * Begins the AI decompilation process for a function. Charges team credits and starts the workflow. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict - `402` [`INSUFFICIENT_CREDITS`](/errors/INSUFFICIENT_CREDITS) — Insufficient Credits * @param functionId Function ID (required) * @param temperature LLM temperature (0.0-1.0). Overrides the server default when set. Omit or set to -1 to use the server default. (optional, default to -1) + * @param typeSuggestions Ask the language model to name the suggested types and their members. Set to false to skip the model call; the statically derived layouts are still computed and stored. Cannot re-enable the pass when the server has it off. (optional, default to true) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -238,9 +247,9 @@ public ApiResponse createAiDecompilationWithHttpInfo(@ 500 Internal Server Error - */ - public okhttp3.Call createAiDecompilationAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createAiDecompilationAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nullable Double temperature, @javax.annotation.Nullable Boolean typeSuggestions, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createAiDecompilationValidateBeforeCall(functionId, temperature, _callback); + okhttp3.Call localVarCall = createAiDecompilationValidateBeforeCall(functionId, temperature, typeSuggestions, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; @@ -1551,8 +1560,10 @@ public okhttp3.Call patchAiDecompilationInlineCommentAsync(@javax.annotation.Non Response Details Status Code Description Response Headers 202 Accepted - + 400 Bad Request - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1615,7 +1626,7 @@ private okhttp3.Call regenerateAiDecompilationInlineCommentsValidateBeforeCall(@ /** * Regenerate AI decompilation inline comments - * Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers the comments would reference. Poll the inline comments status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict * @param functionId Function ID (required) * @return RegenerateOutputBody * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -1624,8 +1635,10 @@ private okhttp3.Call regenerateAiDecompilationInlineCommentsValidateBeforeCall(@ Response Details Status Code Description Response Headers 202 Accepted - + 400 Bad Request - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1637,7 +1650,7 @@ public RegenerateOutputBody regenerateAiDecompilationInlineComments(@javax.annot /** * Regenerate AI decompilation inline comments - * Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers the comments would reference. Poll the inline comments status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict * @param functionId Function ID (required) * @return ApiResponse<RegenerateOutputBody> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -1646,8 +1659,10 @@ public RegenerateOutputBody regenerateAiDecompilationInlineComments(@javax.annot Response Details Status Code Description Response Headers 202 Accepted - + 400 Bad Request - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1660,7 +1675,7 @@ public ApiResponse regenerateAiDecompilationInlineComments /** * Regenerate AI decompilation inline comments (asynchronously) - * Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Starts a new inline comments generation workflow for the function. Requires an existing decompilation with a summary. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers the comments would reference. Poll the inline comments status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict * @param functionId Function ID (required) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -1670,8 +1685,10 @@ public ApiResponse regenerateAiDecompilationInlineComments Response Details Status Code Description Response Headers 202 Accepted - + 400 Bad Request - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1696,6 +1713,7 @@ public okhttp3.Call regenerateAiDecompilationInlineCommentsAsync(@javax.annotati 202 Accepted - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1758,7 +1776,7 @@ private okhttp3.Call regenerateAiDecompilationSummaryValidateBeforeCall(@javax.a /** * Regenerate AI decompilation summary - * Starts a new summary generation workflow for the function. Requires an existing decompilation. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Starts a new summary generation workflow for the function. Requires an existing decompilation. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers a summary would describe. Poll the summary status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict * @param functionId Function ID (required) * @return RegenerateOutputBody * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -1769,6 +1787,7 @@ private okhttp3.Call regenerateAiDecompilationSummaryValidateBeforeCall(@javax.a 202 Accepted - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1780,7 +1799,7 @@ public RegenerateOutputBody regenerateAiDecompilationSummary(@javax.annotation.N /** * Regenerate AI decompilation summary - * Starts a new summary generation workflow for the function. Requires an existing decompilation. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Starts a new summary generation workflow for the function. Requires an existing decompilation. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers a summary would describe. Poll the summary status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict * @param functionId Function ID (required) * @return ApiResponse<RegenerateOutputBody> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -1791,6 +1810,7 @@ public RegenerateOutputBody regenerateAiDecompilationSummary(@javax.annotation.N 202 Accepted - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1803,7 +1823,7 @@ public ApiResponse regenerateAiDecompilationSummaryWithHtt /** * Regenerate AI decompilation summary (asynchronously) - * Starts a new summary generation workflow for the function. Requires an existing decompilation. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Starts a new summary generation workflow for the function. Requires an existing decompilation. Rejected while a decompilation is running: its naming and type-suggestion passes are still changing the identifiers a summary would describe. Poll the summary status endpoint, which reports PENDING until then. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `409` [`CONFLICT`](/errors/CONFLICT) — Conflict * @param functionId Function ID (required) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -1815,6 +1835,7 @@ public ApiResponse regenerateAiDecompilationSummaryWithHtt 202 Accepted - 403 Forbidden - 404 Not Found - + 409 Conflict - 422 Unprocessable Entity - 500 Internal Server Error - @@ -1899,7 +1920,7 @@ private okhttp3.Call streamAiDecompilationValidateBeforeCall(@javax.annotation.N /** * Stream live AI decompilation output (SSE) - * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. Terminal events: `decomp_finished` (success) or `decomp_failed` (all retries exhausted). `attempt_failed` is per-attempt and non-terminal — Temporal may retry the activity. Clients should treat `attempt` changes as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. + * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. **Terminal events — the stream closes on these:** `names_finished` (success) and `decomp_failed` (all retries exhausted). `names_finished` is published on every success path, including when the naming pass is disabled, produces nothing, or fails, so a successful run always closes. **`decomp_finished` is NOT terminal.** It marks the end of the model call, not the end of the run: entity restore, the result write, the placeholder-naming pass and the type-suggestion pass all follow it, and the last two rewrite the identifiers the source renders with. Reading the decompilation at `decomp_finished` therefore returns names that are about to change — wait for `names_finished`. `attempt_failed` is per-attempt and non-terminal too: Temporal may retry, and clients disambiguate on `attempt`, which they should treat as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. * @param functionId Function ID (required) * @return List<ServerSentEventsInner1> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -1918,7 +1939,7 @@ public List streamAiDecompilation(@javax.annotation.Nonn /** * Stream live AI decompilation output (SSE) - * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. Terminal events: `decomp_finished` (success) or `decomp_failed` (all retries exhausted). `attempt_failed` is per-attempt and non-terminal — Temporal may retry the activity. Clients should treat `attempt` changes as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. + * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. **Terminal events — the stream closes on these:** `names_finished` (success) and `decomp_failed` (all retries exhausted). `names_finished` is published on every success path, including when the naming pass is disabled, produces nothing, or fails, so a successful run always closes. **`decomp_finished` is NOT terminal.** It marks the end of the model call, not the end of the run: entity restore, the result write, the placeholder-naming pass and the type-suggestion pass all follow it, and the last two rewrite the identifiers the source renders with. Reading the decompilation at `decomp_finished` therefore returns names that are about to change — wait for `names_finished`. `attempt_failed` is per-attempt and non-terminal too: Temporal may retry, and clients disambiguate on `attempt`, which they should treat as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. * @param functionId Function ID (required) * @return ApiResponse<List<ServerSentEventsInner1>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -1938,7 +1959,7 @@ public ApiResponse> streamAiDecompilationWithHttpIn /** * Stream live AI decompilation output (SSE) (asynchronously) - * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. Terminal events: `decomp_finished` (success) or `decomp_failed` (all retries exhausted). `attempt_failed` is per-attempt and non-terminal — Temporal may retry the activity. Clients should treat `attempt` changes as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. + * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. **Terminal events — the stream closes on these:** `names_finished` (success) and `decomp_failed` (all retries exhausted). `names_finished` is published on every success path, including when the naming pass is disabled, produces nothing, or fails, so a successful run always closes. **`decomp_finished` is NOT terminal.** It marks the end of the model call, not the end of the run: entity restore, the result write, the placeholder-naming pass and the type-suggestion pass all follow it, and the last two rewrite the identifiers the source renders with. Reading the decompilation at `decomp_finished` therefore returns names that are about to change — wait for `names_finished`. `attempt_failed` is per-attempt and non-terminal too: Temporal may retry, and clients disambiguate on `attempt`, which they should treat as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. * @param functionId Function ID (required) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -2385,6 +2406,149 @@ public okhttp3.Call v3GetAiDecompilationTokensAsync(@javax.annotation.Nonnull Lo localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for v3GetAiDecompilationTypeSuggestions + * @param functionId Function ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAiDecompilationTypeSuggestionsCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/v3/functions/{function_id}/ai-decompilation/type-suggestions" + .replace("{" + "function_id" + "}", localVarApiClient.escapeString(functionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey", "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call v3GetAiDecompilationTypeSuggestionsValidateBeforeCall(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'functionId' is set + if (functionId == null) { + throw new ApiException("Missing the required parameter 'functionId' when calling v3GetAiDecompilationTypeSuggestions(Async)"); + } + + return v3GetAiDecompilationTypeSuggestionsCall(functionId, _callback); + + } + + /** + * Get AI decompilation type suggestions + * Returns the aggregate types the AI decompilation inferred for this function: a suggested name for each type and each of its members, the members' offsets and widths, and the gaps between them. Members revealed only by a caller or callee are included and marked by origin, as are members the model placed rather than observed. Nothing here is a data type row — these are proposals, and creating a row from one is the client's call. The list is empty until a run has produced suggestions, which is ordinary and not an error. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + * @param functionId Function ID (required) + * @return TypeSuggestionsData + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public TypeSuggestionsData v3GetAiDecompilationTypeSuggestions(@javax.annotation.Nonnull Long functionId) throws ApiException { + ApiResponse localVarResp = v3GetAiDecompilationTypeSuggestionsWithHttpInfo(functionId); + return localVarResp.getData(); + } + + /** + * Get AI decompilation type suggestions + * Returns the aggregate types the AI decompilation inferred for this function: a suggested name for each type and each of its members, the members' offsets and widths, and the gaps between them. Members revealed only by a caller or callee are included and marked by origin, as are members the model placed rather than observed. Nothing here is a data type row — these are proposals, and creating a row from one is the client's call. The list is empty until a run has produced suggestions, which is ordinary and not an error. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + * @param functionId Function ID (required) + * @return ApiResponse<TypeSuggestionsData> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public ApiResponse v3GetAiDecompilationTypeSuggestionsWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { + okhttp3.Call localVarCall = v3GetAiDecompilationTypeSuggestionsValidateBeforeCall(functionId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get AI decompilation type suggestions (asynchronously) + * Returns the aggregate types the AI decompilation inferred for this function: a suggested name for each type and each of its members, the members' offsets and widths, and the gaps between them. Members revealed only by a caller or callee are included and marked by origin, as are members the model placed rather than observed. Nothing here is a data type row — these are proposals, and creating a row from one is the client's call. The list is empty until a run has produced suggestions, which is ordinary and not an error. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `500` [`INTERNAL_ERROR`](/errors/INTERNAL_ERROR) — Internal Server Error + * @param functionId Function ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
422 Unprocessable Entity -
500 Internal Server Error -
+ */ + public okhttp3.Call v3GetAiDecompilationTypeSuggestionsAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = v3GetAiDecompilationTypeSuggestionsValidateBeforeCall(functionId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for v3UpsertAiDecompilationOverrides * @param functionId Function ID (required) diff --git a/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java b/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java index 61a5cff7..dd36d2c1 100644 --- a/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java +++ b/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java @@ -728,7 +728,7 @@ private okhttp3.Call renameFunctionValidateBeforeCall(@javax.annotation.Nonnull /** * Rename a function - * Renames a single function and records the change in history. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Renames a single function and records the change in history. `source_type` defaults to USER when omitted. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found * @param functionId Function ID (required) * @param renameInputBody (required) * @return RenameOutputBody @@ -751,7 +751,7 @@ public RenameOutputBody renameFunction(@javax.annotation.Nonnull Long functionId /** * Rename a function - * Renames a single function and records the change in history. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Renames a single function and records the change in history. `source_type` defaults to USER when omitted. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found * @param functionId Function ID (required) * @param renameInputBody (required) * @return ApiResponse<RenameOutputBody> @@ -775,7 +775,7 @@ public ApiResponse renameFunctionWithHttpInfo(@javax.annotatio /** * Rename a function (asynchronously) - * Renames a single function and records the change in history. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found + * Renames a single function and records the change in history. `source_type` defaults to USER when omitted. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found * @param functionId Function ID (required) * @param renameInputBody (required) * @param _callback The callback to be executed when the API call finishes diff --git a/src/main/java/ai/reveng/invoker/ApiClient.java b/src/main/java/ai/reveng/invoker/ApiClient.java index c3069cef..aff6cea7 100644 --- a/src/main/java/ai/reveng/invoker/ApiClient.java +++ b/src/main/java/ai/reveng/invoker/ApiClient.java @@ -148,7 +148,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/4.4.0/java"); + setUserAgent("OpenAPI-Generator/4.51.0/java"); authentications = new HashMap(); } diff --git a/src/main/java/ai/reveng/invoker/Configuration.java b/src/main/java/ai/reveng/invoker/Configuration.java index f5dcf070..3a056e05 100644 --- a/src/main/java/ai/reveng/invoker/Configuration.java +++ b/src/main/java/ai/reveng/invoker/Configuration.java @@ -18,7 +18,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { - public static final String VERSION = "4.4.0"; + public static final String VERSION = "4.51.0"; private static final AtomicReference defaultApiClient = new AtomicReference<>(); private static volatile Supplier apiClientFactory = ApiClient::new; diff --git a/src/main/java/ai/reveng/invoker/JSON.java b/src/main/java/ai/reveng/invoker/JSON.java index 5ef87078..bb19ad4d 100644 --- a/src/main/java/ai/reveng/invoker/JSON.java +++ b/src/main/java/ai/reveng/invoker/JSON.java @@ -100,6 +100,25 @@ public Class getClassForElement(JsonEle return getClassByDiscriminator(classByDiscriminatorValue, getDiscriminatorValue(readElement, "kind")); } + }) + .registerTypeSelector(ai.reveng.model.EvidenceInner.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("api_combination", ai.reveng.model.ApiCombinationEvidence.class); + classByDiscriminatorValue.put("call_chain", ai.reveng.model.CallChainEvidence.class); + classByDiscriminatorValue.put("decompiler_summary", ai.reveng.model.DecompilerSummaryEvidence.class); + classByDiscriminatorValue.put("function_similarity", ai.reveng.model.FunctionSimilarityEvidence.class); + classByDiscriminatorValue.put("hardcoded_secret", ai.reveng.model.HardcodedSecretEvidence.class); + classByDiscriminatorValue.put("imported_api_call", ai.reveng.model.ImportedApiCallEvidence.class); + classByDiscriminatorValue.put("known_constant", ai.reveng.model.KnownConstantEvidence.class); + classByDiscriminatorValue.put("model_interpretation", ai.reveng.model.ModelInterpretationEvidence.class); + classByDiscriminatorValue.put("referenced_constant", ai.reveng.model.ReferencedConstantEvidence.class); + classByDiscriminatorValue.put("suspicious_string", ai.reveng.model.SuspiciousStringEvidence.class); + classByDiscriminatorValue.put("Evidence_inner", ai.reveng.model.EvidenceInner.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "evidence_kind")); + } }) .registerTypeSelector(ai.reveng.model.UpdateDataTypeEntry.class, new TypeSelector() { @Override @@ -186,6 +205,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisRecord.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisRecordBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisReport.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisRequirement.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisStringFunction.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisStringInput.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisStringItem.CustomTypeAdapterFactory()); @@ -197,6 +217,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisUpdateTagsRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AnalysisUpdateTagsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ApiCall.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ApiCombinationEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AppApiRestV2AgentSchemaCapability.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AppApiRestV2FunctionsResponsesFunction.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AppApiRestV2FunctionsTypesFunction.CustomTypeAdapterFactory()); @@ -257,10 +278,12 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseLogs.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseModelsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseParams.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseProtocolsAgentResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseQueuedWorkflowTaskResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseRecent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseRemediationAgentResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseReportAnalysisResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseSecretsAgentResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseStatus.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseStr.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseTagSearchResponse.CustomTypeAdapterFactory()); @@ -290,6 +313,9 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BulkCreateUserResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BulkCreateUsersOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BulkDeleteAnalysesRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BytesConstant.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CallChain.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CallChainEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CallEdge.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CallEdgesOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CalleeFunctionInfo.CustomTypeAdapterFactory()); @@ -301,6 +327,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Capabilities.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CapabilitiesAgentResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CapabilitiesOutputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CapabilitiesResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Capability.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CapabilityEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ChildBinariesResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CodeSignatureModel.CustomTypeAdapterFactory()); @@ -321,6 +349,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CommentResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CommentUpdateRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CommentsData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Config.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ConfigResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ConfirmToolInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Connection.CustomTypeAdapterFactory()); @@ -347,9 +376,12 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateGroupInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateIdentityInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateIssuerInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateMetadata.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateOrganisationInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreatePointerDataType.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreatePortalSessionInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateStructDataType.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateTeamInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateTypedefDataType.CustomTypeAdapterFactory()); @@ -357,6 +389,14 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateUnknownDataType.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CreateUserInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Created.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoCall.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoDirectMatch.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoExplainMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoExplainResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoExplainedFunction.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoFinding.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoScanMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CryptoScanResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DataTypeEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DataTypeEnumValueEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DataTypeFunctionEntry.CustomTypeAdapterFactory()); @@ -367,6 +407,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DecompFinishedEvent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DecompilationCommentContext.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DecompilationData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DecompilerSummary.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DecompilerSummaryEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DieMatch.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DisassemblyOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.DnsQuery.CustomTypeAdapterFactory()); @@ -391,6 +433,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventCONTEXTCOMPACTED.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventDecompFailed.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventDecompFinished.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventNamesFinished.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventProse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventRUNCANCELLED.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventRUNERROR.CustomTypeAdapterFactory()); @@ -411,14 +454,36 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventTOOLCALLRESULT.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventTOOLCALLSTART.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventTOOLCONFIRMATIONREQUIRED.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventTypesSuggested.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventWarning.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EvidenceInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Example.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionCall.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionDirectMatch.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionExplainMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionExplainResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionExplainedFunction.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionFinding.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionScanMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExecutionScanResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExportModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExternalResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExtractedBinary.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExtractedURL.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExtractionFailure.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FeedbackOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FileActivityEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FileHashes.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FileMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemAnalyseMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemAnalyseResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemCall.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemDirectMatch.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemExplainedFunction.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemFinding.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemScanMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FilesystemScanResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Finding.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FormFile.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionBlockDestinationResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionBlockResponse.CustomTypeAdapterFactory()); @@ -441,12 +506,15 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionSignatureBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionSignatureEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionSignatureVersion.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionSimilarity.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionSimilarityEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionString.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionStringItem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionStringsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionTypeDefinition.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionsDetailResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionsListRename.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionsProgressOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GeneratePDFOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetAdditionalDetailsOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetAdditionalDetailsStatusOutputBody.CustomTypeAdapterFactory()); @@ -454,29 +522,40 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetAnalysisLogsOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetAnalysisStringsStatusOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetCollectionOutputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetConfigOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetDataTypeHistoryBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetDieInfoOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetFunctionSignatureHistoryBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetMatchesOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetMatchesStatusOutputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetModelsOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetProductsOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetPublicUserResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetRelatedBinariesOutputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetRelatedStatusOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetSubscriptionOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GetTokensResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.HardcodedSecretEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.HistoryActor.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.HistoryEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.HttpRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.IOC.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.IconModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ImportModel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ImportedApi.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ImportedApiCall.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ImportedApiCallEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ImportedFunctionCallerEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ImportedFunctionDetailOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ImportedFunctionEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.IndirectCallSite.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.IndirectCallSitesOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.InlineComment.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.InputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.InsertAnalysisLogRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.InviteUserInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.IssuerAllowedDomain.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.KnownConstantEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.LineAttributionsData.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ListAnalysesOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ListAnalysisDataTypesOutputBody.CustomTypeAdapterFactory()); @@ -499,14 +578,43 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.MatchedFunction.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.MemdumpEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.MessageBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Meta.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.MetaModel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Metadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ModelInterpretation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ModelInterpretationEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ModelsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ModuleLoadEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.MutexEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NameConfidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NameSourceType.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NamesFinishedEvent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkActivity.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingCall.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingDirectMatch.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingExplainMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingExplainResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingExplainedFunction.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingFinding.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingScanMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.NetworkingScanResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OIDCCallbackInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationCreateMetadataCreateResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationCryptoExplainMetadataCryptoExplainResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationCryptoScanMetadataCryptoScanResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationExecutionExplainMetadataExecutionExplainResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationExecutionScanMetadataExecutionScanResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationFilesystemScanMetadataFilesystemScanResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationMetadataCapabilitiesResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationMetadataRemediationResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationMetadataReportResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationMetadataThreatReportResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationMetadataTriageResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationNetworkingExplainMetadataNetworkingExplainResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationNetworkingScanMetadataNetworkingScanResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationSecurityScanMetadataSecurityScanResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OperationWorkflowProgressResultBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Organisation.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OrganisationGroup.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.OrganisationIssuer.CustomTypeAdapterFactory()); @@ -537,16 +645,21 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProductSummary.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProgressMessage.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProseEvent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProtocolsAgentResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.PutAnalysisStringsRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.QueuedWorkflowTaskResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ReAnalysisForm.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Recent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ReferencedConstant.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ReferencedConstantEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RefreshBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RegenerateOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RegisterUserInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RegistryOperation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RelatedBinary.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RelativeBinaryResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RemediationAgentResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RemediationResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RemoveCollectionBinariesInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RenameAppliedEvent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RenameInputBody.CustomTypeAdapterFactory()); @@ -557,15 +670,24 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ReportEvent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ReportInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ReportOptions.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ReportResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ResolvedEntity.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ResultBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.RevokeBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SSOProvider.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SSOProvidersOutputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SandboxConfig.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SandboxOptions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ScheduledTaskEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ScrapeThirdPartyConfig.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ScreenshotEntry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ScreenshotsIndex.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecretsAgentResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SectionModel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityFinding.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityModel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityScanMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityScanResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SegmentInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SendMessageRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ServerSentEventsInner.CustomTypeAdapterFactory()); @@ -604,14 +726,26 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StartMatchingForFunctionsInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StartMatchingOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StartupInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Status.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StatusBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StatusOutput.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StatusResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StringFunctions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StructDataType.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StructDefinition.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Subject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SubjectAnyOf.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SubjectAnyOf1.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SubjectAnyOf2.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SubjectAnyOf3.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SubmitFeedbackInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SubmitUserFeedbackRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SuggestedHole.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SuggestedMemberView.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SuggestedTypeView.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SummaryData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SuspiciousString.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SuspiciousStringEvidence.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Symbols.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Tag.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TagItem.CustomTypeAdapterFactory()); @@ -623,18 +757,32 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TcpCarvedFile.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Team.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TeamMember.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Technique.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ThreatReportResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TimestampModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Token.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TokenInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TokenResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TokenisedData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriageFunction.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriageFunctionResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriageReportResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriageResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerCryptoScanInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerDynamicExecutionInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerExecutionExplainInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerExecutionScanInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerFilesystemAnalyseInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerFilesystemScanInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerNetworkingExplainInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerNetworkingScanInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerRenameUnnamedFunctionsInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriggerSecurityScanInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Ttp.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TypeSuggestionsData.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TypedefDataType.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TypedefDefinition.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TypesSuggestedEvent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UnionDataType.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UnionDefinition.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UnknownDataType.CustomTypeAdapterFactory()); @@ -659,6 +807,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UpdateUserCreditsInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UpdateUserInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UpdateUserPasswordInputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UpgradeAnalysisModelOutputBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UploadOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UploadResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UpsertAiDecomplationRatingRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UpsertOverridesData.CustomTypeAdapterFactory()); diff --git a/src/main/java/ai/reveng/model/APIError.java b/src/main/java/ai/reveng/model/APIError.java index 50170018..73951369 100644 --- a/src/main/java/ai/reveng/model/APIError.java +++ b/src/main/java/ai/reveng/model/APIError.java @@ -76,6 +76,50 @@ public void setError(@javax.annotation.Nonnull ErrorBody error) { this.error = error; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIError instance itself + */ + public APIError putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } APIError apIError = (APIError) o; - return Objects.equals(this.error, apIError.error); + return Objects.equals(this.error, apIError.error)&& + Objects.equals(this.additionalProperties, apIError.additionalProperties); } @Override public int hashCode() { - return Objects.hash(error); + return Objects.hash(error, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class APIError {\n"); sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -137,14 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIError.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIError` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIError.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -152,8 +190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `error` - ErrorBody.validateJsonElement(jsonObj.get("error")); } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -171,6 +207,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIError value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -178,7 +236,28 @@ public void write(JsonWriter out, APIError value) throws IOException { public APIError read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIError instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AddCalleeInputBody.java b/src/main/java/ai/reveng/model/AddCalleeInputBody.java index 53831529..a011b3ea 100644 --- a/src/main/java/ai/reveng/model/AddCalleeInputBody.java +++ b/src/main/java/ai/reveng/model/AddCalleeInputBody.java @@ -173,6 +173,50 @@ public void setThunkedVaddr(@javax.annotation.Nullable Long thunkedVaddr) { this.thunkedVaddr = thunkedVaddr; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AddCalleeInputBody instance itself + */ + public AddCalleeInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -188,12 +232,13 @@ public boolean equals(Object o) { Objects.equals(this.calleeName, addCalleeInputBody.calleeName) && Objects.equals(this.calleeVaddr, addCalleeInputBody.calleeVaddr) && Objects.equals(this.isExternal, addCalleeInputBody.isExternal) && - Objects.equals(this.thunkedVaddr, addCalleeInputBody.thunkedVaddr); + Objects.equals(this.thunkedVaddr, addCalleeInputBody.thunkedVaddr)&& + Objects.equals(this.additionalProperties, addCalleeInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(calleeFunctionId, calleeName, calleeVaddr, isExternal, thunkedVaddr); + return Objects.hash(calleeFunctionId, calleeName, calleeVaddr, isExternal, thunkedVaddr, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" calleeVaddr: ").append(toIndentedString(calleeVaddr)).append("\n"); sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); sb.append(" thunkedVaddr: ").append(toIndentedString(thunkedVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -242,14 +288,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AddCalleeInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddCalleeInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddCalleeInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -277,6 +315,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddCalleeInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -284,7 +344,28 @@ public void write(JsonWriter out, AddCalleeInputBody value) throws IOException { public AddCalleeInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AddCalleeInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AddCollectionBinariesInputBody.java b/src/main/java/ai/reveng/model/AddCollectionBinariesInputBody.java index 2c2f6920..f6a5b559 100644 --- a/src/main/java/ai/reveng/model/AddCollectionBinariesInputBody.java +++ b/src/main/java/ai/reveng/model/AddCollectionBinariesInputBody.java @@ -85,6 +85,50 @@ public void setBinaries(@javax.annotation.Nullable List binaries) { this.binaries = binaries; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AddCollectionBinariesInputBody instance itself + */ + public AddCollectionBinariesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -96,12 +140,13 @@ public boolean equals(Object o) { return false; } AddCollectionBinariesInputBody addCollectionBinariesInputBody = (AddCollectionBinariesInputBody) o; - return Objects.equals(this.binaries, addCollectionBinariesInputBody.binaries); + return Objects.equals(this.binaries, addCollectionBinariesInputBody.binaries)&& + Objects.equals(this.additionalProperties, addCollectionBinariesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaries); + return Objects.hash(binaries, additionalProperties); } @Override @@ -109,6 +154,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AddCollectionBinariesInputBody {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AddCollectionBinariesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddCollectionBinariesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddCollectionBinariesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -184,6 +222,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddCollectionBinariesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -191,7 +251,28 @@ public void write(JsonWriter out, AddCollectionBinariesInputBody value) throws I public AddCollectionBinariesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AddCollectionBinariesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AddUserStringInputBody.java b/src/main/java/ai/reveng/model/AddUserStringInputBody.java index dd6c92b2..9fdfc500 100644 --- a/src/main/java/ai/reveng/model/AddUserStringInputBody.java +++ b/src/main/java/ai/reveng/model/AddUserStringInputBody.java @@ -100,6 +100,50 @@ public void setVirtualAddress(@javax.annotation.Nonnull Long virtualAddress) { this.virtualAddress = virtualAddress; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AddUserStringInputBody instance itself + */ + public AddUserStringInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } AddUserStringInputBody addUserStringInputBody = (AddUserStringInputBody) o; return Objects.equals(this.string, addUserStringInputBody.string) && - Objects.equals(this.virtualAddress, addUserStringInputBody.virtualAddress); + Objects.equals(this.virtualAddress, addUserStringInputBody.virtualAddress)&& + Objects.equals(this.additionalProperties, addUserStringInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(string, virtualAddress); + return Objects.hash(string, virtualAddress, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class AddUserStringInputBody {\n"); sb.append(" string: ").append(toIndentedString(string)).append("\n"); sb.append(" virtualAddress: ").append(toIndentedString(virtualAddress)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AddUserStringInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddUserStringInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddUserStringInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddUserStringInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, AddUserStringInputBody value) throws IOExcepti public AddUserStringInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AddUserStringInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java b/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java index 4cc233d5..a9829fcb 100644 --- a/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java +++ b/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java @@ -100,6 +100,50 @@ public void setVirtualAddress(@javax.annotation.Nonnull Long virtualAddress) { this.virtualAddress = virtualAddress; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AddUserStringToFunctionInputBody instance itself + */ + public AddUserStringToFunctionInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } AddUserStringToFunctionInputBody addUserStringToFunctionInputBody = (AddUserStringToFunctionInputBody) o; return Objects.equals(this.string, addUserStringToFunctionInputBody.string) && - Objects.equals(this.virtualAddress, addUserStringToFunctionInputBody.virtualAddress); + Objects.equals(this.virtualAddress, addUserStringToFunctionInputBody.virtualAddress)&& + Objects.equals(this.additionalProperties, addUserStringToFunctionInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(string, virtualAddress); + return Objects.hash(string, virtualAddress, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class AddUserStringToFunctionInputBody {\n"); sb.append(" string: ").append(toIndentedString(string)).append("\n"); sb.append(" virtualAddress: ").append(toIndentedString(virtualAddress)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AddUserStringToFunctionInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddUserStringToFunctionInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddUserStringToFunctionInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddUserStringToFunctionInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, AddUserStringToFunctionInputBody value) throws public AddUserStringToFunctionInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AddUserStringToFunctionInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java b/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java index 47839ca9..67a5e217 100644 --- a/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java +++ b/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java @@ -191,6 +191,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nonnull private String modelName; + public static final String SERIALIZED_NAME_MODEL_UPGRADE_AVAILABLE = "model_upgrade_available"; + @SerializedName(SERIALIZED_NAME_MODEL_UPGRADE_AVAILABLE) + @javax.annotation.Nonnull + private Boolean modelUpgradeAvailable; + public static final String SERIALIZED_NAME_OWNER_USERNAME = "owner_username"; @SerializedName(SERIALIZED_NAME_OWNER_USERNAME) @javax.annotation.Nonnull @@ -552,6 +557,25 @@ public void setModelName(@javax.annotation.Nonnull String modelName) { } + public AnalysisBasicInfoOutputBody modelUpgradeAvailable(@javax.annotation.Nonnull Boolean modelUpgradeAvailable) { + this.modelUpgradeAvailable = modelUpgradeAvailable; + return this; + } + + /** + * True when the analysis ran on a model older than the current one, so its owner can re-analyse it on the latest. Describes the analysis, not the caller's rights — only the owner may act on it + * @return modelUpgradeAvailable + */ + @javax.annotation.Nonnull + public Boolean getModelUpgradeAvailable() { + return modelUpgradeAvailable; + } + + public void setModelUpgradeAvailable(@javax.annotation.Nonnull Boolean modelUpgradeAvailable) { + this.modelUpgradeAvailable = modelUpgradeAvailable; + } + + public AnalysisBasicInfoOutputBody ownerUsername(@javax.annotation.Nonnull String ownerUsername) { this.ownerUsername = ownerUsername; return this; @@ -684,6 +708,50 @@ public void setTeamId(@javax.annotation.Nonnull Long teamId) { this.teamId = teamId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisBasicInfoOutputBody instance itself + */ + public AnalysisBasicInfoOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -712,18 +780,20 @@ public boolean equals(Object o) { Objects.equals(this.isSystem, analysisBasicInfoOutputBody.isSystem) && Objects.equals(this.modelId, analysisBasicInfoOutputBody.modelId) && Objects.equals(this.modelName, analysisBasicInfoOutputBody.modelName) && + Objects.equals(this.modelUpgradeAvailable, analysisBasicInfoOutputBody.modelUpgradeAvailable) && Objects.equals(this.ownerUsername, analysisBasicInfoOutputBody.ownerUsername) && Objects.equals(this.sequencerVersion, analysisBasicInfoOutputBody.sequencerVersion) && Objects.equals(this.sha256Hash, analysisBasicInfoOutputBody.sha256Hash) && Objects.equals(this.suppliedArchitecture, analysisBasicInfoOutputBody.suppliedArchitecture) && Objects.equals(this.suppliedBinaryFormat, analysisBasicInfoOutputBody.suppliedBinaryFormat) && Objects.equals(this.suppliedBinaryType, analysisBasicInfoOutputBody.suppliedBinaryType) && - Objects.equals(this.teamId, analysisBasicInfoOutputBody.teamId); + Objects.equals(this.teamId, analysisBasicInfoOutputBody.teamId)&& + Objects.equals(this.additionalProperties, analysisBasicInfoOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisScope, baseAddress, binaryId, binaryName, binarySize, binaryUuid, creation, debug, detectedArchitecture, detectedBinaryFormat, detectedBinaryType, functionCount, isAdvanced, isOwner, isSystem, modelId, modelName, ownerUsername, sequencerVersion, sha256Hash, suppliedArchitecture, suppliedBinaryFormat, suppliedBinaryType, teamId); + return Objects.hash(analysisScope, baseAddress, binaryId, binaryName, binarySize, binaryUuid, creation, debug, detectedArchitecture, detectedBinaryFormat, detectedBinaryType, functionCount, isAdvanced, isOwner, isSystem, modelId, modelName, modelUpgradeAvailable, ownerUsername, sequencerVersion, sha256Hash, suppliedArchitecture, suppliedBinaryFormat, suppliedBinaryType, teamId, additionalProperties); } @Override @@ -747,6 +817,7 @@ public String toString() { sb.append(" isSystem: ").append(toIndentedString(isSystem)).append("\n"); sb.append(" modelId: ").append(toIndentedString(modelId)).append("\n"); sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); + sb.append(" modelUpgradeAvailable: ").append(toIndentedString(modelUpgradeAvailable)).append("\n"); sb.append(" ownerUsername: ").append(toIndentedString(ownerUsername)).append("\n"); sb.append(" sequencerVersion: ").append(toIndentedString(sequencerVersion)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); @@ -754,6 +825,7 @@ public String toString() { sb.append(" suppliedBinaryFormat: ").append(toIndentedString(suppliedBinaryFormat)).append("\n"); sb.append(" suppliedBinaryType: ").append(toIndentedString(suppliedBinaryType)).append("\n"); sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -772,10 +844,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "binary_uuid", "creation", "debug", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_count", "is_advanced", "is_owner", "is_system", "model_id", "model_name", "owner_username", "sequencer_version", "sha_256_hash", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "team_id")); + openapiFields = new HashSet(Arrays.asList("analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "binary_uuid", "creation", "debug", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_count", "is_advanced", "is_owner", "is_system", "model_id", "model_name", "model_upgrade_available", "owner_username", "sequencer_version", "sha_256_hash", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "team_id")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "binary_uuid", "creation", "debug", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_count", "is_advanced", "is_owner", "is_system", "model_id", "model_name", "owner_username", "sha_256_hash", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "team_id")); + openapiRequiredFields = new HashSet(Arrays.asList("analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "binary_uuid", "creation", "debug", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_count", "is_advanced", "is_owner", "is_system", "model_id", "model_name", "model_upgrade_available", "owner_username", "sha_256_hash", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "team_id")); } /** @@ -791,14 +863,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisBasicInfoOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisBasicInfoOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisBasicInfoOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -864,6 +928,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisBasicInfoOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -871,7 +957,28 @@ public void write(JsonWriter out, AnalysisBasicInfoOutputBody value) throws IOEx public AnalysisBasicInfoOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisBasicInfoOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisConfig.java b/src/main/java/ai/reveng/model/AnalysisConfig.java index 2f00f812..b475dda3 100644 --- a/src/main/java/ai/reveng/model/AnalysisConfig.java +++ b/src/main/java/ai/reveng/model/AnalysisConfig.java @@ -288,10 +288,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `scrape_third_party_config` - if (jsonObj.get("scrape_third_party_config") != null && !jsonObj.get("scrape_third_party_config").isJsonNull()) { - ScrapeThirdPartyConfig.validateJsonElement(jsonObj.get("scrape_third_party_config")); - } // validate the optional field `sandbox_config` if (jsonObj.get("sandbox_config") != null && !jsonObj.get("sandbox_config").isJsonNull()) { SandboxOptions.validateJsonElement(jsonObj.get("sandbox_config")); diff --git a/src/main/java/ai/reveng/model/AnalysisCreateRequest.java b/src/main/java/ai/reveng/model/AnalysisCreateRequest.java index cca8999d..fb083499 100644 --- a/src/main/java/ai/reveng/model/AnalysisCreateRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisCreateRequest.java @@ -449,10 +449,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("analysis_scope") != null && !jsonObj.get("analysis_scope").isJsonNull()) { AnalysisScope.validateJsonElement(jsonObj.get("analysis_scope")); } - // validate the optional field `symbols` - if (jsonObj.get("symbols") != null && !jsonObj.get("symbols").isJsonNull()) { - Symbols.validateJsonElement(jsonObj.get("symbols")); - } if ((jsonObj.get("debug_hash") != null && !jsonObj.get("debug_hash").isJsonNull()) && !jsonObj.get("debug_hash").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); } @@ -460,14 +456,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("analysis_config") != null && !jsonObj.get("analysis_config").isJsonNull()) { AnalysisConfig.validateJsonElement(jsonObj.get("analysis_config")); } - // validate the optional field `binary_config` - if (jsonObj.get("binary_config") != null && !jsonObj.get("binary_config").isJsonNull()) { - BinaryConfig.validateJsonElement(jsonObj.get("binary_config")); - } - // validate the optional field `auto_run_agents` - if (jsonObj.get("auto_run_agents") != null && !jsonObj.get("auto_run_agents").isJsonNull()) { - AutoRunAgents.validateJsonElement(jsonObj.get("auto_run_agents")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/ai/reveng/model/AnalysisDataTypesGroup.java b/src/main/java/ai/reveng/model/AnalysisDataTypesGroup.java index 57428390..2b8e36ce 100644 --- a/src/main/java/ai/reveng/model/AnalysisDataTypesGroup.java +++ b/src/main/java/ai/reveng/model/AnalysisDataTypesGroup.java @@ -110,6 +110,50 @@ public void setItems(@javax.annotation.Nullable List items) { this.items = items; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisDataTypesGroup instance itself + */ + public AnalysisDataTypesGroup putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } AnalysisDataTypesGroup analysisDataTypesGroup = (AnalysisDataTypesGroup) o; return Objects.equals(this.analysisId, analysisDataTypesGroup.analysisId) && - Objects.equals(this.items, analysisDataTypesGroup.items); + Objects.equals(this.items, analysisDataTypesGroup.items)&& + Objects.equals(this.additionalProperties, analysisDataTypesGroup.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, items); + return Objects.hash(analysisId, items, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class AnalysisDataTypesGroup {\n"); sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisDataTypesGroup.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisDataTypesGroup` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisDataTypesGroup.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -215,6 +253,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisDataTypesGroup value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +282,28 @@ public void write(JsonWriter out, AnalysisDataTypesGroup value) throws IOExcepti public AnalysisDataTypesGroup read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisDataTypesGroup instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisDataTypesOutputBody.java b/src/main/java/ai/reveng/model/AnalysisDataTypesOutputBody.java index cbb39e5c..905fba75 100644 --- a/src/main/java/ai/reveng/model/AnalysisDataTypesOutputBody.java +++ b/src/main/java/ai/reveng/model/AnalysisDataTypesOutputBody.java @@ -86,6 +86,50 @@ public void setDataTypes(@javax.annotation.Nullable List dataType this.dataTypes = dataTypes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisDataTypesOutputBody instance itself + */ + public AnalysisDataTypesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } AnalysisDataTypesOutputBody analysisDataTypesOutputBody = (AnalysisDataTypesOutputBody) o; - return Objects.equals(this.dataTypes, analysisDataTypesOutputBody.dataTypes); + return Objects.equals(this.dataTypes, analysisDataTypesOutputBody.dataTypes)&& + Objects.equals(this.additionalProperties, analysisDataTypesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypes); + return Objects.hash(dataTypes, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AnalysisDataTypesOutputBody {\n"); sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisDataTypesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisDataTypesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisDataTypesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisDataTypesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, AnalysisDataTypesOutputBody value) throws IOEx public AnalysisDataTypesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisDataTypesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisDetailResponse.java b/src/main/java/ai/reveng/model/AnalysisDetailResponse.java index 53672693..739328b2 100644 --- a/src/main/java/ai/reveng/model/AnalysisDetailResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisDetailResponse.java @@ -611,8 +611,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } - // validate the required field `auto_run_agents` - AutoRunAgents.validateJsonElement(jsonObj.get("auto_run_agents")); // validate the required field `requested_config` AnalysisConfigSnapshot.validateJsonElement(jsonObj.get("requested_config")); } diff --git a/src/main/java/ai/reveng/model/AnalysisFunctionEntry.java b/src/main/java/ai/reveng/model/AnalysisFunctionEntry.java index 70077290..52c8fa29 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctionEntry.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctionEntry.java @@ -20,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -228,7 +227,7 @@ public AnalysisFunctionEntry mangledName(@javax.annotation.Nullable String mangl } /** - * Search is applied to string value + * Get mangledName * @return mangledName */ @javax.annotation.Nullable @@ -385,22 +384,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, analysisFunctionEntry.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - @Override public int hashCode() { return Objects.hash(binaryId, debug, functionId, functionName, functionSize, functionVaddr, mangledName, sourceAnalysisId, sourceBinaryId, sourceFunctionId, sourceType, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/ai/reveng/model/AnalysisLogEntry.java b/src/main/java/ai/reveng/model/AnalysisLogEntry.java index da632ed3..ea2fbf15 100644 --- a/src/main/java/ai/reveng/model/AnalysisLogEntry.java +++ b/src/main/java/ai/reveng/model/AnalysisLogEntry.java @@ -204,6 +204,50 @@ public void setTimestamp(@javax.annotation.Nonnull OffsetDateTime timestamp) { this.timestamp = timestamp; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisLogEntry instance itself + */ + public AnalysisLogEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -218,12 +262,13 @@ public boolean equals(Object o) { return Objects.equals(this.level, analysisLogEntry.level) && Objects.equals(this.source, analysisLogEntry.source) && Objects.equals(this.text, analysisLogEntry.text) && - Objects.equals(this.timestamp, analysisLogEntry.timestamp); + Objects.equals(this.timestamp, analysisLogEntry.timestamp)&& + Objects.equals(this.additionalProperties, analysisLogEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(level, source, text, timestamp); + return Objects.hash(level, source, text, timestamp, additionalProperties); } @Override @@ -234,6 +279,7 @@ public String toString() { sb.append(" source: ").append(toIndentedString(source)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -271,14 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisLogEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisLogEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisLogEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -314,6 +352,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisLogEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -321,7 +381,28 @@ public void write(JsonWriter out, AnalysisLogEntry value) throws IOException { public AnalysisLogEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisLogEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisLogMessage.java b/src/main/java/ai/reveng/model/AnalysisLogMessage.java index d31dcd28..93ea31e0 100644 --- a/src/main/java/ai/reveng/model/AnalysisLogMessage.java +++ b/src/main/java/ai/reveng/model/AnalysisLogMessage.java @@ -99,6 +99,50 @@ public void setTime(@javax.annotation.Nonnull String time) { this.time = time; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisLogMessage instance itself + */ + public AnalysisLogMessage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } AnalysisLogMessage analysisLogMessage = (AnalysisLogMessage) o; return Objects.equals(this.message, analysisLogMessage.message) && - Objects.equals(this.time, analysisLogMessage.time); + Objects.equals(this.time, analysisLogMessage.time)&& + Objects.equals(this.additionalProperties, analysisLogMessage.additionalProperties); } @Override public int hashCode() { - return Objects.hash(message, time); + return Objects.hash(message, time, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class AnalysisLogMessage {\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" time: ").append(toIndentedString(time)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisLogMessage.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisLogMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisLogMessage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,6 +238,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisLogMessage value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -207,7 +267,28 @@ public void write(JsonWriter out, AnalysisLogMessage value) throws IOException { public AnalysisLogMessage read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisLogMessage instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisLogs.java b/src/main/java/ai/reveng/model/AnalysisLogs.java index 93eefe82..b75e0843 100644 --- a/src/main/java/ai/reveng/model/AnalysisLogs.java +++ b/src/main/java/ai/reveng/model/AnalysisLogs.java @@ -110,6 +110,50 @@ public void setMessages(@javax.annotation.Nullable List mess this.messages = messages; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisLogs instance itself + */ + public AnalysisLogs putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } AnalysisLogs analysisLogs = (AnalysisLogs) o; return Objects.equals(this.messageCount, analysisLogs.messageCount) && - Objects.equals(this.messages, analysisLogs.messages); + Objects.equals(this.messages, analysisLogs.messages)&& + Objects.equals(this.additionalProperties, analysisLogs.additionalProperties); } @Override public int hashCode() { - return Objects.hash(messageCount, messages); + return Objects.hash(messageCount, messages, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class AnalysisLogs {\n"); sb.append(" messageCount: ").append(toIndentedString(messageCount)).append("\n"); sb.append(" messages: ").append(toIndentedString(messages)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisLogs.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisLogs` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisLogs.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("messages") != null && !jsonObj.get("messages").isJsonNull()) { - if (!jsonObj.get("messages").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); - } - JsonArray jsonArraymessages = jsonObj.getAsJsonArray("messages"); - // validate the required field `messages` (array) - for (int i = 0; i < jsonArraymessages.size(); i++) { - AnalysisLogMessage.validateJsonElement(jsonArraymessages.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("messages") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("messages").isJsonArray() && !jsonObj.get("messages").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisLogs value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, AnalysisLogs value) throws IOException { public AnalysisLogs read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisLogs instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisRecordBody.java b/src/main/java/ai/reveng/model/AnalysisRecordBody.java index 2c1816eb..3ce78fc0 100644 --- a/src/main/java/ai/reveng/model/AnalysisRecordBody.java +++ b/src/main/java/ai/reveng/model/AnalysisRecordBody.java @@ -179,6 +179,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nonnull private String modelName; + public static final String SERIALIZED_NAME_MODEL_UPGRADE_AVAILABLE = "model_upgrade_available"; + @SerializedName(SERIALIZED_NAME_MODEL_UPGRADE_AVAILABLE) + @javax.annotation.Nonnull + private Boolean modelUpgradeAvailable; + public static final String SERIALIZED_NAME_SHA256_HASH = "sha_256_hash"; @SerializedName(SERIALIZED_NAME_SHA256_HASH) @javax.annotation.Nonnull @@ -483,6 +488,25 @@ public void setModelName(@javax.annotation.Nonnull String modelName) { } + public AnalysisRecordBody modelUpgradeAvailable(@javax.annotation.Nonnull Boolean modelUpgradeAvailable) { + this.modelUpgradeAvailable = modelUpgradeAvailable; + return this; + } + + /** + * True when the analysis ran on a model older than the current one, so its owner can re-analyse it on the latest. Describes the analysis, not the caller's rights — only the owner may act on it + * @return modelUpgradeAvailable + */ + @javax.annotation.Nonnull + public Boolean getModelUpgradeAvailable() { + return modelUpgradeAvailable; + } + + public void setModelUpgradeAvailable(@javax.annotation.Nonnull Boolean modelUpgradeAvailable) { + this.modelUpgradeAvailable = modelUpgradeAvailable; + } + + public AnalysisRecordBody sha256Hash(@javax.annotation.Nonnull String sha256Hash) { this.sha256Hash = sha256Hash; return this; @@ -692,6 +716,7 @@ public boolean equals(Object o) { Objects.equals(this.isOwner, analysisRecordBody.isOwner) && Objects.equals(this.modelId, analysisRecordBody.modelId) && Objects.equals(this.modelName, analysisRecordBody.modelName) && + Objects.equals(this.modelUpgradeAvailable, analysisRecordBody.modelUpgradeAvailable) && Objects.equals(this.sha256Hash, analysisRecordBody.sha256Hash) && Objects.equals(this.status, analysisRecordBody.status) && Objects.equals(this.suppliedArchitecture, analysisRecordBody.suppliedArchitecture) && @@ -704,7 +729,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(analysisId, analysisScope, baseAddress, binaryId, binaryName, binarySize, creation, detectedArchitecture, detectedBinaryFormat, detectedBinaryType, functionBoundariesHash, isOwner, modelId, modelName, sha256Hash, status, suppliedArchitecture, suppliedBinaryFormat, suppliedBinaryType, tags, username, additionalProperties); + return Objects.hash(analysisId, analysisScope, baseAddress, binaryId, binaryName, binarySize, creation, detectedArchitecture, detectedBinaryFormat, detectedBinaryType, functionBoundariesHash, isOwner, modelId, modelName, modelUpgradeAvailable, sha256Hash, status, suppliedArchitecture, suppliedBinaryFormat, suppliedBinaryType, tags, username, additionalProperties); } @Override @@ -725,6 +750,7 @@ public String toString() { sb.append(" isOwner: ").append(toIndentedString(isOwner)).append("\n"); sb.append(" modelId: ").append(toIndentedString(modelId)).append("\n"); sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); + sb.append(" modelUpgradeAvailable: ").append(toIndentedString(modelUpgradeAvailable)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" suppliedArchitecture: ").append(toIndentedString(suppliedArchitecture)).append("\n"); @@ -751,10 +777,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("analysis_id", "analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "creation", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_boundaries_hash", "is_owner", "model_id", "model_name", "sha_256_hash", "status", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "tags", "username")); + openapiFields = new HashSet(Arrays.asList("analysis_id", "analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "creation", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_boundaries_hash", "is_owner", "model_id", "model_name", "model_upgrade_available", "sha_256_hash", "status", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "tags", "username")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "creation", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_boundaries_hash", "is_owner", "model_id", "model_name", "sha_256_hash", "status", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "tags", "username")); + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "analysis_scope", "base_address", "binary_id", "binary_name", "binary_size", "creation", "detected_architecture", "detected_binary_format", "detected_binary_type", "function_boundaries_hash", "is_owner", "model_id", "model_name", "model_upgrade_available", "sha_256_hash", "status", "supplied_architecture", "supplied_binary_format", "supplied_binary_type", "tags", "username")); } /** @@ -815,15 +841,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("supplied_binary_type").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `supplied_binary_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("supplied_binary_type").toString())); } - if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull()) { - if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); - } - JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); - // validate the required field `tags` (array) - for (int i = 0; i < jsonArraytags.size(); i++) { - AnalysisTagBody.validateJsonElement(jsonArraytags.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("tags") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("tags").isJsonArray() && !jsonObj.get("tags").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } if (!jsonObj.get("username").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); diff --git a/src/main/java/ai/reveng/model/AnalysisReport.java b/src/main/java/ai/reveng/model/AnalysisReport.java index a735720f..c29a721f 100644 --- a/src/main/java/ai/reveng/model/AnalysisReport.java +++ b/src/main/java/ai/reveng/model/AnalysisReport.java @@ -517,6 +517,50 @@ public void setTtps(@javax.annotation.Nullable List ttps) { this.ttps = ttps; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisReport instance itself + */ + public AnalysisReport putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -542,7 +586,8 @@ public boolean equals(Object o) { Objects.equals(this.scheduledTasks, analysisReport.scheduledTasks) && Objects.equals(this.services, analysisReport.services) && Objects.equals(this.startup, analysisReport.startup) && - Objects.equals(this.ttps, analysisReport.ttps); + Objects.equals(this.ttps, analysisReport.ttps)&& + Objects.equals(this.additionalProperties, analysisReport.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -551,7 +596,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(artifacts, consoleOutput, fileActivity, info, memdumps, moduleLoadAddresses, mutexes, networkActivity, processActivity, processTree, registryOperations, scheduledTasks, services, startup, ttps); + return Objects.hash(artifacts, consoleOutput, fileActivity, info, memdumps, moduleLoadAddresses, mutexes, networkActivity, processActivity, processTree, registryOperations, scheduledTasks, services, startup, ttps, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -580,6 +625,7 @@ public String toString() { sb.append(" services: ").append(toIndentedString(services)).append("\n"); sb.append(" startup: ").append(toIndentedString(startup)).append("\n"); sb.append(" ttps: ").append(toIndentedString(ttps)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -617,14 +663,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisReport.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisReport` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisReport.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -632,173 +670,49 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("artifacts") != null && !jsonObj.get("artifacts").isJsonNull()) { - JsonArray jsonArrayartifacts = jsonObj.getAsJsonArray("artifacts"); - if (jsonArrayartifacts != null) { - // ensure the json data is an array - if (!jsonObj.get("artifacts").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifacts` to be an array in the JSON string but got `%s`", jsonObj.get("artifacts").toString())); - } - - // validate the optional field `artifacts` (array) - for (int i = 0; i < jsonArrayartifacts.size(); i++) { - Artifact.validateJsonElement(jsonArrayartifacts.get(i)); - }; - } - } - if (jsonObj.get("console_output") != null && !jsonObj.get("console_output").isJsonNull()) { - JsonArray jsonArrayconsoleOutput = jsonObj.getAsJsonArray("console_output"); - if (jsonArrayconsoleOutput != null) { - // ensure the json data is an array - if (!jsonObj.get("console_output").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `console_output` to be an array in the JSON string but got `%s`", jsonObj.get("console_output").toString())); - } - - // validate the optional field `console_output` (array) - for (int i = 0; i < jsonArrayconsoleOutput.size(); i++) { - ConsoleOutputEntry.validateJsonElement(jsonArrayconsoleOutput.get(i)); - }; - } - } - if (jsonObj.get("file_activity") != null && !jsonObj.get("file_activity").isJsonNull()) { - JsonArray jsonArrayfileActivity = jsonObj.getAsJsonArray("file_activity"); - if (jsonArrayfileActivity != null) { - // ensure the json data is an array - if (!jsonObj.get("file_activity").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_activity` to be an array in the JSON string but got `%s`", jsonObj.get("file_activity").toString())); - } - - // validate the optional field `file_activity` (array) - for (int i = 0; i < jsonArrayfileActivity.size(); i++) { - FileActivityEntry.validateJsonElement(jsonArrayfileActivity.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("artifacts") != null && !jsonObj.get("artifacts").isJsonNull() && !jsonObj.get("artifacts").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifacts` to be an array in the JSON string but got `%s`", jsonObj.get("artifacts").toString())); } - // validate the required field `info` - ReportInfo.validateJsonElement(jsonObj.get("info")); - if (jsonObj.get("memdumps") != null && !jsonObj.get("memdumps").isJsonNull()) { - JsonArray jsonArraymemdumps = jsonObj.getAsJsonArray("memdumps"); - if (jsonArraymemdumps != null) { - // ensure the json data is an array - if (!jsonObj.get("memdumps").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `memdumps` to be an array in the JSON string but got `%s`", jsonObj.get("memdumps").toString())); - } - - // validate the optional field `memdumps` (array) - for (int i = 0; i < jsonArraymemdumps.size(); i++) { - ProcessMemdumps.validateJsonElement(jsonArraymemdumps.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("console_output") != null && !jsonObj.get("console_output").isJsonNull() && !jsonObj.get("console_output").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `console_output` to be an array in the JSON string but got `%s`", jsonObj.get("console_output").toString())); } - if (jsonObj.get("module_load_addresses") != null && !jsonObj.get("module_load_addresses").isJsonNull()) { - JsonArray jsonArraymoduleLoadAddresses = jsonObj.getAsJsonArray("module_load_addresses"); - if (jsonArraymoduleLoadAddresses != null) { - // ensure the json data is an array - if (!jsonObj.get("module_load_addresses").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `module_load_addresses` to be an array in the JSON string but got `%s`", jsonObj.get("module_load_addresses").toString())); - } - - // validate the optional field `module_load_addresses` (array) - for (int i = 0; i < jsonArraymoduleLoadAddresses.size(); i++) { - ModuleLoadEntry.validateJsonElement(jsonArraymoduleLoadAddresses.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("file_activity") != null && !jsonObj.get("file_activity").isJsonNull() && !jsonObj.get("file_activity").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_activity` to be an array in the JSON string but got `%s`", jsonObj.get("file_activity").toString())); } - if (jsonObj.get("mutexes") != null && !jsonObj.get("mutexes").isJsonNull()) { - JsonArray jsonArraymutexes = jsonObj.getAsJsonArray("mutexes"); - if (jsonArraymutexes != null) { - // ensure the json data is an array - if (!jsonObj.get("mutexes").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mutexes` to be an array in the JSON string but got `%s`", jsonObj.get("mutexes").toString())); - } - - // validate the optional field `mutexes` (array) - for (int i = 0; i < jsonArraymutexes.size(); i++) { - MutexEntry.validateJsonElement(jsonArraymutexes.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("memdumps") != null && !jsonObj.get("memdumps").isJsonNull() && !jsonObj.get("memdumps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `memdumps` to be an array in the JSON string but got `%s`", jsonObj.get("memdumps").toString())); } - // validate the optional field `network_activity` - if (jsonObj.get("network_activity") != null && !jsonObj.get("network_activity").isJsonNull()) { - NetworkActivity.validateJsonElement(jsonObj.get("network_activity")); + // ensure the optional json data is an array if present + if (jsonObj.get("module_load_addresses") != null && !jsonObj.get("module_load_addresses").isJsonNull() && !jsonObj.get("module_load_addresses").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `module_load_addresses` to be an array in the JSON string but got `%s`", jsonObj.get("module_load_addresses").toString())); } - if (jsonObj.get("process_activity") != null && !jsonObj.get("process_activity").isJsonNull()) { - JsonArray jsonArrayprocessActivity = jsonObj.getAsJsonArray("process_activity"); - if (jsonArrayprocessActivity != null) { - // ensure the json data is an array - if (!jsonObj.get("process_activity").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `process_activity` to be an array in the JSON string but got `%s`", jsonObj.get("process_activity").toString())); - } - - // validate the optional field `process_activity` (array) - for (int i = 0; i < jsonArrayprocessActivity.size(); i++) { - ProcessActivityEntry.validateJsonElement(jsonArrayprocessActivity.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("mutexes") != null && !jsonObj.get("mutexes").isJsonNull() && !jsonObj.get("mutexes").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mutexes` to be an array in the JSON string but got `%s`", jsonObj.get("mutexes").toString())); } - // validate the optional field `process_tree` - if (jsonObj.get("process_tree") != null && !jsonObj.get("process_tree").isJsonNull()) { - ProcessTree.validateJsonElement(jsonObj.get("process_tree")); + // ensure the optional json data is an array if present + if (jsonObj.get("process_activity") != null && !jsonObj.get("process_activity").isJsonNull() && !jsonObj.get("process_activity").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `process_activity` to be an array in the JSON string but got `%s`", jsonObj.get("process_activity").toString())); } - if (jsonObj.get("registry_operations") != null && !jsonObj.get("registry_operations").isJsonNull()) { - JsonArray jsonArrayregistryOperations = jsonObj.getAsJsonArray("registry_operations"); - if (jsonArrayregistryOperations != null) { - // ensure the json data is an array - if (!jsonObj.get("registry_operations").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `registry_operations` to be an array in the JSON string but got `%s`", jsonObj.get("registry_operations").toString())); - } - - // validate the optional field `registry_operations` (array) - for (int i = 0; i < jsonArrayregistryOperations.size(); i++) { - RegistryOperation.validateJsonElement(jsonArrayregistryOperations.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("registry_operations") != null && !jsonObj.get("registry_operations").isJsonNull() && !jsonObj.get("registry_operations").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `registry_operations` to be an array in the JSON string but got `%s`", jsonObj.get("registry_operations").toString())); } - if (jsonObj.get("scheduled_tasks") != null && !jsonObj.get("scheduled_tasks").isJsonNull()) { - JsonArray jsonArrayscheduledTasks = jsonObj.getAsJsonArray("scheduled_tasks"); - if (jsonArrayscheduledTasks != null) { - // ensure the json data is an array - if (!jsonObj.get("scheduled_tasks").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `scheduled_tasks` to be an array in the JSON string but got `%s`", jsonObj.get("scheduled_tasks").toString())); - } - - // validate the optional field `scheduled_tasks` (array) - for (int i = 0; i < jsonArrayscheduledTasks.size(); i++) { - ScheduledTaskEntry.validateJsonElement(jsonArrayscheduledTasks.get(i)); - }; - } - } - if (jsonObj.get("services") != null && !jsonObj.get("services").isJsonNull()) { - JsonArray jsonArrayservices = jsonObj.getAsJsonArray("services"); - if (jsonArrayservices != null) { - // ensure the json data is an array - if (!jsonObj.get("services").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `services` to be an array in the JSON string but got `%s`", jsonObj.get("services").toString())); - } - - // validate the optional field `services` (array) - for (int i = 0; i < jsonArrayservices.size(); i++) { - ServiceEntry.validateJsonElement(jsonArrayservices.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("scheduled_tasks") != null && !jsonObj.get("scheduled_tasks").isJsonNull() && !jsonObj.get("scheduled_tasks").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `scheduled_tasks` to be an array in the JSON string but got `%s`", jsonObj.get("scheduled_tasks").toString())); } - // validate the optional field `startup` - if (jsonObj.get("startup") != null && !jsonObj.get("startup").isJsonNull()) { - StartupInfo.validateJsonElement(jsonObj.get("startup")); + // ensure the optional json data is an array if present + if (jsonObj.get("services") != null && !jsonObj.get("services").isJsonNull() && !jsonObj.get("services").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `services` to be an array in the JSON string but got `%s`", jsonObj.get("services").toString())); } - if (jsonObj.get("ttps") != null && !jsonObj.get("ttps").isJsonNull()) { - JsonArray jsonArrayttps = jsonObj.getAsJsonArray("ttps"); - if (jsonArrayttps != null) { - // ensure the json data is an array - if (!jsonObj.get("ttps").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ttps` to be an array in the JSON string but got `%s`", jsonObj.get("ttps").toString())); - } - - // validate the optional field `ttps` (array) - for (int i = 0; i < jsonArrayttps.size(); i++) { - Ttp.validateJsonElement(jsonArrayttps.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("ttps") != null && !jsonObj.get("ttps").isJsonNull() && !jsonObj.get("ttps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ttps` to be an array in the JSON string but got `%s`", jsonObj.get("ttps").toString())); } } @@ -817,6 +731,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisReport value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -824,7 +760,28 @@ public void write(JsonWriter out, AnalysisReport value) throws IOException { public AnalysisReport read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisReport instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisRequirement.java b/src/main/java/ai/reveng/model/AnalysisRequirement.java new file mode 100644 index 00000000..73c82857 --- /dev/null +++ b/src/main/java/ai/reveng/model/AnalysisRequirement.java @@ -0,0 +1,367 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * AnalysisRequirement + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class AnalysisRequirement { + public static final String SERIALIZED_NAME_FIELDS = "fields"; + @SerializedName(SERIALIZED_NAME_FIELDS) + @javax.annotation.Nullable + private List fields; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + @javax.annotation.Nonnull + private String reason; + + public static final String SERIALIZED_NAME_VALUES = "values"; + @SerializedName(SERIALIZED_NAME_VALUES) + @javax.annotation.Nullable + private Map values = new HashMap<>(); + + public AnalysisRequirement() { + } + + public AnalysisRequirement fields(@javax.annotation.Nullable List fields) { + this.fields = fields; + return this; + } + + public AnalysisRequirement addFieldsItem(String fieldsItem) { + if (this.fields == null) { + this.fields = new ArrayList<>(); + } + this.fields.add(fieldsItem); + return this; + } + + /** + * CreateAnalysis field paths that must be provided or enabled to satisfy this requirement. + * @return fields + */ + @javax.annotation.Nullable + public List getFields() { + return fields; + } + + public void setFields(@javax.annotation.Nullable List fields) { + this.fields = fields; + } + + + public AnalysisRequirement reason(@javax.annotation.Nonnull String reason) { + this.reason = reason; + return this; + } + + /** + * Why this requirement unblocks analysis. + * @return reason + */ + @javax.annotation.Nonnull + public String getReason() { + return reason; + } + + public void setReason(@javax.annotation.Nonnull String reason) { + this.reason = reason; + } + + + public AnalysisRequirement values(@javax.annotation.Nullable Map values) { + this.values = values; + return this; + } + + public AnalysisRequirement putValuesItem(String key, String valuesItem) { + if (this.values == null) { + this.values = new HashMap<>(); + } + this.values.put(key, valuesItem); + return this; + } + + /** + * Field paths that must carry a specific value, keyed the same way as fields. + * @return values + */ + @javax.annotation.Nullable + public Map getValues() { + return values; + } + + public void setValues(@javax.annotation.Nullable Map values) { + this.values = values; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisRequirement instance itself + */ + public AnalysisRequirement putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnalysisRequirement analysisRequirement = (AnalysisRequirement) o; + return Objects.equals(this.fields, analysisRequirement.fields) && + Objects.equals(this.reason, analysisRequirement.reason) && + Objects.equals(this.values, analysisRequirement.values)&& + Objects.equals(this.additionalProperties, analysisRequirement.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(fields, reason, values, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnalysisRequirement {\n"); + sb.append(" fields: ").append(toIndentedString(fields)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("fields", "reason", "values")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("fields", "reason")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to AnalysisRequirement + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!AnalysisRequirement.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisRequirement is not found in the empty JSON string", AnalysisRequirement.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AnalysisRequirement.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("fields") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("fields").isJsonArray() && !jsonObj.get("fields").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `fields` to be an array in the JSON string but got `%s`", jsonObj.get("fields").toString())); + } + if (!jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AnalysisRequirement.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AnalysisRequirement' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AnalysisRequirement.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AnalysisRequirement value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public AnalysisRequirement read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisRequirement instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AnalysisRequirement given an JSON string + * + * @param jsonString JSON string + * @return An instance of AnalysisRequirement + * @throws IOException if the JSON string is invalid with respect to AnalysisRequirement + */ + public static AnalysisRequirement fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AnalysisRequirement.class); + } + + /** + * Convert an instance of AnalysisRequirement to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/AnalysisStringFunction.java b/src/main/java/ai/reveng/model/AnalysisStringFunction.java index 482cc8df..4b456971 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringFunction.java +++ b/src/main/java/ai/reveng/model/AnalysisStringFunction.java @@ -99,6 +99,50 @@ public void setFunctionVaddr(@javax.annotation.Nonnull Long functionVaddr) { this.functionVaddr = functionVaddr; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisStringFunction instance itself + */ + public AnalysisStringFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } AnalysisStringFunction analysisStringFunction = (AnalysisStringFunction) o; return Objects.equals(this.functionId, analysisStringFunction.functionId) && - Objects.equals(this.functionVaddr, analysisStringFunction.functionVaddr); + Objects.equals(this.functionVaddr, analysisStringFunction.functionVaddr)&& + Objects.equals(this.additionalProperties, analysisStringFunction.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionVaddr); + return Objects.hash(functionId, functionVaddr, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class AnalysisStringFunction {\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisStringFunction.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisStringFunction` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisStringFunction value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, AnalysisStringFunction value) throws IOExcepti public AnalysisStringFunction read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisStringFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisStringItem.java b/src/main/java/ai/reveng/model/AnalysisStringItem.java index 722aa24f..dbdb245c 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringItem.java +++ b/src/main/java/ai/reveng/model/AnalysisStringItem.java @@ -134,6 +134,50 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisStringItem instance itself + */ + public AnalysisStringItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -147,12 +191,13 @@ public boolean equals(Object o) { AnalysisStringItem analysisStringItem = (AnalysisStringItem) o; return Objects.equals(this.functions, analysisStringItem.functions) && Objects.equals(this.source, analysisStringItem.source) && - Objects.equals(this.value, analysisStringItem.value); + Objects.equals(this.value, analysisStringItem.value)&& + Objects.equals(this.additionalProperties, analysisStringItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functions, source, value); + return Objects.hash(functions, source, value, additionalProperties); } @Override @@ -162,6 +207,7 @@ public String toString() { sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); sb.append(" source: ").append(toIndentedString(source)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -199,14 +245,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisStringItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisStringItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -214,15 +252,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("functions") != null && !jsonObj.get("functions").isJsonNull()) { - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); - } - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - AnalysisStringFunction.validateJsonElement(jsonArrayfunctions.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("functions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("functions").isJsonArray() && !jsonObj.get("functions").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); } if (!jsonObj.get("source").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); @@ -247,6 +281,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisStringItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -254,7 +310,28 @@ public void write(JsonWriter out, AnalysisStringItem value) throws IOException { public AnalysisStringItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisStringItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisTagBody.java b/src/main/java/ai/reveng/model/AnalysisTagBody.java index 77a2efc8..4ead1d60 100644 --- a/src/main/java/ai/reveng/model/AnalysisTagBody.java +++ b/src/main/java/ai/reveng/model/AnalysisTagBody.java @@ -123,6 +123,50 @@ public void setOrigin(@javax.annotation.Nonnull String origin) { this.origin = origin; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AnalysisTagBody instance itself + */ + public AnalysisTagBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -136,12 +180,13 @@ public boolean equals(Object o) { AnalysisTagBody analysisTagBody = (AnalysisTagBody) o; return Objects.equals(this.collectionId, analysisTagBody.collectionId) && Objects.equals(this.name, analysisTagBody.name) && - Objects.equals(this.origin, analysisTagBody.origin); + Objects.equals(this.origin, analysisTagBody.origin)&& + Objects.equals(this.additionalProperties, analysisTagBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(collectionId, name, origin); + return Objects.hash(collectionId, name, origin, additionalProperties); } @Override @@ -151,6 +196,7 @@ public String toString() { sb.append(" collectionId: ").append(toIndentedString(collectionId)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" origin: ").append(toIndentedString(origin)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -188,14 +234,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisTagBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisTagBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisTagBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -226,6 +264,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisTagBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -233,7 +293,28 @@ public void write(JsonWriter out, AnalysisTagBody value) throws IOException { public AnalysisTagBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AnalysisTagBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ApiCall.java b/src/main/java/ai/reveng/model/ApiCall.java index 737e860c..af6d6871 100644 --- a/src/main/java/ai/reveng/model/ApiCall.java +++ b/src/main/java/ai/reveng/model/ApiCall.java @@ -147,6 +147,50 @@ public void setMethod(@javax.annotation.Nonnull String method) { this.method = method; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ApiCall instance itself + */ + public ApiCall putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.calledFrom, apiCall.calledFrom) && Objects.equals(this.calledFromRva, apiCall.calledFromRva) && Objects.equals(this.fromModule, apiCall.fromModule) && - Objects.equals(this.method, apiCall.method); + Objects.equals(this.method, apiCall.method)&& + Objects.equals(this.additionalProperties, apiCall.additionalProperties); } @Override public int hashCode() { - return Objects.hash(calledFrom, calledFromRva, fromModule, method); + return Objects.hash(calledFrom, calledFromRva, fromModule, method, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" calledFromRva: ").append(toIndentedString(calledFromRva)).append("\n"); sb.append(" fromModule: ").append(toIndentedString(fromModule)).append("\n"); sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ApiCall.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ApiCall` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ApiCall.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -258,6 +296,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ApiCall value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -265,7 +325,28 @@ public void write(JsonWriter out, ApiCall value) throws IOException { public ApiCall read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ApiCall instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ApiCombinationEvidence.java b/src/main/java/ai/reveng/model/ApiCombinationEvidence.java new file mode 100644 index 00000000..45e52919 --- /dev/null +++ b/src/main/java/ai/reveng/model/ApiCombinationEvidence.java @@ -0,0 +1,591 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceEffect; +import ai.reveng.model.ImportedApi; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * A known combination of APIs without a demonstrated semantic flow. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiCombinationEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + API_COMBINATION("api_combination"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.API_COMBINATION; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + INDIRECT("indirect"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.INDIRECT; + + public static final String SERIALIZED_NAME_APIS = "apis"; + @SerializedName(SERIALIZED_NAME_APIS) + @javax.annotation.Nonnull + private List apis = new ArrayList<>(); + + public ApiCombinationEvidence() { + } + + public ApiCombinationEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public ApiCombinationEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public ApiCombinationEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public ApiCombinationEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public ApiCombinationEvidence apis(@javax.annotation.Nonnull List apis) { + this.apis = apis; + return this; + } + + public ApiCombinationEvidence addApisItem(ImportedApi apisItem) { + if (this.apis == null) { + this.apis = new ArrayList<>(); + } + this.apis.add(apisItem); + return this; + } + + /** + * Get apis + * @return apis + */ + @javax.annotation.Nonnull + public List getApis() { + return apis; + } + + public void setApis(@javax.annotation.Nonnull List apis) { + this.apis = apis; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ApiCombinationEvidence instance itself + */ + public ApiCombinationEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiCombinationEvidence apiCombinationEvidence = (ApiCombinationEvidence) o; + return Objects.equals(this.evidenceKind, apiCombinationEvidence.evidenceKind) && + Objects.equals(this.kind, apiCombinationEvidence.kind) && + Objects.equals(this.effect, apiCombinationEvidence.effect) && + Objects.equals(this.strength, apiCombinationEvidence.strength) && + Objects.equals(this.apis, apiCombinationEvidence.apis)&& + Objects.equals(this.additionalProperties, apiCombinationEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, apis, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiCombinationEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" apis: ").append(toIndentedString(apis)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "apis")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "apis")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ApiCombinationEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ApiCombinationEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ApiCombinationEvidence is not found in the empty JSON string", ApiCombinationEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ApiCombinationEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + if (jsonObj.get("apis") != null) { + if (!jsonObj.get("apis").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `apis` to be an array in the JSON string but got `%s`", jsonObj.get("apis").toString())); + } + JsonArray jsonArrayapis = jsonObj.getAsJsonArray("apis"); + // validate the required field `apis` (array) + for (int i = 0; i < jsonArrayapis.size(); i++) { + ImportedApi.validateJsonElement(jsonArrayapis.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ApiCombinationEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ApiCombinationEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ApiCombinationEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ApiCombinationEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ApiCombinationEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ApiCombinationEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ApiCombinationEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of ApiCombinationEvidence + * @throws IOException if the JSON string is invalid with respect to ApiCombinationEvidence + */ + public static ApiCombinationEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ApiCombinationEvidence.class); + } + + /** + * Convert an instance of ApiCombinationEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ArrayDataType.java b/src/main/java/ai/reveng/model/ArrayDataType.java index cceb1cbb..61d6e638 100644 --- a/src/main/java/ai/reveng/model/ArrayDataType.java +++ b/src/main/java/ai/reveng/model/ArrayDataType.java @@ -143,6 +143,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -366,6 +371,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public ArrayDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public ArrayDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -403,6 +427,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ArrayDataType instance itself + */ + public ArrayDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -422,13 +490,15 @@ public boolean equals(Object o) { Objects.equals(this.name, arrayDataType.name) && Objects.equals(this.namespace, arrayDataType.namespace) && Objects.equals(this.size, arrayDataType.size) && + Objects.equals(this.sourceAnalysisId, arrayDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, arrayDataType.sourceFunctionId) && - Objects.equals(this.sourceType, arrayDataType.sourceType); + Objects.equals(this.sourceType, arrayDataType.sourceType)&& + Objects.equals(this.additionalProperties, arrayDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -443,8 +513,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -463,7 +535,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -482,14 +554,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ArrayDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ArrayDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ArrayDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -497,10 +561,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `definition` - if (jsonObj.get("definition") != null && !jsonObj.get("definition").isJsonNull()) { - ArrayDefinition.validateJsonElement(jsonObj.get("definition")); - } if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -534,6 +594,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ArrayDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -541,7 +623,28 @@ public void write(JsonWriter out, ArrayDataType value) throws IOException { public ArrayDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ArrayDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ArrayDefinition.java b/src/main/java/ai/reveng/model/ArrayDefinition.java index 87ef1f37..418fffb1 100644 --- a/src/main/java/ai/reveng/model/ArrayDefinition.java +++ b/src/main/java/ai/reveng/model/ArrayDefinition.java @@ -99,6 +99,50 @@ public void setElementDataTypeId(@javax.annotation.Nullable Long elementDataType this.elementDataTypeId = elementDataTypeId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ArrayDefinition instance itself + */ + public ArrayDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } ArrayDefinition arrayDefinition = (ArrayDefinition) o; return Objects.equals(this.count, arrayDefinition.count) && - Objects.equals(this.elementDataTypeId, arrayDefinition.elementDataTypeId); + Objects.equals(this.elementDataTypeId, arrayDefinition.elementDataTypeId)&& + Objects.equals(this.additionalProperties, arrayDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(count, elementDataTypeId); + return Objects.hash(count, elementDataTypeId, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class ArrayDefinition {\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); sb.append(" elementDataTypeId: ").append(toIndentedString(elementDataTypeId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -161,14 +207,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ArrayDefinition is not found in the empty JSON string", ArrayDefinition.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ArrayDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ArrayDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -187,6 +225,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ArrayDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -194,7 +254,28 @@ public void write(JsonWriter out, ArrayDefinition value) throws IOException { public ArrayDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ArrayDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Artifact.java b/src/main/java/ai/reveng/model/Artifact.java index b7afbadc..6a96df68 100644 --- a/src/main/java/ai/reveng/model/Artifact.java +++ b/src/main/java/ai/reveng/model/Artifact.java @@ -604,6 +604,50 @@ public void setYaraHits(@javax.annotation.Nullable List yaraHits) { this.yaraHits = yaraHits; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Artifact instance itself + */ + public Artifact putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -634,7 +678,8 @@ public boolean equals(Object o) { Objects.equals(this.source, artifact.source) && Objects.equals(this.uri, artifact.uri) && Objects.equals(this.wasMapped, artifact.wasMapped) && - Objects.equals(this.yaraHits, artifact.yaraHits); + Objects.equals(this.yaraHits, artifact.yaraHits)&& + Objects.equals(this.additionalProperties, artifact.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -643,7 +688,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(direction, dumpAddr, dumpPid, fileType, host, isPe, mimeType, name, networkSource, originalFilename, path, processSeqid, reason, responseStatus, sha256, size, source, uri, wasMapped, yaraHits); + return Objects.hash(direction, dumpAddr, dumpPid, fileType, host, isPe, mimeType, name, networkSource, originalFilename, path, processSeqid, reason, responseStatus, sha256, size, source, uri, wasMapped, yaraHits, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -677,6 +722,7 @@ public String toString() { sb.append(" uri: ").append(toIndentedString(uri)).append("\n"); sb.append(" wasMapped: ").append(toIndentedString(wasMapped)).append("\n"); sb.append(" yaraHits: ").append(toIndentedString(yaraHits)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -714,14 +760,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Artifact.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Artifact` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Artifact.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -791,6 +829,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Artifact value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -798,7 +858,28 @@ public void write(JsonWriter out, Artifact value) throws IOException { public Artifact read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Artifact instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AttemptFailedEvent.java b/src/main/java/ai/reveng/model/AttemptFailedEvent.java index 003db5a9..053b02b2 100644 --- a/src/main/java/ai/reveng/model/AttemptFailedEvent.java +++ b/src/main/java/ai/reveng/model/AttemptFailedEvent.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AttemptFailedEvent instance itself + */ + public AttemptFailedEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.attempt, attemptFailedEvent.attempt) && Objects.equals(this.error, attemptFailedEvent.error) && Objects.equals(this.seq, attemptFailedEvent.seq) && - Objects.equals(this.type, attemptFailedEvent.type); + Objects.equals(this.type, attemptFailedEvent.type)&& + Objects.equals(this.additionalProperties, attemptFailedEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(attempt, error, seq, type); + return Objects.hash(attempt, error, seq, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" error: ").append(toIndentedString(error)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AttemptFailedEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AttemptFailedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AttemptFailedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AttemptFailedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, AttemptFailedEvent value) throws IOException { public AttemptFailedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AttemptFailedEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AttemptStartedEvent.java b/src/main/java/ai/reveng/model/AttemptStartedEvent.java index aaae9421..2be2427c 100644 --- a/src/main/java/ai/reveng/model/AttemptStartedEvent.java +++ b/src/main/java/ai/reveng/model/AttemptStartedEvent.java @@ -123,6 +123,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AttemptStartedEvent instance itself + */ + public AttemptStartedEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -136,12 +180,13 @@ public boolean equals(Object o) { AttemptStartedEvent attemptStartedEvent = (AttemptStartedEvent) o; return Objects.equals(this.attempt, attemptStartedEvent.attempt) && Objects.equals(this.seq, attemptStartedEvent.seq) && - Objects.equals(this.type, attemptStartedEvent.type); + Objects.equals(this.type, attemptStartedEvent.type)&& + Objects.equals(this.additionalProperties, attemptStartedEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(attempt, seq, type); + return Objects.hash(attempt, seq, type, additionalProperties); } @Override @@ -151,6 +196,7 @@ public String toString() { sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -188,14 +234,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AttemptStartedEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AttemptStartedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AttemptStartedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -223,6 +261,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AttemptStartedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -230,7 +290,28 @@ public void write(JsonWriter out, AttemptStartedEvent value) throws IOException public AttemptStartedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AttemptStartedEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AutoRunAgents.java b/src/main/java/ai/reveng/model/AutoRunAgents.java index 6395eca3..fc3cad0c 100644 --- a/src/main/java/ai/reveng/model/AutoRunAgents.java +++ b/src/main/java/ai/reveng/model/AutoRunAgents.java @@ -52,7 +52,7 @@ public class AutoRunAgents { public static final String SERIALIZED_NAME_TRIAGE = "triage"; @SerializedName(SERIALIZED_NAME_TRIAGE) @javax.annotation.Nullable - private Boolean triage = false; + private Boolean triage; public AutoRunAgents() { } diff --git a/src/main/java/ai/reveng/model/AutoUnstripStatusOutputBody.java b/src/main/java/ai/reveng/model/AutoUnstripStatusOutputBody.java index f895a9c6..d5e8c511 100644 --- a/src/main/java/ai/reveng/model/AutoUnstripStatusOutputBody.java +++ b/src/main/java/ai/reveng/model/AutoUnstripStatusOutputBody.java @@ -135,6 +135,50 @@ public void setStatus(@javax.annotation.Nonnull StatusEnum status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AutoUnstripStatusOutputBody instance itself + */ + public AutoUnstripStatusOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -146,12 +190,13 @@ public boolean equals(Object o) { return false; } AutoUnstripStatusOutputBody autoUnstripStatusOutputBody = (AutoUnstripStatusOutputBody) o; - return Objects.equals(this.status, autoUnstripStatusOutputBody.status); + return Objects.equals(this.status, autoUnstripStatusOutputBody.status)&& + Objects.equals(this.additionalProperties, autoUnstripStatusOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -159,6 +204,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AutoUnstripStatusOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -196,14 +242,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AutoUnstripStatusOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AutoUnstripStatusOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AutoUnstripStatusOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -233,6 +271,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AutoUnstripStatusOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -240,7 +300,28 @@ public void write(JsonWriter out, AutoUnstripStatusOutputBody value) throws IOEx public AutoUnstripStatusOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AutoUnstripStatusOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BaseDataType.java b/src/main/java/ai/reveng/model/BaseDataType.java index 747ed149..1595f498 100644 --- a/src/main/java/ai/reveng/model/BaseDataType.java +++ b/src/main/java/ai/reveng/model/BaseDataType.java @@ -137,6 +137,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -341,6 +346,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public BaseDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public BaseDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -378,6 +402,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BaseDataType instance itself + */ + public BaseDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -396,13 +464,15 @@ public boolean equals(Object o) { Objects.equals(this.name, baseDataType.name) && Objects.equals(this.namespace, baseDataType.namespace) && Objects.equals(this.size, baseDataType.size) && + Objects.equals(this.sourceAnalysisId, baseDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, baseDataType.sourceFunctionId) && - Objects.equals(this.sourceType, baseDataType.sourceType); + Objects.equals(this.sourceType, baseDataType.sourceType)&& + Objects.equals(this.additionalProperties, baseDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -416,8 +486,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -436,7 +508,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -455,14 +527,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BaseDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -503,6 +567,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -510,7 +596,28 @@ public void write(JsonWriter out, BaseDataType value) throws IOException { public BaseDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BaseDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java b/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java index 1bc4e0c6..fdaf0250 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java +++ b/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java @@ -319,19 +319,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { - JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); - if (jsonArraydata != null) { - // ensure the json data is an array - if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); - } - - // validate the optional field `data` (array) - for (int i = 0; i < jsonArraydata.size(); i++) { - DieMatch.validateJsonElement(jsonArraydata.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); diff --git a/src/main/java/ai/reveng/model/BaseResponseProtocolsAgentResponse.java b/src/main/java/ai/reveng/model/BaseResponseProtocolsAgentResponse.java new file mode 100644 index 00000000..04e48961 --- /dev/null +++ b/src/main/java/ai/reveng/model/BaseResponseProtocolsAgentResponse.java @@ -0,0 +1,429 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ErrorModel; +import ai.reveng.model.MetaModel; +import ai.reveng.model.ProtocolsAgentResponse; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * BaseResponseProtocolsAgentResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BaseResponseProtocolsAgentResponse { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable + private Boolean status = true; + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nullable + private ProtocolsAgentResponse data; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable + private String message; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nullable + private List errors; + + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + @javax.annotation.Nullable + private MetaModel meta; + + public BaseResponseProtocolsAgentResponse() { + } + + public BaseResponseProtocolsAgentResponse status(@javax.annotation.Nullable Boolean status) { + this.status = status; + return this; + } + + /** + * Response status on whether the request succeeded + * @return status + */ + @javax.annotation.Nullable + public Boolean getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nullable Boolean status) { + this.status = status; + } + + + public BaseResponseProtocolsAgentResponse data(@javax.annotation.Nullable ProtocolsAgentResponse data) { + this.data = data; + return this; + } + + /** + * Response data + * @return data + */ + @javax.annotation.Nullable + public ProtocolsAgentResponse getData() { + return data; + } + + public void setData(@javax.annotation.Nullable ProtocolsAgentResponse data) { + this.data = data; + } + + + public BaseResponseProtocolsAgentResponse message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Response message + * @return message + */ + @javax.annotation.Nullable + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + public BaseResponseProtocolsAgentResponse errors(@javax.annotation.Nullable List errors) { + this.errors = errors; + return this; + } + + public BaseResponseProtocolsAgentResponse addErrorsItem(ErrorModel errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * List of errors + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nullable List errors) { + this.errors = errors; + } + + + public BaseResponseProtocolsAgentResponse meta(@javax.annotation.Nullable MetaModel meta) { + this.meta = meta; + return this; + } + + /** + * Metadata + * @return meta + */ + @javax.annotation.Nullable + public MetaModel getMeta() { + return meta; + } + + public void setMeta(@javax.annotation.Nullable MetaModel meta) { + this.meta = meta; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BaseResponseProtocolsAgentResponse instance itself + */ + public BaseResponseProtocolsAgentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseResponseProtocolsAgentResponse baseResponseProtocolsAgentResponse = (BaseResponseProtocolsAgentResponse) o; + return Objects.equals(this.status, baseResponseProtocolsAgentResponse.status) && + Objects.equals(this.data, baseResponseProtocolsAgentResponse.data) && + Objects.equals(this.message, baseResponseProtocolsAgentResponse.message) && + Objects.equals(this.errors, baseResponseProtocolsAgentResponse.errors) && + Objects.equals(this.meta, baseResponseProtocolsAgentResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseProtocolsAgentResponse.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(status, data, message, errors, meta, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseResponseProtocolsAgentResponse {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("status", "data", "message", "errors", "meta")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BaseResponseProtocolsAgentResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!BaseResponseProtocolsAgentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseProtocolsAgentResponse is not found in the empty JSON string", BaseResponseProtocolsAgentResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + ErrorModel.validateJsonElement(jsonArrayerrors.get(i)); + }; + } + } + // validate the optional field `meta` + if (jsonObj.get("meta") != null && !jsonObj.get("meta").isJsonNull()) { + MetaModel.validateJsonElement(jsonObj.get("meta")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BaseResponseProtocolsAgentResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BaseResponseProtocolsAgentResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BaseResponseProtocolsAgentResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BaseResponseProtocolsAgentResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public BaseResponseProtocolsAgentResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BaseResponseProtocolsAgentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BaseResponseProtocolsAgentResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of BaseResponseProtocolsAgentResponse + * @throws IOException if the JSON string is invalid with respect to BaseResponseProtocolsAgentResponse + */ + public static BaseResponseProtocolsAgentResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BaseResponseProtocolsAgentResponse.class); + } + + /** + * Convert an instance of BaseResponseProtocolsAgentResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/BaseResponseSecretsAgentResponse.java b/src/main/java/ai/reveng/model/BaseResponseSecretsAgentResponse.java new file mode 100644 index 00000000..6579a57c --- /dev/null +++ b/src/main/java/ai/reveng/model/BaseResponseSecretsAgentResponse.java @@ -0,0 +1,429 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ErrorModel; +import ai.reveng.model.MetaModel; +import ai.reveng.model.SecretsAgentResponse; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * BaseResponseSecretsAgentResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BaseResponseSecretsAgentResponse { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable + private Boolean status = true; + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nullable + private SecretsAgentResponse data; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable + private String message; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nullable + private List errors; + + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + @javax.annotation.Nullable + private MetaModel meta; + + public BaseResponseSecretsAgentResponse() { + } + + public BaseResponseSecretsAgentResponse status(@javax.annotation.Nullable Boolean status) { + this.status = status; + return this; + } + + /** + * Response status on whether the request succeeded + * @return status + */ + @javax.annotation.Nullable + public Boolean getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nullable Boolean status) { + this.status = status; + } + + + public BaseResponseSecretsAgentResponse data(@javax.annotation.Nullable SecretsAgentResponse data) { + this.data = data; + return this; + } + + /** + * Response data + * @return data + */ + @javax.annotation.Nullable + public SecretsAgentResponse getData() { + return data; + } + + public void setData(@javax.annotation.Nullable SecretsAgentResponse data) { + this.data = data; + } + + + public BaseResponseSecretsAgentResponse message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Response message + * @return message + */ + @javax.annotation.Nullable + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + public BaseResponseSecretsAgentResponse errors(@javax.annotation.Nullable List errors) { + this.errors = errors; + return this; + } + + public BaseResponseSecretsAgentResponse addErrorsItem(ErrorModel errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * List of errors + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nullable List errors) { + this.errors = errors; + } + + + public BaseResponseSecretsAgentResponse meta(@javax.annotation.Nullable MetaModel meta) { + this.meta = meta; + return this; + } + + /** + * Metadata + * @return meta + */ + @javax.annotation.Nullable + public MetaModel getMeta() { + return meta; + } + + public void setMeta(@javax.annotation.Nullable MetaModel meta) { + this.meta = meta; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BaseResponseSecretsAgentResponse instance itself + */ + public BaseResponseSecretsAgentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseResponseSecretsAgentResponse baseResponseSecretsAgentResponse = (BaseResponseSecretsAgentResponse) o; + return Objects.equals(this.status, baseResponseSecretsAgentResponse.status) && + Objects.equals(this.data, baseResponseSecretsAgentResponse.data) && + Objects.equals(this.message, baseResponseSecretsAgentResponse.message) && + Objects.equals(this.errors, baseResponseSecretsAgentResponse.errors) && + Objects.equals(this.meta, baseResponseSecretsAgentResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseSecretsAgentResponse.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(status, data, message, errors, meta, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseResponseSecretsAgentResponse {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("status", "data", "message", "errors", "meta")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BaseResponseSecretsAgentResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!BaseResponseSecretsAgentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseSecretsAgentResponse is not found in the empty JSON string", BaseResponseSecretsAgentResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + ErrorModel.validateJsonElement(jsonArrayerrors.get(i)); + }; + } + } + // validate the optional field `meta` + if (jsonObj.get("meta") != null && !jsonObj.get("meta").isJsonNull()) { + MetaModel.validateJsonElement(jsonObj.get("meta")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BaseResponseSecretsAgentResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BaseResponseSecretsAgentResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BaseResponseSecretsAgentResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BaseResponseSecretsAgentResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public BaseResponseSecretsAgentResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BaseResponseSecretsAgentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BaseResponseSecretsAgentResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of BaseResponseSecretsAgentResponse + * @throws IOException if the JSON string is invalid with respect to BaseResponseSecretsAgentResponse + */ + public static BaseResponseSecretsAgentResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BaseResponseSecretsAgentResponse.class); + } + + /** + * Convert an instance of BaseResponseSecretsAgentResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/BatchFunctionSignatureEntry.java b/src/main/java/ai/reveng/model/BatchFunctionSignatureEntry.java index 0b26b971..654fad7b 100644 --- a/src/main/java/ai/reveng/model/BatchFunctionSignatureEntry.java +++ b/src/main/java/ai/reveng/model/BatchFunctionSignatureEntry.java @@ -359,6 +359,50 @@ public void setSourceType(@javax.annotation.Nullable SourceTypeEnum sourceType) this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BatchFunctionSignatureEntry instance itself + */ + public BatchFunctionSignatureEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -379,12 +423,13 @@ public boolean equals(Object o) { Objects.equals(this.parameters, batchFunctionSignatureEntry.parameters) && Objects.equals(this.returnDataTypeId, batchFunctionSignatureEntry.returnDataTypeId) && Objects.equals(this.sourceFunctionId, batchFunctionSignatureEntry.sourceFunctionId) && - Objects.equals(this.sourceType, batchFunctionSignatureEntry.sourceType); + Objects.equals(this.sourceType, batchFunctionSignatureEntry.sourceType)&& + Objects.equals(this.additionalProperties, batchFunctionSignatureEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, callingConvention, createdAt, functionId, functionName, hasSignature, parameters, returnDataTypeId, sourceFunctionId, sourceType); + return Objects.hash(analysisId, callingConvention, createdAt, functionId, functionName, hasSignature, parameters, returnDataTypeId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -401,6 +446,7 @@ public String toString() { sb.append(" returnDataTypeId: ").append(toIndentedString(returnDataTypeId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -438,14 +484,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchFunctionSignatureEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BatchFunctionSignatureEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchFunctionSignatureEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -459,15 +497,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("function_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } - if (jsonObj.get("parameters") != null && !jsonObj.get("parameters").isJsonNull()) { - if (!jsonObj.get("parameters").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); - } - JsonArray jsonArrayparameters = jsonObj.getAsJsonArray("parameters"); - // validate the required field `parameters` (array) - for (int i = 0; i < jsonArrayparameters.size(); i++) { - SignatureParameterEntry.validateJsonElement(jsonArrayparameters.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("parameters") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("parameters").isJsonArray() && !jsonObj.get("parameters").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); } if ((jsonObj.get("source_type") != null && !jsonObj.get("source_type").isJsonNull()) && !jsonObj.get("source_type").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_type").toString())); @@ -493,6 +527,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchFunctionSignatureEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -500,7 +556,28 @@ public void write(JsonWriter out, BatchFunctionSignatureEntry value) throws IOEx public BatchFunctionSignatureEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BatchFunctionSignatureEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BatchMatchingOutputBody.java b/src/main/java/ai/reveng/model/BatchMatchingOutputBody.java index 0dc05fe9..097564c8 100644 --- a/src/main/java/ai/reveng/model/BatchMatchingOutputBody.java +++ b/src/main/java/ai/reveng/model/BatchMatchingOutputBody.java @@ -286,15 +286,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("per_binary") != null && !jsonObj.get("per_binary").isJsonNull()) { - if (!jsonObj.get("per_binary").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `per_binary` to be an array in the JSON string but got `%s`", jsonObj.get("per_binary").toString())); - } - JsonArray jsonArrayperBinary = jsonObj.getAsJsonArray("per_binary"); - // validate the required field `per_binary` (array) - for (int i = 0; i < jsonArrayperBinary.size(); i++) { - BatchBinaryMatchResult.validateJsonElement(jsonArrayperBinary.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("per_binary") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("per_binary").isJsonArray() && !jsonObj.get("per_binary").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `per_binary` to be an array in the JSON string but got `%s`", jsonObj.get("per_binary").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); diff --git a/src/main/java/ai/reveng/model/BatchRenameInputBody.java b/src/main/java/ai/reveng/model/BatchRenameInputBody.java index cb9213c6..826b7771 100644 --- a/src/main/java/ai/reveng/model/BatchRenameInputBody.java +++ b/src/main/java/ai/reveng/model/BatchRenameInputBody.java @@ -86,6 +86,50 @@ public void setFunctions(@javax.annotation.Nullable List functi this.functions = functions; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BatchRenameInputBody instance itself + */ + public BatchRenameInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } BatchRenameInputBody batchRenameInputBody = (BatchRenameInputBody) o; - return Objects.equals(this.functions, batchRenameInputBody.functions); + return Objects.equals(this.functions, batchRenameInputBody.functions)&& + Objects.equals(this.additionalProperties, batchRenameInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functions); + return Objects.hash(functions, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BatchRenameInputBody {\n"); sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchRenameInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BatchRenameInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchRenameInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("functions") != null && !jsonObj.get("functions").isJsonNull()) { - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); - } - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - BatchRenameItem.validateJsonElement(jsonArrayfunctions.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("functions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("functions").isJsonArray() && !jsonObj.get("functions").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchRenameInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, BatchRenameInputBody value) throws IOException public BatchRenameInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BatchRenameInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BatchRenameItem.java b/src/main/java/ai/reveng/model/BatchRenameItem.java index c19fb35e..74b721cd 100644 --- a/src/main/java/ai/reveng/model/BatchRenameItem.java +++ b/src/main/java/ai/reveng/model/BatchRenameItem.java @@ -124,6 +124,50 @@ public void setNewName(@javax.annotation.Nonnull String newName) { this.newName = newName; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BatchRenameItem instance itself + */ + public BatchRenameItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { BatchRenameItem batchRenameItem = (BatchRenameItem) o; return Objects.equals(this.functionId, batchRenameItem.functionId) && Objects.equals(this.newMangledName, batchRenameItem.newMangledName) && - Objects.equals(this.newName, batchRenameItem.newName); + Objects.equals(this.newName, batchRenameItem.newName)&& + Objects.equals(this.additionalProperties, batchRenameItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, newMangledName, newName); + return Objects.hash(functionId, newMangledName, newName, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" newMangledName: ").append(toIndentedString(newMangledName)).append("\n"); sb.append(" newName: ").append(toIndentedString(newName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchRenameItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BatchRenameItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchRenameItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -227,6 +265,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchRenameItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -234,7 +294,28 @@ public void write(JsonWriter out, BatchRenameItem value) throws IOException { public BatchRenameItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BatchRenameItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BatchRenameOutputBody.java b/src/main/java/ai/reveng/model/BatchRenameOutputBody.java index b385d5a0..bc40373a 100644 --- a/src/main/java/ai/reveng/model/BatchRenameOutputBody.java +++ b/src/main/java/ai/reveng/model/BatchRenameOutputBody.java @@ -75,6 +75,50 @@ public void setRenamedCount(@javax.annotation.Nonnull Long renamedCount) { this.renamedCount = renamedCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BatchRenameOutputBody instance itself + */ + public BatchRenameOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } BatchRenameOutputBody batchRenameOutputBody = (BatchRenameOutputBody) o; - return Objects.equals(this.renamedCount, batchRenameOutputBody.renamedCount); + return Objects.equals(this.renamedCount, batchRenameOutputBody.renamedCount)&& + Objects.equals(this.additionalProperties, batchRenameOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(renamedCount); + return Objects.hash(renamedCount, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BatchRenameOutputBody {\n"); sb.append(" renamedCount: ").append(toIndentedString(renamedCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchRenameOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BatchRenameOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchRenameOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -168,6 +206,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchRenameOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -175,7 +235,28 @@ public void write(JsonWriter out, BatchRenameOutputBody value) throws IOExceptio public BatchRenameOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BatchRenameOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Binary.java b/src/main/java/ai/reveng/model/Binary.java index 0af0b965..a53dc128 100644 --- a/src/main/java/ai/reveng/model/Binary.java +++ b/src/main/java/ai/reveng/model/Binary.java @@ -220,6 +220,50 @@ public void setSha256Hash(@javax.annotation.Nonnull String sha256Hash) { this.sha256Hash = sha256Hash; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Binary instance itself + */ + public Binary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -237,12 +281,13 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, binary.createdAt) && Objects.equals(this.isSystemAnalysis, binary.isSystemAnalysis) && Objects.equals(this.ownerId, binary.ownerId) && - Objects.equals(this.sha256Hash, binary.sha256Hash); + Objects.equals(this.sha256Hash, binary.sha256Hash)&& + Objects.equals(this.additionalProperties, binary.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, binaryId, binaryName, createdAt, isSystemAnalysis, ownerId, sha256Hash); + return Objects.hash(analysisId, binaryId, binaryName, createdAt, isSystemAnalysis, ownerId, sha256Hash, additionalProperties); } @Override @@ -256,6 +301,7 @@ public String toString() { sb.append(" isSystemAnalysis: ").append(toIndentedString(isSystemAnalysis)).append("\n"); sb.append(" ownerId: ").append(toIndentedString(ownerId)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -293,14 +339,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Binary.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Binary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Binary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -331,6 +369,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Binary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -338,7 +398,28 @@ public void write(JsonWriter out, Binary value) throws IOException { public Binary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Binary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BinaryConfig.java b/src/main/java/ai/reveng/model/BinaryConfig.java index 34b6811e..47406bf9 100644 --- a/src/main/java/ai/reveng/model/BinaryConfig.java +++ b/src/main/java/ai/reveng/model/BinaryConfig.java @@ -13,9 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import ai.reveng.model.FileFormat; -import ai.reveng.model.ISA; -import ai.reveng.model.Platform; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -23,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -53,78 +49,246 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class BinaryConfig { + /** + * Gets or Sets fileFormat + */ + @JsonAdapter(FileFormatEnum.Adapter.class) + public enum FileFormatEnum { + PE("pe"), + + ELF("elf"), + + BLOB("blob"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + FileFormatEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FileFormatEnum fromValue(String value) { + for (FileFormatEnum b : FileFormatEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FileFormatEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public FileFormatEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return FileFormatEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + FileFormatEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_FILE_FORMAT = "file_format"; + @SerializedName(SERIALIZED_NAME_FILE_FORMAT) + @javax.annotation.Nullable + private FileFormatEnum fileFormat; + + /** + * Gets or Sets isa + */ + @JsonAdapter(IsaEnum.Adapter.class) + public enum IsaEnum { + X86("x86"), + + X86_64("x86_64"), + + ARM("arm"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + IsaEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static IsaEnum fromValue(String value) { + for (IsaEnum b : IsaEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final IsaEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public IsaEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return IsaEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + IsaEnum.fromValue(value); + } + } + public static final String SERIALIZED_NAME_ISA = "isa"; @SerializedName(SERIALIZED_NAME_ISA) @javax.annotation.Nullable - private ISA isa; + private IsaEnum isa; + + /** + * Gets or Sets platform + */ + @JsonAdapter(PlatformEnum.Adapter.class) + public enum PlatformEnum { + LINUX("linux"), + + WINDOWS("windows"), + + ANDROID("android"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + PlatformEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static PlatformEnum fromValue(String value) { + for (PlatformEnum b : PlatformEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final PlatformEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public PlatformEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return PlatformEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + PlatformEnum.fromValue(value); + } + } public static final String SERIALIZED_NAME_PLATFORM = "platform"; @SerializedName(SERIALIZED_NAME_PLATFORM) @javax.annotation.Nullable - private Platform platform; - - public static final String SERIALIZED_NAME_FILE_FORMAT = "file_format"; - @SerializedName(SERIALIZED_NAME_FILE_FORMAT) - @javax.annotation.Nullable - private FileFormat fileFormat; + private PlatformEnum platform; public BinaryConfig() { } - public BinaryConfig isa(@javax.annotation.Nullable ISA isa) { - this.isa = isa; + public BinaryConfig fileFormat(@javax.annotation.Nullable FileFormatEnum fileFormat) { + this.fileFormat = fileFormat; return this; } /** - * Instruction Set Architecture - * @return isa + * Get fileFormat + * @return fileFormat */ @javax.annotation.Nullable - public ISA getIsa() { - return isa; + public FileFormatEnum getFileFormat() { + return fileFormat; } - public void setIsa(@javax.annotation.Nullable ISA isa) { - this.isa = isa; + public void setFileFormat(@javax.annotation.Nullable FileFormatEnum fileFormat) { + this.fileFormat = fileFormat; } - public BinaryConfig platform(@javax.annotation.Nullable Platform platform) { - this.platform = platform; + public BinaryConfig isa(@javax.annotation.Nullable IsaEnum isa) { + this.isa = isa; return this; } /** - * Get platform - * @return platform + * Get isa + * @return isa */ @javax.annotation.Nullable - public Platform getPlatform() { - return platform; + public IsaEnum getIsa() { + return isa; } - public void setPlatform(@javax.annotation.Nullable Platform platform) { - this.platform = platform; + public void setIsa(@javax.annotation.Nullable IsaEnum isa) { + this.isa = isa; } - public BinaryConfig fileFormat(@javax.annotation.Nullable FileFormat fileFormat) { - this.fileFormat = fileFormat; + public BinaryConfig platform(@javax.annotation.Nullable PlatformEnum platform) { + this.platform = platform; return this; } /** - * Get fileFormat - * @return fileFormat + * Get platform + * @return platform */ @javax.annotation.Nullable - public FileFormat getFileFormat() { - return fileFormat; + public PlatformEnum getPlatform() { + return platform; } - public void setFileFormat(@javax.annotation.Nullable FileFormat fileFormat) { - this.fileFormat = fileFormat; + public void setPlatform(@javax.annotation.Nullable PlatformEnum platform) { + this.platform = platform; } /** @@ -182,35 +346,24 @@ public boolean equals(Object o) { return false; } BinaryConfig binaryConfig = (BinaryConfig) o; - return Objects.equals(this.isa, binaryConfig.isa) && - Objects.equals(this.platform, binaryConfig.platform) && - Objects.equals(this.fileFormat, binaryConfig.fileFormat)&& + return Objects.equals(this.fileFormat, binaryConfig.fileFormat) && + Objects.equals(this.isa, binaryConfig.isa) && + Objects.equals(this.platform, binaryConfig.platform)&& Objects.equals(this.additionalProperties, binaryConfig.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - @Override public int hashCode() { - return Objects.hash(isa, platform, fileFormat, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(fileFormat, isa, platform, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BinaryConfig {\n"); + sb.append(" fileFormat: ").append(toIndentedString(fileFormat)).append("\n"); sb.append(" isa: ").append(toIndentedString(isa)).append("\n"); sb.append(" platform: ").append(toIndentedString(platform)).append("\n"); - sb.append(" fileFormat: ").append(toIndentedString(fileFormat)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -230,7 +383,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("isa", "platform", "file_format")); + openapiFields = new HashSet(Arrays.asList("file_format", "isa", "platform")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -249,17 +402,26 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("file_format") != null && !jsonObj.get("file_format").isJsonNull()) && !jsonObj.get("file_format").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_format").toString())); + } + // validate the optional field `file_format` + if (jsonObj.get("file_format") != null && !jsonObj.get("file_format").isJsonNull()) { + FileFormatEnum.validateJsonElement(jsonObj.get("file_format")); + } + if ((jsonObj.get("isa") != null && !jsonObj.get("isa").isJsonNull()) && !jsonObj.get("isa").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `isa` to be a primitive type in the JSON string but got `%s`", jsonObj.get("isa").toString())); + } // validate the optional field `isa` if (jsonObj.get("isa") != null && !jsonObj.get("isa").isJsonNull()) { - ISA.validateJsonElement(jsonObj.get("isa")); + IsaEnum.validateJsonElement(jsonObj.get("isa")); + } + if ((jsonObj.get("platform") != null && !jsonObj.get("platform").isJsonNull()) && !jsonObj.get("platform").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `platform` to be a primitive type in the JSON string but got `%s`", jsonObj.get("platform").toString())); } // validate the optional field `platform` if (jsonObj.get("platform") != null && !jsonObj.get("platform").isJsonNull()) { - Platform.validateJsonElement(jsonObj.get("platform")); - } - // validate the optional field `file_format` - if (jsonObj.get("file_format") != null && !jsonObj.get("file_format").isJsonNull()) { - FileFormat.validateJsonElement(jsonObj.get("file_format")); + PlatformEnum.validateJsonElement(jsonObj.get("platform")); } } diff --git a/src/main/java/ai/reveng/model/BinaryDetailsResponse.java b/src/main/java/ai/reveng/model/BinaryDetailsResponse.java index 8d2a2d3d..1b5f409c 100644 --- a/src/main/java/ai/reveng/model/BinaryDetailsResponse.java +++ b/src/main/java/ai/reveng/model/BinaryDetailsResponse.java @@ -63,7 +63,7 @@ public class BinaryDetailsResponse { public static final String SERIALIZED_NAME_CRC32 = "crc32"; @SerializedName(SERIALIZED_NAME_CRC32) - @javax.annotation.Nonnull + @javax.annotation.Nullable private String crc32; public static final String SERIALIZED_NAME_PROPERTY_CLASS = "Class"; @@ -73,12 +73,12 @@ public class BinaryDetailsResponse { public static final String SERIALIZED_NAME_ENTROPY = "entropy"; @SerializedName(SERIALIZED_NAME_ENTROPY) - @javax.annotation.Nonnull + @javax.annotation.Nullable private BigDecimal entropy; public static final String SERIALIZED_NAME_FILE_SIZE = "file_size"; @SerializedName(SERIALIZED_NAME_FILE_SIZE) - @javax.annotation.Nonnull + @javax.annotation.Nullable private Integer fileSize; public static final String SERIALIZED_NAME_LANGUAGE = "language"; @@ -88,7 +88,7 @@ public class BinaryDetailsResponse { public static final String SERIALIZED_NAME_MD5 = "md5"; @SerializedName(SERIALIZED_NAME_MD5) - @javax.annotation.Nonnull + @javax.annotation.Nullable private String md5; public static final String SERIALIZED_NAME_MACHINE = "machine"; @@ -103,12 +103,12 @@ public class BinaryDetailsResponse { public static final String SERIALIZED_NAME_SHA1 = "sha1"; @SerializedName(SERIALIZED_NAME_SHA1) - @javax.annotation.Nonnull + @javax.annotation.Nullable private String sha1; public static final String SERIALIZED_NAME_SHA256 = "sha256"; @SerializedName(SERIALIZED_NAME_SHA256) - @javax.annotation.Nonnull + @javax.annotation.Nullable private String sha256; public static final String SERIALIZED_NAME_SSDEEP = "ssdeep"; @@ -133,7 +133,7 @@ public class BinaryDetailsResponse { public static final String SERIALIZED_NAME_TLSH = "tlsh"; @SerializedName(SERIALIZED_NAME_TLSH) - @javax.annotation.Nonnull + @javax.annotation.Nullable private String tlsh; public static final String SERIALIZED_NAME_TYPE = "type"; @@ -192,7 +192,7 @@ public void setBits(@javax.annotation.Nonnull Integer bits) { } - public BinaryDetailsResponse crc32(@javax.annotation.Nonnull String crc32) { + public BinaryDetailsResponse crc32(@javax.annotation.Nullable String crc32) { this.crc32 = crc32; return this; } @@ -201,12 +201,12 @@ public BinaryDetailsResponse crc32(@javax.annotation.Nonnull String crc32) { * Get crc32 * @return crc32 */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public String getCrc32() { return crc32; } - public void setCrc32(@javax.annotation.Nonnull String crc32) { + public void setCrc32(@javax.annotation.Nullable String crc32) { this.crc32 = crc32; } @@ -230,7 +230,7 @@ public void setPropertyClass(@javax.annotation.Nonnull String propertyClass) { } - public BinaryDetailsResponse entropy(@javax.annotation.Nonnull BigDecimal entropy) { + public BinaryDetailsResponse entropy(@javax.annotation.Nullable BigDecimal entropy) { this.entropy = entropy; return this; } @@ -239,17 +239,17 @@ public BinaryDetailsResponse entropy(@javax.annotation.Nonnull BigDecimal entrop * Get entropy * @return entropy */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public BigDecimal getEntropy() { return entropy; } - public void setEntropy(@javax.annotation.Nonnull BigDecimal entropy) { + public void setEntropy(@javax.annotation.Nullable BigDecimal entropy) { this.entropy = entropy; } - public BinaryDetailsResponse fileSize(@javax.annotation.Nonnull Integer fileSize) { + public BinaryDetailsResponse fileSize(@javax.annotation.Nullable Integer fileSize) { this.fileSize = fileSize; return this; } @@ -258,12 +258,12 @@ public BinaryDetailsResponse fileSize(@javax.annotation.Nonnull Integer fileSize * Get fileSize * @return fileSize */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public Integer getFileSize() { return fileSize; } - public void setFileSize(@javax.annotation.Nonnull Integer fileSize) { + public void setFileSize(@javax.annotation.Nullable Integer fileSize) { this.fileSize = fileSize; } @@ -287,7 +287,7 @@ public void setLanguage(@javax.annotation.Nonnull String language) { } - public BinaryDetailsResponse md5(@javax.annotation.Nonnull String md5) { + public BinaryDetailsResponse md5(@javax.annotation.Nullable String md5) { this.md5 = md5; return this; } @@ -296,12 +296,12 @@ public BinaryDetailsResponse md5(@javax.annotation.Nonnull String md5) { * Get md5 * @return md5 */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public String getMd5() { return md5; } - public void setMd5(@javax.annotation.Nonnull String md5) { + public void setMd5(@javax.annotation.Nullable String md5) { this.md5 = md5; } @@ -344,7 +344,7 @@ public void setOs(@javax.annotation.Nonnull String os) { } - public BinaryDetailsResponse sha1(@javax.annotation.Nonnull String sha1) { + public BinaryDetailsResponse sha1(@javax.annotation.Nullable String sha1) { this.sha1 = sha1; return this; } @@ -353,17 +353,17 @@ public BinaryDetailsResponse sha1(@javax.annotation.Nonnull String sha1) { * SHA1 hash of the binary * @return sha1 */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public String getSha1() { return sha1; } - public void setSha1(@javax.annotation.Nonnull String sha1) { + public void setSha1(@javax.annotation.Nullable String sha1) { this.sha1 = sha1; } - public BinaryDetailsResponse sha256(@javax.annotation.Nonnull String sha256) { + public BinaryDetailsResponse sha256(@javax.annotation.Nullable String sha256) { this.sha256 = sha256; return this; } @@ -372,12 +372,12 @@ public BinaryDetailsResponse sha256(@javax.annotation.Nonnull String sha256) { * SHA256 hash of the binary * @return sha256 */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public String getSha256() { return sha256; } - public void setSha256(@javax.annotation.Nonnull String sha256) { + public void setSha256(@javax.annotation.Nullable String sha256) { this.sha256 = sha256; } @@ -458,7 +458,7 @@ public void setSubSys(@javax.annotation.Nonnull String subSys) { } - public BinaryDetailsResponse tlsh(@javax.annotation.Nonnull String tlsh) { + public BinaryDetailsResponse tlsh(@javax.annotation.Nullable String tlsh) { this.tlsh = tlsh; return this; } @@ -467,12 +467,12 @@ public BinaryDetailsResponse tlsh(@javax.annotation.Nonnull String tlsh) { * Get tlsh * @return tlsh */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public String getTlsh() { return tlsh; } - public void setTlsh(@javax.annotation.Nonnull String tlsh) { + public void setTlsh(@javax.annotation.Nullable String tlsh) { this.tlsh = tlsh; } @@ -688,7 +688,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("arch").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `arch` to be a primitive type in the JSON string but got `%s`", jsonObj.get("arch").toString())); } - if (!jsonObj.get("crc32").isJsonPrimitive()) { + if ((jsonObj.get("crc32") != null && !jsonObj.get("crc32").isJsonNull()) && !jsonObj.get("crc32").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `crc32` to be a primitive type in the JSON string but got `%s`", jsonObj.get("crc32").toString())); } if (!jsonObj.get("Class").isJsonPrimitive()) { @@ -697,7 +697,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("language").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `language` to be a primitive type in the JSON string but got `%s`", jsonObj.get("language").toString())); } - if (!jsonObj.get("md5").isJsonPrimitive()) { + if ((jsonObj.get("md5") != null && !jsonObj.get("md5").isJsonNull()) && !jsonObj.get("md5").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `md5` to be a primitive type in the JSON string but got `%s`", jsonObj.get("md5").toString())); } if (!jsonObj.get("machine").isJsonPrimitive()) { @@ -706,10 +706,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("os").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `os` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os").toString())); } - if (!jsonObj.get("sha1").isJsonPrimitive()) { + if ((jsonObj.get("sha1") != null && !jsonObj.get("sha1").isJsonNull()) && !jsonObj.get("sha1").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha1").toString())); } - if (!jsonObj.get("sha256").isJsonPrimitive()) { + if ((jsonObj.get("sha256") != null && !jsonObj.get("sha256").isJsonNull()) && !jsonObj.get("sha256").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); } if ((jsonObj.get("ssdeep") != null && !jsonObj.get("ssdeep").isJsonNull()) && !jsonObj.get("ssdeep").isJsonPrimitive()) { @@ -718,7 +718,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("sub_sys").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sub_sys` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_sys").toString())); } - if (!jsonObj.get("tlsh").isJsonPrimitive()) { + if ((jsonObj.get("tlsh") != null && !jsonObj.get("tlsh").isJsonNull()) && !jsonObj.get("tlsh").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tlsh` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tlsh").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { diff --git a/src/main/java/ai/reveng/model/BitfieldDataType.java b/src/main/java/ai/reveng/model/BitfieldDataType.java index ef9fdb5a..325e7526 100644 --- a/src/main/java/ai/reveng/model/BitfieldDataType.java +++ b/src/main/java/ai/reveng/model/BitfieldDataType.java @@ -137,6 +137,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -341,6 +346,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public BitfieldDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public BitfieldDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -378,6 +402,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BitfieldDataType instance itself + */ + public BitfieldDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -396,13 +464,15 @@ public boolean equals(Object o) { Objects.equals(this.name, bitfieldDataType.name) && Objects.equals(this.namespace, bitfieldDataType.namespace) && Objects.equals(this.size, bitfieldDataType.size) && + Objects.equals(this.sourceAnalysisId, bitfieldDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, bitfieldDataType.sourceFunctionId) && - Objects.equals(this.sourceType, bitfieldDataType.sourceType); + Objects.equals(this.sourceType, bitfieldDataType.sourceType)&& + Objects.equals(this.additionalProperties, bitfieldDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -416,8 +486,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -436,7 +508,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -455,14 +527,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BitfieldDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BitfieldDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BitfieldDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -503,6 +567,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BitfieldDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -510,7 +596,28 @@ public void write(JsonWriter out, BitfieldDataType value) throws IOException { public BitfieldDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BitfieldDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BulkCreateUserResult.java b/src/main/java/ai/reveng/model/BulkCreateUserResult.java index 7e5369b0..b357dca6 100644 --- a/src/main/java/ai/reveng/model/BulkCreateUserResult.java +++ b/src/main/java/ai/reveng/model/BulkCreateUserResult.java @@ -326,10 +326,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) && !jsonObj.get("error").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); } - // validate the optional field `user` - if (jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) { - User.validateJsonElement(jsonObj.get("user")); - } if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); } diff --git a/src/main/java/ai/reveng/model/BulkCreateUsersOutputBody.java b/src/main/java/ai/reveng/model/BulkCreateUsersOutputBody.java index c4da6942..c925df94 100644 --- a/src/main/java/ai/reveng/model/BulkCreateUsersOutputBody.java +++ b/src/main/java/ai/reveng/model/BulkCreateUsersOutputBody.java @@ -278,15 +278,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("results") != null && !jsonObj.get("results").isJsonNull()) { - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); - } - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - BulkCreateUserResult.validateJsonElement(jsonArrayresults.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("results") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("results").isJsonArray() && !jsonObj.get("results").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); } } diff --git a/src/main/java/ai/reveng/model/BytesConstant.java b/src/main/java/ai/reveng/model/BytesConstant.java new file mode 100644 index 00000000..aed59208 --- /dev/null +++ b/src/main/java/ai/reveng/model/BytesConstant.java @@ -0,0 +1,405 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Display; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * One exact, contiguous sequence of binary bytes. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BytesConstant { + /** + * Gets or Sets format + */ + @JsonAdapter(FormatEnum.Adapter.class) + public enum FormatEnum { + BYTES("bytes"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + FormatEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FormatEnum fromValue(String value) { + for (FormatEnum b : FormatEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FormatEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public FormatEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return FormatEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + FormatEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_FORMAT = "format"; + @SerializedName(SERIALIZED_NAME_FORMAT) + @javax.annotation.Nullable + private FormatEnum format = FormatEnum.BYTES; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + @javax.annotation.Nonnull + private String value; + + public static final String SERIALIZED_NAME_DISPLAY = "display"; + @SerializedName(SERIALIZED_NAME_DISPLAY) + @javax.annotation.Nullable + private Display display = Display.HEX; + + public BytesConstant() { + } + + public BytesConstant format(@javax.annotation.Nullable FormatEnum format) { + this.format = format; + return this; + } + + /** + * Get format + * @return format + */ + @javax.annotation.Nullable + public FormatEnum getFormat() { + return format; + } + + public void setFormat(@javax.annotation.Nullable FormatEnum format) { + this.format = format; + } + + + public BytesConstant value(@javax.annotation.Nonnull String value) { + this.value = value; + return this; + } + + /** + * Hexadecimal byte pairs representing one exact, contiguous binary value. + * @return value + */ + @javax.annotation.Nonnull + public String getValue() { + return value; + } + + public void setValue(@javax.annotation.Nonnull String value) { + this.value = value; + } + + + public BytesConstant display(@javax.annotation.Nullable Display display) { + this.display = display; + return this; + } + + /** + * Get display + * @return display + */ + @javax.annotation.Nullable + public Display getDisplay() { + return display; + } + + public void setDisplay(@javax.annotation.Nullable Display display) { + this.display = display; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BytesConstant instance itself + */ + public BytesConstant putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BytesConstant bytesConstant = (BytesConstant) o; + return Objects.equals(this.format, bytesConstant.format) && + Objects.equals(this.value, bytesConstant.value) && + Objects.equals(this.display, bytesConstant.display)&& + Objects.equals(this.additionalProperties, bytesConstant.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(format, value, display, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BytesConstant {\n"); + sb.append(" format: ").append(toIndentedString(format)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" display: ").append(toIndentedString(display)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("format", "value", "display")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("value")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BytesConstant + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!BytesConstant.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BytesConstant is not found in the empty JSON string", BytesConstant.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BytesConstant.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("format") != null && !jsonObj.get("format").isJsonNull()) && !jsonObj.get("format").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("format").toString())); + } + // validate the optional field `format` + if (jsonObj.get("format") != null && !jsonObj.get("format").isJsonNull()) { + FormatEnum.validateJsonElement(jsonObj.get("format")); + } + if (!jsonObj.get("value").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + } + // validate the optional field `display` + if (jsonObj.get("display") != null && !jsonObj.get("display").isJsonNull()) { + Display.validateJsonElement(jsonObj.get("display")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BytesConstant.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BytesConstant' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BytesConstant.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BytesConstant value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public BytesConstant read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BytesConstant instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BytesConstant given an JSON string + * + * @param jsonString JSON string + * @return An instance of BytesConstant + * @throws IOException if the JSON string is invalid with respect to BytesConstant + */ + public static BytesConstant fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BytesConstant.class); + } + + /** + * Convert an instance of BytesConstant to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CallChain.java b/src/main/java/ai/reveng/model/CallChain.java new file mode 100644 index 00000000..ca86232c --- /dev/null +++ b/src/main/java/ai/reveng/model/CallChain.java @@ -0,0 +1,302 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CallChain + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CallChain { + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_PATH) + @javax.annotation.Nonnull + private List path = new ArrayList<>(); + + public CallChain() { + } + + public CallChain path(@javax.annotation.Nonnull List path) { + this.path = path; + return this; + } + + public CallChain addPathItem(Integer pathItem) { + if (this.path == null) { + this.path = new ArrayList<>(); + } + this.path.add(pathItem); + return this; + } + + /** + * Get path + * @return path + */ + @javax.annotation.Nonnull + public List getPath() { + return path; + } + + public void setPath(@javax.annotation.Nonnull List path) { + this.path = path; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CallChain instance itself + */ + public CallChain putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CallChain callChain = (CallChain) o; + return Objects.equals(this.path, callChain.path)&& + Objects.equals(this.additionalProperties, callChain.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(path, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CallChain {\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("path")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("path")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CallChain + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CallChain.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CallChain is not found in the empty JSON string", CallChain.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CallChain.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("path") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("path").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `path` to be an array in the JSON string but got `%s`", jsonObj.get("path").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CallChain.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CallChain' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CallChain.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CallChain value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CallChain read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CallChain instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CallChain given an JSON string + * + * @param jsonString JSON string + * @return An instance of CallChain + * @throws IOException if the JSON string is invalid with respect to CallChain + */ + public static CallChain fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CallChain.class); + } + + /** + * Convert an instance of CallChain to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CallChainEvidence.java b/src/main/java/ai/reveng/model/CallChainEvidence.java new file mode 100644 index 00000000..9b204abf --- /dev/null +++ b/src/main/java/ai/reveng/model/CallChainEvidence.java @@ -0,0 +1,586 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceEffect; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * A concrete sequence of calls connecting program locations. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CallChainEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + CALL_CHAIN("call_chain"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.CALL_CHAIN; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + DIRECT("direct"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.DIRECT; + + public static final String SERIALIZED_NAME_CALL_CHAIN = "call_chain"; + @SerializedName(SERIALIZED_NAME_CALL_CHAIN) + @javax.annotation.Nonnull + private List callChain = new ArrayList<>(); + + public CallChainEvidence() { + } + + public CallChainEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public CallChainEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public CallChainEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public CallChainEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public CallChainEvidence callChain(@javax.annotation.Nonnull List callChain) { + this.callChain = callChain; + return this; + } + + public CallChainEvidence addCallChainItem(Integer callChainItem) { + if (this.callChain == null) { + this.callChain = new ArrayList<>(); + } + this.callChain.add(callChainItem); + return this; + } + + /** + * Get callChain + * @return callChain + */ + @javax.annotation.Nonnull + public List getCallChain() { + return callChain; + } + + public void setCallChain(@javax.annotation.Nonnull List callChain) { + this.callChain = callChain; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CallChainEvidence instance itself + */ + public CallChainEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CallChainEvidence callChainEvidence = (CallChainEvidence) o; + return Objects.equals(this.evidenceKind, callChainEvidence.evidenceKind) && + Objects.equals(this.kind, callChainEvidence.kind) && + Objects.equals(this.effect, callChainEvidence.effect) && + Objects.equals(this.strength, callChainEvidence.strength) && + Objects.equals(this.callChain, callChainEvidence.callChain)&& + Objects.equals(this.additionalProperties, callChainEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, callChain, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CallChainEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" callChain: ").append(toIndentedString(callChain)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "call_chain")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "call_chain")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CallChainEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CallChainEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CallChainEvidence is not found in the empty JSON string", CallChainEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CallChainEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + // ensure the required json array is present + if (jsonObj.get("call_chain") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("call_chain").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `call_chain` to be an array in the JSON string but got `%s`", jsonObj.get("call_chain").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CallChainEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CallChainEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CallChainEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CallChainEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CallChainEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CallChainEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CallChainEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of CallChainEvidence + * @throws IOException if the JSON string is invalid with respect to CallChainEvidence + */ + public static CallChainEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CallChainEvidence.class); + } + + /** + * Convert an instance of CallChainEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CallEdge.java b/src/main/java/ai/reveng/model/CallEdge.java index da9507fc..5a28852b 100644 --- a/src/main/java/ai/reveng/model/CallEdge.java +++ b/src/main/java/ai/reveng/model/CallEdge.java @@ -267,6 +267,50 @@ public void setThunkedVaddr(@javax.annotation.Nullable Long thunkedVaddr) { this.thunkedVaddr = thunkedVaddr; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CallEdge instance itself + */ + public CallEdge putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -286,12 +330,13 @@ public boolean equals(Object o) { Objects.equals(this.callerVaddr, callEdge.callerVaddr) && Objects.equals(this.importedFunctionId, callEdge.importedFunctionId) && Objects.equals(this.isExternal, callEdge.isExternal) && - Objects.equals(this.thunkedVaddr, callEdge.thunkedVaddr); + Objects.equals(this.thunkedVaddr, callEdge.thunkedVaddr)&& + Objects.equals(this.additionalProperties, callEdge.additionalProperties); } @Override public int hashCode() { - return Objects.hash(calleeFunctionId, calleeName, calleeVaddr, callerFunctionId, callerName, callerVaddr, importedFunctionId, isExternal, thunkedVaddr); + return Objects.hash(calleeFunctionId, calleeName, calleeVaddr, callerFunctionId, callerName, callerVaddr, importedFunctionId, isExternal, thunkedVaddr, additionalProperties); } @Override @@ -307,6 +352,7 @@ public String toString() { sb.append(" importedFunctionId: ").append(toIndentedString(importedFunctionId)).append("\n"); sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); sb.append(" thunkedVaddr: ").append(toIndentedString(thunkedVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -344,14 +390,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CallEdge.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CallEdge` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CallEdge.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -382,6 +420,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CallEdge value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -389,7 +449,28 @@ public void write(JsonWriter out, CallEdge value) throws IOException { public CallEdge read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CallEdge instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CallEdgesOutputBody.java b/src/main/java/ai/reveng/model/CallEdgesOutputBody.java index 1e090233..ceb12231 100644 --- a/src/main/java/ai/reveng/model/CallEdgesOutputBody.java +++ b/src/main/java/ai/reveng/model/CallEdgesOutputBody.java @@ -86,6 +86,50 @@ public void setEdges(@javax.annotation.Nullable List edges) { this.edges = edges; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CallEdgesOutputBody instance itself + */ + public CallEdgesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } CallEdgesOutputBody callEdgesOutputBody = (CallEdgesOutputBody) o; - return Objects.equals(this.edges, callEdgesOutputBody.edges); + return Objects.equals(this.edges, callEdgesOutputBody.edges)&& + Objects.equals(this.additionalProperties, callEdgesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(edges); + return Objects.hash(edges, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CallEdgesOutputBody {\n"); sb.append(" edges: ").append(toIndentedString(edges)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CallEdgesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CallEdgesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CallEdgesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("edges") != null && !jsonObj.get("edges").isJsonNull()) { - if (!jsonObj.get("edges").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `edges` to be an array in the JSON string but got `%s`", jsonObj.get("edges").toString())); - } - JsonArray jsonArrayedges = jsonObj.getAsJsonArray("edges"); - // validate the required field `edges` (array) - for (int i = 0; i < jsonArrayedges.size(); i++) { - FunctionCallEdges.validateJsonElement(jsonArrayedges.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("edges") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("edges").isJsonArray() && !jsonObj.get("edges").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `edges` to be an array in the JSON string but got `%s`", jsonObj.get("edges").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CallEdgesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, CallEdgesOutputBody value) throws IOException public CallEdgesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CallEdgesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CanonicalName.java b/src/main/java/ai/reveng/model/CanonicalName.java index 3209963d..7e64afd1 100644 --- a/src/main/java/ai/reveng/model/CanonicalName.java +++ b/src/main/java/ai/reveng/model/CanonicalName.java @@ -99,6 +99,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CanonicalName instance itself + */ + public CanonicalName putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } CanonicalName canonicalName = (CanonicalName) o; return Objects.equals(this.canonicalName, canonicalName.canonicalName) && - Objects.equals(this.name, canonicalName.name); + Objects.equals(this.name, canonicalName.name)&& + Objects.equals(this.additionalProperties, canonicalName.additionalProperties); } @Override public int hashCode() { - return Objects.hash(canonicalName, name); + return Objects.hash(canonicalName, name, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class CanonicalName {\n"); sb.append(" canonicalName: ").append(toIndentedString(canonicalName)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CanonicalName.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CanonicalName` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CanonicalName.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,6 +238,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CanonicalName value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -207,7 +267,28 @@ public void write(JsonWriter out, CanonicalName value) throws IOException { public CanonicalName read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CanonicalName instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CanonicalizeNamesInputBody.java b/src/main/java/ai/reveng/model/CanonicalizeNamesInputBody.java index 45048d63..1d1b575e 100644 --- a/src/main/java/ai/reveng/model/CanonicalizeNamesInputBody.java +++ b/src/main/java/ai/reveng/model/CanonicalizeNamesInputBody.java @@ -85,6 +85,50 @@ public void setNames(@javax.annotation.Nullable List names) { this.names = names; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CanonicalizeNamesInputBody instance itself + */ + public CanonicalizeNamesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -96,12 +140,13 @@ public boolean equals(Object o) { return false; } CanonicalizeNamesInputBody canonicalizeNamesInputBody = (CanonicalizeNamesInputBody) o; - return Objects.equals(this.names, canonicalizeNamesInputBody.names); + return Objects.equals(this.names, canonicalizeNamesInputBody.names)&& + Objects.equals(this.additionalProperties, canonicalizeNamesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(names); + return Objects.hash(names, additionalProperties); } @Override @@ -109,6 +154,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CanonicalizeNamesInputBody {\n"); sb.append(" names: ").append(toIndentedString(names)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CanonicalizeNamesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CanonicalizeNamesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CanonicalizeNamesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -184,6 +222,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CanonicalizeNamesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -191,7 +251,28 @@ public void write(JsonWriter out, CanonicalizeNamesInputBody value) throws IOExc public CanonicalizeNamesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CanonicalizeNamesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CanonicalizeNamesOutputBody.java b/src/main/java/ai/reveng/model/CanonicalizeNamesOutputBody.java index 0be4331c..925e7aee 100644 --- a/src/main/java/ai/reveng/model/CanonicalizeNamesOutputBody.java +++ b/src/main/java/ai/reveng/model/CanonicalizeNamesOutputBody.java @@ -86,6 +86,50 @@ public void setResults(@javax.annotation.Nullable List results) { this.results = results; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CanonicalizeNamesOutputBody instance itself + */ + public CanonicalizeNamesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } CanonicalizeNamesOutputBody canonicalizeNamesOutputBody = (CanonicalizeNamesOutputBody) o; - return Objects.equals(this.results, canonicalizeNamesOutputBody.results); + return Objects.equals(this.results, canonicalizeNamesOutputBody.results)&& + Objects.equals(this.additionalProperties, canonicalizeNamesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results); + return Objects.hash(results, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CanonicalizeNamesOutputBody {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CanonicalizeNamesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CanonicalizeNamesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CanonicalizeNamesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("results") != null && !jsonObj.get("results").isJsonNull()) { - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); - } - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - CanonicalName.validateJsonElement(jsonArrayresults.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("results") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("results").isJsonArray() && !jsonObj.get("results").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CanonicalizeNamesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, CanonicalizeNamesOutputBody value) throws IOEx public CanonicalizeNamesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CanonicalizeNamesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CapabilitiesOutputBody.java b/src/main/java/ai/reveng/model/CapabilitiesOutputBody.java index f24a620e..283b5f79 100644 --- a/src/main/java/ai/reveng/model/CapabilitiesOutputBody.java +++ b/src/main/java/ai/reveng/model/CapabilitiesOutputBody.java @@ -86,6 +86,50 @@ public void setCapabilities(@javax.annotation.Nullable List cap this.capabilities = capabilities; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CapabilitiesOutputBody instance itself + */ + public CapabilitiesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } CapabilitiesOutputBody capabilitiesOutputBody = (CapabilitiesOutputBody) o; - return Objects.equals(this.capabilities, capabilitiesOutputBody.capabilities); + return Objects.equals(this.capabilities, capabilitiesOutputBody.capabilities)&& + Objects.equals(this.additionalProperties, capabilitiesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(capabilities); + return Objects.hash(capabilities, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CapabilitiesOutputBody {\n"); sb.append(" capabilities: ").append(toIndentedString(capabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CapabilitiesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CapabilitiesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CapabilitiesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("capabilities") != null && !jsonObj.get("capabilities").isJsonNull()) { - if (!jsonObj.get("capabilities").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); - } - JsonArray jsonArraycapabilities = jsonObj.getAsJsonArray("capabilities"); - // validate the required field `capabilities` (array) - for (int i = 0; i < jsonArraycapabilities.size(); i++) { - CapabilityEntry.validateJsonElement(jsonArraycapabilities.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("capabilities") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("capabilities").isJsonArray() && !jsonObj.get("capabilities").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CapabilitiesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, CapabilitiesOutputBody value) throws IOExcepti public CapabilitiesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CapabilitiesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CapabilitiesResult.java b/src/main/java/ai/reveng/model/CapabilitiesResult.java new file mode 100644 index 00000000..85c0ff89 --- /dev/null +++ b/src/main/java/ai/reveng/model/CapabilitiesResult.java @@ -0,0 +1,303 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Capability; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CapabilitiesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CapabilitiesResult { + public static final String SERIALIZED_NAME_CAPABILITIES = "capabilities"; + @SerializedName(SERIALIZED_NAME_CAPABILITIES) + @javax.annotation.Nullable + private List capabilities; + + public CapabilitiesResult() { + } + + public CapabilitiesResult capabilities(@javax.annotation.Nullable List capabilities) { + this.capabilities = capabilities; + return this; + } + + public CapabilitiesResult addCapabilitiesItem(Capability capabilitiesItem) { + if (this.capabilities == null) { + this.capabilities = new ArrayList<>(); + } + this.capabilities.add(capabilitiesItem); + return this; + } + + /** + * Capabilities found. A capability whose address no longer resolves within the analysis is omitted. + * @return capabilities + */ + @javax.annotation.Nullable + public List getCapabilities() { + return capabilities; + } + + public void setCapabilities(@javax.annotation.Nullable List capabilities) { + this.capabilities = capabilities; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CapabilitiesResult instance itself + */ + public CapabilitiesResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CapabilitiesResult capabilitiesResult = (CapabilitiesResult) o; + return Objects.equals(this.capabilities, capabilitiesResult.capabilities)&& + Objects.equals(this.additionalProperties, capabilitiesResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(capabilities, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CapabilitiesResult {\n"); + sb.append(" capabilities: ").append(toIndentedString(capabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("capabilities")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("capabilities")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CapabilitiesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CapabilitiesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CapabilitiesResult is not found in the empty JSON string", CapabilitiesResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CapabilitiesResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("capabilities") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("capabilities").isJsonArray() && !jsonObj.get("capabilities").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CapabilitiesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CapabilitiesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CapabilitiesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CapabilitiesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CapabilitiesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CapabilitiesResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CapabilitiesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of CapabilitiesResult + * @throws IOException if the JSON string is invalid with respect to CapabilitiesResult + */ + public static CapabilitiesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CapabilitiesResult.class); + } + + /** + * Convert an instance of CapabilitiesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Capability.java b/src/main/java/ai/reveng/model/Capability.java new file mode 100644 index 00000000..1d3a8fe3 --- /dev/null +++ b/src/main/java/ai/reveng/model/Capability.java @@ -0,0 +1,431 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Capability + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Capability { + public static final String SERIALIZED_NAME_CAPABILITY = "capability"; + @SerializedName(SERIALIZED_NAME_CAPABILITY) + @javax.annotation.Nonnull + private String capability; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTION_VADDR = "function_vaddr"; + @SerializedName(SERIALIZED_NAME_FUNCTION_VADDR) + @javax.annotation.Nonnull + private String functionVaddr; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public Capability() { + } + + public Capability capability(@javax.annotation.Nonnull String capability) { + this.capability = capability; + return this; + } + + /** + * The capability itself + * @return capability + */ + @javax.annotation.Nonnull + public String getCapability() { + return capability; + } + + public void setCapability(@javax.annotation.Nonnull String capability) { + this.capability = capability; + } + + + public Capability description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * What the function does to exhibit the capability + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public Capability functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public Capability functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + + public Capability functionVaddr(@javax.annotation.Nonnull String functionVaddr) { + this.functionVaddr = functionVaddr; + return this; + } + + /** + * Virtual address of the function, hex-encoded + * @return functionVaddr + */ + @javax.annotation.Nonnull + public String getFunctionVaddr() { + return functionVaddr; + } + + public void setFunctionVaddr(@javax.annotation.Nonnull String functionVaddr) { + this.functionVaddr = functionVaddr; + } + + + public Capability type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * Capability category + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Capability instance itself + */ + public Capability putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capability capability = (Capability) o; + return Objects.equals(this.capability, capability.capability) && + Objects.equals(this.description, capability.description) && + Objects.equals(this.functionId, capability.functionId) && + Objects.equals(this.functionName, capability.functionName) && + Objects.equals(this.functionVaddr, capability.functionVaddr) && + Objects.equals(this.type, capability.type)&& + Objects.equals(this.additionalProperties, capability.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(capability, description, functionId, functionName, functionVaddr, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capability {\n"); + sb.append(" capability: ").append(toIndentedString(capability)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("capability", "description", "function_id", "function_name", "function_vaddr", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("capability", "description", "function_id", "function_name", "function_vaddr", "type")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Capability + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Capability.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Capability is not found in the empty JSON string", Capability.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Capability.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("capability").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capability` to be a primitive type in the JSON string but got `%s`", jsonObj.get("capability").toString())); + } + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + if (!jsonObj.get("function_vaddr").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_vaddr").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Capability.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Capability' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Capability.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Capability value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Capability read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Capability instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Capability given an JSON string + * + * @param jsonString JSON string + * @return An instance of Capability + * @throws IOException if the JSON string is invalid with respect to Capability + */ + public static Capability fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Capability.class); + } + + /** + * Convert an instance of Capability to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CapabilityEntry.java b/src/main/java/ai/reveng/model/CapabilityEntry.java index 0df567b8..6c04ff04 100644 --- a/src/main/java/ai/reveng/model/CapabilityEntry.java +++ b/src/main/java/ai/reveng/model/CapabilityEntry.java @@ -195,6 +195,50 @@ public void setVaddr(@javax.annotation.Nonnull Long vaddr) { this.vaddr = vaddr; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CapabilityEntry instance itself + */ + public CapabilityEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -211,12 +255,13 @@ public boolean equals(Object o) { Objects.equals(this.functionId, capabilityEntry.functionId) && Objects.equals(this.functionName, capabilityEntry.functionName) && Objects.equals(this.type, capabilityEntry.type) && - Objects.equals(this.vaddr, capabilityEntry.vaddr); + Objects.equals(this.vaddr, capabilityEntry.vaddr)&& + Objects.equals(this.additionalProperties, capabilityEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(capability, description, functionId, functionName, type, vaddr); + return Objects.hash(capability, description, functionId, functionName, type, vaddr, additionalProperties); } @Override @@ -229,6 +274,7 @@ public String toString() { sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" vaddr: ").append(toIndentedString(vaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -266,14 +312,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CapabilityEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CapabilityEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CapabilityEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CapabilityEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, CapabilityEntry value) throws IOException { public CapabilityEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CapabilityEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CollectionListItemBody.java b/src/main/java/ai/reveng/model/CollectionListItemBody.java index 10548015..707a7266 100644 --- a/src/main/java/ai/reveng/model/CollectionListItemBody.java +++ b/src/main/java/ai/reveng/model/CollectionListItemBody.java @@ -326,6 +326,50 @@ public void setUpdatedAt(@javax.annotation.Nonnull OffsetDateTime updatedAt) { this.updatedAt = updatedAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CollectionListItemBody instance itself + */ + public CollectionListItemBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -347,12 +391,13 @@ public boolean equals(Object o) { Objects.equals(this.description, collectionListItemBody.description) && Objects.equals(this.officialCollection, collectionListItemBody.officialCollection) && Objects.equals(this.teamId, collectionListItemBody.teamId) && - Objects.equals(this.updatedAt, collectionListItemBody.updatedAt); + Objects.equals(this.updatedAt, collectionListItemBody.updatedAt)&& + Objects.equals(this.additionalProperties, collectionListItemBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(collectionId, collectionName, collectionOwner, collectionScope, collectionSize, collectionTags, creation, description, officialCollection, teamId, updatedAt); + return Objects.hash(collectionId, collectionName, collectionOwner, collectionScope, collectionSize, collectionTags, creation, description, officialCollection, teamId, updatedAt, additionalProperties); } @Override @@ -370,6 +415,7 @@ public String toString() { sb.append(" officialCollection: ").append(toIndentedString(officialCollection)).append("\n"); sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -407,14 +453,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionListItemBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionListItemBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionListItemBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -457,6 +495,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionListItemBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -464,7 +524,28 @@ public void write(JsonWriter out, CollectionListItemBody value) throws IOExcepti public CollectionListItemBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CollectionListItemBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CommentsData.java b/src/main/java/ai/reveng/model/CommentsData.java index 1bcfb1f1..12cb89f6 100644 --- a/src/main/java/ai/reveng/model/CommentsData.java +++ b/src/main/java/ai/reveng/model/CommentsData.java @@ -166,6 +166,50 @@ public void setTaskStatus(@javax.annotation.Nonnull TaskStatusEnum taskStatus) { this.taskStatus = taskStatus; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentsData instance itself + */ + public CommentsData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -178,12 +222,13 @@ public boolean equals(Object o) { } CommentsData commentsData = (CommentsData) o; return Objects.equals(this.inlineComments, commentsData.inlineComments) && - Objects.equals(this.taskStatus, commentsData.taskStatus); + Objects.equals(this.taskStatus, commentsData.taskStatus)&& + Objects.equals(this.additionalProperties, commentsData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(inlineComments, taskStatus); + return Objects.hash(inlineComments, taskStatus, additionalProperties); } @Override @@ -192,6 +237,7 @@ public String toString() { sb.append("class CommentsData {\n"); sb.append(" inlineComments: ").append(toIndentedString(inlineComments)).append("\n"); sb.append(" taskStatus: ").append(toIndentedString(taskStatus)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -229,14 +275,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentsData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentsData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentsData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -244,15 +282,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("inline_comments") != null && !jsonObj.get("inline_comments").isJsonNull()) { - if (!jsonObj.get("inline_comments").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `inline_comments` to be an array in the JSON string but got `%s`", jsonObj.get("inline_comments").toString())); - } - JsonArray jsonArrayinlineComments = jsonObj.getAsJsonArray("inline_comments"); - // validate the required field `inline_comments` (array) - for (int i = 0; i < jsonArrayinlineComments.size(); i++) { - InlineComment.validateJsonElement(jsonArrayinlineComments.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("inline_comments") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("inline_comments").isJsonArray() && !jsonObj.get("inline_comments").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `inline_comments` to be an array in the JSON string but got `%s`", jsonObj.get("inline_comments").toString())); } if (!jsonObj.get("task_status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `task_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_status").toString())); @@ -276,6 +310,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentsData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -283,7 +339,28 @@ public void write(JsonWriter out, CommentsData value) throws IOException { public CommentsData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentsData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Config.java b/src/main/java/ai/reveng/model/Config.java new file mode 100644 index 00000000..eddd46d8 --- /dev/null +++ b/src/main/java/ai/reveng/model/Config.java @@ -0,0 +1,359 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.SandboxConfig; +import ai.reveng.model.ScrapeThirdPartyConfig; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Config + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Config { + public static final String SERIALIZED_NAME_GENERATE_CAPABILITIES = "generate_capabilities"; + @SerializedName(SERIALIZED_NAME_GENERATE_CAPABILITIES) + @javax.annotation.Nullable + private Boolean generateCapabilities; + + public static final String SERIALIZED_NAME_NO_CACHE = "no_cache"; + @SerializedName(SERIALIZED_NAME_NO_CACHE) + @javax.annotation.Nullable + private Boolean noCache; + + public static final String SERIALIZED_NAME_SANDBOX_CONFIG = "sandbox_config"; + @SerializedName(SERIALIZED_NAME_SANDBOX_CONFIG) + @javax.annotation.Nullable + private SandboxConfig sandboxConfig; + + public static final String SERIALIZED_NAME_SCRAPE_THIRD_PARTY_CONFIG = "scrape_third_party_config"; + @SerializedName(SERIALIZED_NAME_SCRAPE_THIRD_PARTY_CONFIG) + @javax.annotation.Nullable + private ScrapeThirdPartyConfig scrapeThirdPartyConfig; + + public Config() { + } + + public Config generateCapabilities(@javax.annotation.Nullable Boolean generateCapabilities) { + this.generateCapabilities = generateCapabilities; + return this; + } + + /** + * Get generateCapabilities + * @return generateCapabilities + */ + @javax.annotation.Nullable + public Boolean getGenerateCapabilities() { + return generateCapabilities; + } + + public void setGenerateCapabilities(@javax.annotation.Nullable Boolean generateCapabilities) { + this.generateCapabilities = generateCapabilities; + } + + + public Config noCache(@javax.annotation.Nullable Boolean noCache) { + this.noCache = noCache; + return this; + } + + /** + * Get noCache + * @return noCache + */ + @javax.annotation.Nullable + public Boolean getNoCache() { + return noCache; + } + + public void setNoCache(@javax.annotation.Nullable Boolean noCache) { + this.noCache = noCache; + } + + + public Config sandboxConfig(@javax.annotation.Nullable SandboxConfig sandboxConfig) { + this.sandboxConfig = sandboxConfig; + return this; + } + + /** + * Get sandboxConfig + * @return sandboxConfig + */ + @javax.annotation.Nullable + public SandboxConfig getSandboxConfig() { + return sandboxConfig; + } + + public void setSandboxConfig(@javax.annotation.Nullable SandboxConfig sandboxConfig) { + this.sandboxConfig = sandboxConfig; + } + + + public Config scrapeThirdPartyConfig(@javax.annotation.Nullable ScrapeThirdPartyConfig scrapeThirdPartyConfig) { + this.scrapeThirdPartyConfig = scrapeThirdPartyConfig; + return this; + } + + /** + * Get scrapeThirdPartyConfig + * @return scrapeThirdPartyConfig + */ + @javax.annotation.Nullable + public ScrapeThirdPartyConfig getScrapeThirdPartyConfig() { + return scrapeThirdPartyConfig; + } + + public void setScrapeThirdPartyConfig(@javax.annotation.Nullable ScrapeThirdPartyConfig scrapeThirdPartyConfig) { + this.scrapeThirdPartyConfig = scrapeThirdPartyConfig; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Config instance itself + */ + public Config putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Config config = (Config) o; + return Objects.equals(this.generateCapabilities, config.generateCapabilities) && + Objects.equals(this.noCache, config.noCache) && + Objects.equals(this.sandboxConfig, config.sandboxConfig) && + Objects.equals(this.scrapeThirdPartyConfig, config.scrapeThirdPartyConfig)&& + Objects.equals(this.additionalProperties, config.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(generateCapabilities, noCache, sandboxConfig, scrapeThirdPartyConfig, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Config {\n"); + sb.append(" generateCapabilities: ").append(toIndentedString(generateCapabilities)).append("\n"); + sb.append(" noCache: ").append(toIndentedString(noCache)).append("\n"); + sb.append(" sandboxConfig: ").append(toIndentedString(sandboxConfig)).append("\n"); + sb.append(" scrapeThirdPartyConfig: ").append(toIndentedString(scrapeThirdPartyConfig)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("generate_capabilities", "no_cache", "sandbox_config", "scrape_third_party_config")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Config + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Config.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Config is not found in the empty JSON string", Config.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Config.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Config' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Config.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Config value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Config read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Config instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Config given an JSON string + * + * @param jsonString JSON string + * @return An instance of Config + * @throws IOException if the JSON string is invalid with respect to Config + */ + public static Config fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Config.class); + } + + /** + * Convert an instance of Config to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ConfirmToolInputBody.java b/src/main/java/ai/reveng/model/ConfirmToolInputBody.java index 9f12cdb9..5376c1f3 100644 --- a/src/main/java/ai/reveng/model/ConfirmToolInputBody.java +++ b/src/main/java/ai/reveng/model/ConfirmToolInputBody.java @@ -75,6 +75,50 @@ public void setApproved(@javax.annotation.Nonnull Boolean approved) { this.approved = approved; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ConfirmToolInputBody instance itself + */ + public ConfirmToolInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } ConfirmToolInputBody confirmToolInputBody = (ConfirmToolInputBody) o; - return Objects.equals(this.approved, confirmToolInputBody.approved); + return Objects.equals(this.approved, confirmToolInputBody.approved)&& + Objects.equals(this.additionalProperties, confirmToolInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(approved); + return Objects.hash(approved, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ConfirmToolInputBody {\n"); sb.append(" approved: ").append(toIndentedString(approved)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ConfirmToolInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConfirmToolInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ConfirmToolInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -168,6 +206,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ConfirmToolInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -175,7 +235,28 @@ public void write(JsonWriter out, ConfirmToolInputBody value) throws IOException public ConfirmToolInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ConfirmToolInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Connection.java b/src/main/java/ai/reveng/model/Connection.java index db0e63bd..3ab591dd 100644 --- a/src/main/java/ai/reveng/model/Connection.java +++ b/src/main/java/ai/reveng/model/Connection.java @@ -336,6 +336,50 @@ public void setTcpCarvedFiles(@javax.annotation.Nullable List tcp this.tcpCarvedFiles = tcpCarvedFiles; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Connection instance itself + */ + public Connection putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -357,7 +401,8 @@ public boolean equals(Object o) { Objects.equals(this.protocol, connection.protocol) && Objects.equals(this.remoteIp, connection.remoteIp) && Objects.equals(this.remotePort, connection.remotePort) && - Objects.equals(this.tcpCarvedFiles, connection.tcpCarvedFiles); + Objects.equals(this.tcpCarvedFiles, connection.tcpCarvedFiles)&& + Objects.equals(this.additionalProperties, connection.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -366,7 +411,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(bytesReceived, bytesSent, events, ja3, ja3s, localIp, localPort, protocol, remoteIp, remotePort, tcpCarvedFiles); + return Objects.hash(bytesReceived, bytesSent, events, ja3, ja3s, localIp, localPort, protocol, remoteIp, remotePort, tcpCarvedFiles, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -391,6 +436,7 @@ public String toString() { sb.append(" remoteIp: ").append(toIndentedString(remoteIp)).append("\n"); sb.append(" remotePort: ").append(toIndentedString(remotePort)).append("\n"); sb.append(" tcpCarvedFiles: ").append(toIndentedString(tcpCarvedFiles)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -428,14 +474,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Connection.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Connection` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Connection.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -443,19 +481,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if ((jsonObj.get("ja3") != null && !jsonObj.get("ja3").isJsonNull()) && !jsonObj.get("ja3").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ja3` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ja3").toString())); @@ -472,19 +500,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("remote_ip").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `remote_ip` to be a primitive type in the JSON string but got `%s`", jsonObj.get("remote_ip").toString())); } - if (jsonObj.get("tcp_carved_files") != null && !jsonObj.get("tcp_carved_files").isJsonNull()) { - JsonArray jsonArraytcpCarvedFiles = jsonObj.getAsJsonArray("tcp_carved_files"); - if (jsonArraytcpCarvedFiles != null) { - // ensure the json data is an array - if (!jsonObj.get("tcp_carved_files").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tcp_carved_files` to be an array in the JSON string but got `%s`", jsonObj.get("tcp_carved_files").toString())); - } - - // validate the optional field `tcp_carved_files` (array) - for (int i = 0; i < jsonArraytcpCarvedFiles.size(); i++) { - TcpCarvedFile.validateJsonElement(jsonArraytcpCarvedFiles.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("tcp_carved_files") != null && !jsonObj.get("tcp_carved_files").isJsonNull() && !jsonObj.get("tcp_carved_files").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tcp_carved_files` to be an array in the JSON string but got `%s`", jsonObj.get("tcp_carved_files").toString())); } } @@ -503,6 +521,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Connection value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -510,7 +550,28 @@ public void write(JsonWriter out, Connection value) throws IOException { public Connection read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Connection instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ConsoleOutputEntry.java b/src/main/java/ai/reveng/model/ConsoleOutputEntry.java index 298df016..f32ac5aa 100644 --- a/src/main/java/ai/reveng/model/ConsoleOutputEntry.java +++ b/src/main/java/ai/reveng/model/ConsoleOutputEntry.java @@ -99,6 +99,50 @@ public void setProcessSeqid(@javax.annotation.Nonnull Long processSeqid) { this.processSeqid = processSeqid; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ConsoleOutputEntry instance itself + */ + public ConsoleOutputEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } ConsoleOutputEntry consoleOutputEntry = (ConsoleOutputEntry) o; return Objects.equals(this.output, consoleOutputEntry.output) && - Objects.equals(this.processSeqid, consoleOutputEntry.processSeqid); + Objects.equals(this.processSeqid, consoleOutputEntry.processSeqid)&& + Objects.equals(this.additionalProperties, consoleOutputEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(output, processSeqid); + return Objects.hash(output, processSeqid, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class ConsoleOutputEntry {\n"); sb.append(" output: ").append(toIndentedString(output)).append("\n"); sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ConsoleOutputEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConsoleOutputEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ConsoleOutputEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -197,6 +235,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ConsoleOutputEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -204,7 +264,28 @@ public void write(JsonWriter out, ConsoleOutputEntry value) throws IOException { public ConsoleOutputEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ConsoleOutputEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Conversation.java b/src/main/java/ai/reveng/model/Conversation.java index da8f58bb..75ba6e23 100644 --- a/src/main/java/ai/reveng/model/Conversation.java +++ b/src/main/java/ai/reveng/model/Conversation.java @@ -197,6 +197,50 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Conversation instance itself + */ + public Conversation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -213,7 +257,8 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, conversation.createdAt) && Objects.equals(this.title, conversation.title) && Objects.equals(this.updatedAt, conversation.updatedAt) && - Objects.equals(this.userId, conversation.userId); + Objects.equals(this.userId, conversation.userId)&& + Objects.equals(this.additionalProperties, conversation.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -222,7 +267,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(context, conversationUuid, createdAt, title, updatedAt, userId); + return Objects.hash(context, conversationUuid, createdAt, title, updatedAt, userId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -242,6 +287,7 @@ public String toString() { sb.append(" title: ").append(toIndentedString(title)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -279,14 +325,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Conversation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Conversation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Conversation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -317,6 +355,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Conversation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -324,7 +384,28 @@ public void write(JsonWriter out, Conversation value) throws IOException { public Conversation read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Conversation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ConversationContext.java b/src/main/java/ai/reveng/model/ConversationContext.java index a1edbed7..53660cc0 100644 --- a/src/main/java/ai/reveng/model/ConversationContext.java +++ b/src/main/java/ai/reveng/model/ConversationContext.java @@ -99,6 +99,50 @@ public void setFunctionId(@javax.annotation.Nullable Long functionId) { this.functionId = functionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ConversationContext instance itself + */ + public ConversationContext putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } ConversationContext conversationContext = (ConversationContext) o; return Objects.equals(this.analysisId, conversationContext.analysisId) && - Objects.equals(this.functionId, conversationContext.functionId); + Objects.equals(this.functionId, conversationContext.functionId)&& + Objects.equals(this.additionalProperties, conversationContext.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, functionId); + return Objects.hash(analysisId, functionId, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class ConversationContext {\n"); sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -161,14 +207,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ConversationContext is not found in the empty JSON string", ConversationContext.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ConversationContext.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConversationContext` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -187,6 +225,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ConversationContext value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -194,7 +254,28 @@ public void write(JsonWriter out, ConversationContext value) throws IOException public ConversationContext read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ConversationContext instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ConversationWithEvents.java b/src/main/java/ai/reveng/model/ConversationWithEvents.java index 6427402a..75584fd0 100644 --- a/src/main/java/ai/reveng/model/ConversationWithEvents.java +++ b/src/main/java/ai/reveng/model/ConversationWithEvents.java @@ -232,6 +232,50 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ConversationWithEvents instance itself + */ + public ConversationWithEvents putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -249,7 +293,8 @@ public boolean equals(Object o) { Objects.equals(this.events, conversationWithEvents.events) && Objects.equals(this.title, conversationWithEvents.title) && Objects.equals(this.updatedAt, conversationWithEvents.updatedAt) && - Objects.equals(this.userId, conversationWithEvents.userId); + Objects.equals(this.userId, conversationWithEvents.userId)&& + Objects.equals(this.additionalProperties, conversationWithEvents.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -258,7 +303,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(context, conversationUuid, createdAt, events, title, updatedAt, userId); + return Objects.hash(context, conversationUuid, createdAt, events, title, updatedAt, userId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -279,6 +324,7 @@ public String toString() { sb.append(" title: ").append(toIndentedString(title)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -316,14 +362,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ConversationWithEvents.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConversationWithEvents` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ConversationWithEvents.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -334,15 +372,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("conversation_uuid").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); } - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - // validate the required field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - Event.validateJsonElement(jsonArrayevents.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("events") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("events").isJsonArray() && !jsonObj.get("events").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if (!jsonObj.get("title").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); @@ -364,6 +398,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ConversationWithEvents value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -371,7 +427,28 @@ public void write(JsonWriter out, ConversationWithEvents value) throws IOExcepti public ConversationWithEvents read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ConversationWithEvents instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CopyFunctionSignaturesInputBody.java b/src/main/java/ai/reveng/model/CopyFunctionSignaturesInputBody.java index ef89ed68..a1266db0 100644 --- a/src/main/java/ai/reveng/model/CopyFunctionSignaturesInputBody.java +++ b/src/main/java/ai/reveng/model/CopyFunctionSignaturesInputBody.java @@ -86,6 +86,50 @@ public void setCopies(@javax.annotation.Nullable List copies) this.copies = copies; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CopyFunctionSignaturesInputBody instance itself + */ + public CopyFunctionSignaturesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } CopyFunctionSignaturesInputBody copyFunctionSignaturesInputBody = (CopyFunctionSignaturesInputBody) o; - return Objects.equals(this.copies, copyFunctionSignaturesInputBody.copies); + return Objects.equals(this.copies, copyFunctionSignaturesInputBody.copies)&& + Objects.equals(this.additionalProperties, copyFunctionSignaturesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(copies); + return Objects.hash(copies, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CopyFunctionSignaturesInputBody {\n"); sb.append(" copies: ").append(toIndentedString(copies)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CopyFunctionSignaturesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CopyFunctionSignaturesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CopyFunctionSignaturesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("copies") != null && !jsonObj.get("copies").isJsonNull()) { - if (!jsonObj.get("copies").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `copies` to be an array in the JSON string but got `%s`", jsonObj.get("copies").toString())); - } - JsonArray jsonArraycopies = jsonObj.getAsJsonArray("copies"); - // validate the required field `copies` (array) - for (int i = 0; i < jsonArraycopies.size(); i++) { - CopySignatureItem.validateJsonElement(jsonArraycopies.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("copies") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("copies").isJsonArray() && !jsonObj.get("copies").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `copies` to be an array in the JSON string but got `%s`", jsonObj.get("copies").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CopyFunctionSignaturesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, CopyFunctionSignaturesInputBody value) throws public CopyFunctionSignaturesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CopyFunctionSignaturesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CopyFunctionSignaturesOutputBody.java b/src/main/java/ai/reveng/model/CopyFunctionSignaturesOutputBody.java index a218136d..72474db8 100644 --- a/src/main/java/ai/reveng/model/CopyFunctionSignaturesOutputBody.java +++ b/src/main/java/ai/reveng/model/CopyFunctionSignaturesOutputBody.java @@ -119,6 +119,50 @@ public void setSignatures(@javax.annotation.Nullable List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CopyFunctionSignaturesOutputBody instance itself + */ + public CopyFunctionSignaturesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -131,12 +175,13 @@ public boolean equals(Object o) { } CopyFunctionSignaturesOutputBody copyFunctionSignaturesOutputBody = (CopyFunctionSignaturesOutputBody) o; return Objects.equals(this.dataTypes, copyFunctionSignaturesOutputBody.dataTypes) && - Objects.equals(this.signatures, copyFunctionSignaturesOutputBody.signatures); + Objects.equals(this.signatures, copyFunctionSignaturesOutputBody.signatures)&& + Objects.equals(this.additionalProperties, copyFunctionSignaturesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypes, signatures); + return Objects.hash(dataTypes, signatures, additionalProperties); } @Override @@ -145,6 +190,7 @@ public String toString() { sb.append("class CopyFunctionSignaturesOutputBody {\n"); sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); sb.append(" signatures: ").append(toIndentedString(signatures)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -182,14 +228,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CopyFunctionSignaturesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CopyFunctionSignaturesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CopyFunctionSignaturesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -207,15 +245,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti DataTypeEntry.validateJsonElement(jsonArraydataTypes.get(i)); } } - if (jsonObj.get("signatures") != null && !jsonObj.get("signatures").isJsonNull()) { - if (!jsonObj.get("signatures").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `signatures` to be an array in the JSON string but got `%s`", jsonObj.get("signatures").toString())); - } - JsonArray jsonArraysignatures = jsonObj.getAsJsonArray("signatures"); - // validate the required field `signatures` (array) - for (int i = 0; i < jsonArraysignatures.size(); i++) { - FunctionSignatureEntry.validateJsonElement(jsonArraysignatures.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("signatures") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("signatures").isJsonArray() && !jsonObj.get("signatures").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `signatures` to be an array in the JSON string but got `%s`", jsonObj.get("signatures").toString())); } } @@ -234,6 +268,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CopyFunctionSignaturesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +297,28 @@ public void write(JsonWriter out, CopyFunctionSignaturesOutputBody value) throws public CopyFunctionSignaturesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CopyFunctionSignaturesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CopySignatureItem.java b/src/main/java/ai/reveng/model/CopySignatureItem.java index 9851463a..ac1c241e 100644 --- a/src/main/java/ai/reveng/model/CopySignatureItem.java +++ b/src/main/java/ai/reveng/model/CopySignatureItem.java @@ -101,6 +101,50 @@ public void setTargetFunctionId(@javax.annotation.Nonnull Long targetFunctionId) this.targetFunctionId = targetFunctionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CopySignatureItem instance itself + */ + public CopySignatureItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } CopySignatureItem copySignatureItem = (CopySignatureItem) o; return Objects.equals(this.sourceFunctionId, copySignatureItem.sourceFunctionId) && - Objects.equals(this.targetFunctionId, copySignatureItem.targetFunctionId); + Objects.equals(this.targetFunctionId, copySignatureItem.targetFunctionId)&& + Objects.equals(this.additionalProperties, copySignatureItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sourceFunctionId, targetFunctionId); + return Objects.hash(sourceFunctionId, targetFunctionId, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class CopySignatureItem {\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" targetFunctionId: ").append(toIndentedString(targetFunctionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CopySignatureItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CopySignatureItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CopySignatureItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -196,6 +234,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CopySignatureItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -203,7 +263,28 @@ public void write(JsonWriter out, CopySignatureItem value) throws IOException { public CopySignatureItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CopySignatureItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java b/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java index 672d797a..025d9c1d 100644 --- a/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java +++ b/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java @@ -75,6 +75,50 @@ public void setStatus(@javax.annotation.Nonnull Boolean status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateAIDecompOutputBody instance itself + */ + public CreateAIDecompOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } CreateAIDecompOutputBody createAIDecompOutputBody = (CreateAIDecompOutputBody) o; - return Objects.equals(this.status, createAIDecompOutputBody.status); + return Objects.equals(this.status, createAIDecompOutputBody.status)&& + Objects.equals(this.additionalProperties, createAIDecompOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CreateAIDecompOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateAIDecompOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateAIDecompOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateAIDecompOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -168,6 +206,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateAIDecompOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -175,7 +235,28 @@ public void write(JsonWriter out, CreateAIDecompOutputBody value) throws IOExcep public CreateAIDecompOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateAIDecompOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateAnalysisDataTypesInputBody.java b/src/main/java/ai/reveng/model/CreateAnalysisDataTypesInputBody.java index a10fa763..4d7dce3b 100644 --- a/src/main/java/ai/reveng/model/CreateAnalysisDataTypesInputBody.java +++ b/src/main/java/ai/reveng/model/CreateAnalysisDataTypesInputBody.java @@ -86,6 +86,50 @@ public void setDataTypes(@javax.annotation.Nullable List da this.dataTypes = dataTypes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateAnalysisDataTypesInputBody instance itself + */ + public CreateAnalysisDataTypesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } CreateAnalysisDataTypesInputBody createAnalysisDataTypesInputBody = (CreateAnalysisDataTypesInputBody) o; - return Objects.equals(this.dataTypes, createAnalysisDataTypesInputBody.dataTypes); + return Objects.equals(this.dataTypes, createAnalysisDataTypesInputBody.dataTypes)&& + Objects.equals(this.additionalProperties, createAnalysisDataTypesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypes); + return Objects.hash(dataTypes, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CreateAnalysisDataTypesInputBody {\n"); sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateAnalysisDataTypesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateAnalysisDataTypesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateAnalysisDataTypesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateAnalysisDataTypesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, CreateAnalysisDataTypesInputBody value) throws public CreateAnalysisDataTypesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateAnalysisDataTypesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateArrayDataType.java b/src/main/java/ai/reveng/model/CreateArrayDataType.java index f84ce85c..c9e96609 100644 --- a/src/main/java/ai/reveng/model/CreateArrayDataType.java +++ b/src/main/java/ai/reveng/model/CreateArrayDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateArrayDataType instance itself + */ + public CreateArrayDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, createArrayDataType.kind) && Objects.equals(this.name, createArrayDataType.name) && Objects.equals(this.namespace, createArrayDataType.namespace) && - Objects.equals(this.size, createArrayDataType.size); + Objects.equals(this.size, createArrayDataType.size)&& + Objects.equals(this.additionalProperties, createArrayDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(definition, kind, name, namespace, size); + return Objects.hash(definition, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateArrayDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateArrayDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateArrayDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,8 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - ArrayDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -339,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateArrayDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +404,28 @@ public void write(JsonWriter out, CreateArrayDataType value) throws IOException public CreateArrayDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateArrayDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateBaseDataType.java b/src/main/java/ai/reveng/model/CreateBaseDataType.java index 62c99dee..b62a87f6 100644 --- a/src/main/java/ai/reveng/model/CreateBaseDataType.java +++ b/src/main/java/ai/reveng/model/CreateBaseDataType.java @@ -200,6 +200,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateBaseDataType instance itself + */ + public CreateBaseDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -214,12 +258,13 @@ public boolean equals(Object o) { return Objects.equals(this.kind, createBaseDataType.kind) && Objects.equals(this.name, createBaseDataType.name) && Objects.equals(this.namespace, createBaseDataType.namespace) && - Objects.equals(this.size, createBaseDataType.size); + Objects.equals(this.size, createBaseDataType.size)&& + Objects.equals(this.additionalProperties, createBaseDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(kind, name, namespace, size); + return Objects.hash(kind, name, namespace, size, additionalProperties); } @Override @@ -230,6 +275,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -267,14 +313,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateBaseDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateBaseDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateBaseDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateBaseDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, CreateBaseDataType value) throws IOException { public CreateBaseDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateBaseDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateBitfieldDataType.java b/src/main/java/ai/reveng/model/CreateBitfieldDataType.java index 5b036ffb..2d3a21dd 100644 --- a/src/main/java/ai/reveng/model/CreateBitfieldDataType.java +++ b/src/main/java/ai/reveng/model/CreateBitfieldDataType.java @@ -200,6 +200,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateBitfieldDataType instance itself + */ + public CreateBitfieldDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -214,12 +258,13 @@ public boolean equals(Object o) { return Objects.equals(this.kind, createBitfieldDataType.kind) && Objects.equals(this.name, createBitfieldDataType.name) && Objects.equals(this.namespace, createBitfieldDataType.namespace) && - Objects.equals(this.size, createBitfieldDataType.size); + Objects.equals(this.size, createBitfieldDataType.size)&& + Objects.equals(this.additionalProperties, createBitfieldDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(kind, name, namespace, size); + return Objects.hash(kind, name, namespace, size, additionalProperties); } @Override @@ -230,6 +275,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -267,14 +313,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateBitfieldDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateBitfieldDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateBitfieldDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateBitfieldDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, CreateBitfieldDataType value) throws IOExcepti public CreateBitfieldDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateBitfieldDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateCollectionInputBody.java b/src/main/java/ai/reveng/model/CreateCollectionInputBody.java index c4b13174..85bd59ea 100644 --- a/src/main/java/ai/reveng/model/CreateCollectionInputBody.java +++ b/src/main/java/ai/reveng/model/CreateCollectionInputBody.java @@ -248,6 +248,50 @@ public void setTags(@javax.annotation.Nullable List tags) { this.tags = tags; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateCollectionInputBody instance itself + */ + public CreateCollectionInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -263,7 +307,8 @@ public boolean equals(Object o) { Objects.equals(this.collectionName, createCollectionInputBody.collectionName) && Objects.equals(this.collectionScope, createCollectionInputBody.collectionScope) && Objects.equals(this.description, createCollectionInputBody.description) && - Objects.equals(this.tags, createCollectionInputBody.tags); + Objects.equals(this.tags, createCollectionInputBody.tags)&& + Objects.equals(this.additionalProperties, createCollectionInputBody.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -272,7 +317,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaries, collectionName, collectionScope, description, tags); + return Objects.hash(binaries, collectionName, collectionScope, description, tags, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -291,6 +336,7 @@ public String toString() { sb.append(" collectionScope: ").append(toIndentedString(collectionScope)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -328,14 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCollectionInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateCollectionInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateCollectionInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -379,6 +417,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateCollectionInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -386,7 +446,28 @@ public void write(JsonWriter out, CreateCollectionInputBody value) throws IOExce public CreateCollectionInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateCollectionInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java b/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java index 85169a72..fe4bbfe5 100644 --- a/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java +++ b/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java @@ -312,6 +312,50 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateCollectionOutputBody instance itself + */ + public CreateCollectionOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -332,7 +376,8 @@ public boolean equals(Object o) { Objects.equals(this.tags, createCollectionOutputBody.tags) && Objects.equals(this.teamId, createCollectionOutputBody.teamId) && Objects.equals(this.updatedAt, createCollectionOutputBody.updatedAt) && - Objects.equals(this.userId, createCollectionOutputBody.userId); + Objects.equals(this.userId, createCollectionOutputBody.userId)&& + Objects.equals(this.additionalProperties, createCollectionOutputBody.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -341,7 +386,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, tags, teamId, updatedAt, userId); + return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, tags, teamId, updatedAt, userId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -365,6 +410,7 @@ public String toString() { sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -402,14 +448,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCollectionOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateCollectionOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateCollectionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -417,19 +455,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull()) { - JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); - if (jsonArraybinaries != null) { - // ensure the json data is an array - if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); - } - - // validate the optional field `binaries` (array) - for (int i = 0; i < jsonArraybinaries.size(); i++) { - Binary.validateJsonElement(jsonArraybinaries.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull() && !jsonObj.get("binaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } if (!jsonObj.get("collection_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); @@ -461,6 +489,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateCollectionOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -468,7 +518,28 @@ public void write(JsonWriter out, CreateCollectionOutputBody value) throws IOExc public CreateCollectionOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateCollectionOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateConversationRequest.java b/src/main/java/ai/reveng/model/CreateConversationRequest.java index f40b019a..6f32d969 100644 --- a/src/main/java/ai/reveng/model/CreateConversationRequest.java +++ b/src/main/java/ai/reveng/model/CreateConversationRequest.java @@ -100,6 +100,50 @@ public void setTitle(@javax.annotation.Nullable String title) { this.title = title; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateConversationRequest instance itself + */ + public CreateConversationRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } CreateConversationRequest createConversationRequest = (CreateConversationRequest) o; return Objects.equals(this.context, createConversationRequest.context) && - Objects.equals(this.title, createConversationRequest.title); + Objects.equals(this.title, createConversationRequest.title)&& + Objects.equals(this.additionalProperties, createConversationRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(context, title); + return Objects.hash(context, title, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class CreateConversationRequest {\n"); sb.append(" context: ").append(toIndentedString(context)).append("\n"); sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,19 +208,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateConversationRequest is not found in the empty JSON string", CreateConversationRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateConversationRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateConversationRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `context` - if (jsonObj.get("context") != null && !jsonObj.get("context").isJsonNull()) { - ConversationContext.validateJsonElement(jsonObj.get("context")); - } if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); } @@ -195,6 +229,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateConversationRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -202,7 +258,28 @@ public void write(JsonWriter out, CreateConversationRequest value) throws IOExce public CreateConversationRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateConversationRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateEnumDataType.java b/src/main/java/ai/reveng/model/CreateEnumDataType.java index 912bfe45..fe0b7787 100644 --- a/src/main/java/ai/reveng/model/CreateEnumDataType.java +++ b/src/main/java/ai/reveng/model/CreateEnumDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateEnumDataType instance itself + */ + public CreateEnumDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, createEnumDataType.kind) && Objects.equals(this.name, createEnumDataType.name) && Objects.equals(this.namespace, createEnumDataType.namespace) && - Objects.equals(this.size, createEnumDataType.size); + Objects.equals(this.size, createEnumDataType.size)&& + Objects.equals(this.additionalProperties, createEnumDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(definition, kind, name, namespace, size); + return Objects.hash(definition, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateEnumDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateEnumDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateEnumDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,8 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - EnumDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -339,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateEnumDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +404,28 @@ public void write(JsonWriter out, CreateEnumDataType value) throws IOException { public CreateEnumDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateEnumDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateFunctionDataType.java b/src/main/java/ai/reveng/model/CreateFunctionDataType.java index ae0a231a..2933d721 100644 --- a/src/main/java/ai/reveng/model/CreateFunctionDataType.java +++ b/src/main/java/ai/reveng/model/CreateFunctionDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateFunctionDataType instance itself + */ + public CreateFunctionDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, createFunctionDataType.kind) && Objects.equals(this.name, createFunctionDataType.name) && Objects.equals(this.namespace, createFunctionDataType.namespace) && - Objects.equals(this.size, createFunctionDataType.size); + Objects.equals(this.size, createFunctionDataType.size)&& + Objects.equals(this.additionalProperties, createFunctionDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(definition, kind, name, namespace, size); + return Objects.hash(definition, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateFunctionDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateFunctionDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateFunctionDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,8 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - FunctionTypeDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -339,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateFunctionDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +404,28 @@ public void write(JsonWriter out, CreateFunctionDataType value) throws IOExcepti public CreateFunctionDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateFunctionDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateMetadata.java b/src/main/java/ai/reveng/model/CreateMetadata.java new file mode 100644 index 00000000..8f89eb0e --- /dev/null +++ b/src/main/java/ai/reveng/model/CreateMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CreateMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateMetadata { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_BINARY_ID = "binary_id"; + @SerializedName(SERIALIZED_NAME_BINARY_ID) + @javax.annotation.Nonnull + private Long binaryId; + + /** + * Analysis status + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UPLOADED("Uploaded"), + + QUEUED("Queued"), + + PROCESSING("Processing"), + + COMPLETE("Complete"), + + ERROR("Error"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public CreateMetadata() { + } + + public CreateMetadata analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Analysis ID + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public CreateMetadata binaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + return this; + } + + /** + * Binary ID + * @return binaryId + */ + @javax.annotation.Nonnull + public Long getBinaryId() { + return binaryId; + } + + public void setBinaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + } + + + public CreateMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Analysis status + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateMetadata instance itself + */ + public CreateMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateMetadata createMetadata = (CreateMetadata) o; + return Objects.equals(this.analysisId, createMetadata.analysisId) && + Objects.equals(this.binaryId, createMetadata.binaryId) && + Objects.equals(this.status, createMetadata.status)&& + Objects.equals(this.additionalProperties, createMetadata.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, binaryId, status, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateMetadata {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "binary_id", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "binary_id", "status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateMetadata is not found in the empty JSON string", CreateMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateMetadata + * @throws IOException if the JSON string is invalid with respect to CreateMetadata + */ + public static CreateMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateMetadata.class); + } + + /** + * Convert an instance of CreateMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CreatePointerDataType.java b/src/main/java/ai/reveng/model/CreatePointerDataType.java index bdfedcbc..cde5d1ad 100644 --- a/src/main/java/ai/reveng/model/CreatePointerDataType.java +++ b/src/main/java/ai/reveng/model/CreatePointerDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreatePointerDataType instance itself + */ + public CreatePointerDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, createPointerDataType.kind) && Objects.equals(this.name, createPointerDataType.name) && Objects.equals(this.namespace, createPointerDataType.namespace) && - Objects.equals(this.size, createPointerDataType.size); + Objects.equals(this.size, createPointerDataType.size)&& + Objects.equals(this.additionalProperties, createPointerDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(definition, kind, name, namespace, size); + return Objects.hash(definition, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreatePointerDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreatePointerDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreatePointerDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,8 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - PointerDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -339,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreatePointerDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +404,28 @@ public void write(JsonWriter out, CreatePointerDataType value) throws IOExceptio public CreatePointerDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreatePointerDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateRequest.java b/src/main/java/ai/reveng/model/CreateRequest.java new file mode 100644 index 00000000..b169016a --- /dev/null +++ b/src/main/java/ai/reveng/model/CreateRequest.java @@ -0,0 +1,596 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.AutoRunAgents; +import ai.reveng.model.BinaryConfig; +import ai.reveng.model.Config; +import ai.reveng.model.Symbols; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CreateRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateRequest { + public static final String SERIALIZED_NAME_ANALYSIS_CONFIG = "analysis_config"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_CONFIG) + @javax.annotation.Nullable + private Config analysisConfig; + + /** + * Gets or Sets analysisScope + */ + @JsonAdapter(AnalysisScopeEnum.Adapter.class) + public enum AnalysisScopeEnum { + PRIVATE("PRIVATE"), + + PUBLIC("PUBLIC"), + + TEAM("TEAM"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + AnalysisScopeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AnalysisScopeEnum fromValue(String value) { + for (AnalysisScopeEnum b : AnalysisScopeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final AnalysisScopeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AnalysisScopeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return AnalysisScopeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + AnalysisScopeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_ANALYSIS_SCOPE = "analysis_scope"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_SCOPE) + @javax.annotation.Nullable + private AnalysisScopeEnum analysisScope = AnalysisScopeEnum.PRIVATE; + + public static final String SERIALIZED_NAME_AUTO_RUN_AGENTS = "auto_run_agents"; + @SerializedName(SERIALIZED_NAME_AUTO_RUN_AGENTS) + @javax.annotation.Nullable + private AutoRunAgents autoRunAgents; + + public static final String SERIALIZED_NAME_BINARY_CONFIG = "binary_config"; + @SerializedName(SERIALIZED_NAME_BINARY_CONFIG) + @javax.annotation.Nullable + private BinaryConfig binaryConfig; + + public static final String SERIALIZED_NAME_DEBUG_HASH = "debug_hash"; + @SerializedName(SERIALIZED_NAME_DEBUG_HASH) + @javax.annotation.Nullable + private String debugHash; + + public static final String SERIALIZED_NAME_FILENAME = "filename"; + @SerializedName(SERIALIZED_NAME_FILENAME) + @javax.annotation.Nonnull + private String filename; + + public static final String SERIALIZED_NAME_SHA256_HASH = "sha_256_hash"; + @SerializedName(SERIALIZED_NAME_SHA256_HASH) + @javax.annotation.Nonnull + private String sha256Hash; + + public static final String SERIALIZED_NAME_SYMBOLS = "symbols"; + @SerializedName(SERIALIZED_NAME_SYMBOLS) + @javax.annotation.Nullable + private Symbols symbols; + + public static final String SERIALIZED_NAME_TAGS = "tags"; + @SerializedName(SERIALIZED_NAME_TAGS) + @javax.annotation.Nullable + private List tags; + + public CreateRequest() { + } + + public CreateRequest analysisConfig(@javax.annotation.Nullable Config analysisConfig) { + this.analysisConfig = analysisConfig; + return this; + } + + /** + * Get analysisConfig + * @return analysisConfig + */ + @javax.annotation.Nullable + public Config getAnalysisConfig() { + return analysisConfig; + } + + public void setAnalysisConfig(@javax.annotation.Nullable Config analysisConfig) { + this.analysisConfig = analysisConfig; + } + + + public CreateRequest analysisScope(@javax.annotation.Nullable AnalysisScopeEnum analysisScope) { + this.analysisScope = analysisScope; + return this; + } + + /** + * Get analysisScope + * @return analysisScope + */ + @javax.annotation.Nullable + public AnalysisScopeEnum getAnalysisScope() { + return analysisScope; + } + + public void setAnalysisScope(@javax.annotation.Nullable AnalysisScopeEnum analysisScope) { + this.analysisScope = analysisScope; + } + + + public CreateRequest autoRunAgents(@javax.annotation.Nullable AutoRunAgents autoRunAgents) { + this.autoRunAgents = autoRunAgents; + return this; + } + + /** + * Get autoRunAgents + * @return autoRunAgents + */ + @javax.annotation.Nullable + public AutoRunAgents getAutoRunAgents() { + return autoRunAgents; + } + + public void setAutoRunAgents(@javax.annotation.Nullable AutoRunAgents autoRunAgents) { + this.autoRunAgents = autoRunAgents; + } + + + public CreateRequest binaryConfig(@javax.annotation.Nullable BinaryConfig binaryConfig) { + this.binaryConfig = binaryConfig; + return this; + } + + /** + * Get binaryConfig + * @return binaryConfig + */ + @javax.annotation.Nullable + public BinaryConfig getBinaryConfig() { + return binaryConfig; + } + + public void setBinaryConfig(@javax.annotation.Nullable BinaryConfig binaryConfig) { + this.binaryConfig = binaryConfig; + } + + + public CreateRequest debugHash(@javax.annotation.Nullable String debugHash) { + this.debugHash = debugHash; + return this; + } + + /** + * Get debugHash + * @return debugHash + */ + @javax.annotation.Nullable + public String getDebugHash() { + return debugHash; + } + + public void setDebugHash(@javax.annotation.Nullable String debugHash) { + this.debugHash = debugHash; + } + + + public CreateRequest filename(@javax.annotation.Nonnull String filename) { + this.filename = filename; + return this; + } + + /** + * Get filename + * @return filename + */ + @javax.annotation.Nonnull + public String getFilename() { + return filename; + } + + public void setFilename(@javax.annotation.Nonnull String filename) { + this.filename = filename; + } + + + public CreateRequest sha256Hash(@javax.annotation.Nonnull String sha256Hash) { + this.sha256Hash = sha256Hash; + return this; + } + + /** + * Get sha256Hash + * @return sha256Hash + */ + @javax.annotation.Nonnull + public String getSha256Hash() { + return sha256Hash; + } + + public void setSha256Hash(@javax.annotation.Nonnull String sha256Hash) { + this.sha256Hash = sha256Hash; + } + + + public CreateRequest symbols(@javax.annotation.Nullable Symbols symbols) { + this.symbols = symbols; + return this; + } + + /** + * Get symbols + * @return symbols + */ + @javax.annotation.Nullable + public Symbols getSymbols() { + return symbols; + } + + public void setSymbols(@javax.annotation.Nullable Symbols symbols) { + this.symbols = symbols; + } + + + public CreateRequest tags(@javax.annotation.Nullable List tags) { + this.tags = tags; + return this; + } + + public CreateRequest addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + */ + @javax.annotation.Nullable + public List getTags() { + return tags; + } + + public void setTags(@javax.annotation.Nullable List tags) { + this.tags = tags; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateRequest instance itself + */ + public CreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateRequest createRequest = (CreateRequest) o; + return Objects.equals(this.analysisConfig, createRequest.analysisConfig) && + Objects.equals(this.analysisScope, createRequest.analysisScope) && + Objects.equals(this.autoRunAgents, createRequest.autoRunAgents) && + Objects.equals(this.binaryConfig, createRequest.binaryConfig) && + Objects.equals(this.debugHash, createRequest.debugHash) && + Objects.equals(this.filename, createRequest.filename) && + Objects.equals(this.sha256Hash, createRequest.sha256Hash) && + Objects.equals(this.symbols, createRequest.symbols) && + Objects.equals(this.tags, createRequest.tags)&& + Objects.equals(this.additionalProperties, createRequest.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(analysisConfig, analysisScope, autoRunAgents, binaryConfig, debugHash, filename, sha256Hash, symbols, tags, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateRequest {\n"); + sb.append(" analysisConfig: ").append(toIndentedString(analysisConfig)).append("\n"); + sb.append(" analysisScope: ").append(toIndentedString(analysisScope)).append("\n"); + sb.append(" autoRunAgents: ").append(toIndentedString(autoRunAgents)).append("\n"); + sb.append(" binaryConfig: ").append(toIndentedString(binaryConfig)).append("\n"); + sb.append(" debugHash: ").append(toIndentedString(debugHash)).append("\n"); + sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); + sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); + sb.append(" symbols: ").append(toIndentedString(symbols)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_config", "analysis_scope", "auto_run_agents", "binary_config", "debug_hash", "filename", "sha_256_hash", "symbols", "tags")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("filename", "sha_256_hash")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateRequest is not found in the empty JSON string", CreateRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("analysis_scope") != null && !jsonObj.get("analysis_scope").isJsonNull()) && !jsonObj.get("analysis_scope").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); + } + // validate the optional field `analysis_scope` + if (jsonObj.get("analysis_scope") != null && !jsonObj.get("analysis_scope").isJsonNull()) { + AnalysisScopeEnum.validateJsonElement(jsonObj.get("analysis_scope")); + } + if ((jsonObj.get("debug_hash") != null && !jsonObj.get("debug_hash").isJsonNull()) && !jsonObj.get("debug_hash").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); + } + if (!jsonObj.get("filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + } + if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateRequest + * @throws IOException if the JSON string is invalid with respect to CreateRequest + */ + public static CreateRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateRequest.class); + } + + /** + * Convert an instance of CreateRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CreateResult.java b/src/main/java/ai/reveng/model/CreateResult.java new file mode 100644 index 00000000..25e07c96 --- /dev/null +++ b/src/main/java/ai/reveng/model/CreateResult.java @@ -0,0 +1,312 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CreateResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateResult { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_BINARY_ID = "binary_id"; + @SerializedName(SERIALIZED_NAME_BINARY_ID) + @javax.annotation.Nonnull + private Long binaryId; + + public CreateResult() { + } + + public CreateResult analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Analysis ID + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public CreateResult binaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + return this; + } + + /** + * Binary ID + * @return binaryId + */ + @javax.annotation.Nonnull + public Long getBinaryId() { + return binaryId; + } + + public void setBinaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateResult instance itself + */ + public CreateResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateResult createResult = (CreateResult) o; + return Objects.equals(this.analysisId, createResult.analysisId) && + Objects.equals(this.binaryId, createResult.binaryId)&& + Objects.equals(this.additionalProperties, createResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, binaryId, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateResult {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "binary_id")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "binary_id")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateResult is not found in the empty JSON string", CreateResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateResult + * @throws IOException if the JSON string is invalid with respect to CreateResult + */ + public static CreateResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateResult.class); + } + + /** + * Convert an instance of CreateResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CreateStructDataType.java b/src/main/java/ai/reveng/model/CreateStructDataType.java index cbc80db1..b099f1e7 100644 --- a/src/main/java/ai/reveng/model/CreateStructDataType.java +++ b/src/main/java/ai/reveng/model/CreateStructDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateStructDataType instance itself + */ + public CreateStructDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, createStructDataType.kind) && Objects.equals(this.name, createStructDataType.name) && Objects.equals(this.namespace, createStructDataType.namespace) && - Objects.equals(this.size, createStructDataType.size); + Objects.equals(this.size, createStructDataType.size)&& + Objects.equals(this.additionalProperties, createStructDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(definition, kind, name, namespace, size); + return Objects.hash(definition, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateStructDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateStructDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateStructDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,8 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - StructDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -339,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateStructDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +404,28 @@ public void write(JsonWriter out, CreateStructDataType value) throws IOException public CreateStructDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateStructDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateTypedefDataType.java b/src/main/java/ai/reveng/model/CreateTypedefDataType.java index 247354ef..184529b8 100644 --- a/src/main/java/ai/reveng/model/CreateTypedefDataType.java +++ b/src/main/java/ai/reveng/model/CreateTypedefDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTypedefDataType instance itself + */ + public CreateTypedefDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, createTypedefDataType.kind) && Objects.equals(this.name, createTypedefDataType.name) && Objects.equals(this.namespace, createTypedefDataType.namespace) && - Objects.equals(this.size, createTypedefDataType.size); + Objects.equals(this.size, createTypedefDataType.size)&& + Objects.equals(this.additionalProperties, createTypedefDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(definition, kind, name, namespace, size); + return Objects.hash(definition, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTypedefDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTypedefDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTypedefDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,8 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - TypedefDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -339,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTypedefDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +404,28 @@ public void write(JsonWriter out, CreateTypedefDataType value) throws IOExceptio public CreateTypedefDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTypedefDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateUnionDataType.java b/src/main/java/ai/reveng/model/CreateUnionDataType.java index 7f235ee6..929698b8 100644 --- a/src/main/java/ai/reveng/model/CreateUnionDataType.java +++ b/src/main/java/ai/reveng/model/CreateUnionDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateUnionDataType instance itself + */ + public CreateUnionDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, createUnionDataType.kind) && Objects.equals(this.name, createUnionDataType.name) && Objects.equals(this.namespace, createUnionDataType.namespace) && - Objects.equals(this.size, createUnionDataType.size); + Objects.equals(this.size, createUnionDataType.size)&& + Objects.equals(this.additionalProperties, createUnionDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(definition, kind, name, namespace, size); + return Objects.hash(definition, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateUnionDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateUnionDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateUnionDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,8 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - UnionDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -339,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateUnionDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +404,28 @@ public void write(JsonWriter out, CreateUnionDataType value) throws IOException public CreateUnionDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateUnionDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateUnknownDataType.java b/src/main/java/ai/reveng/model/CreateUnknownDataType.java index ad827f60..8720b97b 100644 --- a/src/main/java/ai/reveng/model/CreateUnknownDataType.java +++ b/src/main/java/ai/reveng/model/CreateUnknownDataType.java @@ -200,6 +200,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateUnknownDataType instance itself + */ + public CreateUnknownDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -214,12 +258,13 @@ public boolean equals(Object o) { return Objects.equals(this.kind, createUnknownDataType.kind) && Objects.equals(this.name, createUnknownDataType.name) && Objects.equals(this.namespace, createUnknownDataType.namespace) && - Objects.equals(this.size, createUnknownDataType.size); + Objects.equals(this.size, createUnknownDataType.size)&& + Objects.equals(this.additionalProperties, createUnknownDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(kind, name, namespace, size); + return Objects.hash(kind, name, namespace, size, additionalProperties); } @Override @@ -230,6 +275,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -267,14 +313,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateUnknownDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateUnknownDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateUnknownDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateUnknownDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, CreateUnknownDataType value) throws IOExceptio public CreateUnknownDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateUnknownDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CryptoCall.java b/src/main/java/ai/reveng/model/CryptoCall.java new file mode 100644 index 00000000..2f24d216 --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoCall.java @@ -0,0 +1,599 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoCall + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoCall { + public static final String SERIALIZED_NAME_CALLEE_NAME = "callee_name"; + @SerializedName(SERIALIZED_NAME_CALLEE_NAME) + @javax.annotation.Nonnull + private String calleeName; + + /** + * Crypto category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + SYMMETRIC("symmetric"), + + ASYMMETRIC("asymmetric"), + + HASHING("hashing"), + + MAC("mac"), + + KDF("kdf"), + + RNG("rng"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + LIBRARY_API("library-api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + /** + * Crypto library the match belongs to + */ + @JsonAdapter(LibraryEnum.Adapter.class) + public enum LibraryEnum { + OPENSSL("openssl"), + + MBEDTLS("mbedtls"), + + WOLFSSL("wolfssl"), + + LIBSODIUM("libsodium"), + + LIBGCRYPT("libgcrypt"), + + WINDOWS_CRYPTO_API("windows_crypto_api"), + + CRYPTOPP("cryptopp"), + + CPP_CRYPTO("cpp-crypto"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + LibraryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LibraryEnum fromValue(String value) { + for (LibraryEnum b : LibraryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LibraryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LibraryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LibraryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + LibraryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_LIBRARY = "library"; + @SerializedName(SERIALIZED_NAME_LIBRARY) + @javax.annotation.Nonnull + private LibraryEnum library; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + public CryptoCall() { + } + + public CryptoCall calleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + return this; + } + + /** + * Name of the called function + * @return calleeName + */ + @javax.annotation.Nonnull + public String getCalleeName() { + return calleeName; + } + + public void setCalleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + } + + + public CryptoCall category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Crypto category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public CryptoCall how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public CryptoCall library(@javax.annotation.Nonnull LibraryEnum library) { + this.library = library; + return this; + } + + /** + * Crypto library the match belongs to + * @return library + */ + @javax.annotation.Nonnull + public LibraryEnum getLibrary() { + return library; + } + + public void setLibrary(@javax.annotation.Nonnull LibraryEnum library) { + this.library = library; + } + + + public CryptoCall matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoCall instance itself + */ + public CryptoCall putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoCall cryptoCall = (CryptoCall) o; + return Objects.equals(this.calleeName, cryptoCall.calleeName) && + Objects.equals(this.category, cryptoCall.category) && + Objects.equals(this.how, cryptoCall.how) && + Objects.equals(this.library, cryptoCall.library) && + Objects.equals(this.matchedName, cryptoCall.matchedName)&& + Objects.equals(this.additionalProperties, cryptoCall.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(calleeName, category, how, library, matchedName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoCall {\n"); + sb.append(" calleeName: ").append(toIndentedString(calleeName)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" library: ").append(toIndentedString(library)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("callee_name", "category", "how", "library", "matched_name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("callee_name", "category", "how", "library", "matched_name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoCall + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoCall.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoCall is not found in the empty JSON string", CryptoCall.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoCall.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("callee_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); + } + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("library").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `library` to be a primitive type in the JSON string but got `%s`", jsonObj.get("library").toString())); + } + // validate the required field `library` + LibraryEnum.validateJsonElement(jsonObj.get("library")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoCall.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoCall' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoCall.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoCall value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoCall read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoCall instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoCall given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoCall + * @throws IOException if the JSON string is invalid with respect to CryptoCall + */ + public static CryptoCall fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoCall.class); + } + + /** + * Convert an instance of CryptoCall to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CryptoDirectMatch.java b/src/main/java/ai/reveng/model/CryptoDirectMatch.java new file mode 100644 index 00000000..0ef0e2d1 --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoDirectMatch.java @@ -0,0 +1,570 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoDirectMatch + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoDirectMatch { + /** + * Crypto category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + SYMMETRIC("symmetric"), + + ASYMMETRIC("asymmetric"), + + HASHING("hashing"), + + MAC("mac"), + + KDF("kdf"), + + RNG("rng"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + LIBRARY_API("library-api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + /** + * Crypto library the match belongs to + */ + @JsonAdapter(LibraryEnum.Adapter.class) + public enum LibraryEnum { + OPENSSL("openssl"), + + MBEDTLS("mbedtls"), + + WOLFSSL("wolfssl"), + + LIBSODIUM("libsodium"), + + LIBGCRYPT("libgcrypt"), + + WINDOWS_CRYPTO_API("windows_crypto_api"), + + CRYPTOPP("cryptopp"), + + CPP_CRYPTO("cpp-crypto"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + LibraryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LibraryEnum fromValue(String value) { + for (LibraryEnum b : LibraryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LibraryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LibraryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LibraryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + LibraryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_LIBRARY = "library"; + @SerializedName(SERIALIZED_NAME_LIBRARY) + @javax.annotation.Nonnull + private LibraryEnum library; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + public CryptoDirectMatch() { + } + + public CryptoDirectMatch category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Crypto category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public CryptoDirectMatch how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public CryptoDirectMatch library(@javax.annotation.Nonnull LibraryEnum library) { + this.library = library; + return this; + } + + /** + * Crypto library the match belongs to + * @return library + */ + @javax.annotation.Nonnull + public LibraryEnum getLibrary() { + return library; + } + + public void setLibrary(@javax.annotation.Nonnull LibraryEnum library) { + this.library = library; + } + + + public CryptoDirectMatch matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoDirectMatch instance itself + */ + public CryptoDirectMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoDirectMatch cryptoDirectMatch = (CryptoDirectMatch) o; + return Objects.equals(this.category, cryptoDirectMatch.category) && + Objects.equals(this.how, cryptoDirectMatch.how) && + Objects.equals(this.library, cryptoDirectMatch.library) && + Objects.equals(this.matchedName, cryptoDirectMatch.matchedName)&& + Objects.equals(this.additionalProperties, cryptoDirectMatch.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, how, library, matchedName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoDirectMatch {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" library: ").append(toIndentedString(library)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("category", "how", "library", "matched_name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("category", "how", "library", "matched_name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoDirectMatch + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoDirectMatch.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoDirectMatch is not found in the empty JSON string", CryptoDirectMatch.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoDirectMatch.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("library").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `library` to be a primitive type in the JSON string but got `%s`", jsonObj.get("library").toString())); + } + // validate the required field `library` + LibraryEnum.validateJsonElement(jsonObj.get("library")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoDirectMatch.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoDirectMatch' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoDirectMatch.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoDirectMatch value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoDirectMatch read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoDirectMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoDirectMatch given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoDirectMatch + * @throws IOException if the JSON string is invalid with respect to CryptoDirectMatch + */ + public static CryptoDirectMatch fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoDirectMatch.class); + } + + /** + * Convert an instance of CryptoDirectMatch to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CryptoExplainMetadata.java b/src/main/java/ai/reveng/model/CryptoExplainMetadata.java new file mode 100644 index 00000000..56fec2cc --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoExplainMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoExplainMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoExplainMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public CryptoExplainMetadata() { + } + + public CryptoExplainMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public CryptoExplainMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public CryptoExplainMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoExplainMetadata instance itself + */ + public CryptoExplainMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoExplainMetadata cryptoExplainMetadata = (CryptoExplainMetadata) o; + return Objects.equals(this.logHistory, cryptoExplainMetadata.logHistory) && + Objects.equals(this.status, cryptoExplainMetadata.status)&& + Objects.equals(this.additionalProperties, cryptoExplainMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoExplainMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoExplainMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoExplainMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoExplainMetadata is not found in the empty JSON string", CryptoExplainMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoExplainMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoExplainMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoExplainMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoExplainMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoExplainMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoExplainMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoExplainMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoExplainMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoExplainMetadata + * @throws IOException if the JSON string is invalid with respect to CryptoExplainMetadata + */ + public static CryptoExplainMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoExplainMetadata.class); + } + + /** + * Convert an instance of CryptoExplainMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CryptoExplainResult.java b/src/main/java/ai/reveng/model/CryptoExplainResult.java new file mode 100644 index 00000000..e7812c86 --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoExplainResult.java @@ -0,0 +1,452 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CryptoExplainedFunction; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoExplainResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoExplainResult { + public static final String SERIALIZED_NAME_CANCELLED = "cancelled"; + @SerializedName(SERIALIZED_NAME_CANCELLED) + @javax.annotation.Nonnull + private Boolean cancelled; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private String error; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nullable + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTIONS_INVOLVED = "functions_involved"; + @SerializedName(SERIALIZED_NAME_FUNCTIONS_INVOLVED) + @javax.annotation.Nullable + private List functionsInvolved; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nullable + private String summary; + + public CryptoExplainResult() { + } + + public CryptoExplainResult cancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + return this; + } + + /** + * Whether the run was cancelled + * @return cancelled + */ + @javax.annotation.Nonnull + public Boolean getCancelled() { + return cancelled; + } + + public void setCancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + } + + + public CryptoExplainResult error(@javax.annotation.Nullable String error) { + this.error = error; + return this; + } + + /** + * Why no explanation could be produced. Empty when the run succeeded. + * @return error + */ + @javax.annotation.Nullable + public String getError() { + return error; + } + + public void setError(@javax.annotation.Nullable String error) { + this.error = error; + } + + + public CryptoExplainResult functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the explained function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public CryptoExplainResult functionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the explained function + * @return functionName + */ + @javax.annotation.Nullable + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + } + + + public CryptoExplainResult functionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + return this; + } + + public CryptoExplainResult addFunctionsInvolvedItem(CryptoExplainedFunction functionsInvolvedItem) { + if (this.functionsInvolved == null) { + this.functionsInvolved = new ArrayList<>(); + } + this.functionsInvolved.add(functionsInvolvedItem); + return this; + } + + /** + * Other functions involved in the cryptographic operation + * @return functionsInvolved + */ + @javax.annotation.Nullable + public List getFunctionsInvolved() { + return functionsInvolved; + } + + public void setFunctionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + } + + + public CryptoExplainResult summary(@javax.annotation.Nullable String summary) { + this.summary = summary; + return this; + } + + /** + * Explanation of the cryptography the function performs + * @return summary + */ + @javax.annotation.Nullable + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nullable String summary) { + this.summary = summary; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoExplainResult instance itself + */ + public CryptoExplainResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoExplainResult cryptoExplainResult = (CryptoExplainResult) o; + return Objects.equals(this.cancelled, cryptoExplainResult.cancelled) && + Objects.equals(this.error, cryptoExplainResult.error) && + Objects.equals(this.functionId, cryptoExplainResult.functionId) && + Objects.equals(this.functionName, cryptoExplainResult.functionName) && + Objects.equals(this.functionsInvolved, cryptoExplainResult.functionsInvolved) && + Objects.equals(this.summary, cryptoExplainResult.summary)&& + Objects.equals(this.additionalProperties, cryptoExplainResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(cancelled, error, functionId, functionName, functionsInvolved, summary, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoExplainResult {\n"); + sb.append(" cancelled: ").append(toIndentedString(cancelled)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionsInvolved: ").append(toIndentedString(functionsInvolved)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("cancelled", "error", "function_id", "function_name", "functions_involved", "summary")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("cancelled", "function_id")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoExplainResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoExplainResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoExplainResult is not found in the empty JSON string", CryptoExplainResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoExplainResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) && !jsonObj.get("error").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + } + if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("functions_involved") != null && !jsonObj.get("functions_involved").isJsonNull() && !jsonObj.get("functions_involved").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions_involved` to be an array in the JSON string but got `%s`", jsonObj.get("functions_involved").toString())); + } + if ((jsonObj.get("summary") != null && !jsonObj.get("summary").isJsonNull()) && !jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoExplainResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoExplainResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoExplainResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoExplainResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoExplainResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoExplainResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoExplainResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoExplainResult + * @throws IOException if the JSON string is invalid with respect to CryptoExplainResult + */ + public static CryptoExplainResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoExplainResult.class); + } + + /** + * Convert an instance of CryptoExplainResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CryptoExplainedFunction.java b/src/main/java/ai/reveng/model/CryptoExplainedFunction.java new file mode 100644 index 00000000..4b31c92c --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoExplainedFunction.java @@ -0,0 +1,344 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoExplainedFunction + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoExplainedFunction { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public CryptoExplainedFunction() { + } + + public CryptoExplainedFunction description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * Role this function plays in the cryptographic operation + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public CryptoExplainedFunction functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public CryptoExplainedFunction functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoExplainedFunction instance itself + */ + public CryptoExplainedFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoExplainedFunction cryptoExplainedFunction = (CryptoExplainedFunction) o; + return Objects.equals(this.description, cryptoExplainedFunction.description) && + Objects.equals(this.functionId, cryptoExplainedFunction.functionId) && + Objects.equals(this.functionName, cryptoExplainedFunction.functionName)&& + Objects.equals(this.additionalProperties, cryptoExplainedFunction.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(description, functionId, functionName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoExplainedFunction {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoExplainedFunction + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoExplainedFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoExplainedFunction is not found in the empty JSON string", CryptoExplainedFunction.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoExplainedFunction.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoExplainedFunction.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoExplainedFunction' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoExplainedFunction.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoExplainedFunction value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoExplainedFunction read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoExplainedFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoExplainedFunction given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoExplainedFunction + * @throws IOException if the JSON string is invalid with respect to CryptoExplainedFunction + */ + public static CryptoExplainedFunction fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoExplainedFunction.class); + } + + /** + * Convert an instance of CryptoExplainedFunction to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CryptoFinding.java b/src/main/java/ai/reveng/model/CryptoFinding.java new file mode 100644 index 00000000..01e818f7 --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoFinding.java @@ -0,0 +1,785 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CryptoCall; +import ai.reveng.model.CryptoDirectMatch; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoFinding + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoFinding { + public static final String SERIALIZED_NAME_ADDRESS = "address"; + @SerializedName(SERIALIZED_NAME_ADDRESS) + @javax.annotation.Nonnull + private String address; + + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + SYMMETRIC("symmetric"), + + ASYMMETRIC("asymmetric"), + + HASHING("hashing"), + + MAC("mac"), + + KDF("kdf"), + + RNG("rng"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + /** + * High when a direct name match was found, medium when the function only calls into crypto APIs + */ + @JsonAdapter(ConfidenceEnum.Adapter.class) + public enum ConfidenceEnum { + HIGH("high"), + + MEDIUM("medium"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ConfidenceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ConfidenceEnum fromValue(String value) { + for (ConfidenceEnum b : ConfidenceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ConfidenceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ConfidenceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ConfidenceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ConfidenceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CONFIDENCE = "confidence"; + @SerializedName(SERIALIZED_NAME_CONFIDENCE) + @javax.annotation.Nonnull + private ConfidenceEnum confidence; + + public static final String SERIALIZED_NAME_CRYPTO_CALLS = "crypto_calls"; + @SerializedName(SERIALIZED_NAME_CRYPTO_CALLS) + @javax.annotation.Nullable + private List cryptoCalls; + + public static final String SERIALIZED_NAME_DIRECT_MATCHES = "direct_matches"; + @SerializedName(SERIALIZED_NAME_DIRECT_MATCHES) + @javax.annotation.Nullable + private List directMatches; + + public static final String SERIALIZED_NAME_EVIDENCE_COUNT = "evidence_count"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_COUNT) + @javax.annotation.Nonnull + private Long evidenceCount; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTION_SIZE = "function_size"; + @SerializedName(SERIALIZED_NAME_FUNCTION_SIZE) + @javax.annotation.Nonnull + private Long functionSize; + + /** + * Gets or Sets libraries + */ + @JsonAdapter(LibrariesEnum.Adapter.class) + public enum LibrariesEnum { + OPENSSL("openssl"), + + MBEDTLS("mbedtls"), + + WOLFSSL("wolfssl"), + + LIBSODIUM("libsodium"), + + LIBGCRYPT("libgcrypt"), + + WINDOWS_CRYPTO_API("windows_crypto_api"), + + CRYPTOPP("cryptopp"), + + CPP_CRYPTO("cpp-crypto"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + LibrariesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LibrariesEnum fromValue(String value) { + for (LibrariesEnum b : LibrariesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LibrariesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LibrariesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LibrariesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + LibrariesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_LIBRARIES = "libraries"; + @SerializedName(SERIALIZED_NAME_LIBRARIES) + @javax.annotation.Nullable + private List libraries; + + public CryptoFinding() { + } + + public CryptoFinding address(@javax.annotation.Nonnull String address) { + this.address = address; + return this; + } + + /** + * Function's virtual address, hex-encoded + * @return address + */ + @javax.annotation.Nonnull + public String getAddress() { + return address; + } + + public void setAddress(@javax.annotation.Nonnull String address) { + this.address = address; + } + + + public CryptoFinding categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public CryptoFinding addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Distinct crypto categories evidenced by this function + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public CryptoFinding confidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + return this; + } + + /** + * High when a direct name match was found, medium when the function only calls into crypto APIs + * @return confidence + */ + @javax.annotation.Nonnull + public ConfidenceEnum getConfidence() { + return confidence; + } + + public void setConfidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + } + + + public CryptoFinding cryptoCalls(@javax.annotation.Nullable List cryptoCalls) { + this.cryptoCalls = cryptoCalls; + return this; + } + + public CryptoFinding addCryptoCallsItem(CryptoCall cryptoCallsItem) { + if (this.cryptoCalls == null) { + this.cryptoCalls = new ArrayList<>(); + } + this.cryptoCalls.add(cryptoCallsItem); + return this; + } + + /** + * Matches against names this function calls + * @return cryptoCalls + */ + @javax.annotation.Nullable + public List getCryptoCalls() { + return cryptoCalls; + } + + public void setCryptoCalls(@javax.annotation.Nullable List cryptoCalls) { + this.cryptoCalls = cryptoCalls; + } + + + public CryptoFinding directMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + return this; + } + + public CryptoFinding addDirectMatchesItem(CryptoDirectMatch directMatchesItem) { + if (this.directMatches == null) { + this.directMatches = new ArrayList<>(); + } + this.directMatches.add(directMatchesItem); + return this; + } + + /** + * Matches against the function's own name + * @return directMatches + */ + @javax.annotation.Nullable + public List getDirectMatches() { + return directMatches; + } + + public void setDirectMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + } + + + public CryptoFinding evidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + return this; + } + + /** + * Total number of direct matches and crypto calls + * @return evidenceCount + */ + @javax.annotation.Nonnull + public Long getEvidenceCount() { + return evidenceCount; + } + + public void setEvidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + } + + + public CryptoFinding functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function the finding was reported in + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public CryptoFinding functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function the finding was reported in + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + + public CryptoFinding functionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + return this; + } + + /** + * Size of the function in bytes + * @return functionSize + */ + @javax.annotation.Nonnull + public Long getFunctionSize() { + return functionSize; + } + + public void setFunctionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + } + + + public CryptoFinding libraries(@javax.annotation.Nullable List libraries) { + this.libraries = libraries; + return this; + } + + public CryptoFinding addLibrariesItem(LibrariesEnum librariesItem) { + if (this.libraries == null) { + this.libraries = new ArrayList<>(); + } + this.libraries.add(librariesItem); + return this; + } + + /** + * Distinct crypto libraries evidenced by this function + * @return libraries + */ + @javax.annotation.Nullable + public List getLibraries() { + return libraries; + } + + public void setLibraries(@javax.annotation.Nullable List libraries) { + this.libraries = libraries; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoFinding instance itself + */ + public CryptoFinding putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoFinding cryptoFinding = (CryptoFinding) o; + return Objects.equals(this.address, cryptoFinding.address) && + Objects.equals(this.categories, cryptoFinding.categories) && + Objects.equals(this.confidence, cryptoFinding.confidence) && + Objects.equals(this.cryptoCalls, cryptoFinding.cryptoCalls) && + Objects.equals(this.directMatches, cryptoFinding.directMatches) && + Objects.equals(this.evidenceCount, cryptoFinding.evidenceCount) && + Objects.equals(this.functionId, cryptoFinding.functionId) && + Objects.equals(this.functionName, cryptoFinding.functionName) && + Objects.equals(this.functionSize, cryptoFinding.functionSize) && + Objects.equals(this.libraries, cryptoFinding.libraries)&& + Objects.equals(this.additionalProperties, cryptoFinding.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(address, categories, confidence, cryptoCalls, directMatches, evidenceCount, functionId, functionName, functionSize, libraries, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoFinding {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" cryptoCalls: ").append(toIndentedString(cryptoCalls)).append("\n"); + sb.append(" directMatches: ").append(toIndentedString(directMatches)).append("\n"); + sb.append(" evidenceCount: ").append(toIndentedString(evidenceCount)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionSize: ").append(toIndentedString(functionSize)).append("\n"); + sb.append(" libraries: ").append(toIndentedString(libraries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("address", "categories", "confidence", "crypto_calls", "direct_matches", "evidence_count", "function_id", "function_name", "function_size", "libraries")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("address", "categories", "confidence", "evidence_count", "function_id", "function_name", "function_size", "libraries")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoFinding + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoFinding.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoFinding is not found in the empty JSON string", CryptoFinding.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoFinding.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("address").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); + } + // ensure the required json array is present + if (jsonObj.get("categories") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("categories").isJsonArray() && !jsonObj.get("categories").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + if (!jsonObj.get("confidence").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidence` to be a primitive type in the JSON string but got `%s`", jsonObj.get("confidence").toString())); + } + // validate the required field `confidence` + ConfidenceEnum.validateJsonElement(jsonObj.get("confidence")); + // ensure the optional json data is an array if present + if (jsonObj.get("crypto_calls") != null && !jsonObj.get("crypto_calls").isJsonNull() && !jsonObj.get("crypto_calls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `crypto_calls` to be an array in the JSON string but got `%s`", jsonObj.get("crypto_calls").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("direct_matches") != null && !jsonObj.get("direct_matches").isJsonNull() && !jsonObj.get("direct_matches").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `direct_matches` to be an array in the JSON string but got `%s`", jsonObj.get("direct_matches").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the required json array is present + if (jsonObj.get("libraries") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("libraries").isJsonArray() && !jsonObj.get("libraries").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `libraries` to be an array in the JSON string but got `%s`", jsonObj.get("libraries").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoFinding.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoFinding' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoFinding.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoFinding value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoFinding read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoFinding instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoFinding given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoFinding + * @throws IOException if the JSON string is invalid with respect to CryptoFinding + */ + public static CryptoFinding fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoFinding.class); + } + + /** + * Convert an instance of CryptoFinding to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CryptoScanMetadata.java b/src/main/java/ai/reveng/model/CryptoScanMetadata.java new file mode 100644 index 00000000..1fb5c8ee --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoScanMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoScanMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoScanMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public CryptoScanMetadata() { + } + + public CryptoScanMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public CryptoScanMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public CryptoScanMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoScanMetadata instance itself + */ + public CryptoScanMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoScanMetadata cryptoScanMetadata = (CryptoScanMetadata) o; + return Objects.equals(this.logHistory, cryptoScanMetadata.logHistory) && + Objects.equals(this.status, cryptoScanMetadata.status)&& + Objects.equals(this.additionalProperties, cryptoScanMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoScanMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoScanMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoScanMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoScanMetadata is not found in the empty JSON string", CryptoScanMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoScanMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoScanMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoScanMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoScanMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoScanMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoScanMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoScanMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoScanMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoScanMetadata + * @throws IOException if the JSON string is invalid with respect to CryptoScanMetadata + */ + public static CryptoScanMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoScanMetadata.class); + } + + /** + * Convert an instance of CryptoScanMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/CryptoScanResult.java b/src/main/java/ai/reveng/model/CryptoScanResult.java new file mode 100644 index 00000000..4c17d9d6 --- /dev/null +++ b/src/main/java/ai/reveng/model/CryptoScanResult.java @@ -0,0 +1,365 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CryptoFinding; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * CryptoScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CryptoScanResult { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_FINDINGS = "findings"; + @SerializedName(SERIALIZED_NAME_FINDINGS) + @javax.annotation.Nullable + private List findings; + + public static final String SERIALIZED_NAME_TOTAL_FUNCTIONS = "total_functions"; + @SerializedName(SERIALIZED_NAME_TOTAL_FUNCTIONS) + @javax.annotation.Nonnull + private Long totalFunctions; + + public CryptoScanResult() { + } + + public CryptoScanResult analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Analysis the run was performed against + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public CryptoScanResult findings(@javax.annotation.Nullable List findings) { + this.findings = findings; + return this; + } + + public CryptoScanResult addFindingsItem(CryptoFinding findingsItem) { + if (this.findings == null) { + this.findings = new ArrayList<>(); + } + this.findings.add(findingsItem); + return this; + } + + /** + * Functions with crypto-related evidence, sorted by confidence then evidence count + * @return findings + */ + @javax.annotation.Nullable + public List getFindings() { + return findings; + } + + public void setFindings(@javax.annotation.Nullable List findings) { + this.findings = findings; + } + + + public CryptoScanResult totalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + return this; + } + + /** + * Functions the run considered + * @return totalFunctions + */ + @javax.annotation.Nonnull + public Long getTotalFunctions() { + return totalFunctions; + } + + public void setTotalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CryptoScanResult instance itself + */ + public CryptoScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CryptoScanResult cryptoScanResult = (CryptoScanResult) o; + return Objects.equals(this.analysisId, cryptoScanResult.analysisId) && + Objects.equals(this.findings, cryptoScanResult.findings) && + Objects.equals(this.totalFunctions, cryptoScanResult.totalFunctions)&& + Objects.equals(this.additionalProperties, cryptoScanResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, findings, totalFunctions, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoScanResult {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" findings: ").append(toIndentedString(findings)).append("\n"); + sb.append(" totalFunctions: ").append(toIndentedString(totalFunctions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "findings", "total_functions")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "total_functions")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CryptoScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CryptoScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CryptoScanResult is not found in the empty JSON string", CryptoScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CryptoScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("findings") != null && !jsonObj.get("findings").isJsonNull() && !jsonObj.get("findings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `findings` to be an array in the JSON string but got `%s`", jsonObj.get("findings").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CryptoScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CryptoScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CryptoScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CryptoScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CryptoScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CryptoScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CryptoScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of CryptoScanResult + * @throws IOException if the JSON string is invalid with respect to CryptoScanResult + */ + public static CryptoScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CryptoScanResult.class); + } + + /** + * Convert an instance of CryptoScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/DataTypeEnumValueEntry.java b/src/main/java/ai/reveng/model/DataTypeEnumValueEntry.java index fee12498..ae4351ea 100644 --- a/src/main/java/ai/reveng/model/DataTypeEnumValueEntry.java +++ b/src/main/java/ai/reveng/model/DataTypeEnumValueEntry.java @@ -99,6 +99,50 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DataTypeEnumValueEntry instance itself + */ + public DataTypeEnumValueEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } DataTypeEnumValueEntry dataTypeEnumValueEntry = (DataTypeEnumValueEntry) o; return Objects.equals(this.name, dataTypeEnumValueEntry.name) && - Objects.equals(this.value, dataTypeEnumValueEntry.value); + Objects.equals(this.value, dataTypeEnumValueEntry.value)&& + Objects.equals(this.additionalProperties, dataTypeEnumValueEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, value); + return Objects.hash(name, value, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class DataTypeEnumValueEntry {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DataTypeEnumValueEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DataTypeEnumValueEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DataTypeEnumValueEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,6 +238,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DataTypeEnumValueEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -207,7 +267,28 @@ public void write(JsonWriter out, DataTypeEnumValueEntry value) throws IOExcepti public DataTypeEnumValueEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DataTypeEnumValueEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DataTypeFunctionEntry.java b/src/main/java/ai/reveng/model/DataTypeFunctionEntry.java index 8501b6dd..ecaaf121 100644 --- a/src/main/java/ai/reveng/model/DataTypeFunctionEntry.java +++ b/src/main/java/ai/reveng/model/DataTypeFunctionEntry.java @@ -99,6 +99,50 @@ public void setFunctionName(@javax.annotation.Nonnull String functionName) { this.functionName = functionName; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DataTypeFunctionEntry instance itself + */ + public DataTypeFunctionEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } DataTypeFunctionEntry dataTypeFunctionEntry = (DataTypeFunctionEntry) o; return Objects.equals(this.functionId, dataTypeFunctionEntry.functionId) && - Objects.equals(this.functionName, dataTypeFunctionEntry.functionName); + Objects.equals(this.functionName, dataTypeFunctionEntry.functionName)&& + Objects.equals(this.additionalProperties, dataTypeFunctionEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionName); + return Objects.hash(functionId, functionName, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class DataTypeFunctionEntry {\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DataTypeFunctionEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DataTypeFunctionEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DataTypeFunctionEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -197,6 +235,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DataTypeFunctionEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -204,7 +264,28 @@ public void write(JsonWriter out, DataTypeFunctionEntry value) throws IOExceptio public DataTypeFunctionEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DataTypeFunctionEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DataTypeFunctionParameterEntry.java b/src/main/java/ai/reveng/model/DataTypeFunctionParameterEntry.java index 4258dad5..278dad8a 100644 --- a/src/main/java/ai/reveng/model/DataTypeFunctionParameterEntry.java +++ b/src/main/java/ai/reveng/model/DataTypeFunctionParameterEntry.java @@ -147,6 +147,50 @@ public void setSize(@javax.annotation.Nonnull Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DataTypeFunctionParameterEntry instance itself + */ + public DataTypeFunctionParameterEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.dataTypeId, dataTypeFunctionParameterEntry.dataTypeId) && Objects.equals(this.name, dataTypeFunctionParameterEntry.name) && Objects.equals(this.ordinal, dataTypeFunctionParameterEntry.ordinal) && - Objects.equals(this.size, dataTypeFunctionParameterEntry.size); + Objects.equals(this.size, dataTypeFunctionParameterEntry.size)&& + Objects.equals(this.additionalProperties, dataTypeFunctionParameterEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, name, ordinal, size); + return Objects.hash(dataTypeId, name, ordinal, size, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" ordinal: ").append(toIndentedString(ordinal)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DataTypeFunctionParameterEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DataTypeFunctionParameterEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DataTypeFunctionParameterEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -249,6 +287,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DataTypeFunctionParameterEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -256,7 +316,28 @@ public void write(JsonWriter out, DataTypeFunctionParameterEntry value) throws I public DataTypeFunctionParameterEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DataTypeFunctionParameterEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DataTypeVersion.java b/src/main/java/ai/reveng/model/DataTypeVersion.java index 5c7b66f8..6dc5a222 100644 --- a/src/main/java/ai/reveng/model/DataTypeVersion.java +++ b/src/main/java/ai/reveng/model/DataTypeVersion.java @@ -126,6 +126,50 @@ public void setValue(@javax.annotation.Nonnull DataTypeEntry value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DataTypeVersion instance itself + */ + public DataTypeVersion putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -139,12 +183,13 @@ public boolean equals(Object o) { DataTypeVersion dataTypeVersion = (DataTypeVersion) o; return Objects.equals(this.updatedAt, dataTypeVersion.updatedAt) && Objects.equals(this.updatedBy, dataTypeVersion.updatedBy) && - Objects.equals(this.value, dataTypeVersion.value); + Objects.equals(this.value, dataTypeVersion.value)&& + Objects.equals(this.additionalProperties, dataTypeVersion.additionalProperties); } @Override public int hashCode() { - return Objects.hash(updatedAt, updatedBy, value); + return Objects.hash(updatedAt, updatedBy, value, additionalProperties); } @Override @@ -154,6 +199,7 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" updatedBy: ").append(toIndentedString(updatedBy)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -191,14 +237,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DataTypeVersion.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DataTypeVersion` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DataTypeVersion.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -206,10 +244,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `updated_by` - if (jsonObj.get("updated_by") != null && !jsonObj.get("updated_by").isJsonNull()) { - HistoryActor.validateJsonElement(jsonObj.get("updated_by")); - } // validate the required field `value` DataTypeEntry.validateJsonElement(jsonObj.get("value")); } @@ -229,6 +263,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DataTypeVersion value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -236,7 +292,28 @@ public void write(JsonWriter out, DataTypeVersion value) throws IOException { public DataTypeVersion read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DataTypeVersion instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DecompFailedEvent.java b/src/main/java/ai/reveng/model/DecompFailedEvent.java index 0f64b250..814d5825 100644 --- a/src/main/java/ai/reveng/model/DecompFailedEvent.java +++ b/src/main/java/ai/reveng/model/DecompFailedEvent.java @@ -171,6 +171,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DecompFailedEvent instance itself + */ + public DecompFailedEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -186,12 +230,13 @@ public boolean equals(Object o) { Objects.equals(this.error, decompFailedEvent.error) && Objects.equals(this.errorCode, decompFailedEvent.errorCode) && Objects.equals(this.seq, decompFailedEvent.seq) && - Objects.equals(this.type, decompFailedEvent.type); + Objects.equals(this.type, decompFailedEvent.type)&& + Objects.equals(this.additionalProperties, decompFailedEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(attempt, error, errorCode, seq, type); + return Objects.hash(attempt, error, errorCode, seq, type, additionalProperties); } @Override @@ -203,6 +248,7 @@ public String toString() { sb.append(" errorCode: ").append(toIndentedString(errorCode)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -240,14 +286,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DecompFailedEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompFailedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompFailedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -281,6 +319,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompFailedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -288,7 +348,28 @@ public void write(JsonWriter out, DecompFailedEvent value) throws IOException { public DecompFailedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DecompFailedEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DecompFinishedEvent.java b/src/main/java/ai/reveng/model/DecompFinishedEvent.java index 358767a1..16112eb6 100644 --- a/src/main/java/ai/reveng/model/DecompFinishedEvent.java +++ b/src/main/java/ai/reveng/model/DecompFinishedEvent.java @@ -123,6 +123,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DecompFinishedEvent instance itself + */ + public DecompFinishedEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -136,12 +180,13 @@ public boolean equals(Object o) { DecompFinishedEvent decompFinishedEvent = (DecompFinishedEvent) o; return Objects.equals(this.attempt, decompFinishedEvent.attempt) && Objects.equals(this.seq, decompFinishedEvent.seq) && - Objects.equals(this.type, decompFinishedEvent.type); + Objects.equals(this.type, decompFinishedEvent.type)&& + Objects.equals(this.additionalProperties, decompFinishedEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(attempt, seq, type); + return Objects.hash(attempt, seq, type, additionalProperties); } @Override @@ -151,6 +196,7 @@ public String toString() { sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -188,14 +234,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DecompFinishedEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompFinishedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompFinishedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -223,6 +261,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompFinishedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -230,7 +290,28 @@ public void write(JsonWriter out, DecompFinishedEvent value) throws IOException public DecompFinishedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DecompFinishedEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DecompilationData.java b/src/main/java/ai/reveng/model/DecompilationData.java index affe0e56..a93aabe0 100644 --- a/src/main/java/ai/reveng/model/DecompilationData.java +++ b/src/main/java/ai/reveng/model/DecompilationData.java @@ -159,6 +159,50 @@ public void setStatus(@javax.annotation.Nonnull StatusEnum status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DecompilationData instance itself + */ + public DecompilationData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -171,12 +215,13 @@ public boolean equals(Object o) { } DecompilationData decompilationData = (DecompilationData) o; return Objects.equals(this.decompilation, decompilationData.decompilation) && - Objects.equals(this.status, decompilationData.status); + Objects.equals(this.status, decompilationData.status)&& + Objects.equals(this.additionalProperties, decompilationData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(decompilation, status); + return Objects.hash(decompilation, status, additionalProperties); } @Override @@ -185,6 +230,7 @@ public String toString() { sb.append("class DecompilationData {\n"); sb.append(" decompilation: ").append(toIndentedString(decompilation)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -222,14 +268,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DecompilationData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompilationData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompilationData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -262,6 +300,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompilationData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -269,7 +329,28 @@ public void write(JsonWriter out, DecompilationData value) throws IOException { public DecompilationData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DecompilationData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DecompilerSummary.java b/src/main/java/ai/reveng/model/DecompilerSummary.java new file mode 100644 index 00000000..5156640e --- /dev/null +++ b/src/main/java/ai/reveng/model/DecompilerSummary.java @@ -0,0 +1,361 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CallChain; +import ai.reveng.model.Subject; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * DecompilerSummary + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DecompilerSummary { + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + @javax.annotation.Nonnull + private Subject subject; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nonnull + private String summary; + + public static final String SERIALIZED_NAME_REACHABILITY = "reachability"; + @SerializedName(SERIALIZED_NAME_REACHABILITY) + @javax.annotation.Nullable + private CallChain reachability; + + public DecompilerSummary() { + } + + public DecompilerSummary subject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + return this; + } + + /** + * Get subject + * @return subject + */ + @javax.annotation.Nonnull + public Subject getSubject() { + return subject; + } + + public void setSubject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + } + + + public DecompilerSummary summary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + return this; + } + + /** + * Get summary + * @return summary + */ + @javax.annotation.Nonnull + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + } + + + public DecompilerSummary reachability(@javax.annotation.Nullable CallChain reachability) { + this.reachability = reachability; + return this; + } + + /** + * Get reachability + * @return reachability + */ + @javax.annotation.Nullable + public CallChain getReachability() { + return reachability; + } + + public void setReachability(@javax.annotation.Nullable CallChain reachability) { + this.reachability = reachability; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DecompilerSummary instance itself + */ + public DecompilerSummary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DecompilerSummary decompilerSummary = (DecompilerSummary) o; + return Objects.equals(this.subject, decompilerSummary.subject) && + Objects.equals(this.summary, decompilerSummary.summary) && + Objects.equals(this.reachability, decompilerSummary.reachability)&& + Objects.equals(this.additionalProperties, decompilerSummary.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(subject, summary, reachability, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DecompilerSummary {\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" reachability: ").append(toIndentedString(reachability)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("subject", "summary", "reachability")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("subject", "summary")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to DecompilerSummary + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!DecompilerSummary.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DecompilerSummary is not found in the empty JSON string", DecompilerSummary.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DecompilerSummary.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `subject` + Subject.validateJsonElement(jsonObj.get("subject")); + if (!jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + // validate the optional field `reachability` + if (jsonObj.get("reachability") != null && !jsonObj.get("reachability").isJsonNull()) { + CallChain.validateJsonElement(jsonObj.get("reachability")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DecompilerSummary.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DecompilerSummary' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DecompilerSummary.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DecompilerSummary value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public DecompilerSummary read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DecompilerSummary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DecompilerSummary given an JSON string + * + * @param jsonString JSON string + * @return An instance of DecompilerSummary + * @throws IOException if the JSON string is invalid with respect to DecompilerSummary + */ + public static DecompilerSummary fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DecompilerSummary.class); + } + + /** + * Convert an instance of DecompilerSummary to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/DecompilerSummaryEvidence.java b/src/main/java/ai/reveng/model/DecompilerSummaryEvidence.java new file mode 100644 index 00000000..2bc55f42 --- /dev/null +++ b/src/main/java/ai/reveng/model/DecompilerSummaryEvidence.java @@ -0,0 +1,591 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.DecompilerSummary; +import ai.reveng.model.EvidenceEffect; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Semantic summaries derived from decompiler output. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DecompilerSummaryEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + DECOMPILER_SUMMARY("decompiler_summary"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.DECOMPILER_SUMMARY; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + MODEL_INTERPRETATION("model_interpretation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.MODEL_INTERPRETATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + INDIRECT("indirect"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.INDIRECT; + + public static final String SERIALIZED_NAME_SUMMARIES = "summaries"; + @SerializedName(SERIALIZED_NAME_SUMMARIES) + @javax.annotation.Nonnull + private List summaries = new ArrayList<>(); + + public DecompilerSummaryEvidence() { + } + + public DecompilerSummaryEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public DecompilerSummaryEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public DecompilerSummaryEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public DecompilerSummaryEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public DecompilerSummaryEvidence summaries(@javax.annotation.Nonnull List summaries) { + this.summaries = summaries; + return this; + } + + public DecompilerSummaryEvidence addSummariesItem(DecompilerSummary summariesItem) { + if (this.summaries == null) { + this.summaries = new ArrayList<>(); + } + this.summaries.add(summariesItem); + return this; + } + + /** + * Get summaries + * @return summaries + */ + @javax.annotation.Nonnull + public List getSummaries() { + return summaries; + } + + public void setSummaries(@javax.annotation.Nonnull List summaries) { + this.summaries = summaries; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DecompilerSummaryEvidence instance itself + */ + public DecompilerSummaryEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DecompilerSummaryEvidence decompilerSummaryEvidence = (DecompilerSummaryEvidence) o; + return Objects.equals(this.evidenceKind, decompilerSummaryEvidence.evidenceKind) && + Objects.equals(this.kind, decompilerSummaryEvidence.kind) && + Objects.equals(this.effect, decompilerSummaryEvidence.effect) && + Objects.equals(this.strength, decompilerSummaryEvidence.strength) && + Objects.equals(this.summaries, decompilerSummaryEvidence.summaries)&& + Objects.equals(this.additionalProperties, decompilerSummaryEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, summaries, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DecompilerSummaryEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" summaries: ").append(toIndentedString(summaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "summaries")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "summaries")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to DecompilerSummaryEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!DecompilerSummaryEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DecompilerSummaryEvidence is not found in the empty JSON string", DecompilerSummaryEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DecompilerSummaryEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + if (jsonObj.get("summaries") != null) { + if (!jsonObj.get("summaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summaries` to be an array in the JSON string but got `%s`", jsonObj.get("summaries").toString())); + } + JsonArray jsonArraysummaries = jsonObj.getAsJsonArray("summaries"); + // validate the required field `summaries` (array) + for (int i = 0; i < jsonArraysummaries.size(); i++) { + DecompilerSummary.validateJsonElement(jsonArraysummaries.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DecompilerSummaryEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DecompilerSummaryEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DecompilerSummaryEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DecompilerSummaryEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public DecompilerSummaryEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DecompilerSummaryEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DecompilerSummaryEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of DecompilerSummaryEvidence + * @throws IOException if the JSON string is invalid with respect to DecompilerSummaryEvidence + */ + public static DecompilerSummaryEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DecompilerSummaryEvidence.class); + } + + /** + * Convert an instance of DecompilerSummaryEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/DieMatch.java b/src/main/java/ai/reveng/model/DieMatch.java index 66777bc3..340f731e 100644 --- a/src/main/java/ai/reveng/model/DieMatch.java +++ b/src/main/java/ai/reveng/model/DieMatch.java @@ -49,6 +49,11 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DieMatch { + public static final String SERIALIZED_NAME_DISPLAY = "display"; + @SerializedName(SERIALIZED_NAME_DISPLAY) + @javax.annotation.Nonnull + private String display; + public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) @javax.annotation.Nonnull @@ -59,11 +64,6 @@ public class DieMatch { @javax.annotation.Nonnull private String type; - public static final String SERIALIZED_NAME_DISPLAY = "display"; - @SerializedName(SERIALIZED_NAME_DISPLAY) - @javax.annotation.Nonnull - private String display; - public static final String SERIALIZED_NAME_VERSION = "version"; @SerializedName(SERIALIZED_NAME_VERSION) @javax.annotation.Nonnull @@ -72,13 +72,32 @@ public class DieMatch { public DieMatch() { } + public DieMatch display(@javax.annotation.Nonnull String display) { + this.display = display; + return this; + } + + /** + * Human-readable description from DIE; suitable for display, not parsing + * @return display + */ + @javax.annotation.Nonnull + public String getDisplay() { + return display; + } + + public void setDisplay(@javax.annotation.Nonnull String display) { + this.display = display; + } + + public DieMatch name(@javax.annotation.Nonnull String name) { this.name = name; return this; } /** - * Canonical name of the matched signature/technology (e.g., 'UPX', 'GCC', 'MSVC'). + * Canonical name of the matched signature or technology * @return name */ @javax.annotation.Nonnull @@ -97,7 +116,7 @@ public DieMatch type(@javax.annotation.Nonnull String type) { } /** - * Category assigned by DIE for the match (e.g., 'compiler', 'packer', 'file'). + * Category DIE assigns the match, such as compiler, packer or file * @return type */ @javax.annotation.Nonnull @@ -110,32 +129,13 @@ public void setType(@javax.annotation.Nonnull String type) { } - public DieMatch display(@javax.annotation.Nonnull String display) { - this.display = display; - return this; - } - - /** - * Human-readable description from DIE's 'string' field; suitable for UI/logs, not for parsing. - * @return display - */ - @javax.annotation.Nonnull - public String getDisplay() { - return display; - } - - public void setDisplay(@javax.annotation.Nonnull String display) { - this.display = display; - } - - public DieMatch version(@javax.annotation.Nonnull String version) { this.version = version; return this; } /** - * Extracted version string when available; may be empty/None if unknown. + * Version DIE extracted, empty when it could not determine one * @return version */ @javax.annotation.Nonnull @@ -202,25 +202,25 @@ public boolean equals(Object o) { return false; } DieMatch dieMatch = (DieMatch) o; - return Objects.equals(this.name, dieMatch.name) && + return Objects.equals(this.display, dieMatch.display) && + Objects.equals(this.name, dieMatch.name) && Objects.equals(this.type, dieMatch.type) && - Objects.equals(this.display, dieMatch.display) && Objects.equals(this.version, dieMatch.version)&& Objects.equals(this.additionalProperties, dieMatch.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, type, display, version, additionalProperties); + return Objects.hash(display, name, type, version, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DieMatch {\n"); + sb.append(" display: ").append(toIndentedString(display)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" display: ").append(toIndentedString(display)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); @@ -241,10 +241,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("name", "type", "display", "version")); + openapiFields = new HashSet(Arrays.asList("display", "name", "type", "version")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("name", "type", "display", "version")); + openapiRequiredFields = new HashSet(Arrays.asList("display", "name", "type", "version")); } /** @@ -267,15 +267,15 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("display").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `display` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display").toString())); + } if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } - if (!jsonObj.get("display").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `display` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display").toString())); - } if (!jsonObj.get("version").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); } diff --git a/src/main/java/ai/reveng/model/Display.java b/src/main/java/ai/reveng/model/Display.java new file mode 100644 index 00000000..4c375951 --- /dev/null +++ b/src/main/java/ai/reveng/model/Display.java @@ -0,0 +1,93 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets Display + */ +@JsonAdapter(Display.Adapter.class) +public enum Display { + + HEX("hex"), + + UINT8("uint8"), + + UINT16("uint16"), + + UINT32("uint32"), + + UINT64("uint64"), + + INT8("int8"), + + INT16("int16"), + + INT32("int32"), + + INT64("int64"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + Display(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static Display fromValue(String value) { + for (Display b : Display.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final Display enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public Display read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return Display.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + Display.fromValue(value); + } +} + diff --git a/src/main/java/ai/reveng/model/DnsQuery.java b/src/main/java/ai/reveng/model/DnsQuery.java index 3d541630..c40e4cdd 100644 --- a/src/main/java/ai/reveng/model/DnsQuery.java +++ b/src/main/java/ai/reveng/model/DnsQuery.java @@ -199,6 +199,50 @@ public void setResolvedIps(@javax.annotation.Nullable List resolvedIps) this.resolvedIps = resolvedIps; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DnsQuery instance itself + */ + public DnsQuery putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -214,7 +258,8 @@ public boolean equals(Object o) { Objects.equals(this.domain, dnsQuery.domain) && Objects.equals(this.events, dnsQuery.events) && Objects.equals(this.minTtl, dnsQuery.minTtl) && - Objects.equals(this.resolvedIps, dnsQuery.resolvedIps); + Objects.equals(this.resolvedIps, dnsQuery.resolvedIps)&& + Objects.equals(this.additionalProperties, dnsQuery.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -223,7 +268,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(cnameChain, domain, events, minTtl, resolvedIps); + return Objects.hash(cnameChain, domain, events, minTtl, resolvedIps, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -242,6 +287,7 @@ public String toString() { sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" minTtl: ").append(toIndentedString(minTtl)).append("\n"); sb.append(" resolvedIps: ").append(toIndentedString(resolvedIps)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -279,14 +325,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DnsQuery.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DnsQuery` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DnsQuery.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -301,19 +339,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("domain").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `domain` to be a primitive type in the JSON string but got `%s`", jsonObj.get("domain").toString())); } - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("resolved_ips") != null && !jsonObj.get("resolved_ips").isJsonNull() && !jsonObj.get("resolved_ips").isJsonArray()) { @@ -336,6 +364,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DnsQuery value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -343,7 +393,28 @@ public void write(JsonWriter out, DnsQuery value) throws IOException { public DnsQuery read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DnsQuery instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DrakvufFileMetadata.java b/src/main/java/ai/reveng/model/DrakvufFileMetadata.java index 47a85067..65be9f10 100644 --- a/src/main/java/ai/reveng/model/DrakvufFileMetadata.java +++ b/src/main/java/ai/reveng/model/DrakvufFileMetadata.java @@ -171,6 +171,50 @@ public void setTypeId(@javax.annotation.Nullable String typeId) { this.typeId = typeId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DrakvufFileMetadata instance itself + */ + public DrakvufFileMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -186,12 +230,13 @@ public boolean equals(Object o) { Objects.equals(this.name, drakvufFileMetadata.name) && Objects.equals(this.sha256, drakvufFileMetadata.sha256) && Objects.equals(this.type, drakvufFileMetadata.type) && - Objects.equals(this.typeId, drakvufFileMetadata.typeId); + Objects.equals(this.typeId, drakvufFileMetadata.typeId)&& + Objects.equals(this.additionalProperties, drakvufFileMetadata.additionalProperties); } @Override public int hashCode() { - return Objects.hash(mimeType, name, sha256, type, typeId); + return Objects.hash(mimeType, name, sha256, type, typeId, additionalProperties); } @Override @@ -203,6 +248,7 @@ public String toString() { sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" typeId: ").append(toIndentedString(typeId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -240,14 +286,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DrakvufFileMetadata.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DrakvufFileMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DrakvufFileMetadata.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -287,6 +325,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DrakvufFileMetadata value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -294,7 +354,28 @@ public void write(JsonWriter out, DrakvufFileMetadata value) throws IOException public DrakvufFileMetadata read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DrakvufFileMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java b/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java index aeaa0ed7..7e926851 100644 --- a/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java +++ b/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java @@ -184,6 +184,50 @@ public void setStatus(@javax.annotation.Nonnull StatusEnum status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DynamicExecutionStatusResponse instance itself + */ + public DynamicExecutionStatusResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -197,12 +241,13 @@ public boolean equals(Object o) { DynamicExecutionStatusResponse dynamicExecutionStatusResponse = (DynamicExecutionStatusResponse) o; return Objects.equals(this.errorMessage, dynamicExecutionStatusResponse.errorMessage) && Objects.equals(this.logs, dynamicExecutionStatusResponse.logs) && - Objects.equals(this.status, dynamicExecutionStatusResponse.status); + Objects.equals(this.status, dynamicExecutionStatusResponse.status)&& + Objects.equals(this.additionalProperties, dynamicExecutionStatusResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(errorMessage, logs, status); + return Objects.hash(errorMessage, logs, status, additionalProperties); } @Override @@ -212,6 +257,7 @@ public String toString() { sb.append(" errorMessage: ").append(toIndentedString(errorMessage)).append("\n"); sb.append(" logs: ").append(toIndentedString(logs)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -249,14 +295,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DynamicExecutionStatusResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DynamicExecutionStatusResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DynamicExecutionStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -267,8 +305,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("error_message") != null && !jsonObj.get("error_message").isJsonNull()) && !jsonObj.get("error_message").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); } - // validate the required field `logs` - AnalysisLogs.validateJsonElement(jsonObj.get("logs")); if (!jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } @@ -291,6 +327,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DynamicExecutionStatusResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -298,7 +356,28 @@ public void write(JsonWriter out, DynamicExecutionStatusResponse value) throws I public DynamicExecutionStatusResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DynamicExecutionStatusResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Endianness.java b/src/main/java/ai/reveng/model/Endianness.java new file mode 100644 index 00000000..4d2c72f8 --- /dev/null +++ b/src/main/java/ai/reveng/model/Endianness.java @@ -0,0 +1,81 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets Endianness + */ +@JsonAdapter(Endianness.Adapter.class) +public enum Endianness { + + UNSPECIFIED("unspecified"), + + LITTLE("little"), + + BIG("big"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + Endianness(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static Endianness fromValue(String value) { + for (Endianness b : Endianness.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final Endianness enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public Endianness read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return Endianness.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + Endianness.fromValue(value); + } +} + diff --git a/src/main/java/ai/reveng/model/EnumDataType.java b/src/main/java/ai/reveng/model/EnumDataType.java index 4e75cd59..5fc180c6 100644 --- a/src/main/java/ai/reveng/model/EnumDataType.java +++ b/src/main/java/ai/reveng/model/EnumDataType.java @@ -143,6 +143,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -366,6 +371,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public EnumDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public EnumDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -403,6 +427,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EnumDataType instance itself + */ + public EnumDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -422,13 +490,15 @@ public boolean equals(Object o) { Objects.equals(this.name, enumDataType.name) && Objects.equals(this.namespace, enumDataType.namespace) && Objects.equals(this.size, enumDataType.size) && + Objects.equals(this.sourceAnalysisId, enumDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, enumDataType.sourceFunctionId) && - Objects.equals(this.sourceType, enumDataType.sourceType); + Objects.equals(this.sourceType, enumDataType.sourceType)&& + Objects.equals(this.additionalProperties, enumDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -443,8 +513,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -463,7 +535,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -482,14 +554,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EnumDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `EnumDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EnumDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -497,10 +561,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `definition` - if (jsonObj.get("definition") != null && !jsonObj.get("definition").isJsonNull()) { - EnumDefinition.validateJsonElement(jsonObj.get("definition")); - } if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -534,6 +594,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, EnumDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -541,7 +623,28 @@ public void write(JsonWriter out, EnumDataType value) throws IOException { public EnumDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EnumDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/EnumDefinition.java b/src/main/java/ai/reveng/model/EnumDefinition.java index 77a81a12..be848e58 100644 --- a/src/main/java/ai/reveng/model/EnumDefinition.java +++ b/src/main/java/ai/reveng/model/EnumDefinition.java @@ -86,6 +86,50 @@ public void setValues(@javax.annotation.Nullable List va this.values = values; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EnumDefinition instance itself + */ + public EnumDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } EnumDefinition enumDefinition = (EnumDefinition) o; - return Objects.equals(this.values, enumDefinition.values); + return Objects.equals(this.values, enumDefinition.values)&& + Objects.equals(this.additionalProperties, enumDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(values); + return Objects.hash(values, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class EnumDefinition {\n"); sb.append(" values: ").append(toIndentedString(values)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EnumDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `EnumDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EnumDefinition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("values") != null && !jsonObj.get("values").isJsonNull()) { - if (!jsonObj.get("values").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `values` to be an array in the JSON string but got `%s`", jsonObj.get("values").toString())); - } - JsonArray jsonArrayvalues = jsonObj.getAsJsonArray("values"); - // validate the required field `values` (array) - for (int i = 0; i < jsonArrayvalues.size(); i++) { - DataTypeEnumValueEntry.validateJsonElement(jsonArrayvalues.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("values") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("values").isJsonArray() && !jsonObj.get("values").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `values` to be an array in the JSON string but got `%s`", jsonObj.get("values").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, EnumDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, EnumDefinition value) throws IOException { public EnumDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EnumDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ErrorBody.java b/src/main/java/ai/reveng/model/ErrorBody.java index d8d11468..16cc5999 100644 --- a/src/main/java/ai/reveng/model/ErrorBody.java +++ b/src/main/java/ai/reveng/model/ErrorBody.java @@ -56,22 +56,6 @@ public class ErrorBody { public enum CodeEnum { ACCESS_DENIED("ACCESS_DENIED"), - AGENT_BUDGET_EXCEEDED("AGENT_BUDGET_EXCEEDED"), - - AGENT_DEFINITION_NOT_FOUND("AGENT_DEFINITION_NOT_FOUND"), - - AGENT_INVALID_STARTING_INPUT("AGENT_INVALID_STARTING_INPUT"), - - AGENT_MEMORY_INVALID_SCOPE("AGENT_MEMORY_INVALID_SCOPE"), - - AGENT_MEMORY_NOT_FOUND("AGENT_MEMORY_NOT_FOUND"), - - AGENT_MEMORY_VERSION_CONFLICT("AGENT_MEMORY_VERSION_CONFLICT"), - - AGENT_NO_PENDING_QUESTION("AGENT_NO_PENDING_QUESTION"), - - AGENT_RUN_NOT_FOUND("AGENT_RUN_NOT_FOUND"), - ALREADY_EXISTS("ALREADY_EXISTS"), ANALYSIS_NOT_READY("ANALYSIS_NOT_READY"), @@ -128,6 +112,8 @@ public enum CodeEnum { NOT_FOUND("NOT_FOUND"), + NOT_IMPLEMENTED("NOT_IMPLEMENTED"), + NO_ACTIVE_RUN("NO_ACTIVE_RUN"), NO_PENDING_CONFIRMATION("NO_PENDING_CONFIRMATION"), @@ -331,6 +317,50 @@ public void setTraceId(@javax.annotation.Nonnull String traceId) { this.traceId = traceId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ErrorBody instance itself + */ + public ErrorBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -346,12 +376,13 @@ public boolean equals(Object o) { Objects.equals(this.detail, errorBody.detail) && Objects.equals(this.docUrl, errorBody.docUrl) && Objects.equals(this.message, errorBody.message) && - Objects.equals(this.traceId, errorBody.traceId); + Objects.equals(this.traceId, errorBody.traceId)&& + Objects.equals(this.additionalProperties, errorBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(code, detail, docUrl, message, traceId); + return Objects.hash(code, detail, docUrl, message, traceId, additionalProperties); } @Override @@ -363,6 +394,7 @@ public String toString() { sb.append(" docUrl: ").append(toIndentedString(docUrl)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -400,14 +432,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ErrorBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ErrorBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ErrorBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -449,6 +473,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ErrorBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -456,7 +502,28 @@ public void write(JsonWriter out, ErrorBody value) throws IOException { public ErrorBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ErrorBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Event.java b/src/main/java/ai/reveng/model/Event.java index b0deed47..60673828 100644 --- a/src/main/java/ai/reveng/model/Event.java +++ b/src/main/java/ai/reveng/model/Event.java @@ -220,6 +220,50 @@ public void setType(@javax.annotation.Nonnull Integer type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Event instance itself + */ + public Event putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -237,12 +281,13 @@ public boolean equals(Object o) { Objects.equals(this.eventId, event.eventId) && Objects.equals(this.role, event.role) && Objects.equals(this.tokensUsed, event.tokensUsed) && - Objects.equals(this.type, event.type); + Objects.equals(this.type, event.type)&& + Objects.equals(this.additionalProperties, event.additionalProperties); } @Override public int hashCode() { - return Objects.hash(conversationUuid, createdAt, data, eventId, role, tokensUsed, type); + return Objects.hash(conversationUuid, createdAt, data, eventId, role, tokensUsed, type, additionalProperties); } @Override @@ -256,6 +301,7 @@ public String toString() { sb.append(" role: ").append(toIndentedString(role)).append("\n"); sb.append(" tokensUsed: ").append(toIndentedString(tokensUsed)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -293,14 +339,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Event.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Event` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Event.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -328,6 +366,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Event value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -335,7 +395,28 @@ public void write(JsonWriter out, Event value) throws IOException { public Event read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Event instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/EventAttemptFailed.java b/src/main/java/ai/reveng/model/EventAttemptFailed.java index 196155d7..25d03ed3 100644 --- a/src/main/java/ai/reveng/model/EventAttemptFailed.java +++ b/src/main/java/ai/reveng/model/EventAttemptFailed.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - AttemptFailedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventAttemptStarted.java b/src/main/java/ai/reveng/model/EventAttemptStarted.java index f6a7e614..016aab34 100644 --- a/src/main/java/ai/reveng/model/EventAttemptStarted.java +++ b/src/main/java/ai/reveng/model/EventAttemptStarted.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - AttemptStartedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java b/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java index 3c034a33..7eb528bb 100644 --- a/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java +++ b/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventContextCompactedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventDecompFailed.java b/src/main/java/ai/reveng/model/EventDecompFailed.java index 8117857f..76246f8b 100644 --- a/src/main/java/ai/reveng/model/EventDecompFailed.java +++ b/src/main/java/ai/reveng/model/EventDecompFailed.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - DecompFailedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventDecompFinished.java b/src/main/java/ai/reveng/model/EventDecompFinished.java index a5ea568e..c2992b68 100644 --- a/src/main/java/ai/reveng/model/EventDecompFinished.java +++ b/src/main/java/ai/reveng/model/EventDecompFinished.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - DecompFinishedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventNamesFinished.java b/src/main/java/ai/reveng/model/EventNamesFinished.java new file mode 100644 index 00000000..0a4ad615 --- /dev/null +++ b/src/main/java/ai/reveng/model/EventNamesFinished.java @@ -0,0 +1,422 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.NamesFinishedEvent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * EventNamesFinished + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class EventNamesFinished { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private NamesFinishedEvent data; + + /** + * The event name. + */ + @JsonAdapter(EventEnum.Adapter.class) + public enum EventEnum { + NAMES_FINISHED("names_finished"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EventEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EventEnum fromValue(String value) { + for (EventEnum b : EventEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EventEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EventEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EventEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EventEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVENT = "event"; + @SerializedName(SERIALIZED_NAME_EVENT) + @javax.annotation.Nonnull + private EventEnum event; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nullable + private Integer id; + + public static final String SERIALIZED_NAME_RETRY = "retry"; + @SerializedName(SERIALIZED_NAME_RETRY) + @javax.annotation.Nullable + private Integer retry; + + public EventNamesFinished() { + } + + public EventNamesFinished data(@javax.annotation.Nonnull NamesFinishedEvent data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nonnull + public NamesFinishedEvent getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull NamesFinishedEvent data) { + this.data = data; + } + + + public EventNamesFinished event(@javax.annotation.Nonnull EventEnum event) { + this.event = event; + return this; + } + + /** + * The event name. + * @return event + */ + @javax.annotation.Nonnull + public EventEnum getEvent() { + return event; + } + + public void setEvent(@javax.annotation.Nonnull EventEnum event) { + this.event = event; + } + + + public EventNamesFinished id(@javax.annotation.Nullable Integer id) { + this.id = id; + return this; + } + + /** + * The event ID. + * @return id + */ + @javax.annotation.Nullable + public Integer getId() { + return id; + } + + public void setId(@javax.annotation.Nullable Integer id) { + this.id = id; + } + + + public EventNamesFinished retry(@javax.annotation.Nullable Integer retry) { + this.retry = retry; + return this; + } + + /** + * The retry time in milliseconds. + * @return retry + */ + @javax.annotation.Nullable + public Integer getRetry() { + return retry; + } + + public void setRetry(@javax.annotation.Nullable Integer retry) { + this.retry = retry; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EventNamesFinished instance itself + */ + public EventNamesFinished putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventNamesFinished eventNamesFinished = (EventNamesFinished) o; + return Objects.equals(this.data, eventNamesFinished.data) && + Objects.equals(this.event, eventNamesFinished.event) && + Objects.equals(this.id, eventNamesFinished.id) && + Objects.equals(this.retry, eventNamesFinished.retry)&& + Objects.equals(this.additionalProperties, eventNamesFinished.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, event, id, retry, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventNamesFinished {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" event: ").append(toIndentedString(event)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" retry: ").append(toIndentedString(retry)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("data", "event", "id", "retry")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data", "event")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EventNamesFinished + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EventNamesFinished.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventNamesFinished is not found in the empty JSON string", EventNamesFinished.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EventNamesFinished.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("event").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + } + // validate the required field `event` + EventEnum.validateJsonElement(jsonObj.get("event")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EventNamesFinished.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EventNamesFinished' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EventNamesFinished.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EventNamesFinished value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public EventNamesFinished read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EventNamesFinished instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EventNamesFinished given an JSON string + * + * @param jsonString JSON string + * @return An instance of EventNamesFinished + * @throws IOException if the JSON string is invalid with respect to EventNamesFinished + */ + public static EventNamesFinished fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EventNamesFinished.class); + } + + /** + * Convert an instance of EventNamesFinished to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/EventProse.java b/src/main/java/ai/reveng/model/EventProse.java index e03e01f7..4167ed87 100644 --- a/src/main/java/ai/reveng/model/EventProse.java +++ b/src/main/java/ai/reveng/model/EventProse.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - ProseEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventRUNCANCELLED.java b/src/main/java/ai/reveng/model/EventRUNCANCELLED.java index 2993907c..f4a6fd20 100644 --- a/src/main/java/ai/reveng/model/EventRUNCANCELLED.java +++ b/src/main/java/ai/reveng/model/EventRUNCANCELLED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventRunCancelledData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventRUNERROR.java b/src/main/java/ai/reveng/model/EventRUNERROR.java index b3521a8c..6a7aaa33 100644 --- a/src/main/java/ai/reveng/model/EventRUNERROR.java +++ b/src/main/java/ai/reveng/model/EventRUNERROR.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventRunErrorData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventRUNFINISHED.java b/src/main/java/ai/reveng/model/EventRUNFINISHED.java index ea2f36a4..3f9392f5 100644 --- a/src/main/java/ai/reveng/model/EventRUNFINISHED.java +++ b/src/main/java/ai/reveng/model/EventRUNFINISHED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventRunFinishedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventRUNSTARTED.java b/src/main/java/ai/reveng/model/EventRUNSTARTED.java index 95611ee3..1148857b 100644 --- a/src/main/java/ai/reveng/model/EventRUNSTARTED.java +++ b/src/main/java/ai/reveng/model/EventRUNSTARTED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventRunStartedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventRenameApplied.java b/src/main/java/ai/reveng/model/EventRenameApplied.java index 7cc8b82f..32f2b056 100644 --- a/src/main/java/ai/reveng/model/EventRenameApplied.java +++ b/src/main/java/ai/reveng/model/EventRenameApplied.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - RenameAppliedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventSTEPFINISHED.java b/src/main/java/ai/reveng/model/EventSTEPFINISHED.java index 9ff46464..a21f1179 100644 --- a/src/main/java/ai/reveng/model/EventSTEPFINISHED.java +++ b/src/main/java/ai/reveng/model/EventSTEPFINISHED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventStepFinishedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventSTEPSTARTED.java b/src/main/java/ai/reveng/model/EventSTEPSTARTED.java index 7d7302fd..f0a9458c 100644 --- a/src/main/java/ai/reveng/model/EventSTEPSTARTED.java +++ b/src/main/java/ai/reveng/model/EventSTEPSTARTED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventStepStartedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventSourceDelta.java b/src/main/java/ai/reveng/model/EventSourceDelta.java index eab33def..e960ce65 100644 --- a/src/main/java/ai/reveng/model/EventSourceDelta.java +++ b/src/main/java/ai/reveng/model/EventSourceDelta.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SourceDeltaEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventSourceReset.java b/src/main/java/ai/reveng/model/EventSourceReset.java index 76fb69ae..1fb5d5a4 100644 --- a/src/main/java/ai/reveng/model/EventSourceReset.java +++ b/src/main/java/ai/reveng/model/EventSourceReset.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SourceResetEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java b/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java index f804e8b4..b6b9c92c 100644 --- a/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java +++ b/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventTextMessageContentData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java b/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java index 85c89ffb..11dbfaf7 100644 --- a/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java +++ b/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventTextMessageEndData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java b/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java index 9fa7812e..075955bd 100644 --- a/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java +++ b/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventTextMessageStartData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTITLEUPDATED.java b/src/main/java/ai/reveng/model/EventTITLEUPDATED.java index daeb3fb8..24bf4738 100644 --- a/src/main/java/ai/reveng/model/EventTITLEUPDATED.java +++ b/src/main/java/ai/reveng/model/EventTITLEUPDATED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventTitleUpdatedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java b/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java index 266310cb..1cd69c08 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventToolCallArgsDeltaData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLEND.java b/src/main/java/ai/reveng/model/EventTOOLCALLEND.java index 2d2a42f1..77c83400 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLEND.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLEND.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventToolCallEndData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLPROGRESS.java b/src/main/java/ai/reveng/model/EventTOOLCALLPROGRESS.java index ae51b576..45ea3766 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLPROGRESS.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLPROGRESS.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventToolCallProgressData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java b/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java index 69edf358..fb5cfda3 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventToolCallResultData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java b/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java index 04605332..e04e2427 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventToolCallStartData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java b/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java index 1f6328f0..7b15d0a3 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java +++ b/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - SseEventToolConfirmationRequiredData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EventTypesSuggested.java b/src/main/java/ai/reveng/model/EventTypesSuggested.java new file mode 100644 index 00000000..11f40754 --- /dev/null +++ b/src/main/java/ai/reveng/model/EventTypesSuggested.java @@ -0,0 +1,422 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.TypesSuggestedEvent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * EventTypesSuggested + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class EventTypesSuggested { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private TypesSuggestedEvent data; + + /** + * The event name. + */ + @JsonAdapter(EventEnum.Adapter.class) + public enum EventEnum { + TYPES_SUGGESTED("types_suggested"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EventEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EventEnum fromValue(String value) { + for (EventEnum b : EventEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EventEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EventEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EventEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EventEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVENT = "event"; + @SerializedName(SERIALIZED_NAME_EVENT) + @javax.annotation.Nonnull + private EventEnum event; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nullable + private Integer id; + + public static final String SERIALIZED_NAME_RETRY = "retry"; + @SerializedName(SERIALIZED_NAME_RETRY) + @javax.annotation.Nullable + private Integer retry; + + public EventTypesSuggested() { + } + + public EventTypesSuggested data(@javax.annotation.Nonnull TypesSuggestedEvent data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nonnull + public TypesSuggestedEvent getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull TypesSuggestedEvent data) { + this.data = data; + } + + + public EventTypesSuggested event(@javax.annotation.Nonnull EventEnum event) { + this.event = event; + return this; + } + + /** + * The event name. + * @return event + */ + @javax.annotation.Nonnull + public EventEnum getEvent() { + return event; + } + + public void setEvent(@javax.annotation.Nonnull EventEnum event) { + this.event = event; + } + + + public EventTypesSuggested id(@javax.annotation.Nullable Integer id) { + this.id = id; + return this; + } + + /** + * The event ID. + * @return id + */ + @javax.annotation.Nullable + public Integer getId() { + return id; + } + + public void setId(@javax.annotation.Nullable Integer id) { + this.id = id; + } + + + public EventTypesSuggested retry(@javax.annotation.Nullable Integer retry) { + this.retry = retry; + return this; + } + + /** + * The retry time in milliseconds. + * @return retry + */ + @javax.annotation.Nullable + public Integer getRetry() { + return retry; + } + + public void setRetry(@javax.annotation.Nullable Integer retry) { + this.retry = retry; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EventTypesSuggested instance itself + */ + public EventTypesSuggested putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventTypesSuggested eventTypesSuggested = (EventTypesSuggested) o; + return Objects.equals(this.data, eventTypesSuggested.data) && + Objects.equals(this.event, eventTypesSuggested.event) && + Objects.equals(this.id, eventTypesSuggested.id) && + Objects.equals(this.retry, eventTypesSuggested.retry)&& + Objects.equals(this.additionalProperties, eventTypesSuggested.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, event, id, retry, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventTypesSuggested {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" event: ").append(toIndentedString(event)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" retry: ").append(toIndentedString(retry)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("data", "event", "id", "retry")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data", "event")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EventTypesSuggested + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EventTypesSuggested.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTypesSuggested is not found in the empty JSON string", EventTypesSuggested.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EventTypesSuggested.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("event").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + } + // validate the required field `event` + EventEnum.validateJsonElement(jsonObj.get("event")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EventTypesSuggested.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EventTypesSuggested' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EventTypesSuggested.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EventTypesSuggested value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public EventTypesSuggested read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EventTypesSuggested instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EventTypesSuggested given an JSON string + * + * @param jsonString JSON string + * @return An instance of EventTypesSuggested + * @throws IOException if the JSON string is invalid with respect to EventTypesSuggested + */ + public static EventTypesSuggested fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EventTypesSuggested.class); + } + + /** + * Convert an instance of EventTypesSuggested to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/EventWarning.java b/src/main/java/ai/reveng/model/EventWarning.java index 9290ca71..e81bb2e6 100644 --- a/src/main/java/ai/reveng/model/EventWarning.java +++ b/src/main/java/ai/reveng/model/EventWarning.java @@ -320,8 +320,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `data` - WarningEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } diff --git a/src/main/java/ai/reveng/model/EvidenceEffect.java b/src/main/java/ai/reveng/model/EvidenceEffect.java new file mode 100644 index 00000000..d13da242 --- /dev/null +++ b/src/main/java/ai/reveng/model/EvidenceEffect.java @@ -0,0 +1,79 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets EvidenceEffect + */ +@JsonAdapter(EvidenceEffect.Adapter.class) +public enum EvidenceEffect { + + SUPPORTS("supports"), + + REFUTES("refutes"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceEffect(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceEffect fromValue(String value) { + for (EvidenceEffect b : EvidenceEffect.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceEffect enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceEffect read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceEffect.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceEffect.fromValue(value); + } +} + diff --git a/src/main/java/ai/reveng/model/EvidenceInner.java b/src/main/java/ai/reveng/model/EvidenceInner.java new file mode 100644 index 00000000..4212f35b --- /dev/null +++ b/src/main/java/ai/reveng/model/EvidenceInner.java @@ -0,0 +1,657 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ApiCombinationEvidence; +import ai.reveng.model.BytesConstant; +import ai.reveng.model.CallChainEvidence; +import ai.reveng.model.DecompilerSummary; +import ai.reveng.model.DecompilerSummaryEvidence; +import ai.reveng.model.EvidenceStrength; +import ai.reveng.model.FunctionSimilarity; +import ai.reveng.model.FunctionSimilarityEvidence; +import ai.reveng.model.HardcodedSecretEvidence; +import ai.reveng.model.ImportedApi; +import ai.reveng.model.ImportedApiCall; +import ai.reveng.model.ImportedApiCallEvidence; +import ai.reveng.model.KnownConstantEvidence; +import ai.reveng.model.ModelInterpretation; +import ai.reveng.model.ModelInterpretationEvidence; +import ai.reveng.model.ReferencedConstant; +import ai.reveng.model.ReferencedConstantEvidence; +import ai.reveng.model.RuleKind; +import ai.reveng.model.SuspiciousString; +import ai.reveng.model.SuspiciousStringEvidence; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; + +import ai.reveng.invoker.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class EvidenceInner extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(EvidenceInner.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EvidenceInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EvidenceInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterCallChainEvidence = gson.getDelegateAdapter(this, TypeToken.get(CallChainEvidence.class)); + final TypeAdapter adapterReferencedConstantEvidence = gson.getDelegateAdapter(this, TypeToken.get(ReferencedConstantEvidence.class)); + final TypeAdapter adapterImportedApiCallEvidence = gson.getDelegateAdapter(this, TypeToken.get(ImportedApiCallEvidence.class)); + final TypeAdapter adapterSuspiciousStringEvidence = gson.getDelegateAdapter(this, TypeToken.get(SuspiciousStringEvidence.class)); + final TypeAdapter adapterFunctionSimilarityEvidence = gson.getDelegateAdapter(this, TypeToken.get(FunctionSimilarityEvidence.class)); + final TypeAdapter adapterApiCombinationEvidence = gson.getDelegateAdapter(this, TypeToken.get(ApiCombinationEvidence.class)); + final TypeAdapter adapterDecompilerSummaryEvidence = gson.getDelegateAdapter(this, TypeToken.get(DecompilerSummaryEvidence.class)); + final TypeAdapter adapterModelInterpretationEvidence = gson.getDelegateAdapter(this, TypeToken.get(ModelInterpretationEvidence.class)); + final TypeAdapter adapterKnownConstantEvidence = gson.getDelegateAdapter(this, TypeToken.get(KnownConstantEvidence.class)); + final TypeAdapter adapterHardcodedSecretEvidence = gson.getDelegateAdapter(this, TypeToken.get(HardcodedSecretEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EvidenceInner value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `CallChainEvidence` + if (value.getActualInstance() instanceof CallChainEvidence) { + JsonElement element = adapterCallChainEvidence.toJsonTree((CallChainEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `ReferencedConstantEvidence` + if (value.getActualInstance() instanceof ReferencedConstantEvidence) { + JsonElement element = adapterReferencedConstantEvidence.toJsonTree((ReferencedConstantEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `ImportedApiCallEvidence` + if (value.getActualInstance() instanceof ImportedApiCallEvidence) { + JsonElement element = adapterImportedApiCallEvidence.toJsonTree((ImportedApiCallEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `SuspiciousStringEvidence` + if (value.getActualInstance() instanceof SuspiciousStringEvidence) { + JsonElement element = adapterSuspiciousStringEvidence.toJsonTree((SuspiciousStringEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `FunctionSimilarityEvidence` + if (value.getActualInstance() instanceof FunctionSimilarityEvidence) { + JsonElement element = adapterFunctionSimilarityEvidence.toJsonTree((FunctionSimilarityEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `ApiCombinationEvidence` + if (value.getActualInstance() instanceof ApiCombinationEvidence) { + JsonElement element = adapterApiCombinationEvidence.toJsonTree((ApiCombinationEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `DecompilerSummaryEvidence` + if (value.getActualInstance() instanceof DecompilerSummaryEvidence) { + JsonElement element = adapterDecompilerSummaryEvidence.toJsonTree((DecompilerSummaryEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `ModelInterpretationEvidence` + if (value.getActualInstance() instanceof ModelInterpretationEvidence) { + JsonElement element = adapterModelInterpretationEvidence.toJsonTree((ModelInterpretationEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `KnownConstantEvidence` + if (value.getActualInstance() instanceof KnownConstantEvidence) { + JsonElement element = adapterKnownConstantEvidence.toJsonTree((KnownConstantEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `HardcodedSecretEvidence` + if (value.getActualInstance() instanceof HardcodedSecretEvidence) { + JsonElement element = adapterHardcodedSecretEvidence.toJsonTree((HardcodedSecretEvidence)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: ApiCombinationEvidence, CallChainEvidence, DecompilerSummaryEvidence, FunctionSimilarityEvidence, HardcodedSecretEvidence, ImportedApiCallEvidence, KnownConstantEvidence, ModelInterpretationEvidence, ReferencedConstantEvidence, SuspiciousStringEvidence"); + } + + @Override + public EvidenceInner read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize CallChainEvidence + try { + // validate the JSON object to see if any exception is thrown + CallChainEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterCallChainEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'CallChainEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for CallChainEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'CallChainEvidence'", e); + } + // deserialize ReferencedConstantEvidence + try { + // validate the JSON object to see if any exception is thrown + ReferencedConstantEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterReferencedConstantEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'ReferencedConstantEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ReferencedConstantEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'ReferencedConstantEvidence'", e); + } + // deserialize ImportedApiCallEvidence + try { + // validate the JSON object to see if any exception is thrown + ImportedApiCallEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterImportedApiCallEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'ImportedApiCallEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ImportedApiCallEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'ImportedApiCallEvidence'", e); + } + // deserialize SuspiciousStringEvidence + try { + // validate the JSON object to see if any exception is thrown + SuspiciousStringEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterSuspiciousStringEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'SuspiciousStringEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SuspiciousStringEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SuspiciousStringEvidence'", e); + } + // deserialize FunctionSimilarityEvidence + try { + // validate the JSON object to see if any exception is thrown + FunctionSimilarityEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterFunctionSimilarityEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'FunctionSimilarityEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for FunctionSimilarityEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'FunctionSimilarityEvidence'", e); + } + // deserialize ApiCombinationEvidence + try { + // validate the JSON object to see if any exception is thrown + ApiCombinationEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterApiCombinationEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'ApiCombinationEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ApiCombinationEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'ApiCombinationEvidence'", e); + } + // deserialize DecompilerSummaryEvidence + try { + // validate the JSON object to see if any exception is thrown + DecompilerSummaryEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterDecompilerSummaryEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'DecompilerSummaryEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for DecompilerSummaryEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'DecompilerSummaryEvidence'", e); + } + // deserialize ModelInterpretationEvidence + try { + // validate the JSON object to see if any exception is thrown + ModelInterpretationEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterModelInterpretationEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'ModelInterpretationEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ModelInterpretationEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'ModelInterpretationEvidence'", e); + } + // deserialize KnownConstantEvidence + try { + // validate the JSON object to see if any exception is thrown + KnownConstantEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterKnownConstantEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'KnownConstantEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for KnownConstantEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'KnownConstantEvidence'", e); + } + // deserialize HardcodedSecretEvidence + try { + // validate the JSON object to see if any exception is thrown + HardcodedSecretEvidence.validateJsonElement(jsonElement); + actualAdapter = adapterHardcodedSecretEvidence; + match++; + log.log(Level.FINER, "Input data matches schema 'HardcodedSecretEvidence'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for HardcodedSecretEvidence failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'HardcodedSecretEvidence'", e); + } + + if (match == 1) { + EvidenceInner ret = new EvidenceInner(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } + + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for EvidenceInner: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap>(); + + public EvidenceInner() { + super("oneOf", Boolean.FALSE); + } + + public EvidenceInner(Object o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("CallChainEvidence", CallChainEvidence.class); + schemas.put("ReferencedConstantEvidence", ReferencedConstantEvidence.class); + schemas.put("ImportedApiCallEvidence", ImportedApiCallEvidence.class); + schemas.put("SuspiciousStringEvidence", SuspiciousStringEvidence.class); + schemas.put("FunctionSimilarityEvidence", FunctionSimilarityEvidence.class); + schemas.put("ApiCombinationEvidence", ApiCombinationEvidence.class); + schemas.put("DecompilerSummaryEvidence", DecompilerSummaryEvidence.class); + schemas.put("ModelInterpretationEvidence", ModelInterpretationEvidence.class); + schemas.put("KnownConstantEvidence", KnownConstantEvidence.class); + schemas.put("HardcodedSecretEvidence", HardcodedSecretEvidence.class); + } + + @Override + public Map> getSchemas() { + return EvidenceInner.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * ApiCombinationEvidence, CallChainEvidence, DecompilerSummaryEvidence, FunctionSimilarityEvidence, HardcodedSecretEvidence, ImportedApiCallEvidence, KnownConstantEvidence, ModelInterpretationEvidence, ReferencedConstantEvidence, SuspiciousStringEvidence + * + * It could be an instance of the 'oneOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof CallChainEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ReferencedConstantEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ImportedApiCallEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SuspiciousStringEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof FunctionSimilarityEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ApiCombinationEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof DecompilerSummaryEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof ModelInterpretationEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof KnownConstantEvidence) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof HardcodedSecretEvidence) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be ApiCombinationEvidence, CallChainEvidence, DecompilerSummaryEvidence, FunctionSimilarityEvidence, HardcodedSecretEvidence, ImportedApiCallEvidence, KnownConstantEvidence, ModelInterpretationEvidence, ReferencedConstantEvidence, SuspiciousStringEvidence"); + } + + /** + * Get the actual instance, which can be the following: + * ApiCombinationEvidence, CallChainEvidence, DecompilerSummaryEvidence, FunctionSimilarityEvidence, HardcodedSecretEvidence, ImportedApiCallEvidence, KnownConstantEvidence, ModelInterpretationEvidence, ReferencedConstantEvidence, SuspiciousStringEvidence + * + * @return The actual instance (ApiCombinationEvidence, CallChainEvidence, DecompilerSummaryEvidence, FunctionSimilarityEvidence, HardcodedSecretEvidence, ImportedApiCallEvidence, KnownConstantEvidence, ModelInterpretationEvidence, ReferencedConstantEvidence, SuspiciousStringEvidence) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CallChainEvidence`. If the actual instance is not `CallChainEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `CallChainEvidence` + * @throws ClassCastException if the instance is not `CallChainEvidence` + */ + @SuppressWarnings("unchecked") + public CallChainEvidence getCallChainEvidence() throws ClassCastException { + return (CallChainEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `ReferencedConstantEvidence`. If the actual instance is not `ReferencedConstantEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ReferencedConstantEvidence` + * @throws ClassCastException if the instance is not `ReferencedConstantEvidence` + */ + @SuppressWarnings("unchecked") + public ReferencedConstantEvidence getReferencedConstantEvidence() throws ClassCastException { + return (ReferencedConstantEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `ImportedApiCallEvidence`. If the actual instance is not `ImportedApiCallEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ImportedApiCallEvidence` + * @throws ClassCastException if the instance is not `ImportedApiCallEvidence` + */ + @SuppressWarnings("unchecked") + public ImportedApiCallEvidence getImportedApiCallEvidence() throws ClassCastException { + return (ImportedApiCallEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `SuspiciousStringEvidence`. If the actual instance is not `SuspiciousStringEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SuspiciousStringEvidence` + * @throws ClassCastException if the instance is not `SuspiciousStringEvidence` + */ + @SuppressWarnings("unchecked") + public SuspiciousStringEvidence getSuspiciousStringEvidence() throws ClassCastException { + return (SuspiciousStringEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `FunctionSimilarityEvidence`. If the actual instance is not `FunctionSimilarityEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `FunctionSimilarityEvidence` + * @throws ClassCastException if the instance is not `FunctionSimilarityEvidence` + */ + @SuppressWarnings("unchecked") + public FunctionSimilarityEvidence getFunctionSimilarityEvidence() throws ClassCastException { + return (FunctionSimilarityEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `ApiCombinationEvidence`. If the actual instance is not `ApiCombinationEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ApiCombinationEvidence` + * @throws ClassCastException if the instance is not `ApiCombinationEvidence` + */ + @SuppressWarnings("unchecked") + public ApiCombinationEvidence getApiCombinationEvidence() throws ClassCastException { + return (ApiCombinationEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `DecompilerSummaryEvidence`. If the actual instance is not `DecompilerSummaryEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `DecompilerSummaryEvidence` + * @throws ClassCastException if the instance is not `DecompilerSummaryEvidence` + */ + @SuppressWarnings("unchecked") + public DecompilerSummaryEvidence getDecompilerSummaryEvidence() throws ClassCastException { + return (DecompilerSummaryEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `ModelInterpretationEvidence`. If the actual instance is not `ModelInterpretationEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `ModelInterpretationEvidence` + * @throws ClassCastException if the instance is not `ModelInterpretationEvidence` + */ + @SuppressWarnings("unchecked") + public ModelInterpretationEvidence getModelInterpretationEvidence() throws ClassCastException { + return (ModelInterpretationEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `KnownConstantEvidence`. If the actual instance is not `KnownConstantEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `KnownConstantEvidence` + * @throws ClassCastException if the instance is not `KnownConstantEvidence` + */ + @SuppressWarnings("unchecked") + public KnownConstantEvidence getKnownConstantEvidence() throws ClassCastException { + return (KnownConstantEvidence)super.getActualInstance(); + } + + /** + * Get the actual instance of `HardcodedSecretEvidence`. If the actual instance is not `HardcodedSecretEvidence`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `HardcodedSecretEvidence` + * @throws ClassCastException if the instance is not `HardcodedSecretEvidence` + */ + @SuppressWarnings("unchecked") + public HardcodedSecretEvidence getHardcodedSecretEvidence() throws ClassCastException { + return (HardcodedSecretEvidence)super.getActualInstance(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EvidenceInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with CallChainEvidence + try { + CallChainEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for CallChainEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with ReferencedConstantEvidence + try { + ReferencedConstantEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ReferencedConstantEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with ImportedApiCallEvidence + try { + ImportedApiCallEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ImportedApiCallEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with SuspiciousStringEvidence + try { + SuspiciousStringEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SuspiciousStringEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with FunctionSimilarityEvidence + try { + FunctionSimilarityEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for FunctionSimilarityEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with ApiCombinationEvidence + try { + ApiCombinationEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ApiCombinationEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with DecompilerSummaryEvidence + try { + DecompilerSummaryEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for DecompilerSummaryEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with ModelInterpretationEvidence + try { + ModelInterpretationEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for ModelInterpretationEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with KnownConstantEvidence + try { + KnownConstantEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for KnownConstantEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with HardcodedSecretEvidence + try { + HardcodedSecretEvidence.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for HardcodedSecretEvidence failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for EvidenceInner with oneOf schemas: ApiCombinationEvidence, CallChainEvidence, DecompilerSummaryEvidence, FunctionSimilarityEvidence, HardcodedSecretEvidence, ImportedApiCallEvidence, KnownConstantEvidence, ModelInterpretationEvidence, ReferencedConstantEvidence, SuspiciousStringEvidence. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); + } + } + + /** + * Create an instance of EvidenceInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of EvidenceInner + * @throws IOException if the JSON string is invalid with respect to EvidenceInner + */ + public static EvidenceInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EvidenceInner.class); + } + + /** + * Convert an instance of EvidenceInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/EvidenceStrength.java b/src/main/java/ai/reveng/model/EvidenceStrength.java new file mode 100644 index 00000000..8110474d --- /dev/null +++ b/src/main/java/ai/reveng/model/EvidenceStrength.java @@ -0,0 +1,79 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets EvidenceStrength + */ +@JsonAdapter(EvidenceStrength.Adapter.class) +public enum EvidenceStrength { + + DIRECT("direct"), + + INDIRECT("indirect"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceStrength(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceStrength fromValue(String value) { + for (EvidenceStrength b : EvidenceStrength.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceStrength enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceStrength read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceStrength.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceStrength.fromValue(value); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionCall.java b/src/main/java/ai/reveng/model/ExecutionCall.java new file mode 100644 index 00000000..d4ff3b42 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionCall.java @@ -0,0 +1,603 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionCall + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionCall { + public static final String SERIALIZED_NAME_CALLEE_NAME = "callee_name"; + @SerializedName(SERIALIZED_NAME_CALLEE_NAME) + @javax.annotation.Nonnull + private String calleeName; + + /** + * Execution category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + DYNAMIC_RESOLVE("dynamic-resolve"), + + HOOKING("hooking"), + + INJECTION("injection"), + + MEMORY_EXEC("memory-exec"), + + MODULE_LOAD("module-load"), + + PROCESS_CONTROL("process-control"), + + PROCESS_CREATE("process-create"), + + SCRIPT_EXEC("script-exec"), + + SHELLCODE("shellcode"), + + THREAD_CREATE("thread-create"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + API("api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + /** + * Execution source the match belongs to + */ + @JsonAdapter(SourceEnum.Adapter.class) + public enum SourceEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + SCRIPT_ENGINE("script-engine"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceEnum fromValue(String value) { + for (SourceEnum b : SourceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nonnull + private SourceEnum source; + + public ExecutionCall() { + } + + public ExecutionCall calleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + return this; + } + + /** + * Name of the called function + * @return calleeName + */ + @javax.annotation.Nonnull + public String getCalleeName() { + return calleeName; + } + + public void setCalleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + } + + + public ExecutionCall category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Execution category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public ExecutionCall how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public ExecutionCall matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + + public ExecutionCall source(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + return this; + } + + /** + * Execution source the match belongs to + * @return source + */ + @javax.annotation.Nonnull + public SourceEnum getSource() { + return source; + } + + public void setSource(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionCall instance itself + */ + public ExecutionCall putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionCall executionCall = (ExecutionCall) o; + return Objects.equals(this.calleeName, executionCall.calleeName) && + Objects.equals(this.category, executionCall.category) && + Objects.equals(this.how, executionCall.how) && + Objects.equals(this.matchedName, executionCall.matchedName) && + Objects.equals(this.source, executionCall.source)&& + Objects.equals(this.additionalProperties, executionCall.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(calleeName, category, how, matchedName, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionCall {\n"); + sb.append(" calleeName: ").append(toIndentedString(calleeName)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("callee_name", "category", "how", "matched_name", "source")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("callee_name", "category", "how", "matched_name", "source")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionCall + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionCall.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionCall is not found in the empty JSON string", ExecutionCall.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionCall.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("callee_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); + } + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + // validate the required field `source` + SourceEnum.validateJsonElement(jsonObj.get("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionCall.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionCall' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionCall.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionCall value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionCall read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionCall instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionCall given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionCall + * @throws IOException if the JSON string is invalid with respect to ExecutionCall + */ + public static ExecutionCall fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionCall.class); + } + + /** + * Convert an instance of ExecutionCall to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionDirectMatch.java b/src/main/java/ai/reveng/model/ExecutionDirectMatch.java new file mode 100644 index 00000000..7d008a17 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionDirectMatch.java @@ -0,0 +1,574 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionDirectMatch + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionDirectMatch { + /** + * Execution category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + DYNAMIC_RESOLVE("dynamic-resolve"), + + HOOKING("hooking"), + + INJECTION("injection"), + + MEMORY_EXEC("memory-exec"), + + MODULE_LOAD("module-load"), + + PROCESS_CONTROL("process-control"), + + PROCESS_CREATE("process-create"), + + SCRIPT_EXEC("script-exec"), + + SHELLCODE("shellcode"), + + THREAD_CREATE("thread-create"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + API("api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + /** + * Execution source the match belongs to + */ + @JsonAdapter(SourceEnum.Adapter.class) + public enum SourceEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + SCRIPT_ENGINE("script-engine"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceEnum fromValue(String value) { + for (SourceEnum b : SourceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nonnull + private SourceEnum source; + + public ExecutionDirectMatch() { + } + + public ExecutionDirectMatch category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Execution category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public ExecutionDirectMatch how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public ExecutionDirectMatch matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + + public ExecutionDirectMatch source(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + return this; + } + + /** + * Execution source the match belongs to + * @return source + */ + @javax.annotation.Nonnull + public SourceEnum getSource() { + return source; + } + + public void setSource(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionDirectMatch instance itself + */ + public ExecutionDirectMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionDirectMatch executionDirectMatch = (ExecutionDirectMatch) o; + return Objects.equals(this.category, executionDirectMatch.category) && + Objects.equals(this.how, executionDirectMatch.how) && + Objects.equals(this.matchedName, executionDirectMatch.matchedName) && + Objects.equals(this.source, executionDirectMatch.source)&& + Objects.equals(this.additionalProperties, executionDirectMatch.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, how, matchedName, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionDirectMatch {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("category", "how", "matched_name", "source")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("category", "how", "matched_name", "source")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionDirectMatch + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionDirectMatch.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionDirectMatch is not found in the empty JSON string", ExecutionDirectMatch.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionDirectMatch.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + // validate the required field `source` + SourceEnum.validateJsonElement(jsonObj.get("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionDirectMatch.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionDirectMatch' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionDirectMatch.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionDirectMatch value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionDirectMatch read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionDirectMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionDirectMatch given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionDirectMatch + * @throws IOException if the JSON string is invalid with respect to ExecutionDirectMatch + */ + public static ExecutionDirectMatch fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionDirectMatch.class); + } + + /** + * Convert an instance of ExecutionDirectMatch to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionExplainMetadata.java b/src/main/java/ai/reveng/model/ExecutionExplainMetadata.java new file mode 100644 index 00000000..be210809 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionExplainMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionExplainMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionExplainMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public ExecutionExplainMetadata() { + } + + public ExecutionExplainMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public ExecutionExplainMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public ExecutionExplainMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionExplainMetadata instance itself + */ + public ExecutionExplainMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionExplainMetadata executionExplainMetadata = (ExecutionExplainMetadata) o; + return Objects.equals(this.logHistory, executionExplainMetadata.logHistory) && + Objects.equals(this.status, executionExplainMetadata.status)&& + Objects.equals(this.additionalProperties, executionExplainMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionExplainMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionExplainMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionExplainMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionExplainMetadata is not found in the empty JSON string", ExecutionExplainMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionExplainMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionExplainMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionExplainMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionExplainMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionExplainMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionExplainMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionExplainMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionExplainMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionExplainMetadata + * @throws IOException if the JSON string is invalid with respect to ExecutionExplainMetadata + */ + public static ExecutionExplainMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionExplainMetadata.class); + } + + /** + * Convert an instance of ExecutionExplainMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionExplainResult.java b/src/main/java/ai/reveng/model/ExecutionExplainResult.java new file mode 100644 index 00000000..02da0b07 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionExplainResult.java @@ -0,0 +1,577 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ExecutionExplainedFunction; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionExplainResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionExplainResult { + public static final String SERIALIZED_NAME_CANCELLED = "cancelled"; + @SerializedName(SERIALIZED_NAME_CANCELLED) + @javax.annotation.Nonnull + private Boolean cancelled; + + public static final String SERIALIZED_NAME_CODE_ORIGIN = "code_origin"; + @SerializedName(SERIALIZED_NAME_CODE_ORIGIN) + @javax.annotation.Nullable + private String codeOrigin; + + public static final String SERIALIZED_NAME_EXECUTED_TARGETS = "executed_targets"; + @SerializedName(SERIALIZED_NAME_EXECUTED_TARGETS) + @javax.annotation.Nullable + private List executedTargets; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nullable + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTIONS_INVOLVED = "functions_involved"; + @SerializedName(SERIALIZED_NAME_FUNCTIONS_INVOLVED) + @javax.annotation.Nullable + private List functionsInvolved; + + public static final String SERIALIZED_NAME_PURPOSE = "purpose"; + @SerializedName(SERIALIZED_NAME_PURPOSE) + @javax.annotation.Nullable + private String purpose; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nullable + private String summary; + + public static final String SERIALIZED_NAME_TRIGGER = "trigger"; + @SerializedName(SERIALIZED_NAME_TRIGGER) + @javax.annotation.Nullable + private String trigger; + + public static final String SERIALIZED_NAME_WHAT_EXECUTES = "what_executes"; + @SerializedName(SERIALIZED_NAME_WHAT_EXECUTES) + @javax.annotation.Nullable + private String whatExecutes; + + public ExecutionExplainResult() { + } + + public ExecutionExplainResult cancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + return this; + } + + /** + * Whether the run was cancelled + * @return cancelled + */ + @javax.annotation.Nonnull + public Boolean getCancelled() { + return cancelled; + } + + public void setCancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + } + + + public ExecutionExplainResult codeOrigin(@javax.annotation.Nullable String codeOrigin) { + this.codeOrigin = codeOrigin; + return this; + } + + /** + * Where the executed code originates from + * @return codeOrigin + */ + @javax.annotation.Nullable + public String getCodeOrigin() { + return codeOrigin; + } + + public void setCodeOrigin(@javax.annotation.Nullable String codeOrigin) { + this.codeOrigin = codeOrigin; + } + + + public ExecutionExplainResult executedTargets(@javax.annotation.Nullable List executedTargets) { + this.executedTargets = executedTargets; + return this; + } + + public ExecutionExplainResult addExecutedTargetsItem(String executedTargetsItem) { + if (this.executedTargets == null) { + this.executedTargets = new ArrayList<>(); + } + this.executedTargets.add(executedTargetsItem); + return this; + } + + /** + * Concrete targets that end up executed -- process names, module paths, or shellcode buffers + * @return executedTargets + */ + @javax.annotation.Nullable + public List getExecutedTargets() { + return executedTargets; + } + + public void setExecutedTargets(@javax.annotation.Nullable List executedTargets) { + this.executedTargets = executedTargets; + } + + + public ExecutionExplainResult functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the explained function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public ExecutionExplainResult functionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the explained function + * @return functionName + */ + @javax.annotation.Nullable + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + } + + + public ExecutionExplainResult functionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + return this; + } + + public ExecutionExplainResult addFunctionsInvolvedItem(ExecutionExplainedFunction functionsInvolvedItem) { + if (this.functionsInvolved == null) { + this.functionsInvolved = new ArrayList<>(); + } + this.functionsInvolved.add(functionsInvolvedItem); + return this; + } + + /** + * Other functions involved in the code execution + * @return functionsInvolved + */ + @javax.annotation.Nullable + public List getFunctionsInvolved() { + return functionsInvolved; + } + + public void setFunctionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + } + + + public ExecutionExplainResult purpose(@javax.annotation.Nullable String purpose) { + this.purpose = purpose; + return this; + } + + /** + * Purpose of the code execution + * @return purpose + */ + @javax.annotation.Nullable + public String getPurpose() { + return purpose; + } + + public void setPurpose(@javax.annotation.Nullable String purpose) { + this.purpose = purpose; + } + + + public ExecutionExplainResult summary(@javax.annotation.Nullable String summary) { + this.summary = summary; + return this; + } + + /** + * Explanation of the code execution the function performs + * @return summary + */ + @javax.annotation.Nullable + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nullable String summary) { + this.summary = summary; + } + + + public ExecutionExplainResult trigger(@javax.annotation.Nullable String trigger) { + this.trigger = trigger; + return this; + } + + /** + * What triggers the execution + * @return trigger + */ + @javax.annotation.Nullable + public String getTrigger() { + return trigger; + } + + public void setTrigger(@javax.annotation.Nullable String trigger) { + this.trigger = trigger; + } + + + public ExecutionExplainResult whatExecutes(@javax.annotation.Nullable String whatExecutes) { + this.whatExecutes = whatExecutes; + return this; + } + + /** + * What code ends up executing + * @return whatExecutes + */ + @javax.annotation.Nullable + public String getWhatExecutes() { + return whatExecutes; + } + + public void setWhatExecutes(@javax.annotation.Nullable String whatExecutes) { + this.whatExecutes = whatExecutes; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionExplainResult instance itself + */ + public ExecutionExplainResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionExplainResult executionExplainResult = (ExecutionExplainResult) o; + return Objects.equals(this.cancelled, executionExplainResult.cancelled) && + Objects.equals(this.codeOrigin, executionExplainResult.codeOrigin) && + Objects.equals(this.executedTargets, executionExplainResult.executedTargets) && + Objects.equals(this.functionId, executionExplainResult.functionId) && + Objects.equals(this.functionName, executionExplainResult.functionName) && + Objects.equals(this.functionsInvolved, executionExplainResult.functionsInvolved) && + Objects.equals(this.purpose, executionExplainResult.purpose) && + Objects.equals(this.summary, executionExplainResult.summary) && + Objects.equals(this.trigger, executionExplainResult.trigger) && + Objects.equals(this.whatExecutes, executionExplainResult.whatExecutes)&& + Objects.equals(this.additionalProperties, executionExplainResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(cancelled, codeOrigin, executedTargets, functionId, functionName, functionsInvolved, purpose, summary, trigger, whatExecutes, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionExplainResult {\n"); + sb.append(" cancelled: ").append(toIndentedString(cancelled)).append("\n"); + sb.append(" codeOrigin: ").append(toIndentedString(codeOrigin)).append("\n"); + sb.append(" executedTargets: ").append(toIndentedString(executedTargets)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionsInvolved: ").append(toIndentedString(functionsInvolved)).append("\n"); + sb.append(" purpose: ").append(toIndentedString(purpose)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" trigger: ").append(toIndentedString(trigger)).append("\n"); + sb.append(" whatExecutes: ").append(toIndentedString(whatExecutes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("cancelled", "code_origin", "executed_targets", "function_id", "function_name", "functions_involved", "purpose", "summary", "trigger", "what_executes")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("cancelled", "function_id")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionExplainResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionExplainResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionExplainResult is not found in the empty JSON string", ExecutionExplainResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionExplainResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("code_origin") != null && !jsonObj.get("code_origin").isJsonNull()) && !jsonObj.get("code_origin").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `code_origin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code_origin").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("executed_targets") != null && !jsonObj.get("executed_targets").isJsonNull() && !jsonObj.get("executed_targets").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `executed_targets` to be an array in the JSON string but got `%s`", jsonObj.get("executed_targets").toString())); + } + if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("functions_involved") != null && !jsonObj.get("functions_involved").isJsonNull() && !jsonObj.get("functions_involved").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions_involved` to be an array in the JSON string but got `%s`", jsonObj.get("functions_involved").toString())); + } + if ((jsonObj.get("purpose") != null && !jsonObj.get("purpose").isJsonNull()) && !jsonObj.get("purpose").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `purpose` to be a primitive type in the JSON string but got `%s`", jsonObj.get("purpose").toString())); + } + if ((jsonObj.get("summary") != null && !jsonObj.get("summary").isJsonNull()) && !jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + if ((jsonObj.get("trigger") != null && !jsonObj.get("trigger").isJsonNull()) && !jsonObj.get("trigger").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `trigger` to be a primitive type in the JSON string but got `%s`", jsonObj.get("trigger").toString())); + } + if ((jsonObj.get("what_executes") != null && !jsonObj.get("what_executes").isJsonNull()) && !jsonObj.get("what_executes").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `what_executes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("what_executes").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionExplainResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionExplainResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionExplainResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionExplainResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionExplainResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionExplainResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionExplainResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionExplainResult + * @throws IOException if the JSON string is invalid with respect to ExecutionExplainResult + */ + public static ExecutionExplainResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionExplainResult.class); + } + + /** + * Convert an instance of ExecutionExplainResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionExplainedFunction.java b/src/main/java/ai/reveng/model/ExecutionExplainedFunction.java new file mode 100644 index 00000000..1cbe0f13 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionExplainedFunction.java @@ -0,0 +1,344 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionExplainedFunction + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionExplainedFunction { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public ExecutionExplainedFunction() { + } + + public ExecutionExplainedFunction description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * Role this function plays in the code execution + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public ExecutionExplainedFunction functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public ExecutionExplainedFunction functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionExplainedFunction instance itself + */ + public ExecutionExplainedFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionExplainedFunction executionExplainedFunction = (ExecutionExplainedFunction) o; + return Objects.equals(this.description, executionExplainedFunction.description) && + Objects.equals(this.functionId, executionExplainedFunction.functionId) && + Objects.equals(this.functionName, executionExplainedFunction.functionName)&& + Objects.equals(this.additionalProperties, executionExplainedFunction.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(description, functionId, functionName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionExplainedFunction {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionExplainedFunction + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionExplainedFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionExplainedFunction is not found in the empty JSON string", ExecutionExplainedFunction.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionExplainedFunction.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionExplainedFunction.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionExplainedFunction' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionExplainedFunction.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionExplainedFunction value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionExplainedFunction read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionExplainedFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionExplainedFunction given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionExplainedFunction + * @throws IOException if the JSON string is invalid with respect to ExecutionExplainedFunction + */ + public static ExecutionExplainedFunction fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionExplainedFunction.class); + } + + /** + * Convert an instance of ExecutionExplainedFunction to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionFinding.java b/src/main/java/ai/reveng/model/ExecutionFinding.java new file mode 100644 index 00000000..345ffa98 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionFinding.java @@ -0,0 +1,815 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ExecutionCall; +import ai.reveng.model.ExecutionDirectMatch; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionFinding + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionFinding { + public static final String SERIALIZED_NAME_ADDRESS = "address"; + @SerializedName(SERIALIZED_NAME_ADDRESS) + @javax.annotation.Nonnull + private String address; + + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + DYNAMIC_RESOLVE("dynamic-resolve"), + + HOOKING("hooking"), + + INJECTION("injection"), + + MEMORY_EXEC("memory-exec"), + + MODULE_LOAD("module-load"), + + PROCESS_CONTROL("process-control"), + + PROCESS_CREATE("process-create"), + + SCRIPT_EXEC("script-exec"), + + SHELLCODE("shellcode"), + + THREAD_CREATE("thread-create"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + /** + * High when a direct name match was found, medium when the function only calls into execution APIs + */ + @JsonAdapter(ConfidenceEnum.Adapter.class) + public enum ConfidenceEnum { + HIGH("high"), + + MEDIUM("medium"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ConfidenceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ConfidenceEnum fromValue(String value) { + for (ConfidenceEnum b : ConfidenceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ConfidenceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ConfidenceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ConfidenceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ConfidenceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CONFIDENCE = "confidence"; + @SerializedName(SERIALIZED_NAME_CONFIDENCE) + @javax.annotation.Nonnull + private ConfidenceEnum confidence; + + public static final String SERIALIZED_NAME_DIRECT_MATCHES = "direct_matches"; + @SerializedName(SERIALIZED_NAME_DIRECT_MATCHES) + @javax.annotation.Nullable + private List directMatches; + + public static final String SERIALIZED_NAME_EVIDENCE_COUNT = "evidence_count"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_COUNT) + @javax.annotation.Nonnull + private Long evidenceCount; + + public static final String SERIALIZED_NAME_EXECUTES = "executes"; + @SerializedName(SERIALIZED_NAME_EXECUTES) + @javax.annotation.Nonnull + private Boolean executes; + + public static final String SERIALIZED_NAME_EXECUTION_CALLS = "execution_calls"; + @SerializedName(SERIALIZED_NAME_EXECUTION_CALLS) + @javax.annotation.Nullable + private List executionCalls; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTION_SIZE = "function_size"; + @SerializedName(SERIALIZED_NAME_FUNCTION_SIZE) + @javax.annotation.Nonnull + private Long functionSize; + + /** + * Gets or Sets sources + */ + @JsonAdapter(SourcesEnum.Adapter.class) + public enum SourcesEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + SCRIPT_ENGINE("script-engine"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourcesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourcesEnum fromValue(String value) { + for (SourcesEnum b : SourcesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourcesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourcesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourcesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourcesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCES = "sources"; + @SerializedName(SERIALIZED_NAME_SOURCES) + @javax.annotation.Nullable + private List sources; + + public ExecutionFinding() { + } + + public ExecutionFinding address(@javax.annotation.Nonnull String address) { + this.address = address; + return this; + } + + /** + * Function's virtual address, hex-encoded + * @return address + */ + @javax.annotation.Nonnull + public String getAddress() { + return address; + } + + public void setAddress(@javax.annotation.Nonnull String address) { + this.address = address; + } + + + public ExecutionFinding categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public ExecutionFinding addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Distinct execution categories evidenced by this function + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public ExecutionFinding confidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + return this; + } + + /** + * High when a direct name match was found, medium when the function only calls into execution APIs + * @return confidence + */ + @javax.annotation.Nonnull + public ConfidenceEnum getConfidence() { + return confidence; + } + + public void setConfidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + } + + + public ExecutionFinding directMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + return this; + } + + public ExecutionFinding addDirectMatchesItem(ExecutionDirectMatch directMatchesItem) { + if (this.directMatches == null) { + this.directMatches = new ArrayList<>(); + } + this.directMatches.add(directMatchesItem); + return this; + } + + /** + * Matches against the function's own name + * @return directMatches + */ + @javax.annotation.Nullable + public List getDirectMatches() { + return directMatches; + } + + public void setDirectMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + } + + + public ExecutionFinding evidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + return this; + } + + /** + * Total number of direct matches and execution calls + * @return evidenceCount + */ + @javax.annotation.Nonnull + public Long getEvidenceCount() { + return evidenceCount; + } + + public void setEvidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + } + + + public ExecutionFinding executes(@javax.annotation.Nonnull Boolean executes) { + this.executes = executes; + return this; + } + + /** + * Whether this function evidences executing code rather than only supporting it + * @return executes + */ + @javax.annotation.Nonnull + public Boolean getExecutes() { + return executes; + } + + public void setExecutes(@javax.annotation.Nonnull Boolean executes) { + this.executes = executes; + } + + + public ExecutionFinding executionCalls(@javax.annotation.Nullable List executionCalls) { + this.executionCalls = executionCalls; + return this; + } + + public ExecutionFinding addExecutionCallsItem(ExecutionCall executionCallsItem) { + if (this.executionCalls == null) { + this.executionCalls = new ArrayList<>(); + } + this.executionCalls.add(executionCallsItem); + return this; + } + + /** + * Matches against names this function calls + * @return executionCalls + */ + @javax.annotation.Nullable + public List getExecutionCalls() { + return executionCalls; + } + + public void setExecutionCalls(@javax.annotation.Nullable List executionCalls) { + this.executionCalls = executionCalls; + } + + + public ExecutionFinding functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function the finding was reported in + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public ExecutionFinding functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function the finding was reported in + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + + public ExecutionFinding functionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + return this; + } + + /** + * Size of the function in bytes + * @return functionSize + */ + @javax.annotation.Nonnull + public Long getFunctionSize() { + return functionSize; + } + + public void setFunctionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + } + + + public ExecutionFinding sources(@javax.annotation.Nullable List sources) { + this.sources = sources; + return this; + } + + public ExecutionFinding addSourcesItem(SourcesEnum sourcesItem) { + if (this.sources == null) { + this.sources = new ArrayList<>(); + } + this.sources.add(sourcesItem); + return this; + } + + /** + * Distinct execution sources evidenced by this function + * @return sources + */ + @javax.annotation.Nullable + public List getSources() { + return sources; + } + + public void setSources(@javax.annotation.Nullable List sources) { + this.sources = sources; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionFinding instance itself + */ + public ExecutionFinding putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionFinding executionFinding = (ExecutionFinding) o; + return Objects.equals(this.address, executionFinding.address) && + Objects.equals(this.categories, executionFinding.categories) && + Objects.equals(this.confidence, executionFinding.confidence) && + Objects.equals(this.directMatches, executionFinding.directMatches) && + Objects.equals(this.evidenceCount, executionFinding.evidenceCount) && + Objects.equals(this.executes, executionFinding.executes) && + Objects.equals(this.executionCalls, executionFinding.executionCalls) && + Objects.equals(this.functionId, executionFinding.functionId) && + Objects.equals(this.functionName, executionFinding.functionName) && + Objects.equals(this.functionSize, executionFinding.functionSize) && + Objects.equals(this.sources, executionFinding.sources)&& + Objects.equals(this.additionalProperties, executionFinding.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(address, categories, confidence, directMatches, evidenceCount, executes, executionCalls, functionId, functionName, functionSize, sources, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionFinding {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" directMatches: ").append(toIndentedString(directMatches)).append("\n"); + sb.append(" evidenceCount: ").append(toIndentedString(evidenceCount)).append("\n"); + sb.append(" executes: ").append(toIndentedString(executes)).append("\n"); + sb.append(" executionCalls: ").append(toIndentedString(executionCalls)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionSize: ").append(toIndentedString(functionSize)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("address", "categories", "confidence", "direct_matches", "evidence_count", "executes", "execution_calls", "function_id", "function_name", "function_size", "sources")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("address", "categories", "confidence", "evidence_count", "executes", "function_id", "function_name", "function_size", "sources")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionFinding + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionFinding.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionFinding is not found in the empty JSON string", ExecutionFinding.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionFinding.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("address").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); + } + // ensure the required json array is present + if (jsonObj.get("categories") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("categories").isJsonArray() && !jsonObj.get("categories").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + if (!jsonObj.get("confidence").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidence` to be a primitive type in the JSON string but got `%s`", jsonObj.get("confidence").toString())); + } + // validate the required field `confidence` + ConfidenceEnum.validateJsonElement(jsonObj.get("confidence")); + // ensure the optional json data is an array if present + if (jsonObj.get("direct_matches") != null && !jsonObj.get("direct_matches").isJsonNull() && !jsonObj.get("direct_matches").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `direct_matches` to be an array in the JSON string but got `%s`", jsonObj.get("direct_matches").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("execution_calls") != null && !jsonObj.get("execution_calls").isJsonNull() && !jsonObj.get("execution_calls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `execution_calls` to be an array in the JSON string but got `%s`", jsonObj.get("execution_calls").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the required json array is present + if (jsonObj.get("sources") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("sources").isJsonArray() && !jsonObj.get("sources").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sources` to be an array in the JSON string but got `%s`", jsonObj.get("sources").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionFinding.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionFinding' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionFinding.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionFinding value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionFinding read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionFinding instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionFinding given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionFinding + * @throws IOException if the JSON string is invalid with respect to ExecutionFinding + */ + public static ExecutionFinding fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionFinding.class); + } + + /** + * Convert an instance of ExecutionFinding to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionScanMetadata.java b/src/main/java/ai/reveng/model/ExecutionScanMetadata.java new file mode 100644 index 00000000..fee65c50 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionScanMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionScanMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionScanMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public ExecutionScanMetadata() { + } + + public ExecutionScanMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public ExecutionScanMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public ExecutionScanMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionScanMetadata instance itself + */ + public ExecutionScanMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionScanMetadata executionScanMetadata = (ExecutionScanMetadata) o; + return Objects.equals(this.logHistory, executionScanMetadata.logHistory) && + Objects.equals(this.status, executionScanMetadata.status)&& + Objects.equals(this.additionalProperties, executionScanMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionScanMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionScanMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionScanMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionScanMetadata is not found in the empty JSON string", ExecutionScanMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionScanMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionScanMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionScanMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionScanMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionScanMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionScanMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionScanMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionScanMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionScanMetadata + * @throws IOException if the JSON string is invalid with respect to ExecutionScanMetadata + */ + public static ExecutionScanMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionScanMetadata.class); + } + + /** + * Convert an instance of ExecutionScanMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExecutionScanResult.java b/src/main/java/ai/reveng/model/ExecutionScanResult.java new file mode 100644 index 00000000..1a0eb93b --- /dev/null +++ b/src/main/java/ai/reveng/model/ExecutionScanResult.java @@ -0,0 +1,365 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ExecutionFinding; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExecutionScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExecutionScanResult { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_FINDINGS = "findings"; + @SerializedName(SERIALIZED_NAME_FINDINGS) + @javax.annotation.Nullable + private List findings; + + public static final String SERIALIZED_NAME_TOTAL_FUNCTIONS = "total_functions"; + @SerializedName(SERIALIZED_NAME_TOTAL_FUNCTIONS) + @javax.annotation.Nonnull + private Long totalFunctions; + + public ExecutionScanResult() { + } + + public ExecutionScanResult analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Analysis the run was performed against + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public ExecutionScanResult findings(@javax.annotation.Nullable List findings) { + this.findings = findings; + return this; + } + + public ExecutionScanResult addFindingsItem(ExecutionFinding findingsItem) { + if (this.findings == null) { + this.findings = new ArrayList<>(); + } + this.findings.add(findingsItem); + return this; + } + + /** + * Functions with execution-related evidence, sorted by whether they execute code, then confidence, then evidence count + * @return findings + */ + @javax.annotation.Nullable + public List getFindings() { + return findings; + } + + public void setFindings(@javax.annotation.Nullable List findings) { + this.findings = findings; + } + + + public ExecutionScanResult totalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + return this; + } + + /** + * Functions the run considered + * @return totalFunctions + */ + @javax.annotation.Nonnull + public Long getTotalFunctions() { + return totalFunctions; + } + + public void setTotalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExecutionScanResult instance itself + */ + public ExecutionScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionScanResult executionScanResult = (ExecutionScanResult) o; + return Objects.equals(this.analysisId, executionScanResult.analysisId) && + Objects.equals(this.findings, executionScanResult.findings) && + Objects.equals(this.totalFunctions, executionScanResult.totalFunctions)&& + Objects.equals(this.additionalProperties, executionScanResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, findings, totalFunctions, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionScanResult {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" findings: ").append(toIndentedString(findings)).append("\n"); + sb.append(" totalFunctions: ").append(toIndentedString(totalFunctions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "findings", "total_functions")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "total_functions")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExecutionScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExecutionScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExecutionScanResult is not found in the empty JSON string", ExecutionScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExecutionScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("findings") != null && !jsonObj.get("findings").isJsonNull() && !jsonObj.get("findings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `findings` to be an array in the JSON string but got `%s`", jsonObj.get("findings").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExecutionScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExecutionScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExecutionScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExecutionScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExecutionScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExecutionScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExecutionScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExecutionScanResult + * @throws IOException if the JSON string is invalid with respect to ExecutionScanResult + */ + public static ExecutionScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExecutionScanResult.class); + } + + /** + * Convert an instance of ExecutionScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExtractedBinary.java b/src/main/java/ai/reveng/model/ExtractedBinary.java new file mode 100644 index 00000000..c6ec2065 --- /dev/null +++ b/src/main/java/ai/reveng/model/ExtractedBinary.java @@ -0,0 +1,344 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExtractedBinary + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExtractedBinary { + public static final String SERIALIZED_NAME_FILENAME = "filename"; + @SerializedName(SERIALIZED_NAME_FILENAME) + @javax.annotation.Nonnull + private String filename; + + public static final String SERIALIZED_NAME_SHA256_HASH = "sha_256_hash"; + @SerializedName(SERIALIZED_NAME_SHA256_HASH) + @javax.annotation.Nonnull + private String sha256Hash; + + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + @javax.annotation.Nonnull + private Long size; + + public ExtractedBinary() { + } + + public ExtractedBinary filename(@javax.annotation.Nonnull String filename) { + this.filename = filename; + return this; + } + + /** + * Original filename inside the upload + * @return filename + */ + @javax.annotation.Nonnull + public String getFilename() { + return filename; + } + + public void setFilename(@javax.annotation.Nonnull String filename) { + this.filename = filename; + } + + + public ExtractedBinary sha256Hash(@javax.annotation.Nonnull String sha256Hash) { + this.sha256Hash = sha256Hash; + return this; + } + + /** + * Content hash of the recovered binary + * @return sha256Hash + */ + @javax.annotation.Nonnull + public String getSha256Hash() { + return sha256Hash; + } + + public void setSha256Hash(@javax.annotation.Nonnull String sha256Hash) { + this.sha256Hash = sha256Hash; + } + + + public ExtractedBinary size(@javax.annotation.Nonnull Long size) { + this.size = size; + return this; + } + + /** + * File size (in bytes) + * @return size + */ + @javax.annotation.Nonnull + public Long getSize() { + return size; + } + + public void setSize(@javax.annotation.Nonnull Long size) { + this.size = size; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExtractedBinary instance itself + */ + public ExtractedBinary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExtractedBinary extractedBinary = (ExtractedBinary) o; + return Objects.equals(this.filename, extractedBinary.filename) && + Objects.equals(this.sha256Hash, extractedBinary.sha256Hash) && + Objects.equals(this.size, extractedBinary.size)&& + Objects.equals(this.additionalProperties, extractedBinary.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(filename, sha256Hash, size, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExtractedBinary {\n"); + sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); + sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("filename", "sha_256_hash", "size")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("filename", "sha_256_hash", "size")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExtractedBinary + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExtractedBinary.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExtractedBinary is not found in the empty JSON string", ExtractedBinary.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExtractedBinary.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + } + if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExtractedBinary.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExtractedBinary' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExtractedBinary.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExtractedBinary value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExtractedBinary read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExtractedBinary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExtractedBinary given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExtractedBinary + * @throws IOException if the JSON string is invalid with respect to ExtractedBinary + */ + public static ExtractedBinary fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExtractedBinary.class); + } + + /** + * Convert an instance of ExtractedBinary to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ExtractedURL.java b/src/main/java/ai/reveng/model/ExtractedURL.java index ddf6935f..77cfe710 100644 --- a/src/main/java/ai/reveng/model/ExtractedURL.java +++ b/src/main/java/ai/reveng/model/ExtractedURL.java @@ -111,6 +111,50 @@ public void setUrl(@javax.annotation.Nonnull String url) { this.url = url; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExtractedURL instance itself + */ + public ExtractedURL putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,7 +167,8 @@ public boolean equals(Object o) { } ExtractedURL extractedURL = (ExtractedURL) o; return Objects.equals(this.events, extractedURL.events) && - Objects.equals(this.url, extractedURL.url); + Objects.equals(this.url, extractedURL.url)&& + Objects.equals(this.additionalProperties, extractedURL.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -132,7 +177,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, url); + return Objects.hash(events, url, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -148,6 +193,7 @@ public String toString() { sb.append("class ExtractedURL {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -185,14 +231,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ExtractedURL.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ExtractedURL` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ExtractedURL.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,19 +238,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if (!jsonObj.get("url").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); @@ -234,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ExtractedURL value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +291,28 @@ public void write(JsonWriter out, ExtractedURL value) throws IOException { public ExtractedURL read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExtractedURL instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ExtractionFailure.java b/src/main/java/ai/reveng/model/ExtractionFailure.java new file mode 100644 index 00000000..92b8a2fb --- /dev/null +++ b/src/main/java/ai/reveng/model/ExtractionFailure.java @@ -0,0 +1,315 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ExtractionFailure + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ExtractionFailure { + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nonnull + private String message; + + public static final String SERIALIZED_NAME_RETRYABLE = "retryable"; + @SerializedName(SERIALIZED_NAME_RETRYABLE) + @javax.annotation.Nonnull + private Boolean retryable; + + public ExtractionFailure() { + } + + public ExtractionFailure message(@javax.annotation.Nonnull String message) { + this.message = message; + return this; + } + + /** + * Why this file failed to extract. + * @return message + */ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nonnull String message) { + this.message = message; + } + + + public ExtractionFailure retryable(@javax.annotation.Nonnull Boolean retryable) { + this.retryable = retryable; + return this; + } + + /** + * Whether re-submitting the extraction might resolve this failure. + * @return retryable + */ + @javax.annotation.Nonnull + public Boolean getRetryable() { + return retryable; + } + + public void setRetryable(@javax.annotation.Nonnull Boolean retryable) { + this.retryable = retryable; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ExtractionFailure instance itself + */ + public ExtractionFailure putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExtractionFailure extractionFailure = (ExtractionFailure) o; + return Objects.equals(this.message, extractionFailure.message) && + Objects.equals(this.retryable, extractionFailure.retryable)&& + Objects.equals(this.additionalProperties, extractionFailure.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(message, retryable, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExtractionFailure {\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" retryable: ").append(toIndentedString(retryable)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("message", "retryable")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("message", "retryable")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ExtractionFailure + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ExtractionFailure.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExtractionFailure is not found in the empty JSON string", ExtractionFailure.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ExtractionFailure.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ExtractionFailure.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ExtractionFailure' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ExtractionFailure.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ExtractionFailure value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ExtractionFailure read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ExtractionFailure instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ExtractionFailure given an JSON string + * + * @param jsonString JSON string + * @return An instance of ExtractionFailure + * @throws IOException if the JSON string is invalid with respect to ExtractionFailure + */ + public static ExtractionFailure fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ExtractionFailure.class); + } + + /** + * Convert an instance of ExtractionFailure to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FeedbackOutputBody.java b/src/main/java/ai/reveng/model/FeedbackOutputBody.java new file mode 100644 index 00000000..096ddbce --- /dev/null +++ b/src/main/java/ai/reveng/model/FeedbackOutputBody.java @@ -0,0 +1,349 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FeedbackOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FeedbackOutputBody { + /** + * The sentiment the caller recorded, or null when they have not left any + */ + @JsonAdapter(SentimentEnum.Adapter.class) + public enum SentimentEnum { + POSITIVE("POSITIVE"), + + NEUTRAL("NEUTRAL"), + + NEGATIVE("NEGATIVE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SentimentEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SentimentEnum fromValue(String value) { + for (SentimentEnum b : SentimentEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SentimentEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SentimentEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SentimentEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SentimentEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SENTIMENT = "sentiment"; + @SerializedName(SERIALIZED_NAME_SENTIMENT) + @javax.annotation.Nullable + private SentimentEnum sentiment; + + public FeedbackOutputBody() { + } + + public FeedbackOutputBody sentiment(@javax.annotation.Nullable SentimentEnum sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * The sentiment the caller recorded, or null when they have not left any + * @return sentiment + */ + @javax.annotation.Nullable + public SentimentEnum getSentiment() { + return sentiment; + } + + public void setSentiment(@javax.annotation.Nullable SentimentEnum sentiment) { + this.sentiment = sentiment; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FeedbackOutputBody instance itself + */ + public FeedbackOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FeedbackOutputBody feedbackOutputBody = (FeedbackOutputBody) o; + return Objects.equals(this.sentiment, feedbackOutputBody.sentiment)&& + Objects.equals(this.additionalProperties, feedbackOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(sentiment, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FeedbackOutputBody {\n"); + sb.append(" sentiment: ").append(toIndentedString(sentiment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("sentiment")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("sentiment")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FeedbackOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FeedbackOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FeedbackOutputBody is not found in the empty JSON string", FeedbackOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FeedbackOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("sentiment") != null && !jsonObj.get("sentiment").isJsonNull()) && !jsonObj.get("sentiment").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sentiment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sentiment").toString())); + } + if (jsonObj.get("sentiment") != null && !jsonObj.get("sentiment").isJsonNull()) { + // validate the required field `sentiment` + SentimentEnum.validateJsonElement(jsonObj.get("sentiment")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FeedbackOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FeedbackOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FeedbackOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FeedbackOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FeedbackOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FeedbackOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FeedbackOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of FeedbackOutputBody + * @throws IOException if the JSON string is invalid with respect to FeedbackOutputBody + */ + public static FeedbackOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FeedbackOutputBody.class); + } + + /** + * Convert an instance of FeedbackOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FileActivityEntry.java b/src/main/java/ai/reveng/model/FileActivityEntry.java index c4058e5a..0185de73 100644 --- a/src/main/java/ai/reveng/model/FileActivityEntry.java +++ b/src/main/java/ai/reveng/model/FileActivityEntry.java @@ -111,6 +111,50 @@ public void setPath(@javax.annotation.Nonnull String path) { this.path = path; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FileActivityEntry instance itself + */ + public FileActivityEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,7 +167,8 @@ public boolean equals(Object o) { } FileActivityEntry fileActivityEntry = (FileActivityEntry) o; return Objects.equals(this.events, fileActivityEntry.events) && - Objects.equals(this.path, fileActivityEntry.path); + Objects.equals(this.path, fileActivityEntry.path)&& + Objects.equals(this.additionalProperties, fileActivityEntry.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -132,7 +177,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, path); + return Objects.hash(events, path, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -148,6 +193,7 @@ public String toString() { sb.append("class FileActivityEntry {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -185,14 +231,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FileActivityEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FileActivityEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FileActivityEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,19 +238,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if (!jsonObj.get("path").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); @@ -234,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FileActivityEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +291,28 @@ public void write(JsonWriter out, FileActivityEntry value) throws IOException { public FileActivityEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FileActivityEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FilesystemAnalyseMetadata.java b/src/main/java/ai/reveng/model/FilesystemAnalyseMetadata.java new file mode 100644 index 00000000..c2a9f3cc --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemAnalyseMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemAnalyseMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemAnalyseMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public FilesystemAnalyseMetadata() { + } + + public FilesystemAnalyseMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public FilesystemAnalyseMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public FilesystemAnalyseMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemAnalyseMetadata instance itself + */ + public FilesystemAnalyseMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemAnalyseMetadata filesystemAnalyseMetadata = (FilesystemAnalyseMetadata) o; + return Objects.equals(this.logHistory, filesystemAnalyseMetadata.logHistory) && + Objects.equals(this.status, filesystemAnalyseMetadata.status)&& + Objects.equals(this.additionalProperties, filesystemAnalyseMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemAnalyseMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemAnalyseMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemAnalyseMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemAnalyseMetadata is not found in the empty JSON string", FilesystemAnalyseMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemAnalyseMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemAnalyseMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemAnalyseMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemAnalyseMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemAnalyseMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemAnalyseMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemAnalyseMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemAnalyseMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemAnalyseMetadata + * @throws IOException if the JSON string is invalid with respect to FilesystemAnalyseMetadata + */ + public static FilesystemAnalyseMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemAnalyseMetadata.class); + } + + /** + * Convert an instance of FilesystemAnalyseMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FilesystemAnalyseResult.java b/src/main/java/ai/reveng/model/FilesystemAnalyseResult.java new file mode 100644 index 00000000..7a9bb7e9 --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemAnalyseResult.java @@ -0,0 +1,548 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.FilesystemExplainedFunction; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemAnalyseResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemAnalyseResult { + public static final String SERIALIZED_NAME_CANCELLED = "cancelled"; + @SerializedName(SERIALIZED_NAME_CANCELLED) + @javax.annotation.Nonnull + private Boolean cancelled; + + public static final String SERIALIZED_NAME_DATA_DESCRIPTION = "data_description"; + @SerializedName(SERIALIZED_NAME_DATA_DESCRIPTION) + @javax.annotation.Nullable + private String dataDescription; + + public static final String SERIALIZED_NAME_DATA_DESTINATION = "data_destination"; + @SerializedName(SERIALIZED_NAME_DATA_DESTINATION) + @javax.annotation.Nullable + private String dataDestination; + + public static final String SERIALIZED_NAME_DATA_ORIGIN = "data_origin"; + @SerializedName(SERIALIZED_NAME_DATA_ORIGIN) + @javax.annotation.Nullable + private String dataOrigin; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nullable + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTIONS_INVOLVED = "functions_involved"; + @SerializedName(SERIALIZED_NAME_FUNCTIONS_INVOLVED) + @javax.annotation.Nullable + private List functionsInvolved; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nullable + private String summary; + + public static final String SERIALIZED_NAME_TARGETS = "targets"; + @SerializedName(SERIALIZED_NAME_TARGETS) + @javax.annotation.Nullable + private List targets; + + public FilesystemAnalyseResult() { + } + + public FilesystemAnalyseResult cancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + return this; + } + + /** + * Whether the run was cancelled + * @return cancelled + */ + @javax.annotation.Nonnull + public Boolean getCancelled() { + return cancelled; + } + + public void setCancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + } + + + public FilesystemAnalyseResult dataDescription(@javax.annotation.Nullable String dataDescription) { + this.dataDescription = dataDescription; + return this; + } + + /** + * Description of the data read or written + * @return dataDescription + */ + @javax.annotation.Nullable + public String getDataDescription() { + return dataDescription; + } + + public void setDataDescription(@javax.annotation.Nullable String dataDescription) { + this.dataDescription = dataDescription; + } + + + public FilesystemAnalyseResult dataDestination(@javax.annotation.Nullable String dataDestination) { + this.dataDestination = dataDestination; + return this; + } + + /** + * Where the data ends up + * @return dataDestination + */ + @javax.annotation.Nullable + public String getDataDestination() { + return dataDestination; + } + + public void setDataDestination(@javax.annotation.Nullable String dataDestination) { + this.dataDestination = dataDestination; + } + + + public FilesystemAnalyseResult dataOrigin(@javax.annotation.Nullable String dataOrigin) { + this.dataOrigin = dataOrigin; + return this; + } + + /** + * Where the data originates from + * @return dataOrigin + */ + @javax.annotation.Nullable + public String getDataOrigin() { + return dataOrigin; + } + + public void setDataOrigin(@javax.annotation.Nullable String dataOrigin) { + this.dataOrigin = dataOrigin; + } + + + public FilesystemAnalyseResult functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the explained function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public FilesystemAnalyseResult functionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the explained function + * @return functionName + */ + @javax.annotation.Nullable + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + } + + + public FilesystemAnalyseResult functionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + return this; + } + + public FilesystemAnalyseResult addFunctionsInvolvedItem(FilesystemExplainedFunction functionsInvolvedItem) { + if (this.functionsInvolved == null) { + this.functionsInvolved = new ArrayList<>(); + } + this.functionsInvolved.add(functionsInvolvedItem); + return this; + } + + /** + * Other functions involved in the filesystem access + * @return functionsInvolved + */ + @javax.annotation.Nullable + public List getFunctionsInvolved() { + return functionsInvolved; + } + + public void setFunctionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + } + + + public FilesystemAnalyseResult summary(@javax.annotation.Nullable String summary) { + this.summary = summary; + return this; + } + + /** + * Explanation of the filesystem access the function performs + * @return summary + */ + @javax.annotation.Nullable + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nullable String summary) { + this.summary = summary; + } + + + public FilesystemAnalyseResult targets(@javax.annotation.Nullable List targets) { + this.targets = targets; + return this; + } + + public FilesystemAnalyseResult addTargetsItem(String targetsItem) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + this.targets.add(targetsItem); + return this; + } + + /** + * Concrete filesystem targets identified -- paths, registry keys, or environment variables + * @return targets + */ + @javax.annotation.Nullable + public List getTargets() { + return targets; + } + + public void setTargets(@javax.annotation.Nullable List targets) { + this.targets = targets; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemAnalyseResult instance itself + */ + public FilesystemAnalyseResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemAnalyseResult filesystemAnalyseResult = (FilesystemAnalyseResult) o; + return Objects.equals(this.cancelled, filesystemAnalyseResult.cancelled) && + Objects.equals(this.dataDescription, filesystemAnalyseResult.dataDescription) && + Objects.equals(this.dataDestination, filesystemAnalyseResult.dataDestination) && + Objects.equals(this.dataOrigin, filesystemAnalyseResult.dataOrigin) && + Objects.equals(this.functionId, filesystemAnalyseResult.functionId) && + Objects.equals(this.functionName, filesystemAnalyseResult.functionName) && + Objects.equals(this.functionsInvolved, filesystemAnalyseResult.functionsInvolved) && + Objects.equals(this.summary, filesystemAnalyseResult.summary) && + Objects.equals(this.targets, filesystemAnalyseResult.targets)&& + Objects.equals(this.additionalProperties, filesystemAnalyseResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(cancelled, dataDescription, dataDestination, dataOrigin, functionId, functionName, functionsInvolved, summary, targets, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemAnalyseResult {\n"); + sb.append(" cancelled: ").append(toIndentedString(cancelled)).append("\n"); + sb.append(" dataDescription: ").append(toIndentedString(dataDescription)).append("\n"); + sb.append(" dataDestination: ").append(toIndentedString(dataDestination)).append("\n"); + sb.append(" dataOrigin: ").append(toIndentedString(dataOrigin)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionsInvolved: ").append(toIndentedString(functionsInvolved)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("cancelled", "data_description", "data_destination", "data_origin", "function_id", "function_name", "functions_involved", "summary", "targets")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("cancelled", "function_id")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemAnalyseResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemAnalyseResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemAnalyseResult is not found in the empty JSON string", FilesystemAnalyseResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemAnalyseResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("data_description") != null && !jsonObj.get("data_description").isJsonNull()) && !jsonObj.get("data_description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_description").toString())); + } + if ((jsonObj.get("data_destination") != null && !jsonObj.get("data_destination").isJsonNull()) && !jsonObj.get("data_destination").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_destination` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_destination").toString())); + } + if ((jsonObj.get("data_origin") != null && !jsonObj.get("data_origin").isJsonNull()) && !jsonObj.get("data_origin").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_origin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_origin").toString())); + } + if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("functions_involved") != null && !jsonObj.get("functions_involved").isJsonNull() && !jsonObj.get("functions_involved").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions_involved` to be an array in the JSON string but got `%s`", jsonObj.get("functions_involved").toString())); + } + if ((jsonObj.get("summary") != null && !jsonObj.get("summary").isJsonNull()) && !jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("targets") != null && !jsonObj.get("targets").isJsonNull() && !jsonObj.get("targets").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `targets` to be an array in the JSON string but got `%s`", jsonObj.get("targets").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemAnalyseResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemAnalyseResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemAnalyseResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemAnalyseResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemAnalyseResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemAnalyseResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemAnalyseResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemAnalyseResult + * @throws IOException if the JSON string is invalid with respect to FilesystemAnalyseResult + */ + public static FilesystemAnalyseResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemAnalyseResult.class); + } + + /** + * Convert an instance of FilesystemAnalyseResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FilesystemCall.java b/src/main/java/ai/reveng/model/FilesystemCall.java new file mode 100644 index 00000000..bad3d6ff --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemCall.java @@ -0,0 +1,613 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemCall + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemCall { + public static final String SERIALIZED_NAME_CALLEE_NAME = "callee_name"; + @SerializedName(SERIALIZED_NAME_CALLEE_NAME) + @javax.annotation.Nonnull + private String calleeName; + + /** + * Filesystem category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + DIR_READ("dir-read"), + + DIR_WRITE("dir-write"), + + ENVIRONMENT("environment"), + + FILE_DELETE("file-delete"), + + FILE_OPEN("file-open"), + + FILE_PERMS("file-perms"), + + FILE_READ("file-read"), + + FILE_STAT("file-stat"), + + FILE_WRITE("file-write"), + + MODULE("module"), + + PATH_WRITE("path-write"), + + PROCESS("process"), + + REGISTRY_READ("registry-read"), + + REGISTRY_WRITE("registry-write"), + + SERVICE("service"), + + SYSTEM("system"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + API("api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + /** + * Filesystem source the match belongs to + */ + @JsonAdapter(SourceEnum.Adapter.class) + public enum SourceEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceEnum fromValue(String value) { + for (SourceEnum b : SourceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nonnull + private SourceEnum source; + + public FilesystemCall() { + } + + public FilesystemCall calleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + return this; + } + + /** + * Name of the called function + * @return calleeName + */ + @javax.annotation.Nonnull + public String getCalleeName() { + return calleeName; + } + + public void setCalleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + } + + + public FilesystemCall category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Filesystem category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public FilesystemCall how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public FilesystemCall matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + + public FilesystemCall source(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + return this; + } + + /** + * Filesystem source the match belongs to + * @return source + */ + @javax.annotation.Nonnull + public SourceEnum getSource() { + return source; + } + + public void setSource(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemCall instance itself + */ + public FilesystemCall putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemCall filesystemCall = (FilesystemCall) o; + return Objects.equals(this.calleeName, filesystemCall.calleeName) && + Objects.equals(this.category, filesystemCall.category) && + Objects.equals(this.how, filesystemCall.how) && + Objects.equals(this.matchedName, filesystemCall.matchedName) && + Objects.equals(this.source, filesystemCall.source)&& + Objects.equals(this.additionalProperties, filesystemCall.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(calleeName, category, how, matchedName, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemCall {\n"); + sb.append(" calleeName: ").append(toIndentedString(calleeName)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("callee_name", "category", "how", "matched_name", "source")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("callee_name", "category", "how", "matched_name", "source")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemCall + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemCall.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemCall is not found in the empty JSON string", FilesystemCall.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemCall.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("callee_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); + } + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + // validate the required field `source` + SourceEnum.validateJsonElement(jsonObj.get("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemCall.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemCall' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemCall.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemCall value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemCall read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemCall instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemCall given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemCall + * @throws IOException if the JSON string is invalid with respect to FilesystemCall + */ + public static FilesystemCall fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemCall.class); + } + + /** + * Convert an instance of FilesystemCall to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FilesystemDirectMatch.java b/src/main/java/ai/reveng/model/FilesystemDirectMatch.java new file mode 100644 index 00000000..0d9ba05a --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemDirectMatch.java @@ -0,0 +1,584 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemDirectMatch + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemDirectMatch { + /** + * Filesystem category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + DIR_READ("dir-read"), + + DIR_WRITE("dir-write"), + + ENVIRONMENT("environment"), + + FILE_DELETE("file-delete"), + + FILE_OPEN("file-open"), + + FILE_PERMS("file-perms"), + + FILE_READ("file-read"), + + FILE_STAT("file-stat"), + + FILE_WRITE("file-write"), + + MODULE("module"), + + PATH_WRITE("path-write"), + + PROCESS("process"), + + REGISTRY_READ("registry-read"), + + REGISTRY_WRITE("registry-write"), + + SERVICE("service"), + + SYSTEM("system"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + API("api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + /** + * Filesystem source the match belongs to + */ + @JsonAdapter(SourceEnum.Adapter.class) + public enum SourceEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceEnum fromValue(String value) { + for (SourceEnum b : SourceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nonnull + private SourceEnum source; + + public FilesystemDirectMatch() { + } + + public FilesystemDirectMatch category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Filesystem category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public FilesystemDirectMatch how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public FilesystemDirectMatch matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + + public FilesystemDirectMatch source(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + return this; + } + + /** + * Filesystem source the match belongs to + * @return source + */ + @javax.annotation.Nonnull + public SourceEnum getSource() { + return source; + } + + public void setSource(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemDirectMatch instance itself + */ + public FilesystemDirectMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemDirectMatch filesystemDirectMatch = (FilesystemDirectMatch) o; + return Objects.equals(this.category, filesystemDirectMatch.category) && + Objects.equals(this.how, filesystemDirectMatch.how) && + Objects.equals(this.matchedName, filesystemDirectMatch.matchedName) && + Objects.equals(this.source, filesystemDirectMatch.source)&& + Objects.equals(this.additionalProperties, filesystemDirectMatch.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, how, matchedName, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemDirectMatch {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("category", "how", "matched_name", "source")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("category", "how", "matched_name", "source")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemDirectMatch + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemDirectMatch.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemDirectMatch is not found in the empty JSON string", FilesystemDirectMatch.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemDirectMatch.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + // validate the required field `source` + SourceEnum.validateJsonElement(jsonObj.get("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemDirectMatch.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemDirectMatch' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemDirectMatch.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemDirectMatch value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemDirectMatch read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemDirectMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemDirectMatch given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemDirectMatch + * @throws IOException if the JSON string is invalid with respect to FilesystemDirectMatch + */ + public static FilesystemDirectMatch fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemDirectMatch.class); + } + + /** + * Convert an instance of FilesystemDirectMatch to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FilesystemExplainedFunction.java b/src/main/java/ai/reveng/model/FilesystemExplainedFunction.java new file mode 100644 index 00000000..24e8b676 --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemExplainedFunction.java @@ -0,0 +1,344 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemExplainedFunction + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemExplainedFunction { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public FilesystemExplainedFunction() { + } + + public FilesystemExplainedFunction description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * Role this function plays in the filesystem access + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public FilesystemExplainedFunction functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public FilesystemExplainedFunction functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemExplainedFunction instance itself + */ + public FilesystemExplainedFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemExplainedFunction filesystemExplainedFunction = (FilesystemExplainedFunction) o; + return Objects.equals(this.description, filesystemExplainedFunction.description) && + Objects.equals(this.functionId, filesystemExplainedFunction.functionId) && + Objects.equals(this.functionName, filesystemExplainedFunction.functionName)&& + Objects.equals(this.additionalProperties, filesystemExplainedFunction.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(description, functionId, functionName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemExplainedFunction {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemExplainedFunction + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemExplainedFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemExplainedFunction is not found in the empty JSON string", FilesystemExplainedFunction.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemExplainedFunction.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemExplainedFunction.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemExplainedFunction' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemExplainedFunction.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemExplainedFunction value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemExplainedFunction read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemExplainedFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemExplainedFunction given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemExplainedFunction + * @throws IOException if the JSON string is invalid with respect to FilesystemExplainedFunction + */ + public static FilesystemExplainedFunction fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemExplainedFunction.class); + } + + /** + * Convert an instance of FilesystemExplainedFunction to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FilesystemFinding.java b/src/main/java/ai/reveng/model/FilesystemFinding.java new file mode 100644 index 00000000..8c8d4929 --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemFinding.java @@ -0,0 +1,825 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.FilesystemCall; +import ai.reveng.model.FilesystemDirectMatch; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemFinding + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemFinding { + public static final String SERIALIZED_NAME_ADDRESS = "address"; + @SerializedName(SERIALIZED_NAME_ADDRESS) + @javax.annotation.Nonnull + private String address; + + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + DIR_READ("dir-read"), + + DIR_WRITE("dir-write"), + + ENVIRONMENT("environment"), + + FILE_DELETE("file-delete"), + + FILE_OPEN("file-open"), + + FILE_PERMS("file-perms"), + + FILE_READ("file-read"), + + FILE_STAT("file-stat"), + + FILE_WRITE("file-write"), + + MODULE("module"), + + PATH_WRITE("path-write"), + + PROCESS("process"), + + REGISTRY_READ("registry-read"), + + REGISTRY_WRITE("registry-write"), + + SERVICE("service"), + + SYSTEM("system"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + /** + * High when a direct name match was found, medium when the function only calls into filesystem APIs + */ + @JsonAdapter(ConfidenceEnum.Adapter.class) + public enum ConfidenceEnum { + HIGH("high"), + + MEDIUM("medium"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ConfidenceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ConfidenceEnum fromValue(String value) { + for (ConfidenceEnum b : ConfidenceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ConfidenceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ConfidenceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ConfidenceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ConfidenceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CONFIDENCE = "confidence"; + @SerializedName(SERIALIZED_NAME_CONFIDENCE) + @javax.annotation.Nonnull + private ConfidenceEnum confidence; + + public static final String SERIALIZED_NAME_DIRECT_MATCHES = "direct_matches"; + @SerializedName(SERIALIZED_NAME_DIRECT_MATCHES) + @javax.annotation.Nullable + private List directMatches; + + public static final String SERIALIZED_NAME_EVIDENCE_COUNT = "evidence_count"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_COUNT) + @javax.annotation.Nonnull + private Long evidenceCount; + + public static final String SERIALIZED_NAME_FILESYSTEM_CALLS = "filesystem_calls"; + @SerializedName(SERIALIZED_NAME_FILESYSTEM_CALLS) + @javax.annotation.Nullable + private List filesystemCalls; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTION_SIZE = "function_size"; + @SerializedName(SERIALIZED_NAME_FUNCTION_SIZE) + @javax.annotation.Nonnull + private Long functionSize; + + public static final String SERIALIZED_NAME_MODIFIES = "modifies"; + @SerializedName(SERIALIZED_NAME_MODIFIES) + @javax.annotation.Nonnull + private Boolean modifies; + + /** + * Gets or Sets sources + */ + @JsonAdapter(SourcesEnum.Adapter.class) + public enum SourcesEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourcesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourcesEnum fromValue(String value) { + for (SourcesEnum b : SourcesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourcesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourcesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourcesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourcesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCES = "sources"; + @SerializedName(SERIALIZED_NAME_SOURCES) + @javax.annotation.Nullable + private List sources; + + public FilesystemFinding() { + } + + public FilesystemFinding address(@javax.annotation.Nonnull String address) { + this.address = address; + return this; + } + + /** + * Function's virtual address, hex-encoded + * @return address + */ + @javax.annotation.Nonnull + public String getAddress() { + return address; + } + + public void setAddress(@javax.annotation.Nonnull String address) { + this.address = address; + } + + + public FilesystemFinding categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public FilesystemFinding addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Distinct filesystem categories evidenced by this function + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public FilesystemFinding confidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + return this; + } + + /** + * High when a direct name match was found, medium when the function only calls into filesystem APIs + * @return confidence + */ + @javax.annotation.Nonnull + public ConfidenceEnum getConfidence() { + return confidence; + } + + public void setConfidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + } + + + public FilesystemFinding directMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + return this; + } + + public FilesystemFinding addDirectMatchesItem(FilesystemDirectMatch directMatchesItem) { + if (this.directMatches == null) { + this.directMatches = new ArrayList<>(); + } + this.directMatches.add(directMatchesItem); + return this; + } + + /** + * Matches against the function's own name + * @return directMatches + */ + @javax.annotation.Nullable + public List getDirectMatches() { + return directMatches; + } + + public void setDirectMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + } + + + public FilesystemFinding evidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + return this; + } + + /** + * Total number of direct matches and filesystem calls + * @return evidenceCount + */ + @javax.annotation.Nonnull + public Long getEvidenceCount() { + return evidenceCount; + } + + public void setEvidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + } + + + public FilesystemFinding filesystemCalls(@javax.annotation.Nullable List filesystemCalls) { + this.filesystemCalls = filesystemCalls; + return this; + } + + public FilesystemFinding addFilesystemCallsItem(FilesystemCall filesystemCallsItem) { + if (this.filesystemCalls == null) { + this.filesystemCalls = new ArrayList<>(); + } + this.filesystemCalls.add(filesystemCallsItem); + return this; + } + + /** + * Matches against names this function calls + * @return filesystemCalls + */ + @javax.annotation.Nullable + public List getFilesystemCalls() { + return filesystemCalls; + } + + public void setFilesystemCalls(@javax.annotation.Nullable List filesystemCalls) { + this.filesystemCalls = filesystemCalls; + } + + + public FilesystemFinding functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function the finding was reported in + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public FilesystemFinding functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function the finding was reported in + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + + public FilesystemFinding functionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + return this; + } + + /** + * Size of the function in bytes + * @return functionSize + */ + @javax.annotation.Nonnull + public Long getFunctionSize() { + return functionSize; + } + + public void setFunctionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + } + + + public FilesystemFinding modifies(@javax.annotation.Nonnull Boolean modifies) { + this.modifies = modifies; + return this; + } + + /** + * Whether this function evidences modifying the filesystem rather than only observing it + * @return modifies + */ + @javax.annotation.Nonnull + public Boolean getModifies() { + return modifies; + } + + public void setModifies(@javax.annotation.Nonnull Boolean modifies) { + this.modifies = modifies; + } + + + public FilesystemFinding sources(@javax.annotation.Nullable List sources) { + this.sources = sources; + return this; + } + + public FilesystemFinding addSourcesItem(SourcesEnum sourcesItem) { + if (this.sources == null) { + this.sources = new ArrayList<>(); + } + this.sources.add(sourcesItem); + return this; + } + + /** + * Distinct filesystem sources evidenced by this function + * @return sources + */ + @javax.annotation.Nullable + public List getSources() { + return sources; + } + + public void setSources(@javax.annotation.Nullable List sources) { + this.sources = sources; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemFinding instance itself + */ + public FilesystemFinding putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemFinding filesystemFinding = (FilesystemFinding) o; + return Objects.equals(this.address, filesystemFinding.address) && + Objects.equals(this.categories, filesystemFinding.categories) && + Objects.equals(this.confidence, filesystemFinding.confidence) && + Objects.equals(this.directMatches, filesystemFinding.directMatches) && + Objects.equals(this.evidenceCount, filesystemFinding.evidenceCount) && + Objects.equals(this.filesystemCalls, filesystemFinding.filesystemCalls) && + Objects.equals(this.functionId, filesystemFinding.functionId) && + Objects.equals(this.functionName, filesystemFinding.functionName) && + Objects.equals(this.functionSize, filesystemFinding.functionSize) && + Objects.equals(this.modifies, filesystemFinding.modifies) && + Objects.equals(this.sources, filesystemFinding.sources)&& + Objects.equals(this.additionalProperties, filesystemFinding.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(address, categories, confidence, directMatches, evidenceCount, filesystemCalls, functionId, functionName, functionSize, modifies, sources, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemFinding {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" directMatches: ").append(toIndentedString(directMatches)).append("\n"); + sb.append(" evidenceCount: ").append(toIndentedString(evidenceCount)).append("\n"); + sb.append(" filesystemCalls: ").append(toIndentedString(filesystemCalls)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionSize: ").append(toIndentedString(functionSize)).append("\n"); + sb.append(" modifies: ").append(toIndentedString(modifies)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("address", "categories", "confidence", "direct_matches", "evidence_count", "filesystem_calls", "function_id", "function_name", "function_size", "modifies", "sources")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("address", "categories", "confidence", "evidence_count", "function_id", "function_name", "function_size", "modifies", "sources")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemFinding + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemFinding.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemFinding is not found in the empty JSON string", FilesystemFinding.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemFinding.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("address").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); + } + // ensure the required json array is present + if (jsonObj.get("categories") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("categories").isJsonArray() && !jsonObj.get("categories").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + if (!jsonObj.get("confidence").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidence` to be a primitive type in the JSON string but got `%s`", jsonObj.get("confidence").toString())); + } + // validate the required field `confidence` + ConfidenceEnum.validateJsonElement(jsonObj.get("confidence")); + // ensure the optional json data is an array if present + if (jsonObj.get("direct_matches") != null && !jsonObj.get("direct_matches").isJsonNull() && !jsonObj.get("direct_matches").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `direct_matches` to be an array in the JSON string but got `%s`", jsonObj.get("direct_matches").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("filesystem_calls") != null && !jsonObj.get("filesystem_calls").isJsonNull() && !jsonObj.get("filesystem_calls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filesystem_calls` to be an array in the JSON string but got `%s`", jsonObj.get("filesystem_calls").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the required json array is present + if (jsonObj.get("sources") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("sources").isJsonArray() && !jsonObj.get("sources").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sources` to be an array in the JSON string but got `%s`", jsonObj.get("sources").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemFinding.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemFinding' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemFinding.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemFinding value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemFinding read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemFinding instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemFinding given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemFinding + * @throws IOException if the JSON string is invalid with respect to FilesystemFinding + */ + public static FilesystemFinding fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemFinding.class); + } + + /** + * Convert an instance of FilesystemFinding to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FilesystemScanMetadata.java b/src/main/java/ai/reveng/model/FilesystemScanMetadata.java new file mode 100644 index 00000000..c101e7db --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemScanMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemScanMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemScanMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public FilesystemScanMetadata() { + } + + public FilesystemScanMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public FilesystemScanMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public FilesystemScanMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemScanMetadata instance itself + */ + public FilesystemScanMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemScanMetadata filesystemScanMetadata = (FilesystemScanMetadata) o; + return Objects.equals(this.logHistory, filesystemScanMetadata.logHistory) && + Objects.equals(this.status, filesystemScanMetadata.status)&& + Objects.equals(this.additionalProperties, filesystemScanMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemScanMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemScanMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemScanMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemScanMetadata is not found in the empty JSON string", FilesystemScanMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemScanMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemScanMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemScanMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemScanMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemScanMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemScanMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemScanMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemScanMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemScanMetadata + * @throws IOException if the JSON string is invalid with respect to FilesystemScanMetadata + */ + public static FilesystemScanMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemScanMetadata.class); + } + + /** + * Convert an instance of FilesystemScanMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FilesystemScanResult.java b/src/main/java/ai/reveng/model/FilesystemScanResult.java new file mode 100644 index 00000000..2b96ba67 --- /dev/null +++ b/src/main/java/ai/reveng/model/FilesystemScanResult.java @@ -0,0 +1,365 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.FilesystemFinding; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FilesystemScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FilesystemScanResult { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_FINDINGS = "findings"; + @SerializedName(SERIALIZED_NAME_FINDINGS) + @javax.annotation.Nullable + private List findings; + + public static final String SERIALIZED_NAME_TOTAL_FUNCTIONS = "total_functions"; + @SerializedName(SERIALIZED_NAME_TOTAL_FUNCTIONS) + @javax.annotation.Nonnull + private Long totalFunctions; + + public FilesystemScanResult() { + } + + public FilesystemScanResult analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Analysis the run was performed against + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public FilesystemScanResult findings(@javax.annotation.Nullable List findings) { + this.findings = findings; + return this; + } + + public FilesystemScanResult addFindingsItem(FilesystemFinding findingsItem) { + if (this.findings == null) { + this.findings = new ArrayList<>(); + } + this.findings.add(findingsItem); + return this; + } + + /** + * Functions with filesystem-related evidence, sorted by whether they modify the filesystem, then confidence, then evidence count + * @return findings + */ + @javax.annotation.Nullable + public List getFindings() { + return findings; + } + + public void setFindings(@javax.annotation.Nullable List findings) { + this.findings = findings; + } + + + public FilesystemScanResult totalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + return this; + } + + /** + * Functions the run considered + * @return totalFunctions + */ + @javax.annotation.Nonnull + public Long getTotalFunctions() { + return totalFunctions; + } + + public void setTotalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FilesystemScanResult instance itself + */ + public FilesystemScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilesystemScanResult filesystemScanResult = (FilesystemScanResult) o; + return Objects.equals(this.analysisId, filesystemScanResult.analysisId) && + Objects.equals(this.findings, filesystemScanResult.findings) && + Objects.equals(this.totalFunctions, filesystemScanResult.totalFunctions)&& + Objects.equals(this.additionalProperties, filesystemScanResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, findings, totalFunctions, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilesystemScanResult {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" findings: ").append(toIndentedString(findings)).append("\n"); + sb.append(" totalFunctions: ").append(toIndentedString(totalFunctions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "findings", "total_functions")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "total_functions")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FilesystemScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FilesystemScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FilesystemScanResult is not found in the empty JSON string", FilesystemScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FilesystemScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("findings") != null && !jsonObj.get("findings").isJsonNull() && !jsonObj.get("findings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `findings` to be an array in the JSON string but got `%s`", jsonObj.get("findings").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FilesystemScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FilesystemScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FilesystemScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FilesystemScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FilesystemScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FilesystemScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FilesystemScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of FilesystemScanResult + * @throws IOException if the JSON string is invalid with respect to FilesystemScanResult + */ + public static FilesystemScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FilesystemScanResult.class); + } + + /** + * Convert an instance of FilesystemScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Finding.java b/src/main/java/ai/reveng/model/Finding.java new file mode 100644 index 00000000..757a1fe8 --- /dev/null +++ b/src/main/java/ai/reveng/model/Finding.java @@ -0,0 +1,364 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceInner; +import ai.reveng.model.ReportReachabilityStatus; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Finding + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Finding { + public static final String SERIALIZED_NAME_PROPERTY_ID = "property_id"; + @SerializedName(SERIALIZED_NAME_PROPERTY_ID) + @javax.annotation.Nullable + private String propertyId = ""; + + public static final String SERIALIZED_NAME_REACHABILITY = "reachability"; + @SerializedName(SERIALIZED_NAME_REACHABILITY) + @javax.annotation.Nullable + private ReportReachabilityStatus reachability = ReportReachabilityStatus.UNDETERMINED; + + public static final String SERIALIZED_NAME_EVIDENCE = "evidence"; + @SerializedName(SERIALIZED_NAME_EVIDENCE) + @javax.annotation.Nullable + private List evidence = new ArrayList<>(); + + public Finding() { + } + + public Finding propertyId(@javax.annotation.Nullable String propertyId) { + this.propertyId = propertyId; + return this; + } + + /** + * Get propertyId + * @return propertyId + */ + @javax.annotation.Nullable + public String getPropertyId() { + return propertyId; + } + + public void setPropertyId(@javax.annotation.Nullable String propertyId) { + this.propertyId = propertyId; + } + + + public Finding reachability(@javax.annotation.Nullable ReportReachabilityStatus reachability) { + this.reachability = reachability; + return this; + } + + /** + * Get reachability + * @return reachability + */ + @javax.annotation.Nullable + public ReportReachabilityStatus getReachability() { + return reachability; + } + + public void setReachability(@javax.annotation.Nullable ReportReachabilityStatus reachability) { + this.reachability = reachability; + } + + + public Finding evidence(@javax.annotation.Nullable List evidence) { + this.evidence = evidence; + return this; + } + + public Finding addEvidenceItem(EvidenceInner evidenceItem) { + if (this.evidence == null) { + this.evidence = new ArrayList<>(); + } + this.evidence.add(evidenceItem); + return this; + } + + /** + * Get evidence + * @return evidence + */ + @javax.annotation.Nullable + public List getEvidence() { + return evidence; + } + + public void setEvidence(@javax.annotation.Nullable List evidence) { + this.evidence = evidence; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Finding instance itself + */ + public Finding putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Finding finding = (Finding) o; + return Objects.equals(this.propertyId, finding.propertyId) && + Objects.equals(this.reachability, finding.reachability) && + Objects.equals(this.evidence, finding.evidence)&& + Objects.equals(this.additionalProperties, finding.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(propertyId, reachability, evidence, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Finding {\n"); + sb.append(" propertyId: ").append(toIndentedString(propertyId)).append("\n"); + sb.append(" reachability: ").append(toIndentedString(reachability)).append("\n"); + sb.append(" evidence: ").append(toIndentedString(evidence)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("property_id", "reachability", "evidence")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Finding + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Finding.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Finding is not found in the empty JSON string", Finding.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("property_id") != null && !jsonObj.get("property_id").isJsonNull()) && !jsonObj.get("property_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `property_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("property_id").toString())); + } + // validate the optional field `reachability` + if (jsonObj.get("reachability") != null && !jsonObj.get("reachability").isJsonNull()) { + ReportReachabilityStatus.validateJsonElement(jsonObj.get("reachability")); + } + if (jsonObj.get("evidence") != null && !jsonObj.get("evidence").isJsonNull()) { + JsonArray jsonArrayevidence = jsonObj.getAsJsonArray("evidence"); + if (jsonArrayevidence != null) { + // ensure the json data is an array + if (!jsonObj.get("evidence").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence` to be an array in the JSON string but got `%s`", jsonObj.get("evidence").toString())); + } + + // validate the optional field `evidence` (array) + for (int i = 0; i < jsonArrayevidence.size(); i++) { + EvidenceInner.validateJsonElement(jsonArrayevidence.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Finding.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Finding' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Finding.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Finding value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Finding read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Finding instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Finding given an JSON string + * + * @param jsonString JSON string + * @return An instance of Finding + * @throws IOException if the JSON string is invalid with respect to Finding + */ + public static Finding fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Finding.class); + } + + /** + * Convert an instance of Finding to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FunctionBoundary.java b/src/main/java/ai/reveng/model/FunctionBoundary.java index 5e3d2f94..30eafd9e 100644 --- a/src/main/java/ai/reveng/model/FunctionBoundary.java +++ b/src/main/java/ai/reveng/model/FunctionBoundary.java @@ -20,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -50,16 +49,6 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class FunctionBoundary { - public static final String SERIALIZED_NAME_MANGLED_NAME = "mangled_name"; - @SerializedName(SERIALIZED_NAME_MANGLED_NAME) - @javax.annotation.Nonnull - private String mangledName; - - public static final String SERIALIZED_NAME_START_ADDRESS = "start_address"; - @SerializedName(SERIALIZED_NAME_START_ADDRESS) - @javax.annotation.Nonnull - private Long startAddress; - public static final String SERIALIZED_NAME_END_ADDRESS = "end_address"; @SerializedName(SERIALIZED_NAME_END_ADDRESS) @javax.annotation.Nonnull @@ -70,82 +59,94 @@ public class FunctionBoundary { @javax.annotation.Nullable private Boolean includeInAnalysis; + public static final String SERIALIZED_NAME_MANGLED_NAME = "mangled_name"; + @SerializedName(SERIALIZED_NAME_MANGLED_NAME) + @javax.annotation.Nonnull + private String mangledName; + + public static final String SERIALIZED_NAME_START_ADDRESS = "start_address"; + @SerializedName(SERIALIZED_NAME_START_ADDRESS) + @javax.annotation.Nonnull + private Long startAddress; + public FunctionBoundary() { } - public FunctionBoundary mangledName(@javax.annotation.Nonnull String mangledName) { - this.mangledName = mangledName; + public FunctionBoundary endAddress(@javax.annotation.Nonnull Long endAddress) { + this.endAddress = endAddress; return this; } /** - * Get mangledName - * @return mangledName + * Get endAddress + * minimum: 0 + * @return endAddress */ @javax.annotation.Nonnull - public String getMangledName() { - return mangledName; + public Long getEndAddress() { + return endAddress; } - public void setMangledName(@javax.annotation.Nonnull String mangledName) { - this.mangledName = mangledName; + public void setEndAddress(@javax.annotation.Nonnull Long endAddress) { + this.endAddress = endAddress; } - public FunctionBoundary startAddress(@javax.annotation.Nonnull Long startAddress) { - this.startAddress = startAddress; + public FunctionBoundary includeInAnalysis(@javax.annotation.Nullable Boolean includeInAnalysis) { + this.includeInAnalysis = includeInAnalysis; return this; } /** - * Get startAddress - * @return startAddress + * Get includeInAnalysis + * @return includeInAnalysis */ - @javax.annotation.Nonnull - public Long getStartAddress() { - return startAddress; + @javax.annotation.Nullable + public Boolean getIncludeInAnalysis() { + return includeInAnalysis; } - public void setStartAddress(@javax.annotation.Nonnull Long startAddress) { - this.startAddress = startAddress; + public void setIncludeInAnalysis(@javax.annotation.Nullable Boolean includeInAnalysis) { + this.includeInAnalysis = includeInAnalysis; } - public FunctionBoundary endAddress(@javax.annotation.Nonnull Long endAddress) { - this.endAddress = endAddress; + public FunctionBoundary mangledName(@javax.annotation.Nonnull String mangledName) { + this.mangledName = mangledName; return this; } /** - * Get endAddress - * @return endAddress + * Get mangledName + * @return mangledName */ @javax.annotation.Nonnull - public Long getEndAddress() { - return endAddress; + public String getMangledName() { + return mangledName; } - public void setEndAddress(@javax.annotation.Nonnull Long endAddress) { - this.endAddress = endAddress; + public void setMangledName(@javax.annotation.Nonnull String mangledName) { + this.mangledName = mangledName; } - public FunctionBoundary includeInAnalysis(@javax.annotation.Nullable Boolean includeInAnalysis) { - this.includeInAnalysis = includeInAnalysis; + public FunctionBoundary startAddress(@javax.annotation.Nonnull Long startAddress) { + this.startAddress = startAddress; return this; } /** - * Indicates whether the function should be included in the analysis - * @return includeInAnalysis + * Get startAddress + * minimum: 0 + * @return startAddress */ - @javax.annotation.Nullable - public Boolean getIncludeInAnalysis() { - return includeInAnalysis; + @javax.annotation.Nonnull + public Long getStartAddress() { + return startAddress; } - public void setIncludeInAnalysis(@javax.annotation.Nullable Boolean includeInAnalysis) { - this.includeInAnalysis = includeInAnalysis; + public void setStartAddress(@javax.annotation.Nonnull Long startAddress) { + this.startAddress = startAddress; } /** @@ -203,37 +204,26 @@ public boolean equals(Object o) { return false; } FunctionBoundary functionBoundary = (FunctionBoundary) o; - return Objects.equals(this.mangledName, functionBoundary.mangledName) && - Objects.equals(this.startAddress, functionBoundary.startAddress) && - Objects.equals(this.endAddress, functionBoundary.endAddress) && - Objects.equals(this.includeInAnalysis, functionBoundary.includeInAnalysis)&& + return Objects.equals(this.endAddress, functionBoundary.endAddress) && + Objects.equals(this.includeInAnalysis, functionBoundary.includeInAnalysis) && + Objects.equals(this.mangledName, functionBoundary.mangledName) && + Objects.equals(this.startAddress, functionBoundary.startAddress)&& Objects.equals(this.additionalProperties, functionBoundary.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - @Override public int hashCode() { - return Objects.hash(mangledName, startAddress, endAddress, includeInAnalysis, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(endAddress, includeInAnalysis, mangledName, startAddress, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FunctionBoundary {\n"); - sb.append(" mangledName: ").append(toIndentedString(mangledName)).append("\n"); - sb.append(" startAddress: ").append(toIndentedString(startAddress)).append("\n"); sb.append(" endAddress: ").append(toIndentedString(endAddress)).append("\n"); sb.append(" includeInAnalysis: ").append(toIndentedString(includeInAnalysis)).append("\n"); + sb.append(" mangledName: ").append(toIndentedString(mangledName)).append("\n"); + sb.append(" startAddress: ").append(toIndentedString(startAddress)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -253,10 +243,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("mangled_name", "start_address", "end_address", "include_in_analysis")); + openapiFields = new HashSet(Arrays.asList("end_address", "include_in_analysis", "mangled_name", "start_address")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("mangled_name", "start_address", "end_address")); + openapiRequiredFields = new HashSet(Arrays.asList("end_address", "mangled_name", "start_address")); } /** diff --git a/src/main/java/ai/reveng/model/FunctionCallEdges.java b/src/main/java/ai/reveng/model/FunctionCallEdges.java index 8d6f28e4..1cebd2c6 100644 --- a/src/main/java/ai/reveng/model/FunctionCallEdges.java +++ b/src/main/java/ai/reveng/model/FunctionCallEdges.java @@ -142,6 +142,50 @@ public void setFunctionId(@javax.annotation.Nonnull Long functionId) { this.functionId = functionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionCallEdges instance itself + */ + public FunctionCallEdges putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -155,12 +199,13 @@ public boolean equals(Object o) { FunctionCallEdges functionCallEdges = (FunctionCallEdges) o; return Objects.equals(this.callees, functionCallEdges.callees) && Objects.equals(this.callers, functionCallEdges.callers) && - Objects.equals(this.functionId, functionCallEdges.functionId); + Objects.equals(this.functionId, functionCallEdges.functionId)&& + Objects.equals(this.additionalProperties, functionCallEdges.additionalProperties); } @Override public int hashCode() { - return Objects.hash(callees, callers, functionId); + return Objects.hash(callees, callers, functionId, additionalProperties); } @Override @@ -170,6 +215,7 @@ public String toString() { sb.append(" callees: ").append(toIndentedString(callees)).append("\n"); sb.append(" callers: ").append(toIndentedString(callers)).append("\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -207,14 +253,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionCallEdges.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionCallEdges` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionCallEdges.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -222,25 +260,17 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("callees") != null && !jsonObj.get("callees").isJsonNull()) { - if (!jsonObj.get("callees").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callees` to be an array in the JSON string but got `%s`", jsonObj.get("callees").toString())); - } - JsonArray jsonArraycallees = jsonObj.getAsJsonArray("callees"); - // validate the required field `callees` (array) - for (int i = 0; i < jsonArraycallees.size(); i++) { - CallEdge.validateJsonElement(jsonArraycallees.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("callees") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("callees").isJsonArray() && !jsonObj.get("callees").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callees` to be an array in the JSON string but got `%s`", jsonObj.get("callees").toString())); } - if (jsonObj.get("callers") != null && !jsonObj.get("callers").isJsonNull()) { - if (!jsonObj.get("callers").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callers` to be an array in the JSON string but got `%s`", jsonObj.get("callers").toString())); - } - JsonArray jsonArraycallers = jsonObj.getAsJsonArray("callers"); - // validate the required field `callers` (array) - for (int i = 0; i < jsonArraycallers.size(); i++) { - CallEdge.validateJsonElement(jsonArraycallers.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("callers") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("callers").isJsonArray() && !jsonObj.get("callers").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callers` to be an array in the JSON string but got `%s`", jsonObj.get("callers").toString())); } } @@ -259,6 +289,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionCallEdges value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -266,7 +318,28 @@ public void write(JsonWriter out, FunctionCallEdges value) throws IOException { public FunctionCallEdges read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionCallEdges instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionDataType.java b/src/main/java/ai/reveng/model/FunctionDataType.java index bf243d14..6c9343ca 100644 --- a/src/main/java/ai/reveng/model/FunctionDataType.java +++ b/src/main/java/ai/reveng/model/FunctionDataType.java @@ -143,6 +143,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -366,6 +371,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public FunctionDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public FunctionDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -403,6 +427,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionDataType instance itself + */ + public FunctionDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -422,13 +490,15 @@ public boolean equals(Object o) { Objects.equals(this.name, functionDataType.name) && Objects.equals(this.namespace, functionDataType.namespace) && Objects.equals(this.size, functionDataType.size) && + Objects.equals(this.sourceAnalysisId, functionDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, functionDataType.sourceFunctionId) && - Objects.equals(this.sourceType, functionDataType.sourceType); + Objects.equals(this.sourceType, functionDataType.sourceType)&& + Objects.equals(this.additionalProperties, functionDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -443,8 +513,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -463,7 +535,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -482,14 +554,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -497,10 +561,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `definition` - if (jsonObj.get("definition") != null && !jsonObj.get("definition").isJsonNull()) { - FunctionTypeDefinition.validateJsonElement(jsonObj.get("definition")); - } if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -534,6 +594,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -541,7 +623,28 @@ public void write(JsonWriter out, FunctionDataType value) throws IOException { public FunctionDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionDetailsOutputBody.java b/src/main/java/ai/reveng/model/FunctionDetailsOutputBody.java index fbd830ef..5e4d6bdd 100644 --- a/src/main/java/ai/reveng/model/FunctionDetailsOutputBody.java +++ b/src/main/java/ai/reveng/model/FunctionDetailsOutputBody.java @@ -292,6 +292,50 @@ public void setSourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId this.sourceFunctionId = sourceFunctionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionDetailsOutputBody instance itself + */ + public FunctionDetailsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -312,12 +356,13 @@ public boolean equals(Object o) { Objects.equals(this.functionSize, functionDetailsOutputBody.functionSize) && Objects.equals(this.functionVaddr, functionDetailsOutputBody.functionVaddr) && Objects.equals(this.mangledName, functionDetailsOutputBody.mangledName) && - Objects.equals(this.sourceFunctionId, functionDetailsOutputBody.sourceFunctionId); + Objects.equals(this.sourceFunctionId, functionDetailsOutputBody.sourceFunctionId)&& + Objects.equals(this.additionalProperties, functionDetailsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, binaryId, creation, debug, functionId, functionName, functionSize, functionVaddr, mangledName, sourceFunctionId); + return Objects.hash(analysisId, binaryId, creation, debug, functionId, functionName, functionSize, functionVaddr, mangledName, sourceFunctionId, additionalProperties); } @Override @@ -334,6 +379,7 @@ public String toString() { sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); sb.append(" mangledName: ").append(toIndentedString(mangledName)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -371,14 +417,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionDetailsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionDetailsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDetailsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -409,6 +447,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionDetailsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -416,7 +476,28 @@ public void write(JsonWriter out, FunctionDetailsOutputBody value) throws IOExce public FunctionDetailsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionDetailsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionMatch.java b/src/main/java/ai/reveng/model/FunctionMatch.java index 61643554..b2f6b498 100644 --- a/src/main/java/ai/reveng/model/FunctionMatch.java +++ b/src/main/java/ai/reveng/model/FunctionMatch.java @@ -144,6 +144,50 @@ public void setMatchedFunctions(@javax.annotation.Nullable List this.matchedFunctions = matchedFunctions; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionMatch instance itself + */ + public FunctionMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -157,7 +201,8 @@ public boolean equals(Object o) { FunctionMatch functionMatch = (FunctionMatch) o; return Objects.equals(this.confidences, functionMatch.confidences) && Objects.equals(this.functionId, functionMatch.functionId) && - Objects.equals(this.matchedFunctions, functionMatch.matchedFunctions); + Objects.equals(this.matchedFunctions, functionMatch.matchedFunctions)&& + Objects.equals(this.additionalProperties, functionMatch.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -166,7 +211,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(confidences, functionId, matchedFunctions); + return Objects.hash(confidences, functionId, matchedFunctions, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -183,6 +228,7 @@ public String toString() { sb.append(" confidences: ").append(toIndentedString(confidences)).append("\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" matchedFunctions: ").append(toIndentedString(matchedFunctions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -220,14 +266,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionMatch.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionMatch` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMatch.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -235,29 +273,15 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("confidences") != null && !jsonObj.get("confidences").isJsonNull()) { - JsonArray jsonArrayconfidences = jsonObj.getAsJsonArray("confidences"); - if (jsonArrayconfidences != null) { - // ensure the json data is an array - if (!jsonObj.get("confidences").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidences` to be an array in the JSON string but got `%s`", jsonObj.get("confidences").toString())); - } - - // validate the optional field `confidences` (array) - for (int i = 0; i < jsonArrayconfidences.size(); i++) { - NameConfidence.validateJsonElement(jsonArrayconfidences.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("confidences") != null && !jsonObj.get("confidences").isJsonNull() && !jsonObj.get("confidences").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidences` to be an array in the JSON string but got `%s`", jsonObj.get("confidences").toString())); } - if (jsonObj.get("matched_functions") != null && !jsonObj.get("matched_functions").isJsonNull()) { - if (!jsonObj.get("matched_functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_functions` to be an array in the JSON string but got `%s`", jsonObj.get("matched_functions").toString())); - } - JsonArray jsonArraymatchedFunctions = jsonObj.getAsJsonArray("matched_functions"); - // validate the required field `matched_functions` (array) - for (int i = 0; i < jsonArraymatchedFunctions.size(); i++) { - MatchedFunction.validateJsonElement(jsonArraymatchedFunctions.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("matched_functions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("matched_functions").isJsonArray() && !jsonObj.get("matched_functions").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_functions` to be an array in the JSON string but got `%s`", jsonObj.get("matched_functions").toString())); } } @@ -276,6 +300,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionMatch value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -283,7 +329,28 @@ public void write(JsonWriter out, FunctionMatch value) throws IOException { public FunctionMatch read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionSignatureBody.java b/src/main/java/ai/reveng/model/FunctionSignatureBody.java index ed1e5e3c..eb3ac889 100644 --- a/src/main/java/ai/reveng/model/FunctionSignatureBody.java +++ b/src/main/java/ai/reveng/model/FunctionSignatureBody.java @@ -532,15 +532,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("function_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } - if (jsonObj.get("parameters") != null && !jsonObj.get("parameters").isJsonNull()) { - if (!jsonObj.get("parameters").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); - } - JsonArray jsonArrayparameters = jsonObj.getAsJsonArray("parameters"); - // validate the required field `parameters` (array) - for (int i = 0; i < jsonArrayparameters.size(); i++) { - SignatureParameterEntry.validateJsonElement(jsonArrayparameters.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("parameters") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("parameters").isJsonArray() && !jsonObj.get("parameters").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); } if ((jsonObj.get("source_type") != null && !jsonObj.get("source_type").isJsonNull()) && !jsonObj.get("source_type").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_type").toString())); diff --git a/src/main/java/ai/reveng/model/FunctionSignatureEntry.java b/src/main/java/ai/reveng/model/FunctionSignatureEntry.java index ecb005a6..fafb683d 100644 --- a/src/main/java/ai/reveng/model/FunctionSignatureEntry.java +++ b/src/main/java/ai/reveng/model/FunctionSignatureEntry.java @@ -335,6 +335,50 @@ public void setSourceType(@javax.annotation.Nullable SourceTypeEnum sourceType) this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionSignatureEntry instance itself + */ + public FunctionSignatureEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -354,12 +398,13 @@ public boolean equals(Object o) { Objects.equals(this.parameters, functionSignatureEntry.parameters) && Objects.equals(this.returnDataTypeId, functionSignatureEntry.returnDataTypeId) && Objects.equals(this.sourceFunctionId, functionSignatureEntry.sourceFunctionId) && - Objects.equals(this.sourceType, functionSignatureEntry.sourceType); + Objects.equals(this.sourceType, functionSignatureEntry.sourceType)&& + Objects.equals(this.additionalProperties, functionSignatureEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(callingConvention, createdAt, functionId, functionName, hasSignature, parameters, returnDataTypeId, sourceFunctionId, sourceType); + return Objects.hash(callingConvention, createdAt, functionId, functionName, hasSignature, parameters, returnDataTypeId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -375,6 +420,7 @@ public String toString() { sb.append(" returnDataTypeId: ").append(toIndentedString(returnDataTypeId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -412,14 +458,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionSignatureEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionSignatureEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionSignatureEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -433,15 +471,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("function_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } - if (jsonObj.get("parameters") != null && !jsonObj.get("parameters").isJsonNull()) { - if (!jsonObj.get("parameters").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); - } - JsonArray jsonArrayparameters = jsonObj.getAsJsonArray("parameters"); - // validate the required field `parameters` (array) - for (int i = 0; i < jsonArrayparameters.size(); i++) { - SignatureParameterEntry.validateJsonElement(jsonArrayparameters.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("parameters") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("parameters").isJsonArray() && !jsonObj.get("parameters").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); } if ((jsonObj.get("source_type") != null && !jsonObj.get("source_type").isJsonNull()) && !jsonObj.get("source_type").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_type").toString())); @@ -467,6 +501,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionSignatureEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -474,7 +530,28 @@ public void write(JsonWriter out, FunctionSignatureEntry value) throws IOExcepti public FunctionSignatureEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionSignatureEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionSignatureVersion.java b/src/main/java/ai/reveng/model/FunctionSignatureVersion.java index 99dbaa7b..ade67809 100644 --- a/src/main/java/ai/reveng/model/FunctionSignatureVersion.java +++ b/src/main/java/ai/reveng/model/FunctionSignatureVersion.java @@ -126,6 +126,50 @@ public void setValue(@javax.annotation.Nonnull FunctionSignatureEntry value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionSignatureVersion instance itself + */ + public FunctionSignatureVersion putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -139,12 +183,13 @@ public boolean equals(Object o) { FunctionSignatureVersion functionSignatureVersion = (FunctionSignatureVersion) o; return Objects.equals(this.updatedAt, functionSignatureVersion.updatedAt) && Objects.equals(this.updatedBy, functionSignatureVersion.updatedBy) && - Objects.equals(this.value, functionSignatureVersion.value); + Objects.equals(this.value, functionSignatureVersion.value)&& + Objects.equals(this.additionalProperties, functionSignatureVersion.additionalProperties); } @Override public int hashCode() { - return Objects.hash(updatedAt, updatedBy, value); + return Objects.hash(updatedAt, updatedBy, value, additionalProperties); } @Override @@ -154,6 +199,7 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" updatedBy: ").append(toIndentedString(updatedBy)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -191,14 +237,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionSignatureVersion.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionSignatureVersion` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionSignatureVersion.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -206,12 +244,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `updated_by` - if (jsonObj.get("updated_by") != null && !jsonObj.get("updated_by").isJsonNull()) { - HistoryActor.validateJsonElement(jsonObj.get("updated_by")); - } - // validate the required field `value` - FunctionSignatureEntry.validateJsonElement(jsonObj.get("value")); } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -229,6 +261,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionSignatureVersion value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -236,7 +290,28 @@ public void write(JsonWriter out, FunctionSignatureVersion value) throws IOExcep public FunctionSignatureVersion read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionSignatureVersion instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionSimilarity.java b/src/main/java/ai/reveng/model/FunctionSimilarity.java new file mode 100644 index 00000000..ec45f781 --- /dev/null +++ b/src/main/java/ai/reveng/model/FunctionSimilarity.java @@ -0,0 +1,347 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Subject; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FunctionSimilarity + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FunctionSimilarity { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_SIMILARITY = "similarity"; + @SerializedName(SERIALIZED_NAME_SIMILARITY) + @javax.annotation.Nonnull + private BigDecimal similarity; + + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + @javax.annotation.Nonnull + private Subject subject; + + public FunctionSimilarity() { + } + + public FunctionSimilarity name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public FunctionSimilarity similarity(@javax.annotation.Nonnull BigDecimal similarity) { + this.similarity = similarity; + return this; + } + + /** + * Get similarity + * minimum: 0 + * maximum: 1 + * @return similarity + */ + @javax.annotation.Nonnull + public BigDecimal getSimilarity() { + return similarity; + } + + public void setSimilarity(@javax.annotation.Nonnull BigDecimal similarity) { + this.similarity = similarity; + } + + + public FunctionSimilarity subject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + return this; + } + + /** + * Get subject + * @return subject + */ + @javax.annotation.Nonnull + public Subject getSubject() { + return subject; + } + + public void setSubject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionSimilarity instance itself + */ + public FunctionSimilarity putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionSimilarity functionSimilarity = (FunctionSimilarity) o; + return Objects.equals(this.name, functionSimilarity.name) && + Objects.equals(this.similarity, functionSimilarity.similarity) && + Objects.equals(this.subject, functionSimilarity.subject)&& + Objects.equals(this.additionalProperties, functionSimilarity.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, similarity, subject, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FunctionSimilarity {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" similarity: ").append(toIndentedString(similarity)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("name", "similarity", "subject")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("name", "similarity", "subject")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FunctionSimilarity + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FunctionSimilarity.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionSimilarity is not found in the empty JSON string", FunctionSimilarity.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FunctionSimilarity.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `subject` + Subject.validateJsonElement(jsonObj.get("subject")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FunctionSimilarity.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FunctionSimilarity' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FunctionSimilarity.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FunctionSimilarity value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FunctionSimilarity read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionSimilarity instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FunctionSimilarity given an JSON string + * + * @param jsonString JSON string + * @return An instance of FunctionSimilarity + * @throws IOException if the JSON string is invalid with respect to FunctionSimilarity + */ + public static FunctionSimilarity fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FunctionSimilarity.class); + } + + /** + * Convert an instance of FunctionSimilarity to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FunctionSimilarityEvidence.java b/src/main/java/ai/reveng/model/FunctionSimilarityEvidence.java new file mode 100644 index 00000000..a0d2f856 --- /dev/null +++ b/src/main/java/ai/reveng/model/FunctionSimilarityEvidence.java @@ -0,0 +1,591 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceEffect; +import ai.reveng.model.FunctionSimilarity; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Function-similarity results suggestive of a capability. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FunctionSimilarityEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + FUNCTION_SIMILARITY("function_similarity"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.FUNCTION_SIMILARITY; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + INDIRECT("indirect"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.INDIRECT; + + public static final String SERIALIZED_NAME_SIMILARITIES = "similarities"; + @SerializedName(SERIALIZED_NAME_SIMILARITIES) + @javax.annotation.Nonnull + private List similarities = new ArrayList<>(); + + public FunctionSimilarityEvidence() { + } + + public FunctionSimilarityEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public FunctionSimilarityEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public FunctionSimilarityEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public FunctionSimilarityEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public FunctionSimilarityEvidence similarities(@javax.annotation.Nonnull List similarities) { + this.similarities = similarities; + return this; + } + + public FunctionSimilarityEvidence addSimilaritiesItem(FunctionSimilarity similaritiesItem) { + if (this.similarities == null) { + this.similarities = new ArrayList<>(); + } + this.similarities.add(similaritiesItem); + return this; + } + + /** + * Get similarities + * @return similarities + */ + @javax.annotation.Nonnull + public List getSimilarities() { + return similarities; + } + + public void setSimilarities(@javax.annotation.Nonnull List similarities) { + this.similarities = similarities; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionSimilarityEvidence instance itself + */ + public FunctionSimilarityEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionSimilarityEvidence functionSimilarityEvidence = (FunctionSimilarityEvidence) o; + return Objects.equals(this.evidenceKind, functionSimilarityEvidence.evidenceKind) && + Objects.equals(this.kind, functionSimilarityEvidence.kind) && + Objects.equals(this.effect, functionSimilarityEvidence.effect) && + Objects.equals(this.strength, functionSimilarityEvidence.strength) && + Objects.equals(this.similarities, functionSimilarityEvidence.similarities)&& + Objects.equals(this.additionalProperties, functionSimilarityEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, similarities, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FunctionSimilarityEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" similarities: ").append(toIndentedString(similarities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "similarities")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "similarities")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FunctionSimilarityEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FunctionSimilarityEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionSimilarityEvidence is not found in the empty JSON string", FunctionSimilarityEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FunctionSimilarityEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + if (jsonObj.get("similarities") != null) { + if (!jsonObj.get("similarities").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `similarities` to be an array in the JSON string but got `%s`", jsonObj.get("similarities").toString())); + } + JsonArray jsonArraysimilarities = jsonObj.getAsJsonArray("similarities"); + // validate the required field `similarities` (array) + for (int i = 0; i < jsonArraysimilarities.size(); i++) { + FunctionSimilarity.validateJsonElement(jsonArraysimilarities.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FunctionSimilarityEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FunctionSimilarityEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FunctionSimilarityEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FunctionSimilarityEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FunctionSimilarityEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionSimilarityEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FunctionSimilarityEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of FunctionSimilarityEvidence + * @throws IOException if the JSON string is invalid with respect to FunctionSimilarityEvidence + */ + public static FunctionSimilarityEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FunctionSimilarityEvidence.class); + } + + /** + * Convert an instance of FunctionSimilarityEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/FunctionStringItem.java b/src/main/java/ai/reveng/model/FunctionStringItem.java index f0a6d445..4121ae87 100644 --- a/src/main/java/ai/reveng/model/FunctionStringItem.java +++ b/src/main/java/ai/reveng/model/FunctionStringItem.java @@ -123,6 +123,50 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionStringItem instance itself + */ + public FunctionStringItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -136,12 +180,13 @@ public boolean equals(Object o) { FunctionStringItem functionStringItem = (FunctionStringItem) o; return Objects.equals(this.source, functionStringItem.source) && Objects.equals(this.vaddr, functionStringItem.vaddr) && - Objects.equals(this.value, functionStringItem.value); + Objects.equals(this.value, functionStringItem.value)&& + Objects.equals(this.additionalProperties, functionStringItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(source, vaddr, value); + return Objects.hash(source, vaddr, value, additionalProperties); } @Override @@ -151,6 +196,7 @@ public String toString() { sb.append(" source: ").append(toIndentedString(source)).append("\n"); sb.append(" vaddr: ").append(toIndentedString(vaddr)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -188,14 +234,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionStringItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionStringItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionStringItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -226,6 +264,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionStringItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -233,7 +293,28 @@ public void write(JsonWriter out, FunctionStringItem value) throws IOException { public FunctionStringItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionStringItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionTypeDefinition.java b/src/main/java/ai/reveng/model/FunctionTypeDefinition.java index 94454fbd..d456c5a9 100644 --- a/src/main/java/ai/reveng/model/FunctionTypeDefinition.java +++ b/src/main/java/ai/reveng/model/FunctionTypeDefinition.java @@ -110,6 +110,50 @@ public void setReturnDataTypeId(@javax.annotation.Nullable Long returnDataTypeId this.returnDataTypeId = returnDataTypeId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionTypeDefinition instance itself + */ + public FunctionTypeDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } FunctionTypeDefinition functionTypeDefinition = (FunctionTypeDefinition) o; return Objects.equals(this.parameters, functionTypeDefinition.parameters) && - Objects.equals(this.returnDataTypeId, functionTypeDefinition.returnDataTypeId); + Objects.equals(this.returnDataTypeId, functionTypeDefinition.returnDataTypeId)&& + Objects.equals(this.additionalProperties, functionTypeDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(parameters, returnDataTypeId); + return Objects.hash(parameters, returnDataTypeId, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class FunctionTypeDefinition {\n"); sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); sb.append(" returnDataTypeId: ").append(toIndentedString(returnDataTypeId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionTypeDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionTypeDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionTypeDefinition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("parameters") != null && !jsonObj.get("parameters").isJsonNull()) { - if (!jsonObj.get("parameters").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); - } - JsonArray jsonArrayparameters = jsonObj.getAsJsonArray("parameters"); - // validate the required field `parameters` (array) - for (int i = 0; i < jsonArrayparameters.size(); i++) { - DataTypeFunctionParameterEntry.validateJsonElement(jsonArrayparameters.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("parameters") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("parameters").isJsonArray() && !jsonObj.get("parameters").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionTypeDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, FunctionTypeDefinition value) throws IOExcepti public FunctionTypeDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionTypeDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionsProgressOutputBody.java b/src/main/java/ai/reveng/model/FunctionsProgressOutputBody.java new file mode 100644 index 00000000..cafb64a2 --- /dev/null +++ b/src/main/java/ai/reveng/model/FunctionsProgressOutputBody.java @@ -0,0 +1,338 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * FunctionsProgressOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FunctionsProgressOutputBody { + public static final String SERIALIZED_NAME_FUNCTION_EMBEDDINGS_COUNT = "function_embeddings_count"; + @SerializedName(SERIALIZED_NAME_FUNCTION_EMBEDDINGS_COUNT) + @javax.annotation.Nonnull + private Long functionEmbeddingsCount; + + public static final String SERIALIZED_NAME_FUNCTIONS_COUNT = "functions_count"; + @SerializedName(SERIALIZED_NAME_FUNCTIONS_COUNT) + @javax.annotation.Nonnull + private Long functionsCount; + + public static final String SERIALIZED_NAME_PERCENTAGE_COMPLETED = "percentage_completed"; + @SerializedName(SERIALIZED_NAME_PERCENTAGE_COMPLETED) + @javax.annotation.Nonnull + private Double percentageCompleted; + + public FunctionsProgressOutputBody() { + } + + public FunctionsProgressOutputBody functionEmbeddingsCount(@javax.annotation.Nonnull Long functionEmbeddingsCount) { + this.functionEmbeddingsCount = functionEmbeddingsCount; + return this; + } + + /** + * Functions whose embedding has been written back + * @return functionEmbeddingsCount + */ + @javax.annotation.Nonnull + public Long getFunctionEmbeddingsCount() { + return functionEmbeddingsCount; + } + + public void setFunctionEmbeddingsCount(@javax.annotation.Nonnull Long functionEmbeddingsCount) { + this.functionEmbeddingsCount = functionEmbeddingsCount; + } + + + public FunctionsProgressOutputBody functionsCount(@javax.annotation.Nonnull Long functionsCount) { + this.functionsCount = functionsCount; + return this; + } + + /** + * Functions found in the analysis + * @return functionsCount + */ + @javax.annotation.Nonnull + public Long getFunctionsCount() { + return functionsCount; + } + + public void setFunctionsCount(@javax.annotation.Nonnull Long functionsCount) { + this.functionsCount = functionsCount; + } + + + public FunctionsProgressOutputBody percentageCompleted(@javax.annotation.Nonnull Double percentageCompleted) { + this.percentageCompleted = percentageCompleted; + return this; + } + + /** + * Embeddings as a percentage of functions, to 2 decimal places. 0 when the analysis has no functions + * @return percentageCompleted + */ + @javax.annotation.Nonnull + public Double getPercentageCompleted() { + return percentageCompleted; + } + + public void setPercentageCompleted(@javax.annotation.Nonnull Double percentageCompleted) { + this.percentageCompleted = percentageCompleted; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FunctionsProgressOutputBody instance itself + */ + public FunctionsProgressOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionsProgressOutputBody functionsProgressOutputBody = (FunctionsProgressOutputBody) o; + return Objects.equals(this.functionEmbeddingsCount, functionsProgressOutputBody.functionEmbeddingsCount) && + Objects.equals(this.functionsCount, functionsProgressOutputBody.functionsCount) && + Objects.equals(this.percentageCompleted, functionsProgressOutputBody.percentageCompleted)&& + Objects.equals(this.additionalProperties, functionsProgressOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(functionEmbeddingsCount, functionsCount, percentageCompleted, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FunctionsProgressOutputBody {\n"); + sb.append(" functionEmbeddingsCount: ").append(toIndentedString(functionEmbeddingsCount)).append("\n"); + sb.append(" functionsCount: ").append(toIndentedString(functionsCount)).append("\n"); + sb.append(" percentageCompleted: ").append(toIndentedString(percentageCompleted)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("function_embeddings_count", "functions_count", "percentage_completed")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("function_embeddings_count", "functions_count", "percentage_completed")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FunctionsProgressOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FunctionsProgressOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionsProgressOutputBody is not found in the empty JSON string", FunctionsProgressOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FunctionsProgressOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FunctionsProgressOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FunctionsProgressOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FunctionsProgressOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FunctionsProgressOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public FunctionsProgressOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FunctionsProgressOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FunctionsProgressOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of FunctionsProgressOutputBody + * @throws IOException if the JSON string is invalid with respect to FunctionsProgressOutputBody + */ + public static FunctionsProgressOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FunctionsProgressOutputBody.class); + } + + /** + * Convert an instance of FunctionsProgressOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java b/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java index 3ee859c1..1683b1dc 100644 --- a/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java +++ b/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java @@ -75,6 +75,50 @@ public void setAlreadyRunning(@javax.annotation.Nullable Boolean alreadyRunning) this.alreadyRunning = alreadyRunning; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GeneratePDFOutputBody instance itself + */ + public GeneratePDFOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } GeneratePDFOutputBody generatePDFOutputBody = (GeneratePDFOutputBody) o; - return Objects.equals(this.alreadyRunning, generatePDFOutputBody.alreadyRunning); + return Objects.equals(this.alreadyRunning, generatePDFOutputBody.alreadyRunning)&& + Objects.equals(this.additionalProperties, generatePDFOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(alreadyRunning); + return Objects.hash(alreadyRunning, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GeneratePDFOutputBody {\n"); sb.append(" alreadyRunning: ").append(toIndentedString(alreadyRunning)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -135,14 +181,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GeneratePDFOutputBody is not found in the empty JSON string", GeneratePDFOutputBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GeneratePDFOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GeneratePDFOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -161,6 +199,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GeneratePDFOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -168,7 +228,28 @@ public void write(JsonWriter out, GeneratePDFOutputBody value) throws IOExceptio public GeneratePDFOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GeneratePDFOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java b/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java index 72661b14..f0505fc5 100644 --- a/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java +++ b/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java @@ -99,6 +99,50 @@ public void setDetails(@javax.annotation.Nullable Object details) { this.details = details; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetAdditionalDetailsOutputBody instance itself + */ + public GetAdditionalDetailsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } GetAdditionalDetailsOutputBody getAdditionalDetailsOutputBody = (GetAdditionalDetailsOutputBody) o; return Objects.equals(this.binaryId, getAdditionalDetailsOutputBody.binaryId) && - Objects.equals(this.details, getAdditionalDetailsOutputBody.details); + Objects.equals(this.details, getAdditionalDetailsOutputBody.details)&& + Objects.equals(this.additionalProperties, getAdditionalDetailsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryId, details); + return Objects.hash(binaryId, details, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class GetAdditionalDetailsOutputBody {\n"); sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); sb.append(" details: ").append(toIndentedString(details)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetAdditionalDetailsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAdditionalDetailsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAdditionalDetailsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAdditionalDetailsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, GetAdditionalDetailsOutputBody value) throws I public GetAdditionalDetailsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetAdditionalDetailsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java b/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java index 23255e9c..178e2ce3 100644 --- a/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java +++ b/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java @@ -75,6 +75,50 @@ public void setStatus(@javax.annotation.Nonnull String status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetAdditionalDetailsStatusOutputBody instance itself + */ + public GetAdditionalDetailsStatusOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } GetAdditionalDetailsStatusOutputBody getAdditionalDetailsStatusOutputBody = (GetAdditionalDetailsStatusOutputBody) o; - return Objects.equals(this.status, getAdditionalDetailsStatusOutputBody.status); + return Objects.equals(this.status, getAdditionalDetailsStatusOutputBody.status)&& + Objects.equals(this.additionalProperties, getAdditionalDetailsStatusOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetAdditionalDetailsStatusOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetAdditionalDetailsStatusOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAdditionalDetailsStatusOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAdditionalDetailsStatusOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -171,6 +209,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAdditionalDetailsStatusOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -178,7 +238,28 @@ public void write(JsonWriter out, GetAdditionalDetailsStatusOutputBody value) th public GetAdditionalDetailsStatusOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetAdditionalDetailsStatusOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetAnalysisLogsOutputBody.java b/src/main/java/ai/reveng/model/GetAnalysisLogsOutputBody.java index 6d0b0314..a6970f7b 100644 --- a/src/main/java/ai/reveng/model/GetAnalysisLogsOutputBody.java +++ b/src/main/java/ai/reveng/model/GetAnalysisLogsOutputBody.java @@ -86,6 +86,50 @@ public void setEntries(@javax.annotation.Nullable List entries this.entries = entries; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetAnalysisLogsOutputBody instance itself + */ + public GetAnalysisLogsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } GetAnalysisLogsOutputBody getAnalysisLogsOutputBody = (GetAnalysisLogsOutputBody) o; - return Objects.equals(this.entries, getAnalysisLogsOutputBody.entries); + return Objects.equals(this.entries, getAnalysisLogsOutputBody.entries)&& + Objects.equals(this.additionalProperties, getAnalysisLogsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(entries); + return Objects.hash(entries, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetAnalysisLogsOutputBody {\n"); sb.append(" entries: ").append(toIndentedString(entries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetAnalysisLogsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAnalysisLogsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAnalysisLogsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("entries") != null && !jsonObj.get("entries").isJsonNull()) { - if (!jsonObj.get("entries").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `entries` to be an array in the JSON string but got `%s`", jsonObj.get("entries").toString())); - } - JsonArray jsonArrayentries = jsonObj.getAsJsonArray("entries"); - // validate the required field `entries` (array) - for (int i = 0; i < jsonArrayentries.size(); i++) { - AnalysisLogEntry.validateJsonElement(jsonArrayentries.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("entries") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("entries").isJsonArray() && !jsonObj.get("entries").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `entries` to be an array in the JSON string but got `%s`", jsonObj.get("entries").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAnalysisLogsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, GetAnalysisLogsOutputBody value) throws IOExce public GetAnalysisLogsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetAnalysisLogsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java b/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java index 824d1ae7..00cea71d 100644 --- a/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java +++ b/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java @@ -135,6 +135,50 @@ public void setStatus(@javax.annotation.Nonnull StatusEnum status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetAnalysisStringsStatusOutputBody instance itself + */ + public GetAnalysisStringsStatusOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -146,12 +190,13 @@ public boolean equals(Object o) { return false; } GetAnalysisStringsStatusOutputBody getAnalysisStringsStatusOutputBody = (GetAnalysisStringsStatusOutputBody) o; - return Objects.equals(this.status, getAnalysisStringsStatusOutputBody.status); + return Objects.equals(this.status, getAnalysisStringsStatusOutputBody.status)&& + Objects.equals(this.additionalProperties, getAnalysisStringsStatusOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -159,6 +204,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetAnalysisStringsStatusOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -196,14 +242,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetAnalysisStringsStatusOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAnalysisStringsStatusOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAnalysisStringsStatusOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -233,6 +271,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAnalysisStringsStatusOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -240,7 +300,28 @@ public void write(JsonWriter out, GetAnalysisStringsStatusOutputBody value) thro public GetAnalysisStringsStatusOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetAnalysisStringsStatusOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetCollectionOutputBody.java b/src/main/java/ai/reveng/model/GetCollectionOutputBody.java index d6856ebf..dc31e4eb 100644 --- a/src/main/java/ai/reveng/model/GetCollectionOutputBody.java +++ b/src/main/java/ai/reveng/model/GetCollectionOutputBody.java @@ -384,6 +384,50 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetCollectionOutputBody instance itself + */ + public GetCollectionOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -407,7 +451,8 @@ public boolean equals(Object o) { Objects.equals(this.tags, getCollectionOutputBody.tags) && Objects.equals(this.teamId, getCollectionOutputBody.teamId) && Objects.equals(this.updatedAt, getCollectionOutputBody.updatedAt) && - Objects.equals(this.userId, getCollectionOutputBody.userId); + Objects.equals(this.userId, getCollectionOutputBody.userId)&& + Objects.equals(this.additionalProperties, getCollectionOutputBody.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -416,7 +461,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, hasNextPage, pageNumber, pageSize, tags, teamId, updatedAt, userId); + return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, hasNextPage, pageNumber, pageSize, tags, teamId, updatedAt, userId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -443,6 +488,7 @@ public String toString() { sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -480,14 +526,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetCollectionOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetCollectionOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetCollectionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -495,19 +533,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull()) { - JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); - if (jsonArraybinaries != null) { - // ensure the json data is an array - if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); - } - - // validate the optional field `binaries` (array) - for (int i = 0; i < jsonArraybinaries.size(); i++) { - Binary.validateJsonElement(jsonArraybinaries.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull() && !jsonObj.get("binaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } if (!jsonObj.get("collection_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); @@ -539,6 +567,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetCollectionOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -546,7 +596,28 @@ public void write(JsonWriter out, GetCollectionOutputBody value) throws IOExcept public GetCollectionOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetCollectionOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetConfigOutputBody.java b/src/main/java/ai/reveng/model/GetConfigOutputBody.java new file mode 100644 index 00000000..55d910c7 --- /dev/null +++ b/src/main/java/ai/reveng/model/GetConfigOutputBody.java @@ -0,0 +1,328 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * GetConfigOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GetConfigOutputBody { + public static final String SERIALIZED_NAME_AI_DECOMPILER_UNSUPPORTED_LANGUAGES = "ai_decompiler_unsupported_languages"; + @SerializedName(SERIALIZED_NAME_AI_DECOMPILER_UNSUPPORTED_LANGUAGES) + @javax.annotation.Nullable + private List aiDecompilerUnsupportedLanguages; + + public static final String SERIALIZED_NAME_MAX_FILE_SIZE_BYTES = "max_file_size_bytes"; + @SerializedName(SERIALIZED_NAME_MAX_FILE_SIZE_BYTES) + @javax.annotation.Nonnull + private Long maxFileSizeBytes; + + public GetConfigOutputBody() { + } + + public GetConfigOutputBody aiDecompilerUnsupportedLanguages(@javax.annotation.Nullable List aiDecompilerUnsupportedLanguages) { + this.aiDecompilerUnsupportedLanguages = aiDecompilerUnsupportedLanguages; + return this; + } + + public GetConfigOutputBody addAiDecompilerUnsupportedLanguagesItem(String aiDecompilerUnsupportedLanguagesItem) { + if (this.aiDecompilerUnsupportedLanguages == null) { + this.aiDecompilerUnsupportedLanguages = new ArrayList<>(); + } + this.aiDecompilerUnsupportedLanguages.add(aiDecompilerUnsupportedLanguagesItem); + return this; + } + + /** + * Source languages AI decompilation does not support + * @return aiDecompilerUnsupportedLanguages + */ + @javax.annotation.Nullable + public List getAiDecompilerUnsupportedLanguages() { + return aiDecompilerUnsupportedLanguages; + } + + public void setAiDecompilerUnsupportedLanguages(@javax.annotation.Nullable List aiDecompilerUnsupportedLanguages) { + this.aiDecompilerUnsupportedLanguages = aiDecompilerUnsupportedLanguages; + } + + + public GetConfigOutputBody maxFileSizeBytes(@javax.annotation.Nonnull Long maxFileSizeBytes) { + this.maxFileSizeBytes = maxFileSizeBytes; + return this; + } + + /** + * Largest binary the calling user may submit for analysis, in bytes + * @return maxFileSizeBytes + */ + @javax.annotation.Nonnull + public Long getMaxFileSizeBytes() { + return maxFileSizeBytes; + } + + public void setMaxFileSizeBytes(@javax.annotation.Nonnull Long maxFileSizeBytes) { + this.maxFileSizeBytes = maxFileSizeBytes; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetConfigOutputBody instance itself + */ + public GetConfigOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetConfigOutputBody getConfigOutputBody = (GetConfigOutputBody) o; + return Objects.equals(this.aiDecompilerUnsupportedLanguages, getConfigOutputBody.aiDecompilerUnsupportedLanguages) && + Objects.equals(this.maxFileSizeBytes, getConfigOutputBody.maxFileSizeBytes)&& + Objects.equals(this.additionalProperties, getConfigOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(aiDecompilerUnsupportedLanguages, maxFileSizeBytes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetConfigOutputBody {\n"); + sb.append(" aiDecompilerUnsupportedLanguages: ").append(toIndentedString(aiDecompilerUnsupportedLanguages)).append("\n"); + sb.append(" maxFileSizeBytes: ").append(toIndentedString(maxFileSizeBytes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("ai_decompiler_unsupported_languages", "max_file_size_bytes")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("ai_decompiler_unsupported_languages", "max_file_size_bytes")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetConfigOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetConfigOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetConfigOutputBody is not found in the empty JSON string", GetConfigOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetConfigOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("ai_decompiler_unsupported_languages") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("ai_decompiler_unsupported_languages").isJsonArray() && !jsonObj.get("ai_decompiler_unsupported_languages").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ai_decompiler_unsupported_languages` to be an array in the JSON string but got `%s`", jsonObj.get("ai_decompiler_unsupported_languages").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetConfigOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetConfigOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetConfigOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetConfigOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GetConfigOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetConfigOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetConfigOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetConfigOutputBody + * @throws IOException if the JSON string is invalid with respect to GetConfigOutputBody + */ + public static GetConfigOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetConfigOutputBody.class); + } + + /** + * Convert an instance of GetConfigOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/GetDataTypeHistoryBody.java b/src/main/java/ai/reveng/model/GetDataTypeHistoryBody.java index 4e27ee2d..4e5a7e64 100644 --- a/src/main/java/ai/reveng/model/GetDataTypeHistoryBody.java +++ b/src/main/java/ai/reveng/model/GetDataTypeHistoryBody.java @@ -86,6 +86,50 @@ public void setVersions(@javax.annotation.Nonnull List versions this.versions = versions; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetDataTypeHistoryBody instance itself + */ + public GetDataTypeHistoryBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } GetDataTypeHistoryBody getDataTypeHistoryBody = (GetDataTypeHistoryBody) o; - return Objects.equals(this.versions, getDataTypeHistoryBody.versions); + return Objects.equals(this.versions, getDataTypeHistoryBody.versions)&& + Objects.equals(this.additionalProperties, getDataTypeHistoryBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(versions); + return Objects.hash(versions, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetDataTypeHistoryBody {\n"); sb.append(" versions: ").append(toIndentedString(versions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetDataTypeHistoryBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetDataTypeHistoryBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetDataTypeHistoryBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("versions") != null) { - if (!jsonObj.get("versions").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `versions` to be an array in the JSON string but got `%s`", jsonObj.get("versions").toString())); - } - JsonArray jsonArrayversions = jsonObj.getAsJsonArray("versions"); - // validate the required field `versions` (array) - for (int i = 0; i < jsonArrayversions.size(); i++) { - DataTypeVersion.validateJsonElement(jsonArrayversions.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("versions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("versions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `versions` to be an array in the JSON string but got `%s`", jsonObj.get("versions").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetDataTypeHistoryBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, GetDataTypeHistoryBody value) throws IOExcepti public GetDataTypeHistoryBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetDataTypeHistoryBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetDieInfoOutputBody.java b/src/main/java/ai/reveng/model/GetDieInfoOutputBody.java new file mode 100644 index 00000000..9539d9d7 --- /dev/null +++ b/src/main/java/ai/reveng/model/GetDieInfoOutputBody.java @@ -0,0 +1,303 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.DieMatch; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * GetDieInfoOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GetDieInfoOutputBody { + public static final String SERIALIZED_NAME_MATCHES = "matches"; + @SerializedName(SERIALIZED_NAME_MATCHES) + @javax.annotation.Nullable + private List matches; + + public GetDieInfoOutputBody() { + } + + public GetDieInfoOutputBody matches(@javax.annotation.Nullable List matches) { + this.matches = matches; + return this; + } + + public GetDieInfoOutputBody addMatchesItem(DieMatch matchesItem) { + if (this.matches == null) { + this.matches = new ArrayList<>(); + } + this.matches.add(matchesItem); + return this; + } + + /** + * Signatures Detect It Easy recognised in the binary + * @return matches + */ + @javax.annotation.Nullable + public List getMatches() { + return matches; + } + + public void setMatches(@javax.annotation.Nullable List matches) { + this.matches = matches; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetDieInfoOutputBody instance itself + */ + public GetDieInfoOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetDieInfoOutputBody getDieInfoOutputBody = (GetDieInfoOutputBody) o; + return Objects.equals(this.matches, getDieInfoOutputBody.matches)&& + Objects.equals(this.additionalProperties, getDieInfoOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(matches, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetDieInfoOutputBody {\n"); + sb.append(" matches: ").append(toIndentedString(matches)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("matches")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("matches")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetDieInfoOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetDieInfoOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetDieInfoOutputBody is not found in the empty JSON string", GetDieInfoOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetDieInfoOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("matches") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("matches").isJsonArray() && !jsonObj.get("matches").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matches` to be an array in the JSON string but got `%s`", jsonObj.get("matches").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetDieInfoOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetDieInfoOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetDieInfoOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetDieInfoOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GetDieInfoOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetDieInfoOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetDieInfoOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetDieInfoOutputBody + * @throws IOException if the JSON string is invalid with respect to GetDieInfoOutputBody + */ + public static GetDieInfoOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetDieInfoOutputBody.class); + } + + /** + * Convert an instance of GetDieInfoOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/GetFunctionSignatureHistoryBody.java b/src/main/java/ai/reveng/model/GetFunctionSignatureHistoryBody.java index 6411076b..4152a74c 100644 --- a/src/main/java/ai/reveng/model/GetFunctionSignatureHistoryBody.java +++ b/src/main/java/ai/reveng/model/GetFunctionSignatureHistoryBody.java @@ -86,6 +86,50 @@ public void setVersions(@javax.annotation.Nonnull List this.versions = versions; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetFunctionSignatureHistoryBody instance itself + */ + public GetFunctionSignatureHistoryBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } GetFunctionSignatureHistoryBody getFunctionSignatureHistoryBody = (GetFunctionSignatureHistoryBody) o; - return Objects.equals(this.versions, getFunctionSignatureHistoryBody.versions); + return Objects.equals(this.versions, getFunctionSignatureHistoryBody.versions)&& + Objects.equals(this.additionalProperties, getFunctionSignatureHistoryBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(versions); + return Objects.hash(versions, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetFunctionSignatureHistoryBody {\n"); sb.append(" versions: ").append(toIndentedString(versions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetFunctionSignatureHistoryBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetFunctionSignatureHistoryBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetFunctionSignatureHistoryBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("versions") != null) { - if (!jsonObj.get("versions").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `versions` to be an array in the JSON string but got `%s`", jsonObj.get("versions").toString())); - } - JsonArray jsonArrayversions = jsonObj.getAsJsonArray("versions"); - // validate the required field `versions` (array) - for (int i = 0; i < jsonArrayversions.size(); i++) { - FunctionSignatureVersion.validateJsonElement(jsonArrayversions.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("versions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("versions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `versions` to be an array in the JSON string but got `%s`", jsonObj.get("versions").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetFunctionSignatureHistoryBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, GetFunctionSignatureHistoryBody value) throws public GetFunctionSignatureHistoryBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetFunctionSignatureHistoryBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetMatchesOutputBody.java b/src/main/java/ai/reveng/model/GetMatchesOutputBody.java index 93f19775..12628c14 100644 --- a/src/main/java/ai/reveng/model/GetMatchesOutputBody.java +++ b/src/main/java/ai/reveng/model/GetMatchesOutputBody.java @@ -171,6 +171,50 @@ public void setStatus(@javax.annotation.Nonnull StatusEnum status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMatchesOutputBody instance itself + */ + public GetMatchesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -183,7 +227,8 @@ public boolean equals(Object o) { } GetMatchesOutputBody getMatchesOutputBody = (GetMatchesOutputBody) o; return Objects.equals(this.matches, getMatchesOutputBody.matches) && - Objects.equals(this.status, getMatchesOutputBody.status); + Objects.equals(this.status, getMatchesOutputBody.status)&& + Objects.equals(this.additionalProperties, getMatchesOutputBody.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -192,7 +237,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(matches, status); + return Objects.hash(matches, status, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -208,6 +253,7 @@ public String toString() { sb.append("class GetMatchesOutputBody {\n"); sb.append(" matches: ").append(toIndentedString(matches)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -245,14 +291,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMatchesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetMatchesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetMatchesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -260,19 +298,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("matches") != null && !jsonObj.get("matches").isJsonNull()) { - JsonArray jsonArraymatches = jsonObj.getAsJsonArray("matches"); - if (jsonArraymatches != null) { - // ensure the json data is an array - if (!jsonObj.get("matches").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matches` to be an array in the JSON string but got `%s`", jsonObj.get("matches").toString())); - } - - // validate the optional field `matches` (array) - for (int i = 0; i < jsonArraymatches.size(); i++) { - FunctionMatch.validateJsonElement(jsonArraymatches.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("matches") != null && !jsonObj.get("matches").isJsonNull() && !jsonObj.get("matches").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matches` to be an array in the JSON string but got `%s`", jsonObj.get("matches").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); @@ -296,6 +324,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMatchesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -303,7 +353,28 @@ public void write(JsonWriter out, GetMatchesOutputBody value) throws IOException public GetMatchesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMatchesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetMatchesStatusOutputBody.java b/src/main/java/ai/reveng/model/GetMatchesStatusOutputBody.java index dea4316c..c8fdefa8 100644 --- a/src/main/java/ai/reveng/model/GetMatchesStatusOutputBody.java +++ b/src/main/java/ai/reveng/model/GetMatchesStatusOutputBody.java @@ -57,6 +57,11 @@ public class GetMatchesStatusOutputBody { @javax.annotation.Nullable private List messages; + public static final String SERIALIZED_NAME_PERCENT = "percent"; + @SerializedName(SERIALIZED_NAME_PERCENT) + @javax.annotation.Nonnull + private Long percent; + /** * Current workflow status */ @@ -132,11 +137,31 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nonnull private Long stepIndex; + public static final String SERIALIZED_NAME_STEP_SHARE = "step_share"; + @SerializedName(SERIALIZED_NAME_STEP_SHARE) + @javax.annotation.Nonnull + private Long stepShare; + public static final String SERIALIZED_NAME_STEPS_TOTAL = "steps_total"; @SerializedName(SERIALIZED_NAME_STEPS_TOTAL) @javax.annotation.Nonnull private Long stepsTotal; + public static final String SERIALIZED_NAME_SUB_STEP = "sub_step"; + @SerializedName(SERIALIZED_NAME_SUB_STEP) + @javax.annotation.Nullable + private String subStep; + + public static final String SERIALIZED_NAME_SUB_STEP_DONE = "sub_step_done"; + @SerializedName(SERIALIZED_NAME_SUB_STEP_DONE) + @javax.annotation.Nullable + private Long subStepDone; + + public static final String SERIALIZED_NAME_SUB_STEP_TOTAL = "sub_step_total"; + @SerializedName(SERIALIZED_NAME_SUB_STEP_TOTAL) + @javax.annotation.Nullable + private Long subStepTotal; + public GetMatchesStatusOutputBody() { } @@ -167,6 +192,25 @@ public void setMessages(@javax.annotation.Nullable List message } + public GetMatchesStatusOutputBody percent(@javax.annotation.Nonnull Long percent) { + this.percent = percent; + return this; + } + + /** + * Overall completion as a percentage, weighted by step duration + * @return percent + */ + @javax.annotation.Nonnull + public Long getPercent() { + return percent; + } + + public void setPercent(@javax.annotation.Nonnull Long percent) { + this.percent = percent; + } + + public GetMatchesStatusOutputBody status(@javax.annotation.Nonnull StatusEnum status) { this.status = status; return this; @@ -224,6 +268,25 @@ public void setStepIndex(@javax.annotation.Nonnull Long stepIndex) { } + public GetMatchesStatusOutputBody stepShare(@javax.annotation.Nonnull Long stepShare) { + this.stepShare = stepShare; + return this; + } + + /** + * Percentage points the current step contributes when it completes + * @return stepShare + */ + @javax.annotation.Nonnull + public Long getStepShare() { + return stepShare; + } + + public void setStepShare(@javax.annotation.Nonnull Long stepShare) { + this.stepShare = stepShare; + } + + public GetMatchesStatusOutputBody stepsTotal(@javax.annotation.Nonnull Long stepsTotal) { this.stepsTotal = stepsTotal; return this; @@ -243,6 +306,107 @@ public void setStepsTotal(@javax.annotation.Nonnull Long stepsTotal) { } + public GetMatchesStatusOutputBody subStep(@javax.annotation.Nullable String subStep) { + this.subStep = subStep; + return this; + } + + /** + * Phase within the current step, when the step reports one + * @return subStep + */ + @javax.annotation.Nullable + public String getSubStep() { + return subStep; + } + + public void setSubStep(@javax.annotation.Nullable String subStep) { + this.subStep = subStep; + } + + + public GetMatchesStatusOutputBody subStepDone(@javax.annotation.Nullable Long subStepDone) { + this.subStepDone = subStepDone; + return this; + } + + /** + * Items completed in the current phase + * @return subStepDone + */ + @javax.annotation.Nullable + public Long getSubStepDone() { + return subStepDone; + } + + public void setSubStepDone(@javax.annotation.Nullable Long subStepDone) { + this.subStepDone = subStepDone; + } + + + public GetMatchesStatusOutputBody subStepTotal(@javax.annotation.Nullable Long subStepTotal) { + this.subStepTotal = subStepTotal; + return this; + } + + /** + * Items the current phase will process, 0 when unknown + * @return subStepTotal + */ + @javax.annotation.Nullable + public Long getSubStepTotal() { + return subStepTotal; + } + + public void setSubStepTotal(@javax.annotation.Nullable Long subStepTotal) { + this.subStepTotal = subStepTotal; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMatchesStatusOutputBody instance itself + */ + public GetMatchesStatusOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + @Override public boolean equals(Object o) { @@ -254,15 +418,21 @@ public boolean equals(Object o) { } GetMatchesStatusOutputBody getMatchesStatusOutputBody = (GetMatchesStatusOutputBody) o; return Objects.equals(this.messages, getMatchesStatusOutputBody.messages) && + Objects.equals(this.percent, getMatchesStatusOutputBody.percent) && Objects.equals(this.status, getMatchesStatusOutputBody.status) && Objects.equals(this.step, getMatchesStatusOutputBody.step) && Objects.equals(this.stepIndex, getMatchesStatusOutputBody.stepIndex) && - Objects.equals(this.stepsTotal, getMatchesStatusOutputBody.stepsTotal); + Objects.equals(this.stepShare, getMatchesStatusOutputBody.stepShare) && + Objects.equals(this.stepsTotal, getMatchesStatusOutputBody.stepsTotal) && + Objects.equals(this.subStep, getMatchesStatusOutputBody.subStep) && + Objects.equals(this.subStepDone, getMatchesStatusOutputBody.subStepDone) && + Objects.equals(this.subStepTotal, getMatchesStatusOutputBody.subStepTotal)&& + Objects.equals(this.additionalProperties, getMatchesStatusOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(messages, status, step, stepIndex, stepsTotal); + return Objects.hash(messages, percent, status, step, stepIndex, stepShare, stepsTotal, subStep, subStepDone, subStepTotal, additionalProperties); } @Override @@ -270,10 +440,16 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetMatchesStatusOutputBody {\n"); sb.append(" messages: ").append(toIndentedString(messages)).append("\n"); + sb.append(" percent: ").append(toIndentedString(percent)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" step: ").append(toIndentedString(step)).append("\n"); sb.append(" stepIndex: ").append(toIndentedString(stepIndex)).append("\n"); + sb.append(" stepShare: ").append(toIndentedString(stepShare)).append("\n"); sb.append(" stepsTotal: ").append(toIndentedString(stepsTotal)).append("\n"); + sb.append(" subStep: ").append(toIndentedString(subStep)).append("\n"); + sb.append(" subStepDone: ").append(toIndentedString(subStepDone)).append("\n"); + sb.append(" subStepTotal: ").append(toIndentedString(subStepTotal)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -292,10 +468,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("messages", "status", "step", "step_index", "steps_total")); + openapiFields = new HashSet(Arrays.asList("messages", "percent", "status", "step", "step_index", "step_share", "steps_total", "sub_step", "sub_step_done", "sub_step_total")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("messages", "status", "step", "step_index", "steps_total")); + openapiRequiredFields = new HashSet(Arrays.asList("messages", "percent", "status", "step", "step_index", "step_share", "steps_total")); } /** @@ -311,14 +487,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMatchesStatusOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetMatchesStatusOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetMatchesStatusOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -326,15 +494,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("messages") != null && !jsonObj.get("messages").isJsonNull()) { - if (!jsonObj.get("messages").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); - } - JsonArray jsonArraymessages = jsonObj.getAsJsonArray("messages"); - // validate the required field `messages` (array) - for (int i = 0; i < jsonArraymessages.size(); i++) { - ProgressMessage.validateJsonElement(jsonArraymessages.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("messages") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("messages").isJsonArray() && !jsonObj.get("messages").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); @@ -344,6 +508,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("step").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); } + if ((jsonObj.get("sub_step") != null && !jsonObj.get("sub_step").isJsonNull()) && !jsonObj.get("sub_step").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sub_step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_step").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -361,6 +528,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMatchesStatusOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -368,7 +557,28 @@ public void write(JsonWriter out, GetMatchesStatusOutputBody value) throws IOExc public GetMatchesStatusOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMatchesStatusOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetModelsOutputBody.java b/src/main/java/ai/reveng/model/GetModelsOutputBody.java new file mode 100644 index 00000000..0d6f29f4 --- /dev/null +++ b/src/main/java/ai/reveng/model/GetModelsOutputBody.java @@ -0,0 +1,302 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * GetModelsOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GetModelsOutputBody { + public static final String SERIALIZED_NAME_MODELS = "models"; + @SerializedName(SERIALIZED_NAME_MODELS) + @javax.annotation.Nullable + private List models; + + public GetModelsOutputBody() { + } + + public GetModelsOutputBody models(@javax.annotation.Nullable List models) { + this.models = models; + return this; + } + + public GetModelsOutputBody addModelsItem(String modelsItem) { + if (this.models == null) { + this.models = new ArrayList<>(); + } + this.models.add(modelsItem); + return this; + } + + /** + * Models a new analysis may be run on + * @return models + */ + @javax.annotation.Nullable + public List getModels() { + return models; + } + + public void setModels(@javax.annotation.Nullable List models) { + this.models = models; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetModelsOutputBody instance itself + */ + public GetModelsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetModelsOutputBody getModelsOutputBody = (GetModelsOutputBody) o; + return Objects.equals(this.models, getModelsOutputBody.models)&& + Objects.equals(this.additionalProperties, getModelsOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(models, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetModelsOutputBody {\n"); + sb.append(" models: ").append(toIndentedString(models)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("models")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("models")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetModelsOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetModelsOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetModelsOutputBody is not found in the empty JSON string", GetModelsOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetModelsOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("models") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("models").isJsonArray() && !jsonObj.get("models").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `models` to be an array in the JSON string but got `%s`", jsonObj.get("models").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetModelsOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetModelsOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetModelsOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetModelsOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GetModelsOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetModelsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetModelsOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetModelsOutputBody + * @throws IOException if the JSON string is invalid with respect to GetModelsOutputBody + */ + public static GetModelsOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetModelsOutputBody.class); + } + + /** + * Convert an instance of GetModelsOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/GetProductsOutputBody.java b/src/main/java/ai/reveng/model/GetProductsOutputBody.java index 7e32cda7..15614d88 100644 --- a/src/main/java/ai/reveng/model/GetProductsOutputBody.java +++ b/src/main/java/ai/reveng/model/GetProductsOutputBody.java @@ -200,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("products") != null && !jsonObj.get("products").isJsonNull()) { - if (!jsonObj.get("products").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `products` to be an array in the JSON string but got `%s`", jsonObj.get("products").toString())); - } - JsonArray jsonArrayproducts = jsonObj.getAsJsonArray("products"); - // validate the required field `products` (array) - for (int i = 0; i < jsonArrayproducts.size(); i++) { - ProductOutput.validateJsonElement(jsonArrayproducts.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("products") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("products").isJsonArray() && !jsonObj.get("products").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `products` to be an array in the JSON string but got `%s`", jsonObj.get("products").toString())); } } diff --git a/src/main/java/ai/reveng/model/GetRelatedBinariesOutputBody.java b/src/main/java/ai/reveng/model/GetRelatedBinariesOutputBody.java new file mode 100644 index 00000000..6345f39b --- /dev/null +++ b/src/main/java/ai/reveng/model/GetRelatedBinariesOutputBody.java @@ -0,0 +1,329 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.RelatedBinary; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * GetRelatedBinariesOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GetRelatedBinariesOutputBody { + public static final String SERIALIZED_NAME_CHILDREN = "children"; + @SerializedName(SERIALIZED_NAME_CHILDREN) + @javax.annotation.Nullable + private List children; + + public static final String SERIALIZED_NAME_PARENT = "parent"; + @SerializedName(SERIALIZED_NAME_PARENT) + @javax.annotation.Nonnull + private RelatedBinary parent; + + public GetRelatedBinariesOutputBody() { + } + + public GetRelatedBinariesOutputBody children(@javax.annotation.Nullable List children) { + this.children = children; + return this; + } + + public GetRelatedBinariesOutputBody addChildrenItem(RelatedBinary childrenItem) { + if (this.children == null) { + this.children = new ArrayList<>(); + } + this.children.add(childrenItem); + return this; + } + + /** + * Binaries unpacked out of this one + * @return children + */ + @javax.annotation.Nullable + public List getChildren() { + return children; + } + + public void setChildren(@javax.annotation.Nullable List children) { + this.children = children; + } + + + public GetRelatedBinariesOutputBody parent(@javax.annotation.Nonnull RelatedBinary parent) { + this.parent = parent; + return this; + } + + /** + * Archive this binary was unpacked from, null when it was uploaded directly + * @return parent + */ + @javax.annotation.Nonnull + public RelatedBinary getParent() { + return parent; + } + + public void setParent(@javax.annotation.Nonnull RelatedBinary parent) { + this.parent = parent; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetRelatedBinariesOutputBody instance itself + */ + public GetRelatedBinariesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetRelatedBinariesOutputBody getRelatedBinariesOutputBody = (GetRelatedBinariesOutputBody) o; + return Objects.equals(this.children, getRelatedBinariesOutputBody.children) && + Objects.equals(this.parent, getRelatedBinariesOutputBody.parent)&& + Objects.equals(this.additionalProperties, getRelatedBinariesOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(children, parent, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetRelatedBinariesOutputBody {\n"); + sb.append(" children: ").append(toIndentedString(children)).append("\n"); + sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("children", "parent")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("children", "parent")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetRelatedBinariesOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetRelatedBinariesOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetRelatedBinariesOutputBody is not found in the empty JSON string", GetRelatedBinariesOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetRelatedBinariesOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("children") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("children").isJsonArray() && !jsonObj.get("children").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetRelatedBinariesOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetRelatedBinariesOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetRelatedBinariesOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetRelatedBinariesOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GetRelatedBinariesOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetRelatedBinariesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetRelatedBinariesOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetRelatedBinariesOutputBody + * @throws IOException if the JSON string is invalid with respect to GetRelatedBinariesOutputBody + */ + public static GetRelatedBinariesOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetRelatedBinariesOutputBody.class); + } + + /** + * Convert an instance of GetRelatedBinariesOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/GetRelatedStatusOutputBody.java b/src/main/java/ai/reveng/model/GetRelatedStatusOutputBody.java new file mode 100644 index 00000000..351d92dd --- /dev/null +++ b/src/main/java/ai/reveng/model/GetRelatedStatusOutputBody.java @@ -0,0 +1,351 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * GetRelatedStatusOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GetRelatedStatusOutputBody { + /** + * Status of the task that unpacks an archive into its contents + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public GetRelatedStatusOutputBody() { + } + + public GetRelatedStatusOutputBody status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Status of the task that unpacks an archive into its contents + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetRelatedStatusOutputBody instance itself + */ + public GetRelatedStatusOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetRelatedStatusOutputBody getRelatedStatusOutputBody = (GetRelatedStatusOutputBody) o; + return Objects.equals(this.status, getRelatedStatusOutputBody.status)&& + Objects.equals(this.additionalProperties, getRelatedStatusOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(status, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetRelatedStatusOutputBody {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetRelatedStatusOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetRelatedStatusOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetRelatedStatusOutputBody is not found in the empty JSON string", GetRelatedStatusOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetRelatedStatusOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetRelatedStatusOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetRelatedStatusOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetRelatedStatusOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetRelatedStatusOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GetRelatedStatusOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetRelatedStatusOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetRelatedStatusOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetRelatedStatusOutputBody + * @throws IOException if the JSON string is invalid with respect to GetRelatedStatusOutputBody + */ + public static GetRelatedStatusOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetRelatedStatusOutputBody.class); + } + + /** + * Convert an instance of GetRelatedStatusOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java b/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java index d72cf249..ac23afc4 100644 --- a/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java +++ b/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java @@ -440,14 +440,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `price` - if (jsonObj.get("price") != null && !jsonObj.get("price").isJsonNull()) { - PriceSummary.validateJsonElement(jsonObj.get("price")); - } - // validate the optional field `product` - if (jsonObj.get("product") != null && !jsonObj.get("product").isJsonNull()) { - ProductSummary.validateJsonElement(jsonObj.get("product")); - } if (!jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } diff --git a/src/main/java/ai/reveng/model/GetTokensResponse.java b/src/main/java/ai/reveng/model/GetTokensResponse.java index 9ef672a9..6261e4e0 100644 --- a/src/main/java/ai/reveng/model/GetTokensResponse.java +++ b/src/main/java/ai/reveng/model/GetTokensResponse.java @@ -167,6 +167,50 @@ public void setPlaceholderToUserOverride(@javax.annotation.Nonnull Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTokensResponse instance itself + */ + public GetTokensResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -181,12 +225,13 @@ public boolean equals(Object o) { return Objects.equals(this.aiDecomp, getTokensResponse.aiDecomp) && Objects.equals(this.analysisId, getTokensResponse.analysisId) && Objects.equals(this.placeholderToRenderedToken, getTokensResponse.placeholderToRenderedToken) && - Objects.equals(this.placeholderToUserOverride, getTokensResponse.placeholderToUserOverride); + Objects.equals(this.placeholderToUserOverride, getTokensResponse.placeholderToUserOverride)&& + Objects.equals(this.additionalProperties, getTokensResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(aiDecomp, analysisId, placeholderToRenderedToken, placeholderToUserOverride); + return Objects.hash(aiDecomp, analysisId, placeholderToRenderedToken, placeholderToUserOverride, additionalProperties); } @Override @@ -197,6 +242,7 @@ public String toString() { sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" placeholderToRenderedToken: ").append(toIndentedString(placeholderToRenderedToken)).append("\n"); sb.append(" placeholderToUserOverride: ").append(toIndentedString(placeholderToUserOverride)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,14 +280,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTokensResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTokensResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTokensResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -269,6 +307,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTokensResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -276,7 +336,28 @@ public void write(JsonWriter out, GetTokensResponse value) throws IOException { public GetTokensResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTokensResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/HardcodedSecretEvidence.java b/src/main/java/ai/reveng/model/HardcodedSecretEvidence.java new file mode 100644 index 00000000..bc44b250 --- /dev/null +++ b/src/main/java/ai/reveng/model/HardcodedSecretEvidence.java @@ -0,0 +1,758 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceStrength; +import ai.reveng.model.RuleKind; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * A hard-coded secret identified in the binary's data. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class HardcodedSecretEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + HARDCODED_SECRET("hardcoded_secret"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.HARDCODED_SECRET; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + /** + * Gets or Sets effect + */ + @JsonAdapter(EffectEnum.Adapter.class) + public enum EffectEnum { + SUPPORTS("supports"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EffectEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EffectEnum fromValue(String value) { + for (EffectEnum b : EffectEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EffectEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EffectEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EffectEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EffectEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nullable + private EffectEnum effect = EffectEnum.SUPPORTS; + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nonnull + private EvidenceStrength strength; + + public static final String SERIALIZED_NAME_RULE_ID = "rule_id"; + @SerializedName(SERIALIZED_NAME_RULE_ID) + @javax.annotation.Nonnull + private String ruleId; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_SECRET_KIND = "secret_kind"; + @SerializedName(SERIALIZED_NAME_SECRET_KIND) + @javax.annotation.Nonnull + private RuleKind secretKind; + + public static final String SERIALIZED_NAME_SECRET = "secret"; + @SerializedName(SERIALIZED_NAME_SECRET) + @javax.annotation.Nonnull + private String secret; + + public static final String SERIALIZED_NAME_ENTROPY = "entropy"; + @SerializedName(SERIALIZED_NAME_ENTROPY) + @javax.annotation.Nonnull + private BigDecimal entropy; + + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + @javax.annotation.Nonnull + private Integer size; + + public static final String SERIALIZED_NAME_REFERENCES = "references"; + @SerializedName(SERIALIZED_NAME_REFERENCES) + @javax.annotation.Nonnull + private List references = new ArrayList<>(); + + public HardcodedSecretEvidence() { + } + + public HardcodedSecretEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public HardcodedSecretEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public HardcodedSecretEvidence effect(@javax.annotation.Nullable EffectEnum effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nullable + public EffectEnum getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nullable EffectEnum effect) { + this.effect = effect; + } + + + public HardcodedSecretEvidence strength(@javax.annotation.Nonnull EvidenceStrength strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nonnull + public EvidenceStrength getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nonnull EvidenceStrength strength) { + this.strength = strength; + } + + + public HardcodedSecretEvidence ruleId(@javax.annotation.Nonnull String ruleId) { + this.ruleId = ruleId; + return this; + } + + /** + * Get ruleId + * @return ruleId + */ + @javax.annotation.Nonnull + public String getRuleId() { + return ruleId; + } + + public void setRuleId(@javax.annotation.Nonnull String ruleId) { + this.ruleId = ruleId; + } + + + public HardcodedSecretEvidence description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public HardcodedSecretEvidence secretKind(@javax.annotation.Nonnull RuleKind secretKind) { + this.secretKind = secretKind; + return this; + } + + /** + * Get secretKind + * @return secretKind + */ + @javax.annotation.Nonnull + public RuleKind getSecretKind() { + return secretKind; + } + + public void setSecretKind(@javax.annotation.Nonnull RuleKind secretKind) { + this.secretKind = secretKind; + } + + + public HardcodedSecretEvidence secret(@javax.annotation.Nonnull String secret) { + this.secret = secret; + return this; + } + + /** + * Get secret + * @return secret + */ + @javax.annotation.Nonnull + public String getSecret() { + return secret; + } + + public void setSecret(@javax.annotation.Nonnull String secret) { + this.secret = secret; + } + + + public HardcodedSecretEvidence entropy(@javax.annotation.Nonnull BigDecimal entropy) { + this.entropy = entropy; + return this; + } + + /** + * Get entropy + * minimum: 0 + * maximum: 8 + * @return entropy + */ + @javax.annotation.Nonnull + public BigDecimal getEntropy() { + return entropy; + } + + public void setEntropy(@javax.annotation.Nonnull BigDecimal entropy) { + this.entropy = entropy; + } + + + public HardcodedSecretEvidence size(@javax.annotation.Nonnull Integer size) { + this.size = size; + return this; + } + + /** + * Get size + * minimum: 1 + * @return size + */ + @javax.annotation.Nonnull + public Integer getSize() { + return size; + } + + public void setSize(@javax.annotation.Nonnull Integer size) { + this.size = size; + } + + + public HardcodedSecretEvidence references(@javax.annotation.Nonnull List references) { + this.references = references; + return this; + } + + public HardcodedSecretEvidence addReferencesItem(Integer referencesItem) { + if (this.references == null) { + this.references = new ArrayList<>(); + } + this.references.add(referencesItem); + return this; + } + + /** + * Get references + * @return references + */ + @javax.annotation.Nonnull + public List getReferences() { + return references; + } + + public void setReferences(@javax.annotation.Nonnull List references) { + this.references = references; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the HardcodedSecretEvidence instance itself + */ + public HardcodedSecretEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HardcodedSecretEvidence hardcodedSecretEvidence = (HardcodedSecretEvidence) o; + return Objects.equals(this.evidenceKind, hardcodedSecretEvidence.evidenceKind) && + Objects.equals(this.kind, hardcodedSecretEvidence.kind) && + Objects.equals(this.effect, hardcodedSecretEvidence.effect) && + Objects.equals(this.strength, hardcodedSecretEvidence.strength) && + Objects.equals(this.ruleId, hardcodedSecretEvidence.ruleId) && + Objects.equals(this.description, hardcodedSecretEvidence.description) && + Objects.equals(this.secretKind, hardcodedSecretEvidence.secretKind) && + Objects.equals(this.secret, hardcodedSecretEvidence.secret) && + Objects.equals(this.entropy, hardcodedSecretEvidence.entropy) && + Objects.equals(this.size, hardcodedSecretEvidence.size) && + Objects.equals(this.references, hardcodedSecretEvidence.references)&& + Objects.equals(this.additionalProperties, hardcodedSecretEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, ruleId, description, secretKind, secret, entropy, size, references, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HardcodedSecretEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" ruleId: ").append(toIndentedString(ruleId)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" secretKind: ").append(toIndentedString(secretKind)).append("\n"); + sb.append(" secret: ").append(toIndentedString(secret)).append("\n"); + sb.append(" entropy: ").append(toIndentedString(entropy)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" references: ").append(toIndentedString(references)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "rule_id", "description", "secret_kind", "secret", "entropy", "size", "references")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("strength", "rule_id", "description", "secret_kind", "secret", "entropy", "size", "references")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to HardcodedSecretEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!HardcodedSecretEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in HardcodedSecretEvidence is not found in the empty JSON string", HardcodedSecretEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HardcodedSecretEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + if ((jsonObj.get("effect") != null && !jsonObj.get("effect").isJsonNull()) && !jsonObj.get("effect").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `effect` to be a primitive type in the JSON string but got `%s`", jsonObj.get("effect").toString())); + } + // validate the optional field `effect` + if (jsonObj.get("effect") != null && !jsonObj.get("effect").isJsonNull()) { + EffectEnum.validateJsonElement(jsonObj.get("effect")); + } + // validate the required field `strength` + EvidenceStrength.validateJsonElement(jsonObj.get("strength")); + if (!jsonObj.get("rule_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `rule_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rule_id").toString())); + } + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + // validate the required field `secret_kind` + RuleKind.validateJsonElement(jsonObj.get("secret_kind")); + if (!jsonObj.get("secret").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `secret` to be a primitive type in the JSON string but got `%s`", jsonObj.get("secret").toString())); + } + // ensure the required json array is present + if (jsonObj.get("references") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("references").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `references` to be an array in the JSON string but got `%s`", jsonObj.get("references").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HardcodedSecretEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HardcodedSecretEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(HardcodedSecretEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, HardcodedSecretEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public HardcodedSecretEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HardcodedSecretEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of HardcodedSecretEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of HardcodedSecretEvidence + * @throws IOException if the JSON string is invalid with respect to HardcodedSecretEvidence + */ + public static HardcodedSecretEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HardcodedSecretEvidence.class); + } + + /** + * Convert an instance of HardcodedSecretEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/HistoryActor.java b/src/main/java/ai/reveng/model/HistoryActor.java index 03819af9..3d849d58 100644 --- a/src/main/java/ai/reveng/model/HistoryActor.java +++ b/src/main/java/ai/reveng/model/HistoryActor.java @@ -99,6 +99,50 @@ public void setUsername(@javax.annotation.Nullable String username) { this.username = username; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the HistoryActor instance itself + */ + public HistoryActor putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } HistoryActor historyActor = (HistoryActor) o; return Objects.equals(this.userId, historyActor.userId) && - Objects.equals(this.username, historyActor.username); + Objects.equals(this.username, historyActor.username)&& + Objects.equals(this.additionalProperties, historyActor.additionalProperties); } @Override public int hashCode() { - return Objects.hash(userId, username); + return Objects.hash(userId, username, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class HistoryActor {\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HistoryActor.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `HistoryActor` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : HistoryActor.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -197,6 +235,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HistoryActor value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -204,7 +264,28 @@ public void write(JsonWriter out, HistoryActor value) throws IOException { public HistoryActor read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HistoryActor instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/HistoryEntry.java b/src/main/java/ai/reveng/model/HistoryEntry.java index 79475c5d..1a3dff4f 100644 --- a/src/main/java/ai/reveng/model/HistoryEntry.java +++ b/src/main/java/ai/reveng/model/HistoryEntry.java @@ -268,6 +268,50 @@ public void setSourceType(@javax.annotation.Nonnull String sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the HistoryEntry instance itself + */ + public HistoryEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -287,12 +331,13 @@ public boolean equals(Object o) { Objects.equals(this.mangledName, historyEntry.mangledName) && Objects.equals(this.sourceAnalysisId, historyEntry.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, historyEntry.sourceFunctionId) && - Objects.equals(this.sourceType, historyEntry.sourceType); + Objects.equals(this.sourceType, historyEntry.sourceType)&& + Objects.equals(this.additionalProperties, historyEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(changeMadeBy, createdAt, functionName, historyId, isDebug, mangledName, sourceAnalysisId, sourceFunctionId, sourceType); + return Objects.hash(changeMadeBy, createdAt, functionName, historyId, isDebug, mangledName, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -308,6 +353,7 @@ public String toString() { sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -345,14 +391,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HistoryEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `HistoryEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : HistoryEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -389,6 +427,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HistoryEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -396,7 +456,28 @@ public void write(JsonWriter out, HistoryEntry value) throws IOException { public HistoryEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HistoryEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/HttpRequest.java b/src/main/java/ai/reveng/model/HttpRequest.java index d9e27c1b..b6c5d65f 100644 --- a/src/main/java/ai/reveng/model/HttpRequest.java +++ b/src/main/java/ai/reveng/model/HttpRequest.java @@ -624,6 +624,50 @@ public void setVersion(@javax.annotation.Nullable String version) { this.version = version; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the HttpRequest instance itself + */ + public HttpRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -657,7 +701,8 @@ public boolean equals(Object o) { Objects.equals(this.userAgent, httpRequest.userAgent) && Objects.equals(this.username, httpRequest.username) && Objects.equals(this.verb, httpRequest.verb) && - Objects.equals(this.version, httpRequest.version); + Objects.equals(this.version, httpRequest.version)&& + Objects.equals(this.additionalProperties, httpRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -666,7 +711,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(bytesReceived, bytesSent, events, extraHeaders, flags, password, path, pcapStreamId, postData, proxy, proxyBypass, referer, requestBody, responseBody, responseStatus, serverIp, serverName, serverPort, service, userAgent, username, verb, version); + return Objects.hash(bytesReceived, bytesSent, events, extraHeaders, flags, password, path, pcapStreamId, postData, proxy, proxyBypass, referer, requestBody, responseBody, responseStatus, serverIp, serverName, serverPort, service, userAgent, username, verb, version, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -703,6 +748,7 @@ public String toString() { sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" verb: ").append(toIndentedString(verb)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -739,28 +785,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in HttpRequest is not found in the empty JSON string", HttpRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HttpRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `HttpRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("extra_headers") != null && !jsonObj.get("extra_headers").isJsonNull() && !jsonObj.get("extra_headers").isJsonArray()) { @@ -784,14 +812,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("referer") != null && !jsonObj.get("referer").isJsonNull()) && !jsonObj.get("referer").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `referer` to be a primitive type in the JSON string but got `%s`", jsonObj.get("referer").toString())); } - // validate the optional field `request_body` - if (jsonObj.get("request_body") != null && !jsonObj.get("request_body").isJsonNull()) { - PcapBodyInfo.validateJsonElement(jsonObj.get("request_body")); - } - // validate the optional field `response_body` - if (jsonObj.get("response_body") != null && !jsonObj.get("response_body").isJsonNull()) { - PcapBodyInfo.validateJsonElement(jsonObj.get("response_body")); - } if ((jsonObj.get("server_ip") != null && !jsonObj.get("server_ip").isJsonNull()) && !jsonObj.get("server_ip").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `server_ip` to be a primitive type in the JSON string but got `%s`", jsonObj.get("server_ip").toString())); } @@ -827,6 +847,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HttpRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -834,7 +876,28 @@ public void write(JsonWriter out, HttpRequest value) throws IOException { public HttpRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HttpRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/IOC.java b/src/main/java/ai/reveng/model/IOC.java index 57da4b10..0ea35136 100644 --- a/src/main/java/ai/reveng/model/IOC.java +++ b/src/main/java/ai/reveng/model/IOC.java @@ -20,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -50,189 +49,93 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class IOC { - /** - * Type of the IOC - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - IP("ip"), - - DOMAIN("domain"), - - URL("url"), - - USERNAMES("usernames"), - - PASSWORDS("passwords"), - - FILE_HASH("file_hash"), - - MUTEX("mutex"), - - REGISTRY_KEY("registry_key"), - - FILENAME("filename"), - - EMAIL("email"), - - C2_ENDPOINT("c2_endpoint"), - - USER_AGENT("user_agent"), - - PEM_KEY("pem_key"), - - SSH_KEY("ssh_key"), - - NETWORK_PORT("network_port"), - - JA3("ja3"), - - SSL_CERT_FINGERPRINT("ssl_cert_fingerprint"), - - HTTP_HEADER("http_header"), - - SERVICE("service"), - - SCHEDULED_TASK("scheduled_task"), - - PE_HEADER("pe_header"), - - ENTROPY("entropy"), - - OTHER("other"), - - UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); - - private String value; - - TypeEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - return UNKNOWN_DEFAULT_OPEN_API; - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - String value = jsonElement.getAsString(); - TypeEnum.fromValue(value); - } - } - - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - @javax.annotation.Nonnull - private TypeEnum type; - - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - @javax.annotation.Nonnull - private String value; - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; @SerializedName(SERIALIZED_NAME_DESCRIPTION) @javax.annotation.Nonnull private String description; - public static final String SERIALIZED_NAME_SOURCE = "source"; - @SerializedName(SERIALIZED_NAME_SOURCE) - @javax.annotation.Nullable - private String source; - public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; @SerializedName(SERIALIZED_NAME_FUNCTION_ID) @javax.annotation.Nullable - private Integer functionId; + private Long functionId; public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) @javax.annotation.Nullable private String functionName; + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nullable + private String source; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + @javax.annotation.Nonnull + private String value; + public IOC() { } - public IOC type(@javax.annotation.Nonnull TypeEnum type) { - this.type = type; + public IOC description(@javax.annotation.Nonnull String description) { + this.description = description; return this; } /** - * Type of the IOC - * @return type + * What the indicator means + * @return description */ @javax.annotation.Nonnull - public TypeEnum getType() { - return type; + public String getDescription() { + return description; } - public void setType(@javax.annotation.Nonnull TypeEnum type) { - this.type = type; + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; } - public IOC value(@javax.annotation.Nonnull String value) { - this.value = value; + public IOC functionId(@javax.annotation.Nullable Long functionId) { + this.functionId = functionId; return this; } /** - * Value of the IOC - * @return value + * ID of the function it was found in. Null when the source does not resolve to one. + * @return functionId */ - @javax.annotation.Nonnull - public String getValue() { - return value; + @javax.annotation.Nullable + public Long getFunctionId() { + return functionId; } - public void setValue(@javax.annotation.Nonnull String value) { - this.value = value; + public void setFunctionId(@javax.annotation.Nullable Long functionId) { + this.functionId = functionId; } - public IOC description(@javax.annotation.Nonnull String description) { - this.description = description; + public IOC functionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; return this; } /** - * Description of the IOC - * @return description + * Name of the function it was found in. Null when the source does not resolve to one. + * @return functionName */ - @javax.annotation.Nonnull - public String getDescription() { - return description; + @javax.annotation.Nullable + public String getFunctionName() { + return functionName; } - public void setDescription(@javax.annotation.Nonnull String description) { - this.description = description; + public void setFunctionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; } @@ -242,7 +145,7 @@ public IOC source(@javax.annotation.Nullable String source) { } /** - * The source address where the IOC can be found in the binary if possible. + * Where in the binary it was found, usually a hex address. Null when the agent did not report one. * @return source */ @javax.annotation.Nullable @@ -255,41 +158,41 @@ public void setSource(@javax.annotation.Nullable String source) { } - public IOC functionId(@javax.annotation.Nullable Integer functionId) { - this.functionId = functionId; + public IOC type(@javax.annotation.Nonnull String type) { + this.type = type; return this; } /** - * Unique identifier of the function containing the IOC - * @return functionId + * Indicator type + * @return type */ - @javax.annotation.Nullable - public Integer getFunctionId() { - return functionId; + @javax.annotation.Nonnull + public String getType() { + return type; } - public void setFunctionId(@javax.annotation.Nullable Integer functionId) { - this.functionId = functionId; + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; } - public IOC functionName(@javax.annotation.Nullable String functionName) { - this.functionName = functionName; + public IOC value(@javax.annotation.Nonnull String value) { + this.value = value; return this; } /** - * Name of the function containing the IOC - * @return functionName + * The indicator itself + * @return value */ - @javax.annotation.Nullable - public String getFunctionName() { - return functionName; + @javax.annotation.Nonnull + public String getValue() { + return value; } - public void setFunctionName(@javax.annotation.Nullable String functionName) { - this.functionName = functionName; + public void setValue(@javax.annotation.Nonnull String value) { + this.value = value; } /** @@ -347,41 +250,30 @@ public boolean equals(Object o) { return false; } IOC IOC = (IOC) o; - return Objects.equals(this.type, IOC.type) && - Objects.equals(this.value, IOC.value) && - Objects.equals(this.description, IOC.description) && - Objects.equals(this.source, IOC.source) && + return Objects.equals(this.description, IOC.description) && Objects.equals(this.functionId, IOC.functionId) && - Objects.equals(this.functionName, IOC.functionName)&& + Objects.equals(this.functionName, IOC.functionName) && + Objects.equals(this.source, IOC.source) && + Objects.equals(this.type, IOC.type) && + Objects.equals(this.value, IOC.value)&& Objects.equals(this.additionalProperties, IOC.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - @Override public int hashCode() { - return Objects.hash(type, value, description, source, functionId, functionName, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(description, functionId, functionName, source, type, value, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class IOC {\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" source: ").append(toIndentedString(source)).append("\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -401,10 +293,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("type", "value", "description", "source", "function_id", "function_name")); + openapiFields = new HashSet(Arrays.asList("description", "function_id", "function_name", "source", "type", "value")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("type", "value", "description")); + openapiRequiredFields = new HashSet(Arrays.asList("description", "function_id", "function_name", "source", "type", "value")); } /** @@ -427,22 +319,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - // validate the required field `type` - TypeEnum.validateJsonElement(jsonObj.get("type")); - if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); - } if (!jsonObj.get("description").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } + if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } if ((jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) && !jsonObj.get("source").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); } - if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("value").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } } diff --git a/src/main/java/ai/reveng/model/ImportedApi.java b/src/main/java/ai/reveng/model/ImportedApi.java new file mode 100644 index 00000000..b82e39f6 --- /dev/null +++ b/src/main/java/ai/reveng/model/ImportedApi.java @@ -0,0 +1,330 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ImportedApi + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ImportedApi { + public static final String SERIALIZED_NAME_MODULE = "module"; + @SerializedName(SERIALIZED_NAME_MODULE) + @javax.annotation.Nullable + private String module; + + public static final String SERIALIZED_NAME_API = "api"; + @SerializedName(SERIALIZED_NAME_API) + @javax.annotation.Nonnull + private String api; + + public ImportedApi() { + } + + public ImportedApi module(@javax.annotation.Nullable String module) { + this.module = module; + return this; + } + + /** + * Get module + * @return module + */ + @javax.annotation.Nullable + public String getModule() { + return module; + } + + public void setModule(@javax.annotation.Nullable String module) { + this.module = module; + } + + + public ImportedApi api(@javax.annotation.Nonnull String api) { + this.api = api; + return this; + } + + /** + * Get api + * @return api + */ + @javax.annotation.Nonnull + public String getApi() { + return api; + } + + public void setApi(@javax.annotation.Nonnull String api) { + this.api = api; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ImportedApi instance itself + */ + public ImportedApi putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImportedApi importedApi = (ImportedApi) o; + return Objects.equals(this.module, importedApi.module) && + Objects.equals(this.api, importedApi.api)&& + Objects.equals(this.additionalProperties, importedApi.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(module, api, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ImportedApi {\n"); + sb.append(" module: ").append(toIndentedString(module)).append("\n"); + sb.append(" api: ").append(toIndentedString(api)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("module", "api")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("api")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ImportedApi + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ImportedApi.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ImportedApi is not found in the empty JSON string", ImportedApi.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ImportedApi.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("module") != null && !jsonObj.get("module").isJsonNull()) && !jsonObj.get("module").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `module` to be a primitive type in the JSON string but got `%s`", jsonObj.get("module").toString())); + } + if (!jsonObj.get("api").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `api` to be a primitive type in the JSON string but got `%s`", jsonObj.get("api").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ImportedApi.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ImportedApi' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ImportedApi.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ImportedApi value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ImportedApi read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ImportedApi instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ImportedApi given an JSON string + * + * @param jsonString JSON string + * @return An instance of ImportedApi + * @throws IOException if the JSON string is invalid with respect to ImportedApi + */ + public static ImportedApi fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ImportedApi.class); + } + + /** + * Convert an instance of ImportedApi to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ImportedApiCall.java b/src/main/java/ai/reveng/model/ImportedApiCall.java new file mode 100644 index 00000000..9cf34d37 --- /dev/null +++ b/src/main/java/ai/reveng/model/ImportedApiCall.java @@ -0,0 +1,361 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CallChain; +import ai.reveng.model.ImportedApi; +import ai.reveng.model.Subject; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ImportedApiCall + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ImportedApiCall { + public static final String SERIALIZED_NAME_IMPORTED_API = "imported_api"; + @SerializedName(SERIALIZED_NAME_IMPORTED_API) + @javax.annotation.Nonnull + private ImportedApi importedApi; + + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + @javax.annotation.Nonnull + private Subject subject; + + public static final String SERIALIZED_NAME_REACHABILITY = "reachability"; + @SerializedName(SERIALIZED_NAME_REACHABILITY) + @javax.annotation.Nullable + private CallChain reachability; + + public ImportedApiCall() { + } + + public ImportedApiCall importedApi(@javax.annotation.Nonnull ImportedApi importedApi) { + this.importedApi = importedApi; + return this; + } + + /** + * Get importedApi + * @return importedApi + */ + @javax.annotation.Nonnull + public ImportedApi getImportedApi() { + return importedApi; + } + + public void setImportedApi(@javax.annotation.Nonnull ImportedApi importedApi) { + this.importedApi = importedApi; + } + + + public ImportedApiCall subject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + return this; + } + + /** + * Get subject + * @return subject + */ + @javax.annotation.Nonnull + public Subject getSubject() { + return subject; + } + + public void setSubject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + } + + + public ImportedApiCall reachability(@javax.annotation.Nullable CallChain reachability) { + this.reachability = reachability; + return this; + } + + /** + * Get reachability + * @return reachability + */ + @javax.annotation.Nullable + public CallChain getReachability() { + return reachability; + } + + public void setReachability(@javax.annotation.Nullable CallChain reachability) { + this.reachability = reachability; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ImportedApiCall instance itself + */ + public ImportedApiCall putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImportedApiCall importedApiCall = (ImportedApiCall) o; + return Objects.equals(this.importedApi, importedApiCall.importedApi) && + Objects.equals(this.subject, importedApiCall.subject) && + Objects.equals(this.reachability, importedApiCall.reachability)&& + Objects.equals(this.additionalProperties, importedApiCall.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(importedApi, subject, reachability, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ImportedApiCall {\n"); + sb.append(" importedApi: ").append(toIndentedString(importedApi)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" reachability: ").append(toIndentedString(reachability)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("imported_api", "subject", "reachability")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("imported_api", "subject")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ImportedApiCall + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ImportedApiCall.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ImportedApiCall is not found in the empty JSON string", ImportedApiCall.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ImportedApiCall.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `imported_api` + ImportedApi.validateJsonElement(jsonObj.get("imported_api")); + // validate the required field `subject` + Subject.validateJsonElement(jsonObj.get("subject")); + // validate the optional field `reachability` + if (jsonObj.get("reachability") != null && !jsonObj.get("reachability").isJsonNull()) { + CallChain.validateJsonElement(jsonObj.get("reachability")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ImportedApiCall.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ImportedApiCall' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ImportedApiCall.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ImportedApiCall value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ImportedApiCall read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ImportedApiCall instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ImportedApiCall given an JSON string + * + * @param jsonString JSON string + * @return An instance of ImportedApiCall + * @throws IOException if the JSON string is invalid with respect to ImportedApiCall + */ + public static ImportedApiCall fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ImportedApiCall.class); + } + + /** + * Convert an instance of ImportedApiCall to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ImportedApiCallEvidence.java b/src/main/java/ai/reveng/model/ImportedApiCallEvidence.java new file mode 100644 index 00000000..e6dd6191 --- /dev/null +++ b/src/main/java/ai/reveng/model/ImportedApiCallEvidence.java @@ -0,0 +1,591 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceEffect; +import ai.reveng.model.ImportedApiCall; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Imported API calls observed in the program. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ImportedApiCallEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + IMPORTED_API_CALL("imported_api_call"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.IMPORTED_API_CALL; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + DIRECT("direct"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.DIRECT; + + public static final String SERIALIZED_NAME_CALLS = "calls"; + @SerializedName(SERIALIZED_NAME_CALLS) + @javax.annotation.Nonnull + private List calls = new ArrayList<>(); + + public ImportedApiCallEvidence() { + } + + public ImportedApiCallEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public ImportedApiCallEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public ImportedApiCallEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public ImportedApiCallEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public ImportedApiCallEvidence calls(@javax.annotation.Nonnull List calls) { + this.calls = calls; + return this; + } + + public ImportedApiCallEvidence addCallsItem(ImportedApiCall callsItem) { + if (this.calls == null) { + this.calls = new ArrayList<>(); + } + this.calls.add(callsItem); + return this; + } + + /** + * Get calls + * @return calls + */ + @javax.annotation.Nonnull + public List getCalls() { + return calls; + } + + public void setCalls(@javax.annotation.Nonnull List calls) { + this.calls = calls; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ImportedApiCallEvidence instance itself + */ + public ImportedApiCallEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImportedApiCallEvidence importedApiCallEvidence = (ImportedApiCallEvidence) o; + return Objects.equals(this.evidenceKind, importedApiCallEvidence.evidenceKind) && + Objects.equals(this.kind, importedApiCallEvidence.kind) && + Objects.equals(this.effect, importedApiCallEvidence.effect) && + Objects.equals(this.strength, importedApiCallEvidence.strength) && + Objects.equals(this.calls, importedApiCallEvidence.calls)&& + Objects.equals(this.additionalProperties, importedApiCallEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, calls, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ImportedApiCallEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" calls: ").append(toIndentedString(calls)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "calls")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "calls")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ImportedApiCallEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ImportedApiCallEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ImportedApiCallEvidence is not found in the empty JSON string", ImportedApiCallEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ImportedApiCallEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + if (jsonObj.get("calls") != null) { + if (!jsonObj.get("calls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `calls` to be an array in the JSON string but got `%s`", jsonObj.get("calls").toString())); + } + JsonArray jsonArraycalls = jsonObj.getAsJsonArray("calls"); + // validate the required field `calls` (array) + for (int i = 0; i < jsonArraycalls.size(); i++) { + ImportedApiCall.validateJsonElement(jsonArraycalls.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ImportedApiCallEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ImportedApiCallEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ImportedApiCallEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ImportedApiCallEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ImportedApiCallEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ImportedApiCallEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ImportedApiCallEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of ImportedApiCallEvidence + * @throws IOException if the JSON string is invalid with respect to ImportedApiCallEvidence + */ + public static ImportedApiCallEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ImportedApiCallEvidence.class); + } + + /** + * Convert an instance of ImportedApiCallEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ImportedFunctionCallerEntry.java b/src/main/java/ai/reveng/model/ImportedFunctionCallerEntry.java index f09c0294..dbd948f2 100644 --- a/src/main/java/ai/reveng/model/ImportedFunctionCallerEntry.java +++ b/src/main/java/ai/reveng/model/ImportedFunctionCallerEntry.java @@ -147,6 +147,50 @@ public void setStubVaddr(@javax.annotation.Nonnull Long stubVaddr) { this.stubVaddr = stubVaddr; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ImportedFunctionCallerEntry instance itself + */ + public ImportedFunctionCallerEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.functionId, importedFunctionCallerEntry.functionId) && Objects.equals(this.functionName, importedFunctionCallerEntry.functionName) && Objects.equals(this.functionVaddr, importedFunctionCallerEntry.functionVaddr) && - Objects.equals(this.stubVaddr, importedFunctionCallerEntry.stubVaddr); + Objects.equals(this.stubVaddr, importedFunctionCallerEntry.stubVaddr)&& + Objects.equals(this.additionalProperties, importedFunctionCallerEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionName, functionVaddr, stubVaddr); + return Objects.hash(functionId, functionName, functionVaddr, stubVaddr, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); sb.append(" stubVaddr: ").append(toIndentedString(stubVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ImportedFunctionCallerEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ImportedFunctionCallerEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ImportedFunctionCallerEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -249,6 +287,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ImportedFunctionCallerEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -256,7 +316,28 @@ public void write(JsonWriter out, ImportedFunctionCallerEntry value) throws IOEx public ImportedFunctionCallerEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ImportedFunctionCallerEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ImportedFunctionDetailOutputBody.java b/src/main/java/ai/reveng/model/ImportedFunctionDetailOutputBody.java index 5464269b..c0cdd415 100644 --- a/src/main/java/ai/reveng/model/ImportedFunctionDetailOutputBody.java +++ b/src/main/java/ai/reveng/model/ImportedFunctionDetailOutputBody.java @@ -286,6 +286,50 @@ public void setVaddr(@javax.annotation.Nullable Long vaddr) { this.vaddr = vaddr; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ImportedFunctionDetailOutputBody instance itself + */ + public ImportedFunctionDetailOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -305,12 +349,13 @@ public boolean equals(Object o) { Objects.equals(this.name, importedFunctionDetailOutputBody.name) && Objects.equals(this.originalName, importedFunctionDetailOutputBody.originalName) && Objects.equals(this.stubVaddrs, importedFunctionDetailOutputBody.stubVaddrs) && - Objects.equals(this.vaddr, importedFunctionDetailOutputBody.vaddr); + Objects.equals(this.vaddr, importedFunctionDetailOutputBody.vaddr)&& + Objects.equals(this.additionalProperties, importedFunctionDetailOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(callers, importedFunctionId, isFunction, libraryName, libraryVersion, name, originalName, stubVaddrs, vaddr); + return Objects.hash(callers, importedFunctionId, isFunction, libraryName, libraryVersion, name, originalName, stubVaddrs, vaddr, additionalProperties); } @Override @@ -326,6 +371,7 @@ public String toString() { sb.append(" originalName: ").append(toIndentedString(originalName)).append("\n"); sb.append(" stubVaddrs: ").append(toIndentedString(stubVaddrs)).append("\n"); sb.append(" vaddr: ").append(toIndentedString(vaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -363,14 +409,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ImportedFunctionDetailOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ImportedFunctionDetailOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ImportedFunctionDetailOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -378,15 +416,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("callers") != null && !jsonObj.get("callers").isJsonNull()) { - if (!jsonObj.get("callers").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callers` to be an array in the JSON string but got `%s`", jsonObj.get("callers").toString())); - } - JsonArray jsonArraycallers = jsonObj.getAsJsonArray("callers"); - // validate the required field `callers` (array) - for (int i = 0; i < jsonArraycallers.size(); i++) { - ImportedFunctionCallerEntry.validateJsonElement(jsonArraycallers.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("callers") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("callers").isJsonArray() && !jsonObj.get("callers").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callers` to be an array in the JSON string but got `%s`", jsonObj.get("callers").toString())); } if (!jsonObj.get("library_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `library_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("library_name").toString())); @@ -423,6 +457,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ImportedFunctionDetailOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -430,7 +486,28 @@ public void write(JsonWriter out, ImportedFunctionDetailOutputBody value) throws public ImportedFunctionDetailOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ImportedFunctionDetailOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/IndirectCallSite.java b/src/main/java/ai/reveng/model/IndirectCallSite.java index 29ecca18..7bd99d55 100644 --- a/src/main/java/ai/reveng/model/IndirectCallSite.java +++ b/src/main/java/ai/reveng/model/IndirectCallSite.java @@ -171,6 +171,50 @@ public void setTargetVaddr(@javax.annotation.Nonnull Long targetVaddr) { this.targetVaddr = targetVaddr; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the IndirectCallSite instance itself + */ + public IndirectCallSite putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -186,12 +230,13 @@ public boolean equals(Object o) { Objects.equals(this.instVaddr, indirectCallSite.instVaddr) && Objects.equals(this.isExternal, indirectCallSite.isExternal) && Objects.equals(this.targetName, indirectCallSite.targetName) && - Objects.equals(this.targetVaddr, indirectCallSite.targetVaddr); + Objects.equals(this.targetVaddr, indirectCallSite.targetVaddr)&& + Objects.equals(this.additionalProperties, indirectCallSite.additionalProperties); } @Override public int hashCode() { - return Objects.hash(calleeFunctionId, instVaddr, isExternal, targetName, targetVaddr); + return Objects.hash(calleeFunctionId, instVaddr, isExternal, targetName, targetVaddr, additionalProperties); } @Override @@ -203,6 +248,7 @@ public String toString() { sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); sb.append(" targetName: ").append(toIndentedString(targetName)).append("\n"); sb.append(" targetVaddr: ").append(toIndentedString(targetVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -240,14 +286,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!IndirectCallSite.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `IndirectCallSite` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : IndirectCallSite.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -275,6 +313,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, IndirectCallSite value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -282,7 +342,28 @@ public void write(JsonWriter out, IndirectCallSite value) throws IOException { public IndirectCallSite read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + IndirectCallSite instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/IndirectCallSitesOutputBody.java b/src/main/java/ai/reveng/model/IndirectCallSitesOutputBody.java index eadd9c60..79fdbb85 100644 --- a/src/main/java/ai/reveng/model/IndirectCallSitesOutputBody.java +++ b/src/main/java/ai/reveng/model/IndirectCallSitesOutputBody.java @@ -110,6 +110,50 @@ public void setSites(@javax.annotation.Nullable List sites) { this.sites = sites; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the IndirectCallSitesOutputBody instance itself + */ + public IndirectCallSitesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } IndirectCallSitesOutputBody indirectCallSitesOutputBody = (IndirectCallSitesOutputBody) o; return Objects.equals(this.functionId, indirectCallSitesOutputBody.functionId) && - Objects.equals(this.sites, indirectCallSitesOutputBody.sites); + Objects.equals(this.sites, indirectCallSitesOutputBody.sites)&& + Objects.equals(this.additionalProperties, indirectCallSitesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, sites); + return Objects.hash(functionId, sites, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class IndirectCallSitesOutputBody {\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" sites: ").append(toIndentedString(sites)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!IndirectCallSitesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `IndirectCallSitesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : IndirectCallSitesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("sites") != null && !jsonObj.get("sites").isJsonNull()) { - if (!jsonObj.get("sites").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sites` to be an array in the JSON string but got `%s`", jsonObj.get("sites").toString())); - } - JsonArray jsonArraysites = jsonObj.getAsJsonArray("sites"); - // validate the required field `sites` (array) - for (int i = 0; i < jsonArraysites.size(); i++) { - IndirectCallSite.validateJsonElement(jsonArraysites.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("sites") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("sites").isJsonArray() && !jsonObj.get("sites").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sites` to be an array in the JSON string but got `%s`", jsonObj.get("sites").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, IndirectCallSitesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, IndirectCallSitesOutputBody value) throws IOEx public IndirectCallSitesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + IndirectCallSitesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/InlineComment.java b/src/main/java/ai/reveng/model/InlineComment.java index 2413f44c..a2f24f5d 100644 --- a/src/main/java/ai/reveng/model/InlineComment.java +++ b/src/main/java/ai/reveng/model/InlineComment.java @@ -99,6 +99,50 @@ public void setLine(@javax.annotation.Nonnull Long line) { this.line = line; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the InlineComment instance itself + */ + public InlineComment putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } InlineComment inlineComment = (InlineComment) o; return Objects.equals(this.comment, inlineComment.comment) && - Objects.equals(this.line, inlineComment.line); + Objects.equals(this.line, inlineComment.line)&& + Objects.equals(this.additionalProperties, inlineComment.additionalProperties); } @Override public int hashCode() { - return Objects.hash(comment, line); + return Objects.hash(comment, line, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class InlineComment {\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" line: ").append(toIndentedString(line)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!InlineComment.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `InlineComment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InlineComment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -197,6 +235,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, InlineComment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -204,7 +264,28 @@ public void write(JsonWriter out, InlineComment value) throws IOException { public InlineComment read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + InlineComment instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/InputBody.java b/src/main/java/ai/reveng/model/InputBody.java new file mode 100644 index 00000000..926a3838 --- /dev/null +++ b/src/main/java/ai/reveng/model/InputBody.java @@ -0,0 +1,282 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * InputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InputBody { + public static final String SERIALIZED_NAME_PASSWORD = "password"; + @SerializedName(SERIALIZED_NAME_PASSWORD) + @javax.annotation.Nullable + private String password; + + public InputBody() { + } + + public InputBody password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * Password to decrypt an encrypted archive. + * @return password + */ + @javax.annotation.Nullable + public String getPassword() { + return password; + } + + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the InputBody instance itself + */ + public InputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InputBody inputBody = (InputBody) o; + return Objects.equals(this.password, inputBody.password)&& + Objects.equals(this.additionalProperties, inputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(password, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InputBody {\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("password")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to InputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!InputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in InputBody is not found in the empty JSON string", InputBody.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!InputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'InputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(InputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, InputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public InputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + InputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of InputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of InputBody + * @throws IOException if the JSON string is invalid with respect to InputBody + */ + public static InputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, InputBody.class); + } + + /** + * Convert an instance of InputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/KnownConstantEvidence.java b/src/main/java/ai/reveng/model/KnownConstantEvidence.java new file mode 100644 index 00000000..08e02a9a --- /dev/null +++ b/src/main/java/ai/reveng/model/KnownConstantEvidence.java @@ -0,0 +1,587 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.BytesConstant; +import ai.reveng.model.EvidenceEffect; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * A known constant whose semantic use has not been demonstrated. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class KnownConstantEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + KNOWN_CONSTANT("known_constant"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.KNOWN_CONSTANT; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + INDIRECT("indirect"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.INDIRECT; + + public static final String SERIALIZED_NAME_VALUES = "values"; + @SerializedName(SERIALIZED_NAME_VALUES) + @javax.annotation.Nonnull + private List values = new ArrayList<>(); + + public KnownConstantEvidence() { + } + + public KnownConstantEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public KnownConstantEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public KnownConstantEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public KnownConstantEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public KnownConstantEvidence values(@javax.annotation.Nonnull List values) { + this.values = values; + return this; + } + + public KnownConstantEvidence addValuesItem(BytesConstant valuesItem) { + if (this.values == null) { + this.values = new ArrayList<>(); + } + this.values.add(valuesItem); + return this; + } + + /** + * Get values + * @return values + */ + @javax.annotation.Nonnull + public List getValues() { + return values; + } + + public void setValues(@javax.annotation.Nonnull List values) { + this.values = values; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the KnownConstantEvidence instance itself + */ + public KnownConstantEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + KnownConstantEvidence knownConstantEvidence = (KnownConstantEvidence) o; + return Objects.equals(this.evidenceKind, knownConstantEvidence.evidenceKind) && + Objects.equals(this.kind, knownConstantEvidence.kind) && + Objects.equals(this.effect, knownConstantEvidence.effect) && + Objects.equals(this.strength, knownConstantEvidence.strength) && + Objects.equals(this.values, knownConstantEvidence.values)&& + Objects.equals(this.additionalProperties, knownConstantEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, values, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class KnownConstantEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "values")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "values")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to KnownConstantEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!KnownConstantEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in KnownConstantEvidence is not found in the empty JSON string", KnownConstantEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : KnownConstantEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + // ensure the required json array is present + if (jsonObj.get("values") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("values").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `values` to be an array in the JSON string but got `%s`", jsonObj.get("values").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!KnownConstantEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'KnownConstantEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(KnownConstantEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, KnownConstantEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public KnownConstantEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + KnownConstantEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of KnownConstantEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of KnownConstantEvidence + * @throws IOException if the JSON string is invalid with respect to KnownConstantEvidence + */ + public static KnownConstantEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, KnownConstantEvidence.class); + } + + /** + * Convert an instance of KnownConstantEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/LineAttributionsData.java b/src/main/java/ai/reveng/model/LineAttributionsData.java index 1dd8ed16..1dc7a141 100644 --- a/src/main/java/ai/reveng/model/LineAttributionsData.java +++ b/src/main/java/ai/reveng/model/LineAttributionsData.java @@ -86,6 +86,50 @@ public void setDisassemblyLineNumberToAiDecompilationLineNumbers(@javax.annotati this.disassemblyLineNumberToAiDecompilationLineNumbers = disassemblyLineNumberToAiDecompilationLineNumbers; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the LineAttributionsData instance itself + */ + public LineAttributionsData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } LineAttributionsData lineAttributionsData = (LineAttributionsData) o; - return Objects.equals(this.disassemblyLineNumberToAiDecompilationLineNumbers, lineAttributionsData.disassemblyLineNumberToAiDecompilationLineNumbers); + return Objects.equals(this.disassemblyLineNumberToAiDecompilationLineNumbers, lineAttributionsData.disassemblyLineNumberToAiDecompilationLineNumbers)&& + Objects.equals(this.additionalProperties, lineAttributionsData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(disassemblyLineNumberToAiDecompilationLineNumbers); + return Objects.hash(disassemblyLineNumberToAiDecompilationLineNumbers, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class LineAttributionsData {\n"); sb.append(" disassemblyLineNumberToAiDecompilationLineNumbers: ").append(toIndentedString(disassemblyLineNumberToAiDecompilationLineNumbers)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LineAttributionsData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `LineAttributionsData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : LineAttributionsData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -179,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, LineAttributionsData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -186,7 +246,28 @@ public void write(JsonWriter out, LineAttributionsData value) throws IOException public LineAttributionsData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + LineAttributionsData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListAnalysesOutputBody.java b/src/main/java/ai/reveng/model/ListAnalysesOutputBody.java index 7f1a8357..b142ae3d 100644 --- a/src/main/java/ai/reveng/model/ListAnalysesOutputBody.java +++ b/src/main/java/ai/reveng/model/ListAnalysesOutputBody.java @@ -134,6 +134,50 @@ public void setResults(@javax.annotation.Nullable List resul this.results = results; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListAnalysesOutputBody instance itself + */ + public ListAnalysesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -147,12 +191,13 @@ public boolean equals(Object o) { ListAnalysesOutputBody listAnalysesOutputBody = (ListAnalysesOutputBody) o; return Objects.equals(this.nextPageToken, listAnalysesOutputBody.nextPageToken) && Objects.equals(this.pageSize, listAnalysesOutputBody.pageSize) && - Objects.equals(this.results, listAnalysesOutputBody.results); + Objects.equals(this.results, listAnalysesOutputBody.results)&& + Objects.equals(this.additionalProperties, listAnalysesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(nextPageToken, pageSize, results); + return Objects.hash(nextPageToken, pageSize, results, additionalProperties); } @Override @@ -162,6 +207,7 @@ public String toString() { sb.append(" nextPageToken: ").append(toIndentedString(nextPageToken)).append("\n"); sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -199,14 +245,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListAnalysesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListAnalysesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListAnalysesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -217,15 +255,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("next_page_token") != null && !jsonObj.get("next_page_token").isJsonNull()) && !jsonObj.get("next_page_token").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `next_page_token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("next_page_token").toString())); } - if (jsonObj.get("results") != null && !jsonObj.get("results").isJsonNull()) { - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); - } - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - AnalysisRecordBody.validateJsonElement(jsonArrayresults.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("results") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("results").isJsonArray() && !jsonObj.get("results").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); } } @@ -244,6 +278,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListAnalysesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -251,7 +307,28 @@ public void write(JsonWriter out, ListAnalysesOutputBody value) throws IOExcepti public ListAnalysesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListAnalysesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListAnalysisDataTypesOutputBody.java b/src/main/java/ai/reveng/model/ListAnalysisDataTypesOutputBody.java index 90d901e9..a5be988c 100644 --- a/src/main/java/ai/reveng/model/ListAnalysisDataTypesOutputBody.java +++ b/src/main/java/ai/reveng/model/ListAnalysisDataTypesOutputBody.java @@ -110,6 +110,50 @@ public void setTotalCount(@javax.annotation.Nonnull Long totalCount) { this.totalCount = totalCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListAnalysisDataTypesOutputBody instance itself + */ + public ListAnalysisDataTypesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } ListAnalysisDataTypesOutputBody listAnalysisDataTypesOutputBody = (ListAnalysisDataTypesOutputBody) o; return Objects.equals(this.items, listAnalysisDataTypesOutputBody.items) && - Objects.equals(this.totalCount, listAnalysisDataTypesOutputBody.totalCount); + Objects.equals(this.totalCount, listAnalysisDataTypesOutputBody.totalCount)&& + Objects.equals(this.additionalProperties, listAnalysisDataTypesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(items, totalCount); + return Objects.hash(items, totalCount, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class ListAnalysisDataTypesOutputBody {\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListAnalysisDataTypesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListAnalysisDataTypesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListAnalysisDataTypesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -215,6 +253,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListAnalysisDataTypesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +282,28 @@ public void write(JsonWriter out, ListAnalysisDataTypesOutputBody value) throws public ListAnalysisDataTypesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListAnalysisDataTypesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListAnalysisFunctionsOutputBody.java b/src/main/java/ai/reveng/model/ListAnalysisFunctionsOutputBody.java index ea62c9c4..0a4a1365 100644 --- a/src/main/java/ai/reveng/model/ListAnalysisFunctionsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListAnalysisFunctionsOutputBody.java @@ -110,6 +110,50 @@ public void setTotalCount(@javax.annotation.Nonnull Long totalCount) { this.totalCount = totalCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListAnalysisFunctionsOutputBody instance itself + */ + public ListAnalysisFunctionsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } ListAnalysisFunctionsOutputBody listAnalysisFunctionsOutputBody = (ListAnalysisFunctionsOutputBody) o; return Objects.equals(this.functions, listAnalysisFunctionsOutputBody.functions) && - Objects.equals(this.totalCount, listAnalysisFunctionsOutputBody.totalCount); + Objects.equals(this.totalCount, listAnalysisFunctionsOutputBody.totalCount)&& + Objects.equals(this.additionalProperties, listAnalysisFunctionsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functions, totalCount); + return Objects.hash(functions, totalCount, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class ListAnalysisFunctionsOutputBody {\n"); sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListAnalysisFunctionsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListAnalysisFunctionsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListAnalysisFunctionsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("functions") != null && !jsonObj.get("functions").isJsonNull()) { - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); - } - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - AnalysisFunctionEntry.validateJsonElement(jsonArrayfunctions.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("functions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("functions").isJsonArray() && !jsonObj.get("functions").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListAnalysisFunctionsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, ListAnalysisFunctionsOutputBody value) throws public ListAnalysisFunctionsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListAnalysisFunctionsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java b/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java index 189cbcf7..fdeb2731 100644 --- a/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java @@ -110,6 +110,50 @@ public void setTotalStrings(@javax.annotation.Nonnull Long totalStrings) { this.totalStrings = totalStrings; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListAnalysisStringsOutputBody instance itself + */ + public ListAnalysisStringsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } ListAnalysisStringsOutputBody listAnalysisStringsOutputBody = (ListAnalysisStringsOutputBody) o; return Objects.equals(this.strings, listAnalysisStringsOutputBody.strings) && - Objects.equals(this.totalStrings, listAnalysisStringsOutputBody.totalStrings); + Objects.equals(this.totalStrings, listAnalysisStringsOutputBody.totalStrings)&& + Objects.equals(this.additionalProperties, listAnalysisStringsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(strings, totalStrings); + return Objects.hash(strings, totalStrings, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class ListAnalysisStringsOutputBody {\n"); sb.append(" strings: ").append(toIndentedString(strings)).append("\n"); sb.append(" totalStrings: ").append(toIndentedString(totalStrings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListAnalysisStringsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListAnalysisStringsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListAnalysisStringsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("strings") != null && !jsonObj.get("strings").isJsonNull()) { - if (!jsonObj.get("strings").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); - } - JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); - // validate the required field `strings` (array) - for (int i = 0; i < jsonArraystrings.size(); i++) { - AnalysisStringItem.validateJsonElement(jsonArraystrings.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("strings") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("strings").isJsonArray() && !jsonObj.get("strings").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListAnalysisStringsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, ListAnalysisStringsOutputBody value) throws IO public ListAnalysisStringsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListAnalysisStringsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListArchiveContentsOutputBody.java b/src/main/java/ai/reveng/model/ListArchiveContentsOutputBody.java index 29f7f2b6..8e52f607 100644 --- a/src/main/java/ai/reveng/model/ListArchiveContentsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListArchiveContentsOutputBody.java @@ -304,15 +304,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("entries") != null && !jsonObj.get("entries").isJsonNull()) { - if (!jsonObj.get("entries").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `entries` to be an array in the JSON string but got `%s`", jsonObj.get("entries").toString())); - } - JsonArray jsonArrayentries = jsonObj.getAsJsonArray("entries"); - // validate the required field `entries` (array) - for (int i = 0; i < jsonArrayentries.size(); i++) { - ArchiveContentEntry.validateJsonElement(jsonArrayentries.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("entries") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("entries").isJsonArray() && !jsonObj.get("entries").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `entries` to be an array in the JSON string but got `%s`", jsonObj.get("entries").toString())); } } diff --git a/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java b/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java index 9be38307..35cff04a 100644 --- a/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java @@ -158,6 +158,50 @@ public void setResults(@javax.annotation.Nullable List r this.results = results; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListCollectionsOutputBody instance itself + */ + public ListCollectionsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -172,12 +216,13 @@ public boolean equals(Object o) { return Objects.equals(this.hasNextPage, listCollectionsOutputBody.hasNextPage) && Objects.equals(this.pageNumber, listCollectionsOutputBody.pageNumber) && Objects.equals(this.pageSize, listCollectionsOutputBody.pageSize) && - Objects.equals(this.results, listCollectionsOutputBody.results); + Objects.equals(this.results, listCollectionsOutputBody.results)&& + Objects.equals(this.additionalProperties, listCollectionsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(hasNextPage, pageNumber, pageSize, results); + return Objects.hash(hasNextPage, pageNumber, pageSize, results, additionalProperties); } @Override @@ -188,6 +233,7 @@ public String toString() { sb.append(" pageNumber: ").append(toIndentedString(pageNumber)).append("\n"); sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -225,14 +271,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListCollectionsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListCollectionsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListCollectionsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -240,15 +278,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("results") != null && !jsonObj.get("results").isJsonNull()) { - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); - } - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - CollectionListItemBody.validateJsonElement(jsonArrayresults.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("results") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("results").isJsonArray() && !jsonObj.get("results").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); } } @@ -267,6 +301,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListCollectionsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -274,7 +330,28 @@ public void write(JsonWriter out, ListCollectionsOutputBody value) throws IOExce public ListCollectionsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListCollectionsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListDataTypeFunctionsBody.java b/src/main/java/ai/reveng/model/ListDataTypeFunctionsBody.java index 3a150e66..89ef4fb6 100644 --- a/src/main/java/ai/reveng/model/ListDataTypeFunctionsBody.java +++ b/src/main/java/ai/reveng/model/ListDataTypeFunctionsBody.java @@ -110,6 +110,50 @@ public void setNextAfterFunctionId(@javax.annotation.Nullable Long nextAfterFunc this.nextAfterFunctionId = nextAfterFunctionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListDataTypeFunctionsBody instance itself + */ + public ListDataTypeFunctionsBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } ListDataTypeFunctionsBody listDataTypeFunctionsBody = (ListDataTypeFunctionsBody) o; return Objects.equals(this.items, listDataTypeFunctionsBody.items) && - Objects.equals(this.nextAfterFunctionId, listDataTypeFunctionsBody.nextAfterFunctionId); + Objects.equals(this.nextAfterFunctionId, listDataTypeFunctionsBody.nextAfterFunctionId)&& + Objects.equals(this.additionalProperties, listDataTypeFunctionsBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(items, nextAfterFunctionId); + return Objects.hash(items, nextAfterFunctionId, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class ListDataTypeFunctionsBody {\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); sb.append(" nextAfterFunctionId: ").append(toIndentedString(nextAfterFunctionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListDataTypeFunctionsBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListDataTypeFunctionsBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListDataTypeFunctionsBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("items") != null) { - if (!jsonObj.get("items").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); - } - JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); - // validate the required field `items` (array) - for (int i = 0; i < jsonArrayitems.size(); i++) { - DataTypeFunctionEntry.validateJsonElement(jsonArrayitems.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("items") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListDataTypeFunctionsBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, ListDataTypeFunctionsBody value) throws IOExce public ListDataTypeFunctionsBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListDataTypeFunctionsBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListExampleAnalysesOutputBody.java b/src/main/java/ai/reveng/model/ListExampleAnalysesOutputBody.java index 9f81653d..59517869 100644 --- a/src/main/java/ai/reveng/model/ListExampleAnalysesOutputBody.java +++ b/src/main/java/ai/reveng/model/ListExampleAnalysesOutputBody.java @@ -86,6 +86,50 @@ public void setAnalyses(@javax.annotation.Nullable List analyses) { this.analyses = analyses; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListExampleAnalysesOutputBody instance itself + */ + public ListExampleAnalysesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } ListExampleAnalysesOutputBody listExampleAnalysesOutputBody = (ListExampleAnalysesOutputBody) o; - return Objects.equals(this.analyses, listExampleAnalysesOutputBody.analyses); + return Objects.equals(this.analyses, listExampleAnalysesOutputBody.analyses)&& + Objects.equals(this.additionalProperties, listExampleAnalysesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analyses); + return Objects.hash(analyses, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ListExampleAnalysesOutputBody {\n"); sb.append(" analyses: ").append(toIndentedString(analyses)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListExampleAnalysesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListExampleAnalysesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListExampleAnalysesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("analyses") != null && !jsonObj.get("analyses").isJsonNull()) { - if (!jsonObj.get("analyses").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analyses` to be an array in the JSON string but got `%s`", jsonObj.get("analyses").toString())); - } - JsonArray jsonArrayanalyses = jsonObj.getAsJsonArray("analyses"); - // validate the required field `analyses` (array) - for (int i = 0; i < jsonArrayanalyses.size(); i++) { - Example.validateJsonElement(jsonArrayanalyses.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("analyses") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("analyses").isJsonArray() && !jsonObj.get("analyses").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analyses` to be an array in the JSON string but got `%s`", jsonObj.get("analyses").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListExampleAnalysesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, ListExampleAnalysesOutputBody value) throws IO public ListExampleAnalysesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListExampleAnalysesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListFunctionSignaturesOutputBody.java b/src/main/java/ai/reveng/model/ListFunctionSignaturesOutputBody.java index e8ec36d1..9d47a34f 100644 --- a/src/main/java/ai/reveng/model/ListFunctionSignaturesOutputBody.java +++ b/src/main/java/ai/reveng/model/ListFunctionSignaturesOutputBody.java @@ -120,6 +120,50 @@ public void setItems(@javax.annotation.Nullable List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListFunctionSignaturesOutputBody instance itself + */ + public ListFunctionSignaturesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -132,7 +176,8 @@ public boolean equals(Object o) { } ListFunctionSignaturesOutputBody listFunctionSignaturesOutputBody = (ListFunctionSignaturesOutputBody) o; return Objects.equals(this.dataTypes, listFunctionSignaturesOutputBody.dataTypes) && - Objects.equals(this.items, listFunctionSignaturesOutputBody.items); + Objects.equals(this.items, listFunctionSignaturesOutputBody.items)&& + Objects.equals(this.additionalProperties, listFunctionSignaturesOutputBody.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -141,7 +186,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(dataTypes, items); + return Objects.hash(dataTypes, items, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -157,6 +202,7 @@ public String toString() { sb.append("class ListFunctionSignaturesOutputBody {\n"); sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -194,14 +240,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListFunctionSignaturesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListFunctionSignaturesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListFunctionSignaturesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -209,29 +247,15 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("data_types") != null && !jsonObj.get("data_types").isJsonNull()) { - JsonArray jsonArraydataTypes = jsonObj.getAsJsonArray("data_types"); - if (jsonArraydataTypes != null) { - // ensure the json data is an array - if (!jsonObj.get("data_types").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_types` to be an array in the JSON string but got `%s`", jsonObj.get("data_types").toString())); - } - - // validate the optional field `data_types` (array) - for (int i = 0; i < jsonArraydataTypes.size(); i++) { - AnalysisDataTypesGroup.validateJsonElement(jsonArraydataTypes.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("data_types") != null && !jsonObj.get("data_types").isJsonNull() && !jsonObj.get("data_types").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_types` to be an array in the JSON string but got `%s`", jsonObj.get("data_types").toString())); } - if (jsonObj.get("items") != null && !jsonObj.get("items").isJsonNull()) { - if (!jsonObj.get("items").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); - } - JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); - // validate the required field `items` (array) - for (int i = 0; i < jsonArrayitems.size(); i++) { - BatchFunctionSignatureEntry.validateJsonElement(jsonArrayitems.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("items") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("items").isJsonArray() && !jsonObj.get("items").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); } } @@ -250,6 +274,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListFunctionSignaturesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -257,7 +303,28 @@ public void write(JsonWriter out, ListFunctionSignaturesOutputBody value) throws public ListFunctionSignaturesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListFunctionSignaturesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java b/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java index 103cff0f..26511fb3 100644 --- a/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java @@ -110,6 +110,50 @@ public void setTotalStrings(@javax.annotation.Nonnull Long totalStrings) { this.totalStrings = totalStrings; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListFunctionStringsOutputBody instance itself + */ + public ListFunctionStringsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } ListFunctionStringsOutputBody listFunctionStringsOutputBody = (ListFunctionStringsOutputBody) o; return Objects.equals(this.strings, listFunctionStringsOutputBody.strings) && - Objects.equals(this.totalStrings, listFunctionStringsOutputBody.totalStrings); + Objects.equals(this.totalStrings, listFunctionStringsOutputBody.totalStrings)&& + Objects.equals(this.additionalProperties, listFunctionStringsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(strings, totalStrings); + return Objects.hash(strings, totalStrings, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class ListFunctionStringsOutputBody {\n"); sb.append(" strings: ").append(toIndentedString(strings)).append("\n"); sb.append(" totalStrings: ").append(toIndentedString(totalStrings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListFunctionStringsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListFunctionStringsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListFunctionStringsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("strings") != null && !jsonObj.get("strings").isJsonNull()) { - if (!jsonObj.get("strings").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); - } - JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); - // validate the required field `strings` (array) - for (int i = 0; i < jsonArraystrings.size(); i++) { - FunctionStringItem.validateJsonElement(jsonArraystrings.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("strings") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("strings").isJsonArray() && !jsonObj.get("strings").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListFunctionStringsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, ListFunctionStringsOutputBody value) throws IO public ListFunctionStringsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListFunctionStringsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListImportedFunctionsOutputBody.java b/src/main/java/ai/reveng/model/ListImportedFunctionsOutputBody.java index c565c366..de2fe60c 100644 --- a/src/main/java/ai/reveng/model/ListImportedFunctionsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListImportedFunctionsOutputBody.java @@ -110,6 +110,50 @@ public void setTotalCount(@javax.annotation.Nonnull Long totalCount) { this.totalCount = totalCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListImportedFunctionsOutputBody instance itself + */ + public ListImportedFunctionsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } ListImportedFunctionsOutputBody listImportedFunctionsOutputBody = (ListImportedFunctionsOutputBody) o; return Objects.equals(this.importedFunctions, listImportedFunctionsOutputBody.importedFunctions) && - Objects.equals(this.totalCount, listImportedFunctionsOutputBody.totalCount); + Objects.equals(this.totalCount, listImportedFunctionsOutputBody.totalCount)&& + Objects.equals(this.additionalProperties, listImportedFunctionsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(importedFunctions, totalCount); + return Objects.hash(importedFunctions, totalCount, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class ListImportedFunctionsOutputBody {\n"); sb.append(" importedFunctions: ").append(toIndentedString(importedFunctions)).append("\n"); sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListImportedFunctionsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListImportedFunctionsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListImportedFunctionsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -188,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("imported_functions") != null && !jsonObj.get("imported_functions").isJsonNull()) { - if (!jsonObj.get("imported_functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `imported_functions` to be an array in the JSON string but got `%s`", jsonObj.get("imported_functions").toString())); - } - JsonArray jsonArrayimportedFunctions = jsonObj.getAsJsonArray("imported_functions"); - // validate the required field `imported_functions` (array) - for (int i = 0; i < jsonArrayimportedFunctions.size(); i++) { - ImportedFunctionEntry.validateJsonElement(jsonArrayimportedFunctions.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("imported_functions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("imported_functions").isJsonArray() && !jsonObj.get("imported_functions").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `imported_functions` to be an array in the JSON string but got `%s`", jsonObj.get("imported_functions").toString())); } } @@ -215,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListImportedFunctionsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +278,28 @@ public void write(JsonWriter out, ListImportedFunctionsOutputBody value) throws public ListImportedFunctionsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListImportedFunctionsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListTeamsOutputBody.java b/src/main/java/ai/reveng/model/ListTeamsOutputBody.java index 932162d5..0a98a119 100644 --- a/src/main/java/ai/reveng/model/ListTeamsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListTeamsOutputBody.java @@ -226,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("teams") != null && !jsonObj.get("teams").isJsonNull()) { - if (!jsonObj.get("teams").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `teams` to be an array in the JSON string but got `%s`", jsonObj.get("teams").toString())); - } - JsonArray jsonArrayteams = jsonObj.getAsJsonArray("teams"); - // validate the required field `teams` (array) - for (int i = 0; i < jsonArrayteams.size(); i++) { - Team.validateJsonElement(jsonArrayteams.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("teams") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("teams").isJsonArray() && !jsonObj.get("teams").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `teams` to be an array in the JSON string but got `%s`", jsonObj.get("teams").toString())); } } diff --git a/src/main/java/ai/reveng/model/ListUsersOutputBody.java b/src/main/java/ai/reveng/model/ListUsersOutputBody.java index 25fe92f1..66c97ec5 100644 --- a/src/main/java/ai/reveng/model/ListUsersOutputBody.java +++ b/src/main/java/ai/reveng/model/ListUsersOutputBody.java @@ -226,15 +226,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("users") != null && !jsonObj.get("users").isJsonNull()) { - if (!jsonObj.get("users").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `users` to be an array in the JSON string but got `%s`", jsonObj.get("users").toString())); - } - JsonArray jsonArrayusers = jsonObj.getAsJsonArray("users"); - // validate the required field `users` (array) - for (int i = 0; i < jsonArrayusers.size(); i++) { - User.validateJsonElement(jsonArrayusers.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("users") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("users").isJsonArray() && !jsonObj.get("users").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `users` to be an array in the JSON string but got `%s`", jsonObj.get("users").toString())); } } diff --git a/src/main/java/ai/reveng/model/MemdumpEntry.java b/src/main/java/ai/reveng/model/MemdumpEntry.java index b19d0390..4e2396e2 100644 --- a/src/main/java/ai/reveng/model/MemdumpEntry.java +++ b/src/main/java/ai/reveng/model/MemdumpEntry.java @@ -339,6 +339,50 @@ public void setTargetProcess(@javax.annotation.Nullable Long targetProcess) { this.targetProcess = targetProcess; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MemdumpEntry instance itself + */ + public MemdumpEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -361,12 +405,13 @@ public boolean equals(Object o) { Objects.equals(this.sha256, memdumpEntry.sha256) && Objects.equals(this.size, memdumpEntry.size) && Objects.equals(this.targetAddr, memdumpEntry.targetAddr) && - Objects.equals(this.targetProcess, memdumpEntry.targetProcess); + Objects.equals(this.targetProcess, memdumpEntry.targetProcess)&& + Objects.equals(this.additionalProperties, memdumpEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(address, dumpReason, fileType, filename, index, isPe, method, mimeType, sha256, size, targetAddr, targetProcess); + return Objects.hash(address, dumpReason, fileType, filename, index, isPe, method, mimeType, sha256, size, targetAddr, targetProcess, additionalProperties); } @Override @@ -385,6 +430,7 @@ public String toString() { sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" targetAddr: ").append(toIndentedString(targetAddr)).append("\n"); sb.append(" targetProcess: ").append(toIndentedString(targetProcess)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -422,14 +468,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MemdumpEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MemdumpEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MemdumpEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -478,6 +516,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MemdumpEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -485,7 +545,28 @@ public void write(JsonWriter out, MemdumpEntry value) throws IOException { public MemdumpEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MemdumpEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Meta.java b/src/main/java/ai/reveng/model/Meta.java new file mode 100644 index 00000000..89bec5d0 --- /dev/null +++ b/src/main/java/ai/reveng/model/Meta.java @@ -0,0 +1,284 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Endianness; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Meta + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Meta { + public static final String SERIALIZED_NAME_ENDIANNESS = "endianness"; + @SerializedName(SERIALIZED_NAME_ENDIANNESS) + @javax.annotation.Nullable + private Endianness endianness = Endianness.UNSPECIFIED; + + public Meta() { + } + + public Meta endianness(@javax.annotation.Nullable Endianness endianness) { + this.endianness = endianness; + return this; + } + + /** + * Get endianness + * @return endianness + */ + @javax.annotation.Nullable + public Endianness getEndianness() { + return endianness; + } + + public void setEndianness(@javax.annotation.Nullable Endianness endianness) { + this.endianness = endianness; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Meta instance itself + */ + public Meta putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Meta meta = (Meta) o; + return Objects.equals(this.endianness, meta.endianness)&& + Objects.equals(this.additionalProperties, meta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(endianness, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Meta {\n"); + sb.append(" endianness: ").append(toIndentedString(endianness)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("endianness")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Meta + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Meta.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Meta is not found in the empty JSON string", Meta.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `endianness` + if (jsonObj.get("endianness") != null && !jsonObj.get("endianness").isJsonNull()) { + Endianness.validateJsonElement(jsonObj.get("endianness")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Meta.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Meta' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Meta.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Meta value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Meta read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Meta instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Meta given an JSON string + * + * @param jsonString JSON string + * @return An instance of Meta + * @throws IOException if the JSON string is invalid with respect to Meta + */ + public static Meta fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Meta.class); + } + + /** + * Convert an instance of Meta to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Metadata.java b/src/main/java/ai/reveng/model/Metadata.java new file mode 100644 index 00000000..7befc519 --- /dev/null +++ b/src/main/java/ai/reveng/model/Metadata.java @@ -0,0 +1,393 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Metadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Metadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means this agent has never been triggered for the analysis, so it is safe to start one. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public Metadata() { + } + + public Metadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public Metadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first, empty until the run logs anything. Each entry is a [timestamp, message] pair. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public Metadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means this agent has never been triggered for the analysis, so it is safe to start one. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Metadata instance itself + */ + public Metadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Metadata metadata = (Metadata) o; + return Objects.equals(this.logHistory, metadata.logHistory) && + Objects.equals(this.status, metadata.status)&& + Objects.equals(this.additionalProperties, metadata.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Metadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("log_history", "status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Metadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Metadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Metadata is not found in the empty JSON string", Metadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Metadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("log_history") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("log_history").isJsonArray() && !jsonObj.get("log_history").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Metadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Metadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Metadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Metadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Metadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Metadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Metadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of Metadata + * @throws IOException if the JSON string is invalid with respect to Metadata + */ + public static Metadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Metadata.class); + } + + /** + * Convert an instance of Metadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ModelInterpretation.java b/src/main/java/ai/reveng/model/ModelInterpretation.java new file mode 100644 index 00000000..8a9355fa --- /dev/null +++ b/src/main/java/ai/reveng/model/ModelInterpretation.java @@ -0,0 +1,294 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ModelInterpretation + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelInterpretation { + public static final String SERIALIZED_NAME_INTERPRETATION = "interpretation"; + @SerializedName(SERIALIZED_NAME_INTERPRETATION) + @javax.annotation.Nullable + private String interpretation; + + public ModelInterpretation() { + } + + public ModelInterpretation interpretation(@javax.annotation.Nullable String interpretation) { + this.interpretation = interpretation; + return this; + } + + /** + * Get interpretation + * @return interpretation + */ + @javax.annotation.Nullable + public String getInterpretation() { + return interpretation; + } + + public void setInterpretation(@javax.annotation.Nullable String interpretation) { + this.interpretation = interpretation; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModelInterpretation instance itself + */ + public ModelInterpretation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelInterpretation modelInterpretation = (ModelInterpretation) o; + return Objects.equals(this.interpretation, modelInterpretation.interpretation)&& + Objects.equals(this.additionalProperties, modelInterpretation.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(interpretation, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelInterpretation {\n"); + sb.append(" interpretation: ").append(toIndentedString(interpretation)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("interpretation")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ModelInterpretation + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ModelInterpretation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ModelInterpretation is not found in the empty JSON string", ModelInterpretation.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("interpretation") != null && !jsonObj.get("interpretation").isJsonNull()) && !jsonObj.get("interpretation").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `interpretation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("interpretation").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ModelInterpretation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ModelInterpretation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ModelInterpretation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ModelInterpretation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ModelInterpretation read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModelInterpretation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ModelInterpretation given an JSON string + * + * @param jsonString JSON string + * @return An instance of ModelInterpretation + * @throws IOException if the JSON string is invalid with respect to ModelInterpretation + */ + public static ModelInterpretation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ModelInterpretation.class); + } + + /** + * Convert an instance of ModelInterpretation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ModelInterpretationEvidence.java b/src/main/java/ai/reveng/model/ModelInterpretationEvidence.java new file mode 100644 index 00000000..20f67f43 --- /dev/null +++ b/src/main/java/ai/reveng/model/ModelInterpretationEvidence.java @@ -0,0 +1,537 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceEffect; +import ai.reveng.model.EvidenceStrength; +import ai.reveng.model.ModelInterpretation; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * LLM interpretations of observations. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ModelInterpretationEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + MODEL_INTERPRETATION("model_interpretation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.MODEL_INTERPRETATION; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + MODEL_INTERPRETATION("model_interpretation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.MODEL_INTERPRETATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private EvidenceStrength strength = EvidenceStrength.INDIRECT; + + public static final String SERIALIZED_NAME_INTERPRETATIONS = "interpretations"; + @SerializedName(SERIALIZED_NAME_INTERPRETATIONS) + @javax.annotation.Nonnull + private List interpretations = new ArrayList<>(); + + public ModelInterpretationEvidence() { + } + + public ModelInterpretationEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public ModelInterpretationEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public ModelInterpretationEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public ModelInterpretationEvidence strength(@javax.annotation.Nullable EvidenceStrength strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public EvidenceStrength getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable EvidenceStrength strength) { + this.strength = strength; + } + + + public ModelInterpretationEvidence interpretations(@javax.annotation.Nonnull List interpretations) { + this.interpretations = interpretations; + return this; + } + + public ModelInterpretationEvidence addInterpretationsItem(ModelInterpretation interpretationsItem) { + if (this.interpretations == null) { + this.interpretations = new ArrayList<>(); + } + this.interpretations.add(interpretationsItem); + return this; + } + + /** + * Get interpretations + * @return interpretations + */ + @javax.annotation.Nonnull + public List getInterpretations() { + return interpretations; + } + + public void setInterpretations(@javax.annotation.Nonnull List interpretations) { + this.interpretations = interpretations; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModelInterpretationEvidence instance itself + */ + public ModelInterpretationEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelInterpretationEvidence modelInterpretationEvidence = (ModelInterpretationEvidence) o; + return Objects.equals(this.evidenceKind, modelInterpretationEvidence.evidenceKind) && + Objects.equals(this.kind, modelInterpretationEvidence.kind) && + Objects.equals(this.effect, modelInterpretationEvidence.effect) && + Objects.equals(this.strength, modelInterpretationEvidence.strength) && + Objects.equals(this.interpretations, modelInterpretationEvidence.interpretations)&& + Objects.equals(this.additionalProperties, modelInterpretationEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, interpretations, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelInterpretationEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" interpretations: ").append(toIndentedString(interpretations)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "interpretations")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "interpretations")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ModelInterpretationEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ModelInterpretationEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ModelInterpretationEvidence is not found in the empty JSON string", ModelInterpretationEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ModelInterpretationEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + EvidenceStrength.validateJsonElement(jsonObj.get("strength")); + } + if (jsonObj.get("interpretations") != null) { + if (!jsonObj.get("interpretations").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `interpretations` to be an array in the JSON string but got `%s`", jsonObj.get("interpretations").toString())); + } + JsonArray jsonArrayinterpretations = jsonObj.getAsJsonArray("interpretations"); + // validate the required field `interpretations` (array) + for (int i = 0; i < jsonArrayinterpretations.size(); i++) { + ModelInterpretation.validateJsonElement(jsonArrayinterpretations.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ModelInterpretationEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ModelInterpretationEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ModelInterpretationEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ModelInterpretationEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ModelInterpretationEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModelInterpretationEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ModelInterpretationEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of ModelInterpretationEvidence + * @throws IOException if the JSON string is invalid with respect to ModelInterpretationEvidence + */ + public static ModelInterpretationEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ModelInterpretationEvidence.class); + } + + /** + * Convert an instance of ModelInterpretationEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ModuleLoadEntry.java b/src/main/java/ai/reveng/model/ModuleLoadEntry.java index 5efd941d..7ea437f6 100644 --- a/src/main/java/ai/reveng/model/ModuleLoadEntry.java +++ b/src/main/java/ai/reveng/model/ModuleLoadEntry.java @@ -157,6 +157,50 @@ public void setProcessSeqid(@javax.annotation.Nullable Long processSeqid) { this.processSeqid = processSeqid; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModuleLoadEntry instance itself + */ + public ModuleLoadEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -171,12 +215,13 @@ public boolean equals(Object o) { return Objects.equals(this.modules, moduleLoadEntry.modules) && Objects.equals(this.pid, moduleLoadEntry.pid) && Objects.equals(this.processName, moduleLoadEntry.processName) && - Objects.equals(this.processSeqid, moduleLoadEntry.processSeqid); + Objects.equals(this.processSeqid, moduleLoadEntry.processSeqid)&& + Objects.equals(this.additionalProperties, moduleLoadEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(modules, pid, processName, processSeqid); + return Objects.hash(modules, pid, processName, processSeqid, additionalProperties); } @Override @@ -187,6 +232,7 @@ public String toString() { sb.append(" pid: ").append(toIndentedString(pid)).append("\n"); sb.append(" processName: ").append(toIndentedString(processName)).append("\n"); sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -224,14 +270,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModuleLoadEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModuleLoadEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModuleLoadEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -259,6 +297,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModuleLoadEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -266,7 +326,28 @@ public void write(JsonWriter out, ModuleLoadEntry value) throws IOException { public ModuleLoadEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModuleLoadEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/MutexEntry.java b/src/main/java/ai/reveng/model/MutexEntry.java index 5bac596f..cb23ba89 100644 --- a/src/main/java/ai/reveng/model/MutexEntry.java +++ b/src/main/java/ai/reveng/model/MutexEntry.java @@ -111,6 +111,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MutexEntry instance itself + */ + public MutexEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,7 +167,8 @@ public boolean equals(Object o) { } MutexEntry mutexEntry = (MutexEntry) o; return Objects.equals(this.events, mutexEntry.events) && - Objects.equals(this.name, mutexEntry.name); + Objects.equals(this.name, mutexEntry.name)&& + Objects.equals(this.additionalProperties, mutexEntry.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -132,7 +177,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, name); + return Objects.hash(events, name, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -148,6 +193,7 @@ public String toString() { sb.append("class MutexEntry {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -185,14 +231,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MutexEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MutexEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MutexEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,19 +238,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -234,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MutexEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +291,28 @@ public void write(JsonWriter out, MutexEntry value) throws IOException { public MutexEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MutexEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/NameConfidence.java b/src/main/java/ai/reveng/model/NameConfidence.java index 767d48af..44454145 100644 --- a/src/main/java/ai/reveng/model/NameConfidence.java +++ b/src/main/java/ai/reveng/model/NameConfidence.java @@ -99,6 +99,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NameConfidence instance itself + */ + public NameConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } NameConfidence nameConfidence = (NameConfidence) o; return Objects.equals(this.confidence, nameConfidence.confidence) && - Objects.equals(this.name, nameConfidence.name); + Objects.equals(this.name, nameConfidence.name)&& + Objects.equals(this.additionalProperties, nameConfidence.additionalProperties); } @Override public int hashCode() { - return Objects.hash(confidence, name); + return Objects.hash(confidence, name, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class NameConfidence {\n"); sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -162,14 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NameConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NameConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NameConfidence.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -197,6 +235,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NameConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -204,7 +264,28 @@ public void write(JsonWriter out, NameConfidence value) throws IOException { public NameConfidence read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NameConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/NamesFinishedEvent.java b/src/main/java/ai/reveng/model/NamesFinishedEvent.java new file mode 100644 index 00000000..188baef6 --- /dev/null +++ b/src/main/java/ai/reveng/model/NamesFinishedEvent.java @@ -0,0 +1,367 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NamesFinishedEvent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NamesFinishedEvent { + public static final String SERIALIZED_NAME_APPLIED = "applied"; + @SerializedName(SERIALIZED_NAME_APPLIED) + @javax.annotation.Nonnull + private Integer applied; + + public static final String SERIALIZED_NAME_ATTEMPT = "attempt"; + @SerializedName(SERIALIZED_NAME_ATTEMPT) + @javax.annotation.Nonnull + private Integer attempt; + + public static final String SERIALIZED_NAME_SEQ = "seq"; + @SerializedName(SERIALIZED_NAME_SEQ) + @javax.annotation.Nonnull + private Integer seq; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public NamesFinishedEvent() { + } + + public NamesFinishedEvent applied(@javax.annotation.Nonnull Integer applied) { + this.applied = applied; + return this; + } + + /** + * Get applied + * @return applied + */ + @javax.annotation.Nonnull + public Integer getApplied() { + return applied; + } + + public void setApplied(@javax.annotation.Nonnull Integer applied) { + this.applied = applied; + } + + + public NamesFinishedEvent attempt(@javax.annotation.Nonnull Integer attempt) { + this.attempt = attempt; + return this; + } + + /** + * Get attempt + * @return attempt + */ + @javax.annotation.Nonnull + public Integer getAttempt() { + return attempt; + } + + public void setAttempt(@javax.annotation.Nonnull Integer attempt) { + this.attempt = attempt; + } + + + public NamesFinishedEvent seq(@javax.annotation.Nonnull Integer seq) { + this.seq = seq; + return this; + } + + /** + * Get seq + * @return seq + */ + @javax.annotation.Nonnull + public Integer getSeq() { + return seq; + } + + public void setSeq(@javax.annotation.Nonnull Integer seq) { + this.seq = seq; + } + + + public NamesFinishedEvent type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NamesFinishedEvent instance itself + */ + public NamesFinishedEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NamesFinishedEvent namesFinishedEvent = (NamesFinishedEvent) o; + return Objects.equals(this.applied, namesFinishedEvent.applied) && + Objects.equals(this.attempt, namesFinishedEvent.attempt) && + Objects.equals(this.seq, namesFinishedEvent.seq) && + Objects.equals(this.type, namesFinishedEvent.type)&& + Objects.equals(this.additionalProperties, namesFinishedEvent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(applied, attempt, seq, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NamesFinishedEvent {\n"); + sb.append(" applied: ").append(toIndentedString(applied)).append("\n"); + sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); + sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("applied", "attempt", "seq", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("applied", "attempt", "seq", "type")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NamesFinishedEvent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NamesFinishedEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NamesFinishedEvent is not found in the empty JSON string", NamesFinishedEvent.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NamesFinishedEvent.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NamesFinishedEvent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NamesFinishedEvent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NamesFinishedEvent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NamesFinishedEvent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NamesFinishedEvent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NamesFinishedEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NamesFinishedEvent given an JSON string + * + * @param jsonString JSON string + * @return An instance of NamesFinishedEvent + * @throws IOException if the JSON string is invalid with respect to NamesFinishedEvent + */ + public static NamesFinishedEvent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NamesFinishedEvent.class); + } + + /** + * Convert an instance of NamesFinishedEvent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkActivity.java b/src/main/java/ai/reveng/model/NetworkActivity.java index f872388e..4471b738 100644 --- a/src/main/java/ai/reveng/model/NetworkActivity.java +++ b/src/main/java/ai/reveng/model/NetworkActivity.java @@ -186,6 +186,50 @@ public void setHttpRequests(@javax.annotation.Nullable List httpReq this.httpRequests = httpRequests; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkActivity instance itself + */ + public NetworkActivity putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -200,7 +244,8 @@ public boolean equals(Object o) { return Objects.equals(this.connections, networkActivity.connections) && Objects.equals(this.dnsQueries, networkActivity.dnsQueries) && Objects.equals(this.extractedUrls, networkActivity.extractedUrls) && - Objects.equals(this.httpRequests, networkActivity.httpRequests); + Objects.equals(this.httpRequests, networkActivity.httpRequests)&& + Objects.equals(this.additionalProperties, networkActivity.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -209,7 +254,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(connections, dnsQueries, extractedUrls, httpRequests); + return Objects.hash(connections, dnsQueries, extractedUrls, httpRequests, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -227,6 +272,7 @@ public String toString() { sb.append(" dnsQueries: ").append(toIndentedString(dnsQueries)).append("\n"); sb.append(" extractedUrls: ").append(toIndentedString(extractedUrls)).append("\n"); sb.append(" httpRequests: ").append(toIndentedString(httpRequests)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -263,70 +309,22 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkActivity is not found in the empty JSON string", NetworkActivity.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NetworkActivity.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NetworkActivity` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("connections") != null && !jsonObj.get("connections").isJsonNull()) { - JsonArray jsonArrayconnections = jsonObj.getAsJsonArray("connections"); - if (jsonArrayconnections != null) { - // ensure the json data is an array - if (!jsonObj.get("connections").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `connections` to be an array in the JSON string but got `%s`", jsonObj.get("connections").toString())); - } - - // validate the optional field `connections` (array) - for (int i = 0; i < jsonArrayconnections.size(); i++) { - Connection.validateJsonElement(jsonArrayconnections.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("connections") != null && !jsonObj.get("connections").isJsonNull() && !jsonObj.get("connections").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `connections` to be an array in the JSON string but got `%s`", jsonObj.get("connections").toString())); } - if (jsonObj.get("dns_queries") != null && !jsonObj.get("dns_queries").isJsonNull()) { - JsonArray jsonArraydnsQueries = jsonObj.getAsJsonArray("dns_queries"); - if (jsonArraydnsQueries != null) { - // ensure the json data is an array - if (!jsonObj.get("dns_queries").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dns_queries` to be an array in the JSON string but got `%s`", jsonObj.get("dns_queries").toString())); - } - - // validate the optional field `dns_queries` (array) - for (int i = 0; i < jsonArraydnsQueries.size(); i++) { - DnsQuery.validateJsonElement(jsonArraydnsQueries.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("dns_queries") != null && !jsonObj.get("dns_queries").isJsonNull() && !jsonObj.get("dns_queries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dns_queries` to be an array in the JSON string but got `%s`", jsonObj.get("dns_queries").toString())); } - if (jsonObj.get("extracted_urls") != null && !jsonObj.get("extracted_urls").isJsonNull()) { - JsonArray jsonArrayextractedUrls = jsonObj.getAsJsonArray("extracted_urls"); - if (jsonArrayextractedUrls != null) { - // ensure the json data is an array - if (!jsonObj.get("extracted_urls").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `extracted_urls` to be an array in the JSON string but got `%s`", jsonObj.get("extracted_urls").toString())); - } - - // validate the optional field `extracted_urls` (array) - for (int i = 0; i < jsonArrayextractedUrls.size(); i++) { - ExtractedURL.validateJsonElement(jsonArrayextractedUrls.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("extracted_urls") != null && !jsonObj.get("extracted_urls").isJsonNull() && !jsonObj.get("extracted_urls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `extracted_urls` to be an array in the JSON string but got `%s`", jsonObj.get("extracted_urls").toString())); } - if (jsonObj.get("http_requests") != null && !jsonObj.get("http_requests").isJsonNull()) { - JsonArray jsonArrayhttpRequests = jsonObj.getAsJsonArray("http_requests"); - if (jsonArrayhttpRequests != null) { - // ensure the json data is an array - if (!jsonObj.get("http_requests").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `http_requests` to be an array in the JSON string but got `%s`", jsonObj.get("http_requests").toString())); - } - - // validate the optional field `http_requests` (array) - for (int i = 0; i < jsonArrayhttpRequests.size(); i++) { - HttpRequest.validateJsonElement(jsonArrayhttpRequests.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("http_requests") != null && !jsonObj.get("http_requests").isJsonNull() && !jsonObj.get("http_requests").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `http_requests` to be an array in the JSON string but got `%s`", jsonObj.get("http_requests").toString())); } } @@ -345,6 +343,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NetworkActivity value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -352,7 +372,28 @@ public void write(JsonWriter out, NetworkActivity value) throws IOException { public NetworkActivity read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkActivity instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/NetworkingCall.java b/src/main/java/ai/reveng/model/NetworkingCall.java new file mode 100644 index 00000000..79d58928 --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingCall.java @@ -0,0 +1,611 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingCall + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingCall { + public static final String SERIALIZED_NAME_CALLEE_NAME = "callee_name"; + @SerializedName(SERIALIZED_NAME_CALLEE_NAME) + @javax.annotation.Nonnull + private String calleeName; + + /** + * Networking category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + ACCEPT("accept"), + + ADDRESS("address"), + + CONNECT("connect"), + + DNS("dns"), + + HTTP("http"), + + NETINFO("netinfo"), + + RAW_PACKET("raw-packet"), + + RECV("recv"), + + SEND("send"), + + SOCKET("socket"), + + TLS("tls"), + + URL("url"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + API("api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + /** + * Networking source the match belongs to + */ + @JsonAdapter(SourceEnum.Adapter.class) + public enum SourceEnum { + BOOST("boost"), + + CPP("cpp"), + + CURL("curl"), + + GENERIC("generic"), + + LIBC("libc"), + + PCAP("pcap"), + + POCO("poco"), + + QT("qt"), + + TLS("tls"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceEnum fromValue(String value) { + for (SourceEnum b : SourceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nonnull + private SourceEnum source; + + public NetworkingCall() { + } + + public NetworkingCall calleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + return this; + } + + /** + * Name of the called function + * @return calleeName + */ + @javax.annotation.Nonnull + public String getCalleeName() { + return calleeName; + } + + public void setCalleeName(@javax.annotation.Nonnull String calleeName) { + this.calleeName = calleeName; + } + + + public NetworkingCall category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Networking category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public NetworkingCall how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public NetworkingCall matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + + public NetworkingCall source(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + return this; + } + + /** + * Networking source the match belongs to + * @return source + */ + @javax.annotation.Nonnull + public SourceEnum getSource() { + return source; + } + + public void setSource(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingCall instance itself + */ + public NetworkingCall putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingCall networkingCall = (NetworkingCall) o; + return Objects.equals(this.calleeName, networkingCall.calleeName) && + Objects.equals(this.category, networkingCall.category) && + Objects.equals(this.how, networkingCall.how) && + Objects.equals(this.matchedName, networkingCall.matchedName) && + Objects.equals(this.source, networkingCall.source)&& + Objects.equals(this.additionalProperties, networkingCall.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(calleeName, category, how, matchedName, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingCall {\n"); + sb.append(" calleeName: ").append(toIndentedString(calleeName)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("callee_name", "category", "how", "matched_name", "source")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("callee_name", "category", "how", "matched_name", "source")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingCall + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingCall.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingCall is not found in the empty JSON string", NetworkingCall.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingCall.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("callee_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); + } + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + // validate the required field `source` + SourceEnum.validateJsonElement(jsonObj.get("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingCall.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingCall' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingCall.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingCall value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingCall read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingCall instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingCall given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingCall + * @throws IOException if the JSON string is invalid with respect to NetworkingCall + */ + public static NetworkingCall fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingCall.class); + } + + /** + * Convert an instance of NetworkingCall to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkingDirectMatch.java b/src/main/java/ai/reveng/model/NetworkingDirectMatch.java new file mode 100644 index 00000000..9d986c0a --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingDirectMatch.java @@ -0,0 +1,582 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingDirectMatch + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingDirectMatch { + /** + * Networking category of the match + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + ACCEPT("accept"), + + ADDRESS("address"), + + CONNECT("connect"), + + DNS("dns"), + + HTTP("http"), + + NETINFO("netinfo"), + + RAW_PACKET("raw-packet"), + + RECV("recv"), + + SEND("send"), + + SOCKET("socket"), + + TLS("tls"), + + URL("url"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + /** + * Detection tier that produced the match + */ + @JsonAdapter(HowEnum.Adapter.class) + public enum HowEnum { + API("api"), + + CPP_CLASS_TOKEN("cpp-class-token"), + + GENERIC_KEYWORD("generic-keyword"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + HowEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static HowEnum fromValue(String value) { + for (HowEnum b : HowEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final HowEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public HowEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return HowEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + HowEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_HOW = "how"; + @SerializedName(SERIALIZED_NAME_HOW) + @javax.annotation.Nonnull + private HowEnum how; + + public static final String SERIALIZED_NAME_MATCHED_NAME = "matched_name"; + @SerializedName(SERIALIZED_NAME_MATCHED_NAME) + @javax.annotation.Nonnull + private String matchedName; + + /** + * Networking source the match belongs to + */ + @JsonAdapter(SourceEnum.Adapter.class) + public enum SourceEnum { + BOOST("boost"), + + CPP("cpp"), + + CURL("curl"), + + GENERIC("generic"), + + LIBC("libc"), + + PCAP("pcap"), + + POCO("poco"), + + QT("qt"), + + TLS("tls"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceEnum fromValue(String value) { + for (SourceEnum b : SourceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nonnull + private SourceEnum source; + + public NetworkingDirectMatch() { + } + + public NetworkingDirectMatch category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Networking category of the match + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + + public NetworkingDirectMatch how(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + return this; + } + + /** + * Detection tier that produced the match + * @return how + */ + @javax.annotation.Nonnull + public HowEnum getHow() { + return how; + } + + public void setHow(@javax.annotation.Nonnull HowEnum how) { + this.how = how; + } + + + public NetworkingDirectMatch matchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + return this; + } + + /** + * Name or token that matched + * @return matchedName + */ + @javax.annotation.Nonnull + public String getMatchedName() { + return matchedName; + } + + public void setMatchedName(@javax.annotation.Nonnull String matchedName) { + this.matchedName = matchedName; + } + + + public NetworkingDirectMatch source(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + return this; + } + + /** + * Networking source the match belongs to + * @return source + */ + @javax.annotation.Nonnull + public SourceEnum getSource() { + return source; + } + + public void setSource(@javax.annotation.Nonnull SourceEnum source) { + this.source = source; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingDirectMatch instance itself + */ + public NetworkingDirectMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingDirectMatch networkingDirectMatch = (NetworkingDirectMatch) o; + return Objects.equals(this.category, networkingDirectMatch.category) && + Objects.equals(this.how, networkingDirectMatch.how) && + Objects.equals(this.matchedName, networkingDirectMatch.matchedName) && + Objects.equals(this.source, networkingDirectMatch.source)&& + Objects.equals(this.additionalProperties, networkingDirectMatch.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, how, matchedName, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingDirectMatch {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" how: ").append(toIndentedString(how)).append("\n"); + sb.append(" matchedName: ").append(toIndentedString(matchedName)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("category", "how", "matched_name", "source")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("category", "how", "matched_name", "source")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingDirectMatch + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingDirectMatch.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingDirectMatch is not found in the empty JSON string", NetworkingDirectMatch.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingDirectMatch.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + if (!jsonObj.get("how").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `how` to be a primitive type in the JSON string but got `%s`", jsonObj.get("how").toString())); + } + // validate the required field `how` + HowEnum.validateJsonElement(jsonObj.get("how")); + if (!jsonObj.get("matched_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("matched_name").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + // validate the required field `source` + SourceEnum.validateJsonElement(jsonObj.get("source")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingDirectMatch.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingDirectMatch' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingDirectMatch.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingDirectMatch value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingDirectMatch read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingDirectMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingDirectMatch given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingDirectMatch + * @throws IOException if the JSON string is invalid with respect to NetworkingDirectMatch + */ + public static NetworkingDirectMatch fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingDirectMatch.class); + } + + /** + * Convert an instance of NetworkingDirectMatch to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkingExplainMetadata.java b/src/main/java/ai/reveng/model/NetworkingExplainMetadata.java new file mode 100644 index 00000000..d0022d1c --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingExplainMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingExplainMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingExplainMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public NetworkingExplainMetadata() { + } + + public NetworkingExplainMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public NetworkingExplainMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public NetworkingExplainMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this function. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingExplainMetadata instance itself + */ + public NetworkingExplainMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingExplainMetadata networkingExplainMetadata = (NetworkingExplainMetadata) o; + return Objects.equals(this.logHistory, networkingExplainMetadata.logHistory) && + Objects.equals(this.status, networkingExplainMetadata.status)&& + Objects.equals(this.additionalProperties, networkingExplainMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingExplainMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingExplainMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingExplainMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingExplainMetadata is not found in the empty JSON string", NetworkingExplainMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingExplainMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingExplainMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingExplainMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingExplainMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingExplainMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingExplainMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingExplainMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingExplainMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingExplainMetadata + * @throws IOException if the JSON string is invalid with respect to NetworkingExplainMetadata + */ + public static NetworkingExplainMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingExplainMetadata.class); + } + + /** + * Convert an instance of NetworkingExplainMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkingExplainResult.java b/src/main/java/ai/reveng/model/NetworkingExplainResult.java new file mode 100644 index 00000000..fe0505e4 --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingExplainResult.java @@ -0,0 +1,606 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.NetworkingExplainedFunction; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingExplainResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingExplainResult { + public static final String SERIALIZED_NAME_CANCELLED = "cancelled"; + @SerializedName(SERIALIZED_NAME_CANCELLED) + @javax.annotation.Nonnull + private Boolean cancelled; + + public static final String SERIALIZED_NAME_DATA_RECEIVED = "data_received"; + @SerializedName(SERIALIZED_NAME_DATA_RECEIVED) + @javax.annotation.Nullable + private String dataReceived; + + public static final String SERIALIZED_NAME_DATA_SENT = "data_sent"; + @SerializedName(SERIALIZED_NAME_DATA_SENT) + @javax.annotation.Nullable + private String dataSent; + + public static final String SERIALIZED_NAME_DATA_USAGE = "data_usage"; + @SerializedName(SERIALIZED_NAME_DATA_USAGE) + @javax.annotation.Nullable + private String dataUsage; + + public static final String SERIALIZED_NAME_ENDPOINTS = "endpoints"; + @SerializedName(SERIALIZED_NAME_ENDPOINTS) + @javax.annotation.Nullable + private List endpoints; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nullable + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTIONS_INVOLVED = "functions_involved"; + @SerializedName(SERIALIZED_NAME_FUNCTIONS_INVOLVED) + @javax.annotation.Nullable + private List functionsInvolved; + + public static final String SERIALIZED_NAME_PROTOCOL = "protocol"; + @SerializedName(SERIALIZED_NAME_PROTOCOL) + @javax.annotation.Nullable + private String protocol; + + public static final String SERIALIZED_NAME_PURPOSE = "purpose"; + @SerializedName(SERIALIZED_NAME_PURPOSE) + @javax.annotation.Nullable + private String purpose; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nullable + private String summary; + + public NetworkingExplainResult() { + } + + public NetworkingExplainResult cancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + return this; + } + + /** + * Whether the run was cancelled + * @return cancelled + */ + @javax.annotation.Nonnull + public Boolean getCancelled() { + return cancelled; + } + + public void setCancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + } + + + public NetworkingExplainResult dataReceived(@javax.annotation.Nullable String dataReceived) { + this.dataReceived = dataReceived; + return this; + } + + /** + * Description of the data received + * @return dataReceived + */ + @javax.annotation.Nullable + public String getDataReceived() { + return dataReceived; + } + + public void setDataReceived(@javax.annotation.Nullable String dataReceived) { + this.dataReceived = dataReceived; + } + + + public NetworkingExplainResult dataSent(@javax.annotation.Nullable String dataSent) { + this.dataSent = dataSent; + return this; + } + + /** + * Description of the data sent + * @return dataSent + */ + @javax.annotation.Nullable + public String getDataSent() { + return dataSent; + } + + public void setDataSent(@javax.annotation.Nullable String dataSent) { + this.dataSent = dataSent; + } + + + public NetworkingExplainResult dataUsage(@javax.annotation.Nullable String dataUsage) { + this.dataUsage = dataUsage; + return this; + } + + /** + * How the sent or received data is used + * @return dataUsage + */ + @javax.annotation.Nullable + public String getDataUsage() { + return dataUsage; + } + + public void setDataUsage(@javax.annotation.Nullable String dataUsage) { + this.dataUsage = dataUsage; + } + + + public NetworkingExplainResult endpoints(@javax.annotation.Nullable List endpoints) { + this.endpoints = endpoints; + return this; + } + + public NetworkingExplainResult addEndpointsItem(String endpointsItem) { + if (this.endpoints == null) { + this.endpoints = new ArrayList<>(); + } + this.endpoints.add(endpointsItem); + return this; + } + + /** + * Concrete remote endpoints identified -- IPs, hostnames, or URLs + * @return endpoints + */ + @javax.annotation.Nullable + public List getEndpoints() { + return endpoints; + } + + public void setEndpoints(@javax.annotation.Nullable List endpoints) { + this.endpoints = endpoints; + } + + + public NetworkingExplainResult functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the explained function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public NetworkingExplainResult functionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the explained function + * @return functionName + */ + @javax.annotation.Nullable + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + } + + + public NetworkingExplainResult functionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + return this; + } + + public NetworkingExplainResult addFunctionsInvolvedItem(NetworkingExplainedFunction functionsInvolvedItem) { + if (this.functionsInvolved == null) { + this.functionsInvolved = new ArrayList<>(); + } + this.functionsInvolved.add(functionsInvolvedItem); + return this; + } + + /** + * Other functions involved in the network communication + * @return functionsInvolved + */ + @javax.annotation.Nullable + public List getFunctionsInvolved() { + return functionsInvolved; + } + + public void setFunctionsInvolved(@javax.annotation.Nullable List functionsInvolved) { + this.functionsInvolved = functionsInvolved; + } + + + public NetworkingExplainResult protocol(@javax.annotation.Nullable String protocol) { + this.protocol = protocol; + return this; + } + + /** + * Protocol used for the communication + * @return protocol + */ + @javax.annotation.Nullable + public String getProtocol() { + return protocol; + } + + public void setProtocol(@javax.annotation.Nullable String protocol) { + this.protocol = protocol; + } + + + public NetworkingExplainResult purpose(@javax.annotation.Nullable String purpose) { + this.purpose = purpose; + return this; + } + + /** + * Purpose of the network communication + * @return purpose + */ + @javax.annotation.Nullable + public String getPurpose() { + return purpose; + } + + public void setPurpose(@javax.annotation.Nullable String purpose) { + this.purpose = purpose; + } + + + public NetworkingExplainResult summary(@javax.annotation.Nullable String summary) { + this.summary = summary; + return this; + } + + /** + * Explanation of the network communication the function performs + * @return summary + */ + @javax.annotation.Nullable + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nullable String summary) { + this.summary = summary; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingExplainResult instance itself + */ + public NetworkingExplainResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingExplainResult networkingExplainResult = (NetworkingExplainResult) o; + return Objects.equals(this.cancelled, networkingExplainResult.cancelled) && + Objects.equals(this.dataReceived, networkingExplainResult.dataReceived) && + Objects.equals(this.dataSent, networkingExplainResult.dataSent) && + Objects.equals(this.dataUsage, networkingExplainResult.dataUsage) && + Objects.equals(this.endpoints, networkingExplainResult.endpoints) && + Objects.equals(this.functionId, networkingExplainResult.functionId) && + Objects.equals(this.functionName, networkingExplainResult.functionName) && + Objects.equals(this.functionsInvolved, networkingExplainResult.functionsInvolved) && + Objects.equals(this.protocol, networkingExplainResult.protocol) && + Objects.equals(this.purpose, networkingExplainResult.purpose) && + Objects.equals(this.summary, networkingExplainResult.summary)&& + Objects.equals(this.additionalProperties, networkingExplainResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(cancelled, dataReceived, dataSent, dataUsage, endpoints, functionId, functionName, functionsInvolved, protocol, purpose, summary, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingExplainResult {\n"); + sb.append(" cancelled: ").append(toIndentedString(cancelled)).append("\n"); + sb.append(" dataReceived: ").append(toIndentedString(dataReceived)).append("\n"); + sb.append(" dataSent: ").append(toIndentedString(dataSent)).append("\n"); + sb.append(" dataUsage: ").append(toIndentedString(dataUsage)).append("\n"); + sb.append(" endpoints: ").append(toIndentedString(endpoints)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionsInvolved: ").append(toIndentedString(functionsInvolved)).append("\n"); + sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n"); + sb.append(" purpose: ").append(toIndentedString(purpose)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("cancelled", "data_received", "data_sent", "data_usage", "endpoints", "function_id", "function_name", "functions_involved", "protocol", "purpose", "summary")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("cancelled", "function_id")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingExplainResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingExplainResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingExplainResult is not found in the empty JSON string", NetworkingExplainResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingExplainResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("data_received") != null && !jsonObj.get("data_received").isJsonNull()) && !jsonObj.get("data_received").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_received` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_received").toString())); + } + if ((jsonObj.get("data_sent") != null && !jsonObj.get("data_sent").isJsonNull()) && !jsonObj.get("data_sent").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_sent` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_sent").toString())); + } + if ((jsonObj.get("data_usage") != null && !jsonObj.get("data_usage").isJsonNull()) && !jsonObj.get("data_usage").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data_usage` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_usage").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("endpoints") != null && !jsonObj.get("endpoints").isJsonNull() && !jsonObj.get("endpoints").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `endpoints` to be an array in the JSON string but got `%s`", jsonObj.get("endpoints").toString())); + } + if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("functions_involved") != null && !jsonObj.get("functions_involved").isJsonNull() && !jsonObj.get("functions_involved").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions_involved` to be an array in the JSON string but got `%s`", jsonObj.get("functions_involved").toString())); + } + if ((jsonObj.get("protocol") != null && !jsonObj.get("protocol").isJsonNull()) && !jsonObj.get("protocol").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `protocol` to be a primitive type in the JSON string but got `%s`", jsonObj.get("protocol").toString())); + } + if ((jsonObj.get("purpose") != null && !jsonObj.get("purpose").isJsonNull()) && !jsonObj.get("purpose").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `purpose` to be a primitive type in the JSON string but got `%s`", jsonObj.get("purpose").toString())); + } + if ((jsonObj.get("summary") != null && !jsonObj.get("summary").isJsonNull()) && !jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingExplainResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingExplainResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingExplainResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingExplainResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingExplainResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingExplainResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingExplainResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingExplainResult + * @throws IOException if the JSON string is invalid with respect to NetworkingExplainResult + */ + public static NetworkingExplainResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingExplainResult.class); + } + + /** + * Convert an instance of NetworkingExplainResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkingExplainedFunction.java b/src/main/java/ai/reveng/model/NetworkingExplainedFunction.java new file mode 100644 index 00000000..57cdfedd --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingExplainedFunction.java @@ -0,0 +1,344 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingExplainedFunction + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingExplainedFunction { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public NetworkingExplainedFunction() { + } + + public NetworkingExplainedFunction description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * Role this function plays in the network communication + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public NetworkingExplainedFunction functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public NetworkingExplainedFunction functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingExplainedFunction instance itself + */ + public NetworkingExplainedFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingExplainedFunction networkingExplainedFunction = (NetworkingExplainedFunction) o; + return Objects.equals(this.description, networkingExplainedFunction.description) && + Objects.equals(this.functionId, networkingExplainedFunction.functionId) && + Objects.equals(this.functionName, networkingExplainedFunction.functionName)&& + Objects.equals(this.additionalProperties, networkingExplainedFunction.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(description, functionId, functionName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingExplainedFunction {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("description", "function_id", "function_name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingExplainedFunction + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingExplainedFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingExplainedFunction is not found in the empty JSON string", NetworkingExplainedFunction.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingExplainedFunction.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingExplainedFunction.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingExplainedFunction' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingExplainedFunction.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingExplainedFunction value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingExplainedFunction read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingExplainedFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingExplainedFunction given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingExplainedFunction + * @throws IOException if the JSON string is invalid with respect to NetworkingExplainedFunction + */ + public static NetworkingExplainedFunction fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingExplainedFunction.class); + } + + /** + * Convert an instance of NetworkingExplainedFunction to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkingFinding.java b/src/main/java/ai/reveng/model/NetworkingFinding.java new file mode 100644 index 00000000..503105d2 --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingFinding.java @@ -0,0 +1,823 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.NetworkingCall; +import ai.reveng.model.NetworkingDirectMatch; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingFinding + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingFinding { + public static final String SERIALIZED_NAME_ADDRESS = "address"; + @SerializedName(SERIALIZED_NAME_ADDRESS) + @javax.annotation.Nonnull + private String address; + + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + ACCEPT("accept"), + + ADDRESS("address"), + + CONNECT("connect"), + + DNS("dns"), + + HTTP("http"), + + NETINFO("netinfo"), + + RAW_PACKET("raw-packet"), + + RECV("recv"), + + SEND("send"), + + SOCKET("socket"), + + TLS("tls"), + + URL("url"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + /** + * High when a direct name match was found, medium when the function only calls into networking APIs + */ + @JsonAdapter(ConfidenceEnum.Adapter.class) + public enum ConfidenceEnum { + HIGH("high"), + + MEDIUM("medium"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ConfidenceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ConfidenceEnum fromValue(String value) { + for (ConfidenceEnum b : ConfidenceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ConfidenceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ConfidenceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ConfidenceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ConfidenceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CONFIDENCE = "confidence"; + @SerializedName(SERIALIZED_NAME_CONFIDENCE) + @javax.annotation.Nonnull + private ConfidenceEnum confidence; + + public static final String SERIALIZED_NAME_DIRECT_MATCHES = "direct_matches"; + @SerializedName(SERIALIZED_NAME_DIRECT_MATCHES) + @javax.annotation.Nullable + private List directMatches; + + public static final String SERIALIZED_NAME_EVIDENCE_COUNT = "evidence_count"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_COUNT) + @javax.annotation.Nonnull + private Long evidenceCount; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public static final String SERIALIZED_NAME_FUNCTION_SIZE = "function_size"; + @SerializedName(SERIALIZED_NAME_FUNCTION_SIZE) + @javax.annotation.Nonnull + private Long functionSize; + + public static final String SERIALIZED_NAME_NETWORK_CALLS = "network_calls"; + @SerializedName(SERIALIZED_NAME_NETWORK_CALLS) + @javax.annotation.Nullable + private List networkCalls; + + public static final String SERIALIZED_NAME_REMOTE = "remote"; + @SerializedName(SERIALIZED_NAME_REMOTE) + @javax.annotation.Nonnull + private Boolean remote; + + /** + * Gets or Sets sources + */ + @JsonAdapter(SourcesEnum.Adapter.class) + public enum SourcesEnum { + BOOST("boost"), + + CPP("cpp"), + + CURL("curl"), + + GENERIC("generic"), + + LIBC("libc"), + + PCAP("pcap"), + + POCO("poco"), + + QT("qt"), + + TLS("tls"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourcesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourcesEnum fromValue(String value) { + for (SourcesEnum b : SourcesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourcesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourcesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourcesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourcesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCES = "sources"; + @SerializedName(SERIALIZED_NAME_SOURCES) + @javax.annotation.Nullable + private List sources; + + public NetworkingFinding() { + } + + public NetworkingFinding address(@javax.annotation.Nonnull String address) { + this.address = address; + return this; + } + + /** + * Function's virtual address, hex-encoded + * @return address + */ + @javax.annotation.Nonnull + public String getAddress() { + return address; + } + + public void setAddress(@javax.annotation.Nonnull String address) { + this.address = address; + } + + + public NetworkingFinding categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public NetworkingFinding addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Distinct networking categories evidenced by this function + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public NetworkingFinding confidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + return this; + } + + /** + * High when a direct name match was found, medium when the function only calls into networking APIs + * @return confidence + */ + @javax.annotation.Nonnull + public ConfidenceEnum getConfidence() { + return confidence; + } + + public void setConfidence(@javax.annotation.Nonnull ConfidenceEnum confidence) { + this.confidence = confidence; + } + + + public NetworkingFinding directMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + return this; + } + + public NetworkingFinding addDirectMatchesItem(NetworkingDirectMatch directMatchesItem) { + if (this.directMatches == null) { + this.directMatches = new ArrayList<>(); + } + this.directMatches.add(directMatchesItem); + return this; + } + + /** + * Matches against the function's own name + * @return directMatches + */ + @javax.annotation.Nullable + public List getDirectMatches() { + return directMatches; + } + + public void setDirectMatches(@javax.annotation.Nullable List directMatches) { + this.directMatches = directMatches; + } + + + public NetworkingFinding evidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + return this; + } + + /** + * Total number of direct matches and network calls + * @return evidenceCount + */ + @javax.annotation.Nonnull + public Long getEvidenceCount() { + return evidenceCount; + } + + public void setEvidenceCount(@javax.annotation.Nonnull Long evidenceCount) { + this.evidenceCount = evidenceCount; + } + + + public NetworkingFinding functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function the finding was reported in + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public NetworkingFinding functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function the finding was reported in + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + + public NetworkingFinding functionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + return this; + } + + /** + * Size of the function in bytes + * @return functionSize + */ + @javax.annotation.Nonnull + public Long getFunctionSize() { + return functionSize; + } + + public void setFunctionSize(@javax.annotation.Nonnull Long functionSize) { + this.functionSize = functionSize; + } + + + public NetworkingFinding networkCalls(@javax.annotation.Nullable List networkCalls) { + this.networkCalls = networkCalls; + return this; + } + + public NetworkingFinding addNetworkCallsItem(NetworkingCall networkCallsItem) { + if (this.networkCalls == null) { + this.networkCalls = new ArrayList<>(); + } + this.networkCalls.add(networkCallsItem); + return this; + } + + /** + * Matches against names this function calls + * @return networkCalls + */ + @javax.annotation.Nullable + public List getNetworkCalls() { + return networkCalls; + } + + public void setNetworkCalls(@javax.annotation.Nullable List networkCalls) { + this.networkCalls = networkCalls; + } + + + public NetworkingFinding remote(@javax.annotation.Nonnull Boolean remote) { + this.remote = remote; + return this; + } + + /** + * Whether this function evidences remote communication rather than only supporting it + * @return remote + */ + @javax.annotation.Nonnull + public Boolean getRemote() { + return remote; + } + + public void setRemote(@javax.annotation.Nonnull Boolean remote) { + this.remote = remote; + } + + + public NetworkingFinding sources(@javax.annotation.Nullable List sources) { + this.sources = sources; + return this; + } + + public NetworkingFinding addSourcesItem(SourcesEnum sourcesItem) { + if (this.sources == null) { + this.sources = new ArrayList<>(); + } + this.sources.add(sourcesItem); + return this; + } + + /** + * Distinct networking sources evidenced by this function + * @return sources + */ + @javax.annotation.Nullable + public List getSources() { + return sources; + } + + public void setSources(@javax.annotation.Nullable List sources) { + this.sources = sources; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingFinding instance itself + */ + public NetworkingFinding putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingFinding networkingFinding = (NetworkingFinding) o; + return Objects.equals(this.address, networkingFinding.address) && + Objects.equals(this.categories, networkingFinding.categories) && + Objects.equals(this.confidence, networkingFinding.confidence) && + Objects.equals(this.directMatches, networkingFinding.directMatches) && + Objects.equals(this.evidenceCount, networkingFinding.evidenceCount) && + Objects.equals(this.functionId, networkingFinding.functionId) && + Objects.equals(this.functionName, networkingFinding.functionName) && + Objects.equals(this.functionSize, networkingFinding.functionSize) && + Objects.equals(this.networkCalls, networkingFinding.networkCalls) && + Objects.equals(this.remote, networkingFinding.remote) && + Objects.equals(this.sources, networkingFinding.sources)&& + Objects.equals(this.additionalProperties, networkingFinding.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(address, categories, confidence, directMatches, evidenceCount, functionId, functionName, functionSize, networkCalls, remote, sources, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingFinding {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" directMatches: ").append(toIndentedString(directMatches)).append("\n"); + sb.append(" evidenceCount: ").append(toIndentedString(evidenceCount)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" functionSize: ").append(toIndentedString(functionSize)).append("\n"); + sb.append(" networkCalls: ").append(toIndentedString(networkCalls)).append("\n"); + sb.append(" remote: ").append(toIndentedString(remote)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("address", "categories", "confidence", "direct_matches", "evidence_count", "function_id", "function_name", "function_size", "network_calls", "remote", "sources")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("address", "categories", "confidence", "evidence_count", "function_id", "function_name", "function_size", "remote", "sources")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingFinding + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingFinding.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingFinding is not found in the empty JSON string", NetworkingFinding.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingFinding.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("address").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); + } + // ensure the required json array is present + if (jsonObj.get("categories") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("categories").isJsonArray() && !jsonObj.get("categories").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + if (!jsonObj.get("confidence").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidence` to be a primitive type in the JSON string but got `%s`", jsonObj.get("confidence").toString())); + } + // validate the required field `confidence` + ConfidenceEnum.validateJsonElement(jsonObj.get("confidence")); + // ensure the optional json data is an array if present + if (jsonObj.get("direct_matches") != null && !jsonObj.get("direct_matches").isJsonNull() && !jsonObj.get("direct_matches").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `direct_matches` to be an array in the JSON string but got `%s`", jsonObj.get("direct_matches").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("network_calls") != null && !jsonObj.get("network_calls").isJsonNull() && !jsonObj.get("network_calls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `network_calls` to be an array in the JSON string but got `%s`", jsonObj.get("network_calls").toString())); + } + // ensure the required json array is present + if (jsonObj.get("sources") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("sources").isJsonArray() && !jsonObj.get("sources").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sources` to be an array in the JSON string but got `%s`", jsonObj.get("sources").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingFinding.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingFinding' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingFinding.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingFinding value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingFinding read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingFinding instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingFinding given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingFinding + * @throws IOException if the JSON string is invalid with respect to NetworkingFinding + */ + public static NetworkingFinding fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingFinding.class); + } + + /** + * Convert an instance of NetworkingFinding to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkingScanMetadata.java b/src/main/java/ai/reveng/model/NetworkingScanMetadata.java new file mode 100644 index 00000000..ee9e4152 --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingScanMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingScanMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingScanMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public NetworkingScanMetadata() { + } + + public NetworkingScanMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public NetworkingScanMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public NetworkingScanMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingScanMetadata instance itself + */ + public NetworkingScanMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingScanMetadata networkingScanMetadata = (NetworkingScanMetadata) o; + return Objects.equals(this.logHistory, networkingScanMetadata.logHistory) && + Objects.equals(this.status, networkingScanMetadata.status)&& + Objects.equals(this.additionalProperties, networkingScanMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingScanMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingScanMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingScanMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingScanMetadata is not found in the empty JSON string", NetworkingScanMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingScanMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingScanMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingScanMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingScanMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingScanMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingScanMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingScanMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingScanMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingScanMetadata + * @throws IOException if the JSON string is invalid with respect to NetworkingScanMetadata + */ + public static NetworkingScanMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingScanMetadata.class); + } + + /** + * Convert an instance of NetworkingScanMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/NetworkingScanResult.java b/src/main/java/ai/reveng/model/NetworkingScanResult.java new file mode 100644 index 00000000..7d765d04 --- /dev/null +++ b/src/main/java/ai/reveng/model/NetworkingScanResult.java @@ -0,0 +1,365 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.NetworkingFinding; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * NetworkingScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NetworkingScanResult { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_FINDINGS = "findings"; + @SerializedName(SERIALIZED_NAME_FINDINGS) + @javax.annotation.Nullable + private List findings; + + public static final String SERIALIZED_NAME_TOTAL_FUNCTIONS = "total_functions"; + @SerializedName(SERIALIZED_NAME_TOTAL_FUNCTIONS) + @javax.annotation.Nonnull + private Long totalFunctions; + + public NetworkingScanResult() { + } + + public NetworkingScanResult analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Analysis the run was performed against + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public NetworkingScanResult findings(@javax.annotation.Nullable List findings) { + this.findings = findings; + return this; + } + + public NetworkingScanResult addFindingsItem(NetworkingFinding findingsItem) { + if (this.findings == null) { + this.findings = new ArrayList<>(); + } + this.findings.add(findingsItem); + return this; + } + + /** + * Functions with networking-related evidence, sorted by remoteness then confidence then evidence count + * @return findings + */ + @javax.annotation.Nullable + public List getFindings() { + return findings; + } + + public void setFindings(@javax.annotation.Nullable List findings) { + this.findings = findings; + } + + + public NetworkingScanResult totalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + return this; + } + + /** + * Functions the run considered + * @return totalFunctions + */ + @javax.annotation.Nonnull + public Long getTotalFunctions() { + return totalFunctions; + } + + public void setTotalFunctions(@javax.annotation.Nonnull Long totalFunctions) { + this.totalFunctions = totalFunctions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NetworkingScanResult instance itself + */ + public NetworkingScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkingScanResult networkingScanResult = (NetworkingScanResult) o; + return Objects.equals(this.analysisId, networkingScanResult.analysisId) && + Objects.equals(this.findings, networkingScanResult.findings) && + Objects.equals(this.totalFunctions, networkingScanResult.totalFunctions)&& + Objects.equals(this.additionalProperties, networkingScanResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, findings, totalFunctions, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkingScanResult {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" findings: ").append(toIndentedString(findings)).append("\n"); + sb.append(" totalFunctions: ").append(toIndentedString(totalFunctions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "findings", "total_functions")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "total_functions")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NetworkingScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!NetworkingScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkingScanResult is not found in the empty JSON string", NetworkingScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NetworkingScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("findings") != null && !jsonObj.get("findings").isJsonNull() && !jsonObj.get("findings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `findings` to be an array in the JSON string but got `%s`", jsonObj.get("findings").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NetworkingScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NetworkingScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NetworkingScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NetworkingScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NetworkingScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NetworkingScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NetworkingScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkingScanResult + * @throws IOException if the JSON string is invalid with respect to NetworkingScanResult + */ + public static NetworkingScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NetworkingScanResult.class); + } + + /** + * Convert an instance of NetworkingScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationCreateMetadataCreateResult.java b/src/main/java/ai/reveng/model/OperationCreateMetadataCreateResult.java new file mode 100644 index 00000000..4dc452fc --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationCreateMetadataCreateResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CreateMetadata; +import ai.reveng.model.CreateResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationCreateMetadataCreateResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationCreateMetadataCreateResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private CreateMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private CreateResult response; + + public OperationCreateMetadataCreateResult() { + } + + public OperationCreateMetadataCreateResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationCreateMetadataCreateResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationCreateMetadataCreateResult metadata(@javax.annotation.Nullable CreateMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public CreateMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable CreateMetadata metadata) { + this.metadata = metadata; + } + + + public OperationCreateMetadataCreateResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationCreateMetadataCreateResult response(@javax.annotation.Nullable CreateResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public CreateResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable CreateResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationCreateMetadataCreateResult instance itself + */ + public OperationCreateMetadataCreateResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationCreateMetadataCreateResult operationCreateMetadataCreateResult = (OperationCreateMetadataCreateResult) o; + return Objects.equals(this.done, operationCreateMetadataCreateResult.done) && + Objects.equals(this.error, operationCreateMetadataCreateResult.error) && + Objects.equals(this.metadata, operationCreateMetadataCreateResult.metadata) && + Objects.equals(this.name, operationCreateMetadataCreateResult.name) && + Objects.equals(this.response, operationCreateMetadataCreateResult.response)&& + Objects.equals(this.additionalProperties, operationCreateMetadataCreateResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationCreateMetadataCreateResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationCreateMetadataCreateResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationCreateMetadataCreateResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationCreateMetadataCreateResult is not found in the empty JSON string", OperationCreateMetadataCreateResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationCreateMetadataCreateResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationCreateMetadataCreateResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationCreateMetadataCreateResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationCreateMetadataCreateResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationCreateMetadataCreateResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationCreateMetadataCreateResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationCreateMetadataCreateResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationCreateMetadataCreateResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationCreateMetadataCreateResult + * @throws IOException if the JSON string is invalid with respect to OperationCreateMetadataCreateResult + */ + public static OperationCreateMetadataCreateResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationCreateMetadataCreateResult.class); + } + + /** + * Convert an instance of OperationCreateMetadataCreateResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationCryptoExplainMetadataCryptoExplainResult.java b/src/main/java/ai/reveng/model/OperationCryptoExplainMetadataCryptoExplainResult.java new file mode 100644 index 00000000..ef6a3f03 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationCryptoExplainMetadataCryptoExplainResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CryptoExplainMetadata; +import ai.reveng.model.CryptoExplainResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationCryptoExplainMetadataCryptoExplainResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationCryptoExplainMetadataCryptoExplainResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private CryptoExplainMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private CryptoExplainResult response; + + public OperationCryptoExplainMetadataCryptoExplainResult() { + } + + public OperationCryptoExplainMetadataCryptoExplainResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationCryptoExplainMetadataCryptoExplainResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationCryptoExplainMetadataCryptoExplainResult metadata(@javax.annotation.Nullable CryptoExplainMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public CryptoExplainMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable CryptoExplainMetadata metadata) { + this.metadata = metadata; + } + + + public OperationCryptoExplainMetadataCryptoExplainResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationCryptoExplainMetadataCryptoExplainResult response(@javax.annotation.Nullable CryptoExplainResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public CryptoExplainResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable CryptoExplainResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationCryptoExplainMetadataCryptoExplainResult instance itself + */ + public OperationCryptoExplainMetadataCryptoExplainResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationCryptoExplainMetadataCryptoExplainResult operationCryptoExplainMetadataCryptoExplainResult = (OperationCryptoExplainMetadataCryptoExplainResult) o; + return Objects.equals(this.done, operationCryptoExplainMetadataCryptoExplainResult.done) && + Objects.equals(this.error, operationCryptoExplainMetadataCryptoExplainResult.error) && + Objects.equals(this.metadata, operationCryptoExplainMetadataCryptoExplainResult.metadata) && + Objects.equals(this.name, operationCryptoExplainMetadataCryptoExplainResult.name) && + Objects.equals(this.response, operationCryptoExplainMetadataCryptoExplainResult.response)&& + Objects.equals(this.additionalProperties, operationCryptoExplainMetadataCryptoExplainResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationCryptoExplainMetadataCryptoExplainResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationCryptoExplainMetadataCryptoExplainResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationCryptoExplainMetadataCryptoExplainResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationCryptoExplainMetadataCryptoExplainResult is not found in the empty JSON string", OperationCryptoExplainMetadataCryptoExplainResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationCryptoExplainMetadataCryptoExplainResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationCryptoExplainMetadataCryptoExplainResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationCryptoExplainMetadataCryptoExplainResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationCryptoExplainMetadataCryptoExplainResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationCryptoExplainMetadataCryptoExplainResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationCryptoExplainMetadataCryptoExplainResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationCryptoExplainMetadataCryptoExplainResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationCryptoExplainMetadataCryptoExplainResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationCryptoExplainMetadataCryptoExplainResult + * @throws IOException if the JSON string is invalid with respect to OperationCryptoExplainMetadataCryptoExplainResult + */ + public static OperationCryptoExplainMetadataCryptoExplainResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationCryptoExplainMetadataCryptoExplainResult.class); + } + + /** + * Convert an instance of OperationCryptoExplainMetadataCryptoExplainResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationCryptoScanMetadataCryptoScanResult.java b/src/main/java/ai/reveng/model/OperationCryptoScanMetadataCryptoScanResult.java new file mode 100644 index 00000000..f16bf2de --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationCryptoScanMetadataCryptoScanResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CryptoScanMetadata; +import ai.reveng.model.CryptoScanResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationCryptoScanMetadataCryptoScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationCryptoScanMetadataCryptoScanResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private CryptoScanMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private CryptoScanResult response; + + public OperationCryptoScanMetadataCryptoScanResult() { + } + + public OperationCryptoScanMetadataCryptoScanResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationCryptoScanMetadataCryptoScanResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationCryptoScanMetadataCryptoScanResult metadata(@javax.annotation.Nullable CryptoScanMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public CryptoScanMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable CryptoScanMetadata metadata) { + this.metadata = metadata; + } + + + public OperationCryptoScanMetadataCryptoScanResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationCryptoScanMetadataCryptoScanResult response(@javax.annotation.Nullable CryptoScanResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public CryptoScanResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable CryptoScanResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationCryptoScanMetadataCryptoScanResult instance itself + */ + public OperationCryptoScanMetadataCryptoScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationCryptoScanMetadataCryptoScanResult operationCryptoScanMetadataCryptoScanResult = (OperationCryptoScanMetadataCryptoScanResult) o; + return Objects.equals(this.done, operationCryptoScanMetadataCryptoScanResult.done) && + Objects.equals(this.error, operationCryptoScanMetadataCryptoScanResult.error) && + Objects.equals(this.metadata, operationCryptoScanMetadataCryptoScanResult.metadata) && + Objects.equals(this.name, operationCryptoScanMetadataCryptoScanResult.name) && + Objects.equals(this.response, operationCryptoScanMetadataCryptoScanResult.response)&& + Objects.equals(this.additionalProperties, operationCryptoScanMetadataCryptoScanResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationCryptoScanMetadataCryptoScanResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationCryptoScanMetadataCryptoScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationCryptoScanMetadataCryptoScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationCryptoScanMetadataCryptoScanResult is not found in the empty JSON string", OperationCryptoScanMetadataCryptoScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationCryptoScanMetadataCryptoScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationCryptoScanMetadataCryptoScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationCryptoScanMetadataCryptoScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationCryptoScanMetadataCryptoScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationCryptoScanMetadataCryptoScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationCryptoScanMetadataCryptoScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationCryptoScanMetadataCryptoScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationCryptoScanMetadataCryptoScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationCryptoScanMetadataCryptoScanResult + * @throws IOException if the JSON string is invalid with respect to OperationCryptoScanMetadataCryptoScanResult + */ + public static OperationCryptoScanMetadataCryptoScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationCryptoScanMetadataCryptoScanResult.class); + } + + /** + * Convert an instance of OperationCryptoScanMetadataCryptoScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationExecutionExplainMetadataExecutionExplainResult.java b/src/main/java/ai/reveng/model/OperationExecutionExplainMetadataExecutionExplainResult.java new file mode 100644 index 00000000..d6ade1e3 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationExecutionExplainMetadataExecutionExplainResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ExecutionExplainMetadata; +import ai.reveng.model.ExecutionExplainResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationExecutionExplainMetadataExecutionExplainResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationExecutionExplainMetadataExecutionExplainResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private ExecutionExplainMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private ExecutionExplainResult response; + + public OperationExecutionExplainMetadataExecutionExplainResult() { + } + + public OperationExecutionExplainMetadataExecutionExplainResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationExecutionExplainMetadataExecutionExplainResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationExecutionExplainMetadataExecutionExplainResult metadata(@javax.annotation.Nullable ExecutionExplainMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public ExecutionExplainMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable ExecutionExplainMetadata metadata) { + this.metadata = metadata; + } + + + public OperationExecutionExplainMetadataExecutionExplainResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationExecutionExplainMetadataExecutionExplainResult response(@javax.annotation.Nullable ExecutionExplainResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public ExecutionExplainResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable ExecutionExplainResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationExecutionExplainMetadataExecutionExplainResult instance itself + */ + public OperationExecutionExplainMetadataExecutionExplainResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationExecutionExplainMetadataExecutionExplainResult operationExecutionExplainMetadataExecutionExplainResult = (OperationExecutionExplainMetadataExecutionExplainResult) o; + return Objects.equals(this.done, operationExecutionExplainMetadataExecutionExplainResult.done) && + Objects.equals(this.error, operationExecutionExplainMetadataExecutionExplainResult.error) && + Objects.equals(this.metadata, operationExecutionExplainMetadataExecutionExplainResult.metadata) && + Objects.equals(this.name, operationExecutionExplainMetadataExecutionExplainResult.name) && + Objects.equals(this.response, operationExecutionExplainMetadataExecutionExplainResult.response)&& + Objects.equals(this.additionalProperties, operationExecutionExplainMetadataExecutionExplainResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationExecutionExplainMetadataExecutionExplainResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationExecutionExplainMetadataExecutionExplainResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationExecutionExplainMetadataExecutionExplainResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationExecutionExplainMetadataExecutionExplainResult is not found in the empty JSON string", OperationExecutionExplainMetadataExecutionExplainResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationExecutionExplainMetadataExecutionExplainResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationExecutionExplainMetadataExecutionExplainResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationExecutionExplainMetadataExecutionExplainResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationExecutionExplainMetadataExecutionExplainResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationExecutionExplainMetadataExecutionExplainResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationExecutionExplainMetadataExecutionExplainResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationExecutionExplainMetadataExecutionExplainResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationExecutionExplainMetadataExecutionExplainResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationExecutionExplainMetadataExecutionExplainResult + * @throws IOException if the JSON string is invalid with respect to OperationExecutionExplainMetadataExecutionExplainResult + */ + public static OperationExecutionExplainMetadataExecutionExplainResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationExecutionExplainMetadataExecutionExplainResult.class); + } + + /** + * Convert an instance of OperationExecutionExplainMetadataExecutionExplainResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationExecutionScanMetadataExecutionScanResult.java b/src/main/java/ai/reveng/model/OperationExecutionScanMetadataExecutionScanResult.java new file mode 100644 index 00000000..cffd1a33 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationExecutionScanMetadataExecutionScanResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ExecutionScanMetadata; +import ai.reveng.model.ExecutionScanResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationExecutionScanMetadataExecutionScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationExecutionScanMetadataExecutionScanResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private ExecutionScanMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private ExecutionScanResult response; + + public OperationExecutionScanMetadataExecutionScanResult() { + } + + public OperationExecutionScanMetadataExecutionScanResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationExecutionScanMetadataExecutionScanResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationExecutionScanMetadataExecutionScanResult metadata(@javax.annotation.Nullable ExecutionScanMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public ExecutionScanMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable ExecutionScanMetadata metadata) { + this.metadata = metadata; + } + + + public OperationExecutionScanMetadataExecutionScanResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationExecutionScanMetadataExecutionScanResult response(@javax.annotation.Nullable ExecutionScanResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public ExecutionScanResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable ExecutionScanResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationExecutionScanMetadataExecutionScanResult instance itself + */ + public OperationExecutionScanMetadataExecutionScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationExecutionScanMetadataExecutionScanResult operationExecutionScanMetadataExecutionScanResult = (OperationExecutionScanMetadataExecutionScanResult) o; + return Objects.equals(this.done, operationExecutionScanMetadataExecutionScanResult.done) && + Objects.equals(this.error, operationExecutionScanMetadataExecutionScanResult.error) && + Objects.equals(this.metadata, operationExecutionScanMetadataExecutionScanResult.metadata) && + Objects.equals(this.name, operationExecutionScanMetadataExecutionScanResult.name) && + Objects.equals(this.response, operationExecutionScanMetadataExecutionScanResult.response)&& + Objects.equals(this.additionalProperties, operationExecutionScanMetadataExecutionScanResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationExecutionScanMetadataExecutionScanResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationExecutionScanMetadataExecutionScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationExecutionScanMetadataExecutionScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationExecutionScanMetadataExecutionScanResult is not found in the empty JSON string", OperationExecutionScanMetadataExecutionScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationExecutionScanMetadataExecutionScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationExecutionScanMetadataExecutionScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationExecutionScanMetadataExecutionScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationExecutionScanMetadataExecutionScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationExecutionScanMetadataExecutionScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationExecutionScanMetadataExecutionScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationExecutionScanMetadataExecutionScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationExecutionScanMetadataExecutionScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationExecutionScanMetadataExecutionScanResult + * @throws IOException if the JSON string is invalid with respect to OperationExecutionScanMetadataExecutionScanResult + */ + public static OperationExecutionScanMetadataExecutionScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationExecutionScanMetadataExecutionScanResult.class); + } + + /** + * Convert an instance of OperationExecutionScanMetadataExecutionScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.java b/src/main/java/ai/reveng/model/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.java new file mode 100644 index 00000000..161e4443 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.FilesystemAnalyseMetadata; +import ai.reveng.model.FilesystemAnalyseResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationFilesystemAnalyseMetadataFilesystemAnalyseResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationFilesystemAnalyseMetadataFilesystemAnalyseResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private FilesystemAnalyseMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private FilesystemAnalyseResult response; + + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult() { + } + + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult metadata(@javax.annotation.Nullable FilesystemAnalyseMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public FilesystemAnalyseMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable FilesystemAnalyseMetadata metadata) { + this.metadata = metadata; + } + + + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult response(@javax.annotation.Nullable FilesystemAnalyseResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public FilesystemAnalyseResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable FilesystemAnalyseResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationFilesystemAnalyseMetadataFilesystemAnalyseResult instance itself + */ + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationFilesystemAnalyseMetadataFilesystemAnalyseResult operationFilesystemAnalyseMetadataFilesystemAnalyseResult = (OperationFilesystemAnalyseMetadataFilesystemAnalyseResult) o; + return Objects.equals(this.done, operationFilesystemAnalyseMetadataFilesystemAnalyseResult.done) && + Objects.equals(this.error, operationFilesystemAnalyseMetadataFilesystemAnalyseResult.error) && + Objects.equals(this.metadata, operationFilesystemAnalyseMetadataFilesystemAnalyseResult.metadata) && + Objects.equals(this.name, operationFilesystemAnalyseMetadataFilesystemAnalyseResult.name) && + Objects.equals(this.response, operationFilesystemAnalyseMetadataFilesystemAnalyseResult.response)&& + Objects.equals(this.additionalProperties, operationFilesystemAnalyseMetadataFilesystemAnalyseResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationFilesystemAnalyseMetadataFilesystemAnalyseResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationFilesystemAnalyseMetadataFilesystemAnalyseResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationFilesystemAnalyseMetadataFilesystemAnalyseResult is not found in the empty JSON string", OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationFilesystemAnalyseMetadataFilesystemAnalyseResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationFilesystemAnalyseMetadataFilesystemAnalyseResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationFilesystemAnalyseMetadataFilesystemAnalyseResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationFilesystemAnalyseMetadataFilesystemAnalyseResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationFilesystemAnalyseMetadataFilesystemAnalyseResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationFilesystemAnalyseMetadataFilesystemAnalyseResult + * @throws IOException if the JSON string is invalid with respect to OperationFilesystemAnalyseMetadataFilesystemAnalyseResult + */ + public static OperationFilesystemAnalyseMetadataFilesystemAnalyseResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationFilesystemAnalyseMetadataFilesystemAnalyseResult.class); + } + + /** + * Convert an instance of OperationFilesystemAnalyseMetadataFilesystemAnalyseResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationFilesystemScanMetadataFilesystemScanResult.java b/src/main/java/ai/reveng/model/OperationFilesystemScanMetadataFilesystemScanResult.java new file mode 100644 index 00000000..205ccace --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationFilesystemScanMetadataFilesystemScanResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.FilesystemScanMetadata; +import ai.reveng.model.FilesystemScanResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationFilesystemScanMetadataFilesystemScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationFilesystemScanMetadataFilesystemScanResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private FilesystemScanMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private FilesystemScanResult response; + + public OperationFilesystemScanMetadataFilesystemScanResult() { + } + + public OperationFilesystemScanMetadataFilesystemScanResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationFilesystemScanMetadataFilesystemScanResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationFilesystemScanMetadataFilesystemScanResult metadata(@javax.annotation.Nullable FilesystemScanMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public FilesystemScanMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable FilesystemScanMetadata metadata) { + this.metadata = metadata; + } + + + public OperationFilesystemScanMetadataFilesystemScanResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationFilesystemScanMetadataFilesystemScanResult response(@javax.annotation.Nullable FilesystemScanResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public FilesystemScanResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable FilesystemScanResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationFilesystemScanMetadataFilesystemScanResult instance itself + */ + public OperationFilesystemScanMetadataFilesystemScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationFilesystemScanMetadataFilesystemScanResult operationFilesystemScanMetadataFilesystemScanResult = (OperationFilesystemScanMetadataFilesystemScanResult) o; + return Objects.equals(this.done, operationFilesystemScanMetadataFilesystemScanResult.done) && + Objects.equals(this.error, operationFilesystemScanMetadataFilesystemScanResult.error) && + Objects.equals(this.metadata, operationFilesystemScanMetadataFilesystemScanResult.metadata) && + Objects.equals(this.name, operationFilesystemScanMetadataFilesystemScanResult.name) && + Objects.equals(this.response, operationFilesystemScanMetadataFilesystemScanResult.response)&& + Objects.equals(this.additionalProperties, operationFilesystemScanMetadataFilesystemScanResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationFilesystemScanMetadataFilesystemScanResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationFilesystemScanMetadataFilesystemScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationFilesystemScanMetadataFilesystemScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationFilesystemScanMetadataFilesystemScanResult is not found in the empty JSON string", OperationFilesystemScanMetadataFilesystemScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationFilesystemScanMetadataFilesystemScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationFilesystemScanMetadataFilesystemScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationFilesystemScanMetadataFilesystemScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationFilesystemScanMetadataFilesystemScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationFilesystemScanMetadataFilesystemScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationFilesystemScanMetadataFilesystemScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationFilesystemScanMetadataFilesystemScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationFilesystemScanMetadataFilesystemScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationFilesystemScanMetadataFilesystemScanResult + * @throws IOException if the JSON string is invalid with respect to OperationFilesystemScanMetadataFilesystemScanResult + */ + public static OperationFilesystemScanMetadataFilesystemScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationFilesystemScanMetadataFilesystemScanResult.class); + } + + /** + * Convert an instance of OperationFilesystemScanMetadataFilesystemScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationMetadataCapabilitiesResult.java b/src/main/java/ai/reveng/model/OperationMetadataCapabilitiesResult.java new file mode 100644 index 00000000..6679b6c9 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationMetadataCapabilitiesResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.CapabilitiesResult; +import ai.reveng.model.Metadata; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationMetadataCapabilitiesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationMetadataCapabilitiesResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private Metadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private CapabilitiesResult response; + + public OperationMetadataCapabilitiesResult() { + } + + public OperationMetadataCapabilitiesResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationMetadataCapabilitiesResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationMetadataCapabilitiesResult metadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + } + + + public OperationMetadataCapabilitiesResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationMetadataCapabilitiesResult response(@javax.annotation.Nullable CapabilitiesResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public CapabilitiesResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable CapabilitiesResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationMetadataCapabilitiesResult instance itself + */ + public OperationMetadataCapabilitiesResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationMetadataCapabilitiesResult operationMetadataCapabilitiesResult = (OperationMetadataCapabilitiesResult) o; + return Objects.equals(this.done, operationMetadataCapabilitiesResult.done) && + Objects.equals(this.error, operationMetadataCapabilitiesResult.error) && + Objects.equals(this.metadata, operationMetadataCapabilitiesResult.metadata) && + Objects.equals(this.name, operationMetadataCapabilitiesResult.name) && + Objects.equals(this.response, operationMetadataCapabilitiesResult.response)&& + Objects.equals(this.additionalProperties, operationMetadataCapabilitiesResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationMetadataCapabilitiesResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationMetadataCapabilitiesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationMetadataCapabilitiesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationMetadataCapabilitiesResult is not found in the empty JSON string", OperationMetadataCapabilitiesResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationMetadataCapabilitiesResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationMetadataCapabilitiesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationMetadataCapabilitiesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationMetadataCapabilitiesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationMetadataCapabilitiesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationMetadataCapabilitiesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationMetadataCapabilitiesResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationMetadataCapabilitiesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationMetadataCapabilitiesResult + * @throws IOException if the JSON string is invalid with respect to OperationMetadataCapabilitiesResult + */ + public static OperationMetadataCapabilitiesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationMetadataCapabilitiesResult.class); + } + + /** + * Convert an instance of OperationMetadataCapabilitiesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationMetadataRemediationResult.java b/src/main/java/ai/reveng/model/OperationMetadataRemediationResult.java new file mode 100644 index 00000000..1365e6c1 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationMetadataRemediationResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Metadata; +import ai.reveng.model.RemediationResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationMetadataRemediationResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationMetadataRemediationResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private Metadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private RemediationResult response; + + public OperationMetadataRemediationResult() { + } + + public OperationMetadataRemediationResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationMetadataRemediationResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationMetadataRemediationResult metadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + } + + + public OperationMetadataRemediationResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationMetadataRemediationResult response(@javax.annotation.Nullable RemediationResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public RemediationResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable RemediationResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationMetadataRemediationResult instance itself + */ + public OperationMetadataRemediationResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationMetadataRemediationResult operationMetadataRemediationResult = (OperationMetadataRemediationResult) o; + return Objects.equals(this.done, operationMetadataRemediationResult.done) && + Objects.equals(this.error, operationMetadataRemediationResult.error) && + Objects.equals(this.metadata, operationMetadataRemediationResult.metadata) && + Objects.equals(this.name, operationMetadataRemediationResult.name) && + Objects.equals(this.response, operationMetadataRemediationResult.response)&& + Objects.equals(this.additionalProperties, operationMetadataRemediationResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationMetadataRemediationResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationMetadataRemediationResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationMetadataRemediationResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationMetadataRemediationResult is not found in the empty JSON string", OperationMetadataRemediationResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationMetadataRemediationResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationMetadataRemediationResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationMetadataRemediationResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationMetadataRemediationResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationMetadataRemediationResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationMetadataRemediationResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationMetadataRemediationResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationMetadataRemediationResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationMetadataRemediationResult + * @throws IOException if the JSON string is invalid with respect to OperationMetadataRemediationResult + */ + public static OperationMetadataRemediationResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationMetadataRemediationResult.class); + } + + /** + * Convert an instance of OperationMetadataRemediationResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationMetadataReportResult.java b/src/main/java/ai/reveng/model/OperationMetadataReportResult.java new file mode 100644 index 00000000..d3204f22 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationMetadataReportResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Metadata; +import ai.reveng.model.ReportResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationMetadataReportResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationMetadataReportResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private Metadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private ReportResult response; + + public OperationMetadataReportResult() { + } + + public OperationMetadataReportResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationMetadataReportResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationMetadataReportResult metadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + } + + + public OperationMetadataReportResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationMetadataReportResult response(@javax.annotation.Nullable ReportResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public ReportResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable ReportResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationMetadataReportResult instance itself + */ + public OperationMetadataReportResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationMetadataReportResult operationMetadataReportResult = (OperationMetadataReportResult) o; + return Objects.equals(this.done, operationMetadataReportResult.done) && + Objects.equals(this.error, operationMetadataReportResult.error) && + Objects.equals(this.metadata, operationMetadataReportResult.metadata) && + Objects.equals(this.name, operationMetadataReportResult.name) && + Objects.equals(this.response, operationMetadataReportResult.response)&& + Objects.equals(this.additionalProperties, operationMetadataReportResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationMetadataReportResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationMetadataReportResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationMetadataReportResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationMetadataReportResult is not found in the empty JSON string", OperationMetadataReportResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationMetadataReportResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationMetadataReportResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationMetadataReportResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationMetadataReportResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationMetadataReportResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationMetadataReportResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationMetadataReportResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationMetadataReportResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationMetadataReportResult + * @throws IOException if the JSON string is invalid with respect to OperationMetadataReportResult + */ + public static OperationMetadataReportResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationMetadataReportResult.class); + } + + /** + * Convert an instance of OperationMetadataReportResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationMetadataThreatReportResult.java b/src/main/java/ai/reveng/model/OperationMetadataThreatReportResult.java new file mode 100644 index 00000000..5105506a --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationMetadataThreatReportResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Metadata; +import ai.reveng.model.Status; +import ai.reveng.model.ThreatReportResult; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationMetadataThreatReportResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationMetadataThreatReportResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private Metadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private ThreatReportResult response; + + public OperationMetadataThreatReportResult() { + } + + public OperationMetadataThreatReportResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationMetadataThreatReportResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationMetadataThreatReportResult metadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + } + + + public OperationMetadataThreatReportResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationMetadataThreatReportResult response(@javax.annotation.Nullable ThreatReportResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public ThreatReportResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable ThreatReportResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationMetadataThreatReportResult instance itself + */ + public OperationMetadataThreatReportResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationMetadataThreatReportResult operationMetadataThreatReportResult = (OperationMetadataThreatReportResult) o; + return Objects.equals(this.done, operationMetadataThreatReportResult.done) && + Objects.equals(this.error, operationMetadataThreatReportResult.error) && + Objects.equals(this.metadata, operationMetadataThreatReportResult.metadata) && + Objects.equals(this.name, operationMetadataThreatReportResult.name) && + Objects.equals(this.response, operationMetadataThreatReportResult.response)&& + Objects.equals(this.additionalProperties, operationMetadataThreatReportResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationMetadataThreatReportResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationMetadataThreatReportResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationMetadataThreatReportResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationMetadataThreatReportResult is not found in the empty JSON string", OperationMetadataThreatReportResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationMetadataThreatReportResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationMetadataThreatReportResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationMetadataThreatReportResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationMetadataThreatReportResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationMetadataThreatReportResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationMetadataThreatReportResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationMetadataThreatReportResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationMetadataThreatReportResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationMetadataThreatReportResult + * @throws IOException if the JSON string is invalid with respect to OperationMetadataThreatReportResult + */ + public static OperationMetadataThreatReportResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationMetadataThreatReportResult.class); + } + + /** + * Convert an instance of OperationMetadataThreatReportResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationMetadataTriageResult.java b/src/main/java/ai/reveng/model/OperationMetadataTriageResult.java new file mode 100644 index 00000000..1639c238 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationMetadataTriageResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Metadata; +import ai.reveng.model.Status; +import ai.reveng.model.TriageResult; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationMetadataTriageResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationMetadataTriageResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private Metadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private TriageResult response; + + public OperationMetadataTriageResult() { + } + + public OperationMetadataTriageResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationMetadataTriageResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationMetadataTriageResult metadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable Metadata metadata) { + this.metadata = metadata; + } + + + public OperationMetadataTriageResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationMetadataTriageResult response(@javax.annotation.Nullable TriageResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public TriageResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable TriageResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationMetadataTriageResult instance itself + */ + public OperationMetadataTriageResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationMetadataTriageResult operationMetadataTriageResult = (OperationMetadataTriageResult) o; + return Objects.equals(this.done, operationMetadataTriageResult.done) && + Objects.equals(this.error, operationMetadataTriageResult.error) && + Objects.equals(this.metadata, operationMetadataTriageResult.metadata) && + Objects.equals(this.name, operationMetadataTriageResult.name) && + Objects.equals(this.response, operationMetadataTriageResult.response)&& + Objects.equals(this.additionalProperties, operationMetadataTriageResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationMetadataTriageResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationMetadataTriageResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationMetadataTriageResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationMetadataTriageResult is not found in the empty JSON string", OperationMetadataTriageResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationMetadataTriageResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationMetadataTriageResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationMetadataTriageResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationMetadataTriageResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationMetadataTriageResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationMetadataTriageResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationMetadataTriageResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationMetadataTriageResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationMetadataTriageResult + * @throws IOException if the JSON string is invalid with respect to OperationMetadataTriageResult + */ + public static OperationMetadataTriageResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationMetadataTriageResult.class); + } + + /** + * Convert an instance of OperationMetadataTriageResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationNetworkingExplainMetadataNetworkingExplainResult.java b/src/main/java/ai/reveng/model/OperationNetworkingExplainMetadataNetworkingExplainResult.java new file mode 100644 index 00000000..a3a53266 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationNetworkingExplainMetadataNetworkingExplainResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.NetworkingExplainMetadata; +import ai.reveng.model.NetworkingExplainResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationNetworkingExplainMetadataNetworkingExplainResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationNetworkingExplainMetadataNetworkingExplainResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private NetworkingExplainMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private NetworkingExplainResult response; + + public OperationNetworkingExplainMetadataNetworkingExplainResult() { + } + + public OperationNetworkingExplainMetadataNetworkingExplainResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationNetworkingExplainMetadataNetworkingExplainResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationNetworkingExplainMetadataNetworkingExplainResult metadata(@javax.annotation.Nullable NetworkingExplainMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public NetworkingExplainMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable NetworkingExplainMetadata metadata) { + this.metadata = metadata; + } + + + public OperationNetworkingExplainMetadataNetworkingExplainResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationNetworkingExplainMetadataNetworkingExplainResult response(@javax.annotation.Nullable NetworkingExplainResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public NetworkingExplainResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable NetworkingExplainResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationNetworkingExplainMetadataNetworkingExplainResult instance itself + */ + public OperationNetworkingExplainMetadataNetworkingExplainResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationNetworkingExplainMetadataNetworkingExplainResult operationNetworkingExplainMetadataNetworkingExplainResult = (OperationNetworkingExplainMetadataNetworkingExplainResult) o; + return Objects.equals(this.done, operationNetworkingExplainMetadataNetworkingExplainResult.done) && + Objects.equals(this.error, operationNetworkingExplainMetadataNetworkingExplainResult.error) && + Objects.equals(this.metadata, operationNetworkingExplainMetadataNetworkingExplainResult.metadata) && + Objects.equals(this.name, operationNetworkingExplainMetadataNetworkingExplainResult.name) && + Objects.equals(this.response, operationNetworkingExplainMetadataNetworkingExplainResult.response)&& + Objects.equals(this.additionalProperties, operationNetworkingExplainMetadataNetworkingExplainResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationNetworkingExplainMetadataNetworkingExplainResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationNetworkingExplainMetadataNetworkingExplainResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationNetworkingExplainMetadataNetworkingExplainResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationNetworkingExplainMetadataNetworkingExplainResult is not found in the empty JSON string", OperationNetworkingExplainMetadataNetworkingExplainResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationNetworkingExplainMetadataNetworkingExplainResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationNetworkingExplainMetadataNetworkingExplainResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationNetworkingExplainMetadataNetworkingExplainResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationNetworkingExplainMetadataNetworkingExplainResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationNetworkingExplainMetadataNetworkingExplainResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationNetworkingExplainMetadataNetworkingExplainResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationNetworkingExplainMetadataNetworkingExplainResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationNetworkingExplainMetadataNetworkingExplainResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationNetworkingExplainMetadataNetworkingExplainResult + * @throws IOException if the JSON string is invalid with respect to OperationNetworkingExplainMetadataNetworkingExplainResult + */ + public static OperationNetworkingExplainMetadataNetworkingExplainResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationNetworkingExplainMetadataNetworkingExplainResult.class); + } + + /** + * Convert an instance of OperationNetworkingExplainMetadataNetworkingExplainResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationNetworkingScanMetadataNetworkingScanResult.java b/src/main/java/ai/reveng/model/OperationNetworkingScanMetadataNetworkingScanResult.java new file mode 100644 index 00000000..542e230c --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationNetworkingScanMetadataNetworkingScanResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.NetworkingScanMetadata; +import ai.reveng.model.NetworkingScanResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationNetworkingScanMetadataNetworkingScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationNetworkingScanMetadataNetworkingScanResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private NetworkingScanMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private NetworkingScanResult response; + + public OperationNetworkingScanMetadataNetworkingScanResult() { + } + + public OperationNetworkingScanMetadataNetworkingScanResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationNetworkingScanMetadataNetworkingScanResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationNetworkingScanMetadataNetworkingScanResult metadata(@javax.annotation.Nullable NetworkingScanMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public NetworkingScanMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable NetworkingScanMetadata metadata) { + this.metadata = metadata; + } + + + public OperationNetworkingScanMetadataNetworkingScanResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationNetworkingScanMetadataNetworkingScanResult response(@javax.annotation.Nullable NetworkingScanResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public NetworkingScanResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable NetworkingScanResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationNetworkingScanMetadataNetworkingScanResult instance itself + */ + public OperationNetworkingScanMetadataNetworkingScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationNetworkingScanMetadataNetworkingScanResult operationNetworkingScanMetadataNetworkingScanResult = (OperationNetworkingScanMetadataNetworkingScanResult) o; + return Objects.equals(this.done, operationNetworkingScanMetadataNetworkingScanResult.done) && + Objects.equals(this.error, operationNetworkingScanMetadataNetworkingScanResult.error) && + Objects.equals(this.metadata, operationNetworkingScanMetadataNetworkingScanResult.metadata) && + Objects.equals(this.name, operationNetworkingScanMetadataNetworkingScanResult.name) && + Objects.equals(this.response, operationNetworkingScanMetadataNetworkingScanResult.response)&& + Objects.equals(this.additionalProperties, operationNetworkingScanMetadataNetworkingScanResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationNetworkingScanMetadataNetworkingScanResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationNetworkingScanMetadataNetworkingScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationNetworkingScanMetadataNetworkingScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationNetworkingScanMetadataNetworkingScanResult is not found in the empty JSON string", OperationNetworkingScanMetadataNetworkingScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationNetworkingScanMetadataNetworkingScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationNetworkingScanMetadataNetworkingScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationNetworkingScanMetadataNetworkingScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationNetworkingScanMetadataNetworkingScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationNetworkingScanMetadataNetworkingScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationNetworkingScanMetadataNetworkingScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationNetworkingScanMetadataNetworkingScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationNetworkingScanMetadataNetworkingScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationNetworkingScanMetadataNetworkingScanResult + * @throws IOException if the JSON string is invalid with respect to OperationNetworkingScanMetadataNetworkingScanResult + */ + public static OperationNetworkingScanMetadataNetworkingScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationNetworkingScanMetadataNetworkingScanResult.class); + } + + /** + * Convert an instance of OperationNetworkingScanMetadataNetworkingScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationSecurityScanMetadataSecurityScanResult.java b/src/main/java/ai/reveng/model/OperationSecurityScanMetadataSecurityScanResult.java new file mode 100644 index 00000000..9da86f24 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationSecurityScanMetadataSecurityScanResult.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.SecurityScanMetadata; +import ai.reveng.model.SecurityScanResult; +import ai.reveng.model.Status; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationSecurityScanMetadataSecurityScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationSecurityScanMetadataSecurityScanResult { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private SecurityScanMetadata metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private SecurityScanResult response; + + public OperationSecurityScanMetadataSecurityScanResult() { + } + + public OperationSecurityScanMetadataSecurityScanResult done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationSecurityScanMetadataSecurityScanResult error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationSecurityScanMetadataSecurityScanResult metadata(@javax.annotation.Nullable SecurityScanMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public SecurityScanMetadata getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable SecurityScanMetadata metadata) { + this.metadata = metadata; + } + + + public OperationSecurityScanMetadataSecurityScanResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationSecurityScanMetadataSecurityScanResult response(@javax.annotation.Nullable SecurityScanResult response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public SecurityScanResult getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable SecurityScanResult response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationSecurityScanMetadataSecurityScanResult instance itself + */ + public OperationSecurityScanMetadataSecurityScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationSecurityScanMetadataSecurityScanResult operationSecurityScanMetadataSecurityScanResult = (OperationSecurityScanMetadataSecurityScanResult) o; + return Objects.equals(this.done, operationSecurityScanMetadataSecurityScanResult.done) && + Objects.equals(this.error, operationSecurityScanMetadataSecurityScanResult.error) && + Objects.equals(this.metadata, operationSecurityScanMetadataSecurityScanResult.metadata) && + Objects.equals(this.name, operationSecurityScanMetadataSecurityScanResult.name) && + Objects.equals(this.response, operationSecurityScanMetadataSecurityScanResult.response)&& + Objects.equals(this.additionalProperties, operationSecurityScanMetadataSecurityScanResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationSecurityScanMetadataSecurityScanResult {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationSecurityScanMetadataSecurityScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationSecurityScanMetadataSecurityScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationSecurityScanMetadataSecurityScanResult is not found in the empty JSON string", OperationSecurityScanMetadataSecurityScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationSecurityScanMetadataSecurityScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationSecurityScanMetadataSecurityScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationSecurityScanMetadataSecurityScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationSecurityScanMetadataSecurityScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationSecurityScanMetadataSecurityScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationSecurityScanMetadataSecurityScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationSecurityScanMetadataSecurityScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationSecurityScanMetadataSecurityScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationSecurityScanMetadataSecurityScanResult + * @throws IOException if the JSON string is invalid with respect to OperationSecurityScanMetadataSecurityScanResult + */ + public static OperationSecurityScanMetadataSecurityScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationSecurityScanMetadataSecurityScanResult.class); + } + + /** + * Convert an instance of OperationSecurityScanMetadataSecurityScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/OperationWorkflowProgressResultBody.java b/src/main/java/ai/reveng/model/OperationWorkflowProgressResultBody.java new file mode 100644 index 00000000..26a29205 --- /dev/null +++ b/src/main/java/ai/reveng/model/OperationWorkflowProgressResultBody.java @@ -0,0 +1,396 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ResultBody; +import ai.reveng.model.Status; +import ai.reveng.model.WorkflowProgress; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * OperationWorkflowProgressResultBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class OperationWorkflowProgressResultBody { + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + @javax.annotation.Nonnull + private Boolean done; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable + private Status error; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable + private WorkflowProgress metadata; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_RESPONSE = "response"; + @SerializedName(SERIALIZED_NAME_RESPONSE) + @javax.annotation.Nullable + private ResultBody response; + + public OperationWorkflowProgressResultBody() { + } + + public OperationWorkflowProgressResultBody done(@javax.annotation.Nonnull Boolean done) { + this.done = done; + return this; + } + + /** + * Whether the operation has reached a terminal state. + * @return done + */ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + public void setDone(@javax.annotation.Nonnull Boolean done) { + this.done = done; + } + + + public OperationWorkflowProgressResultBody error(@javax.annotation.Nullable Status error) { + this.error = error; + return this; + } + + /** + * Failure detail, populated only when done is true and the operation failed. + * @return error + */ + @javax.annotation.Nullable + public Status getError() { + return error; + } + + public void setError(@javax.annotation.Nullable Status error) { + this.error = error; + } + + + public OperationWorkflowProgressResultBody metadata(@javax.annotation.Nullable WorkflowProgress metadata) { + this.metadata = metadata; + return this; + } + + /** + * In-flight information and details. + * @return metadata + */ + @javax.annotation.Nullable + public WorkflowProgress getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable WorkflowProgress metadata) { + this.metadata = metadata; + } + + + public OperationWorkflowProgressResultBody name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * API resource name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OperationWorkflowProgressResultBody response(@javax.annotation.Nullable ResultBody response) { + this.response = response; + return this; + } + + /** + * Result, set only when done is true and the operation succeeded. + * @return response + */ + @javax.annotation.Nullable + public ResultBody getResponse() { + return response; + } + + public void setResponse(@javax.annotation.Nullable ResultBody response) { + this.response = response; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OperationWorkflowProgressResultBody instance itself + */ + public OperationWorkflowProgressResultBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationWorkflowProgressResultBody operationWorkflowProgressResultBody = (OperationWorkflowProgressResultBody) o; + return Objects.equals(this.done, operationWorkflowProgressResultBody.done) && + Objects.equals(this.error, operationWorkflowProgressResultBody.error) && + Objects.equals(this.metadata, operationWorkflowProgressResultBody.metadata) && + Objects.equals(this.name, operationWorkflowProgressResultBody.name) && + Objects.equals(this.response, operationWorkflowProgressResultBody.response)&& + Objects.equals(this.additionalProperties, operationWorkflowProgressResultBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationWorkflowProgressResultBody {\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" response: ").append(toIndentedString(response)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("done", "error", "metadata", "name", "response")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("done", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OperationWorkflowProgressResultBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OperationWorkflowProgressResultBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in OperationWorkflowProgressResultBody is not found in the empty JSON string", OperationWorkflowProgressResultBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OperationWorkflowProgressResultBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OperationWorkflowProgressResultBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OperationWorkflowProgressResultBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OperationWorkflowProgressResultBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OperationWorkflowProgressResultBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OperationWorkflowProgressResultBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OperationWorkflowProgressResultBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OperationWorkflowProgressResultBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of OperationWorkflowProgressResultBody + * @throws IOException if the JSON string is invalid with respect to OperationWorkflowProgressResultBody + */ + public static OperationWorkflowProgressResultBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OperationWorkflowProgressResultBody.class); + } + + /** + * Convert an instance of OperationWorkflowProgressResultBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java b/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java index bdf4f850..adcbdfcf 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java @@ -85,6 +85,50 @@ public void setBinaries(@javax.annotation.Nullable List binaries) { this.binaries = binaries; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchCollectionBinariesInputBody instance itself + */ + public PatchCollectionBinariesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -96,12 +140,13 @@ public boolean equals(Object o) { return false; } PatchCollectionBinariesInputBody patchCollectionBinariesInputBody = (PatchCollectionBinariesInputBody) o; - return Objects.equals(this.binaries, patchCollectionBinariesInputBody.binaries); + return Objects.equals(this.binaries, patchCollectionBinariesInputBody.binaries)&& + Objects.equals(this.additionalProperties, patchCollectionBinariesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaries); + return Objects.hash(binaries, additionalProperties); } @Override @@ -109,6 +154,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionBinariesInputBody {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchCollectionBinariesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionBinariesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionBinariesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -184,6 +222,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionBinariesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -191,7 +251,28 @@ public void write(JsonWriter out, PatchCollectionBinariesInputBody value) throws public PatchCollectionBinariesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchCollectionBinariesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java b/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java index fc119fff..343e81bf 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java @@ -86,6 +86,50 @@ public void setBinaries(@javax.annotation.Nullable List binaries) { this.binaries = binaries; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchCollectionBinariesOutputBody instance itself + */ + public PatchCollectionBinariesOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } PatchCollectionBinariesOutputBody patchCollectionBinariesOutputBody = (PatchCollectionBinariesOutputBody) o; - return Objects.equals(this.binaries, patchCollectionBinariesOutputBody.binaries); + return Objects.equals(this.binaries, patchCollectionBinariesOutputBody.binaries)&& + Objects.equals(this.additionalProperties, patchCollectionBinariesOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaries); + return Objects.hash(binaries, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionBinariesOutputBody {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchCollectionBinariesOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionBinariesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionBinariesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull()) { - if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); - } - JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); - // validate the required field `binaries` (array) - for (int i = 0; i < jsonArraybinaries.size(); i++) { - Binary.validateJsonElement(jsonArraybinaries.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("binaries") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("binaries").isJsonArray() && !jsonObj.get("binaries").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionBinariesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, PatchCollectionBinariesOutputBody value) throw public PatchCollectionBinariesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchCollectionBinariesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionInputBody.java b/src/main/java/ai/reveng/model/PatchCollectionInputBody.java index d5c65cbf..fd8bf073 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionInputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionInputBody.java @@ -123,6 +123,50 @@ public void setDescription(@javax.annotation.Nullable String description) { this.description = description; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchCollectionInputBody instance itself + */ + public PatchCollectionInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -136,12 +180,13 @@ public boolean equals(Object o) { PatchCollectionInputBody patchCollectionInputBody = (PatchCollectionInputBody) o; return Objects.equals(this.collectionName, patchCollectionInputBody.collectionName) && Objects.equals(this.collectionScope, patchCollectionInputBody.collectionScope) && - Objects.equals(this.description, patchCollectionInputBody.description); + Objects.equals(this.description, patchCollectionInputBody.description)&& + Objects.equals(this.additionalProperties, patchCollectionInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(collectionName, collectionScope, description); + return Objects.hash(collectionName, collectionScope, description, additionalProperties); } @Override @@ -151,6 +196,7 @@ public String toString() { sb.append(" collectionName: ").append(toIndentedString(collectionName)).append("\n"); sb.append(" collectionScope: ").append(toIndentedString(collectionScope)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -187,14 +233,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCollectionInputBody is not found in the empty JSON string", PatchCollectionInputBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchCollectionInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("collection_name") != null && !jsonObj.get("collection_name").isJsonNull()) && !jsonObj.get("collection_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); @@ -222,6 +260,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -229,7 +289,28 @@ public void write(JsonWriter out, PatchCollectionInputBody value) throws IOExcep public PatchCollectionInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchCollectionInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java b/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java index d4092197..8c40f533 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java @@ -268,6 +268,50 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchCollectionOutputBody instance itself + */ + public PatchCollectionOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -287,12 +331,13 @@ public boolean equals(Object o) { Objects.equals(this.description, patchCollectionOutputBody.description) && Objects.equals(this.teamId, patchCollectionOutputBody.teamId) && Objects.equals(this.updatedAt, patchCollectionOutputBody.updatedAt) && - Objects.equals(this.userId, patchCollectionOutputBody.userId); + Objects.equals(this.userId, patchCollectionOutputBody.userId)&& + Objects.equals(this.additionalProperties, patchCollectionOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryCount, collectionId, collectionName, collectionScope, createdAt, description, teamId, updatedAt, userId); + return Objects.hash(binaryCount, collectionId, collectionName, collectionScope, createdAt, description, teamId, updatedAt, userId, additionalProperties); } @Override @@ -308,6 +353,7 @@ public String toString() { sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -345,14 +391,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchCollectionOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -386,6 +424,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -393,7 +453,28 @@ public void write(JsonWriter out, PatchCollectionOutputBody value) throws IOExce public PatchCollectionOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchCollectionOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java b/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java index f2872675..2a3903e5 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java @@ -85,6 +85,50 @@ public void setTags(@javax.annotation.Nullable List tags) { this.tags = tags; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchCollectionTagsInputBody instance itself + */ + public PatchCollectionTagsInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -96,12 +140,13 @@ public boolean equals(Object o) { return false; } PatchCollectionTagsInputBody patchCollectionTagsInputBody = (PatchCollectionTagsInputBody) o; - return Objects.equals(this.tags, patchCollectionTagsInputBody.tags); + return Objects.equals(this.tags, patchCollectionTagsInputBody.tags)&& + Objects.equals(this.additionalProperties, patchCollectionTagsInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tags); + return Objects.hash(tags, additionalProperties); } @Override @@ -109,6 +154,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionTagsInputBody {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchCollectionTagsInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionTagsInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionTagsInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -184,6 +222,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionTagsInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -191,7 +251,28 @@ public void write(JsonWriter out, PatchCollectionTagsInputBody value) throws IOE public PatchCollectionTagsInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchCollectionTagsInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java b/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java index 805ccf56..d3c191f5 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java @@ -85,6 +85,50 @@ public void setTags(@javax.annotation.Nullable List tags) { this.tags = tags; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchCollectionTagsOutputBody instance itself + */ + public PatchCollectionTagsOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -96,12 +140,13 @@ public boolean equals(Object o) { return false; } PatchCollectionTagsOutputBody patchCollectionTagsOutputBody = (PatchCollectionTagsOutputBody) o; - return Objects.equals(this.tags, patchCollectionTagsOutputBody.tags); + return Objects.equals(this.tags, patchCollectionTagsOutputBody.tags)&& + Objects.equals(this.additionalProperties, patchCollectionTagsOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tags); + return Objects.hash(tags, additionalProperties); } @Override @@ -109,6 +154,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionTagsOutputBody {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchCollectionTagsOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionTagsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionTagsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -184,6 +222,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionTagsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -191,7 +251,28 @@ public void write(JsonWriter out, PatchCollectionTagsOutputBody value) throws IO public PatchCollectionTagsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchCollectionTagsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCommentBody.java b/src/main/java/ai/reveng/model/PatchCommentBody.java index 3d3f1fcf..7c19a96e 100644 --- a/src/main/java/ai/reveng/model/PatchCommentBody.java +++ b/src/main/java/ai/reveng/model/PatchCommentBody.java @@ -100,6 +100,50 @@ public void setLine(@javax.annotation.Nonnull Long line) { this.line = line; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchCommentBody instance itself + */ + public PatchCommentBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } PatchCommentBody patchCommentBody = (PatchCommentBody) o; return Objects.equals(this.comment, patchCommentBody.comment) && - Objects.equals(this.line, patchCommentBody.line); + Objects.equals(this.line, patchCommentBody.line)&& + Objects.equals(this.additionalProperties, patchCommentBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(comment, line); + return Objects.hash(comment, line, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class PatchCommentBody {\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" line: ").append(toIndentedString(line)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchCommentBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCommentBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCommentBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCommentBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, PatchCommentBody value) throws IOException { public PatchCommentBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchCommentBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PcapBodyInfo.java b/src/main/java/ai/reveng/model/PcapBodyInfo.java index 0b452ab6..fd823ac2 100644 --- a/src/main/java/ai/reveng/model/PcapBodyInfo.java +++ b/src/main/java/ai/reveng/model/PcapBodyInfo.java @@ -230,6 +230,50 @@ public void setYaraHits(@javax.annotation.Nullable List yaraHits) { this.yaraHits = yaraHits; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PcapBodyInfo instance itself + */ + public PcapBodyInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -247,7 +291,8 @@ public boolean equals(Object o) { Objects.equals(this.preview, pcapBodyInfo.preview) && Objects.equals(this.sha256, pcapBodyInfo.sha256) && Objects.equals(this.size, pcapBodyInfo.size) && - Objects.equals(this.yaraHits, pcapBodyInfo.yaraHits); + Objects.equals(this.yaraHits, pcapBodyInfo.yaraHits)&& + Objects.equals(this.additionalProperties, pcapBodyInfo.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -256,7 +301,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(filename, isPe, mimeType, preview, sha256, size, yaraHits); + return Objects.hash(filename, isPe, mimeType, preview, sha256, size, yaraHits, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -277,6 +322,7 @@ public String toString() { sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" yaraHits: ").append(toIndentedString(yaraHits)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -314,14 +360,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PcapBodyInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PcapBodyInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PcapBodyInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -362,6 +400,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PcapBodyInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -369,7 +429,28 @@ public void write(JsonWriter out, PcapBodyInfo value) throws IOException { public PcapBodyInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PcapBodyInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Permissions.java b/src/main/java/ai/reveng/model/Permissions.java index aecf3c74..7278e656 100644 --- a/src/main/java/ai/reveng/model/Permissions.java +++ b/src/main/java/ai/reveng/model/Permissions.java @@ -195,6 +195,50 @@ public void setCanUsePrivateAnalyses(@javax.annotation.Nonnull Boolean canUsePri this.canUsePrivateAnalyses = canUsePrivateAnalyses; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Permissions instance itself + */ + public Permissions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -211,12 +255,13 @@ public boolean equals(Object o) { Objects.equals(this.canUseAiMalwareAnalysis, permissions.canUseAiMalwareAnalysis) && Objects.equals(this.canUseCompositionAnalysis, permissions.canUseCompositionAnalysis) && Objects.equals(this.canUseMalwareSandbox, permissions.canUseMalwareSandbox) && - Objects.equals(this.canUsePrivateAnalyses, permissions.canUsePrivateAnalyses); + Objects.equals(this.canUsePrivateAnalyses, permissions.canUsePrivateAnalyses)&& + Objects.equals(this.additionalProperties, permissions.additionalProperties); } @Override public int hashCode() { - return Objects.hash(canExportSymbols, canGeneratePdfReports, canUseAiMalwareAnalysis, canUseCompositionAnalysis, canUseMalwareSandbox, canUsePrivateAnalyses); + return Objects.hash(canExportSymbols, canGeneratePdfReports, canUseAiMalwareAnalysis, canUseCompositionAnalysis, canUseMalwareSandbox, canUsePrivateAnalyses, additionalProperties); } @Override @@ -229,6 +274,7 @@ public String toString() { sb.append(" canUseCompositionAnalysis: ").append(toIndentedString(canUseCompositionAnalysis)).append("\n"); sb.append(" canUseMalwareSandbox: ").append(toIndentedString(canUseMalwareSandbox)).append("\n"); sb.append(" canUsePrivateAnalyses: ").append(toIndentedString(canUsePrivateAnalyses)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -266,14 +312,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Permissions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Permissions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Permissions.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -298,6 +336,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Permissions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -305,7 +365,28 @@ public void write(JsonWriter out, Permissions value) throws IOException { public Permissions read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Permissions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PointerDataType.java b/src/main/java/ai/reveng/model/PointerDataType.java index 00e18f06..54b7c0af 100644 --- a/src/main/java/ai/reveng/model/PointerDataType.java +++ b/src/main/java/ai/reveng/model/PointerDataType.java @@ -143,6 +143,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -366,6 +371,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public PointerDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public PointerDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -403,6 +427,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PointerDataType instance itself + */ + public PointerDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -422,13 +490,15 @@ public boolean equals(Object o) { Objects.equals(this.name, pointerDataType.name) && Objects.equals(this.namespace, pointerDataType.namespace) && Objects.equals(this.size, pointerDataType.size) && + Objects.equals(this.sourceAnalysisId, pointerDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, pointerDataType.sourceFunctionId) && - Objects.equals(this.sourceType, pointerDataType.sourceType); + Objects.equals(this.sourceType, pointerDataType.sourceType)&& + Objects.equals(this.additionalProperties, pointerDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -443,8 +513,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -463,7 +535,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -482,14 +554,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PointerDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PointerDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PointerDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -497,10 +561,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `definition` - if (jsonObj.get("definition") != null && !jsonObj.get("definition").isJsonNull()) { - PointerDefinition.validateJsonElement(jsonObj.get("definition")); - } if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -534,6 +594,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PointerDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -541,7 +623,28 @@ public void write(JsonWriter out, PointerDataType value) throws IOException { public PointerDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PointerDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PointerDefinition.java b/src/main/java/ai/reveng/model/PointerDefinition.java index e3f893b4..211572b1 100644 --- a/src/main/java/ai/reveng/model/PointerDefinition.java +++ b/src/main/java/ai/reveng/model/PointerDefinition.java @@ -75,6 +75,50 @@ public void setPointeeDataTypeId(@javax.annotation.Nullable Long pointeeDataType this.pointeeDataTypeId = pointeeDataTypeId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PointerDefinition instance itself + */ + public PointerDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } PointerDefinition pointerDefinition = (PointerDefinition) o; - return Objects.equals(this.pointeeDataTypeId, pointerDefinition.pointeeDataTypeId); + return Objects.equals(this.pointeeDataTypeId, pointerDefinition.pointeeDataTypeId)&& + Objects.equals(this.additionalProperties, pointerDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(pointeeDataTypeId); + return Objects.hash(pointeeDataTypeId, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PointerDefinition {\n"); sb.append(" pointeeDataTypeId: ").append(toIndentedString(pointeeDataTypeId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -135,14 +181,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PointerDefinition is not found in the empty JSON string", PointerDefinition.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PointerDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PointerDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -161,6 +199,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PointerDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -168,7 +228,28 @@ public void write(JsonWriter out, PointerDefinition value) throws IOException { public PointerDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PointerDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PriceOutput.java b/src/main/java/ai/reveng/model/PriceOutput.java index f1433585..c507afe0 100644 --- a/src/main/java/ai/reveng/model/PriceOutput.java +++ b/src/main/java/ai/reveng/model/PriceOutput.java @@ -201,6 +201,50 @@ public void setUnitAmount(@javax.annotation.Nonnull Long unitAmount) { this.unitAmount = unitAmount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PriceOutput instance itself + */ + public PriceOutput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -215,12 +259,13 @@ public boolean equals(Object o) { return Objects.equals(this.currency, priceOutput.currency) && Objects.equals(this.id, priceOutput.id) && Objects.equals(this.interval, priceOutput.interval) && - Objects.equals(this.unitAmount, priceOutput.unitAmount); + Objects.equals(this.unitAmount, priceOutput.unitAmount)&& + Objects.equals(this.additionalProperties, priceOutput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(currency, id, interval, unitAmount); + return Objects.hash(currency, id, interval, unitAmount, additionalProperties); } @Override @@ -231,6 +276,7 @@ public String toString() { sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" interval: ").append(toIndentedString(interval)).append("\n"); sb.append(" unitAmount: ").append(toIndentedString(unitAmount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PriceOutput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PriceOutput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PriceOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -311,6 +349,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PriceOutput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -318,7 +378,28 @@ public void write(JsonWriter out, PriceOutput value) throws IOException { public PriceOutput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PriceOutput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PriceSummary.java b/src/main/java/ai/reveng/model/PriceSummary.java index 42ea5d4d..202370bb 100644 --- a/src/main/java/ai/reveng/model/PriceSummary.java +++ b/src/main/java/ai/reveng/model/PriceSummary.java @@ -177,6 +177,50 @@ public void setUnitAmount(@javax.annotation.Nonnull Long unitAmount) { this.unitAmount = unitAmount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PriceSummary instance itself + */ + public PriceSummary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -190,12 +234,13 @@ public boolean equals(Object o) { PriceSummary priceSummary = (PriceSummary) o; return Objects.equals(this.currency, priceSummary.currency) && Objects.equals(this.interval, priceSummary.interval) && - Objects.equals(this.unitAmount, priceSummary.unitAmount); + Objects.equals(this.unitAmount, priceSummary.unitAmount)&& + Objects.equals(this.additionalProperties, priceSummary.additionalProperties); } @Override public int hashCode() { - return Objects.hash(currency, interval, unitAmount); + return Objects.hash(currency, interval, unitAmount, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); sb.append(" interval: ").append(toIndentedString(interval)).append("\n"); sb.append(" unitAmount: ").append(toIndentedString(unitAmount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -242,14 +288,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PriceSummary.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PriceSummary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PriceSummary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -282,6 +320,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PriceSummary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -289,7 +349,28 @@ public void write(JsonWriter out, PriceSummary value) throws IOException { public PriceSummary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PriceSummary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessActivityEntry.java b/src/main/java/ai/reveng/model/ProcessActivityEntry.java index eb27cf14..31d80672 100644 --- a/src/main/java/ai/reveng/model/ProcessActivityEntry.java +++ b/src/main/java/ai/reveng/model/ProcessActivityEntry.java @@ -239,6 +239,50 @@ public void setPid(@javax.annotation.Nonnull Long pid) { this.pid = pid; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProcessActivityEntry instance itself + */ + public ProcessActivityEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -256,7 +300,8 @@ public boolean equals(Object o) { Objects.equals(this.exitCode, processActivityEntry.exitCode) && Objects.equals(this.exitCodeStr, processActivityEntry.exitCodeStr) && Objects.equals(this.name, processActivityEntry.name) && - Objects.equals(this.pid, processActivityEntry.pid); + Objects.equals(this.pid, processActivityEntry.pid)&& + Objects.equals(this.additionalProperties, processActivityEntry.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -265,7 +310,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(args, childSeqid, events, exitCode, exitCodeStr, name, pid); + return Objects.hash(args, childSeqid, events, exitCode, exitCodeStr, name, pid, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -286,6 +331,7 @@ public String toString() { sb.append(" exitCodeStr: ").append(toIndentedString(exitCodeStr)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" pid: ").append(toIndentedString(pid)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -323,14 +369,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessActivityEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessActivityEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessActivityEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -342,19 +380,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("args") != null && !jsonObj.get("args").isJsonNull() && !jsonObj.get("args").isJsonArray()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `args` to be an array in the JSON string but got `%s`", jsonObj.get("args").toString())); } - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if ((jsonObj.get("exit_code_str") != null && !jsonObj.get("exit_code_str").isJsonNull()) && !jsonObj.get("exit_code_str").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `exit_code_str` to be a primitive type in the JSON string but got `%s`", jsonObj.get("exit_code_str").toString())); @@ -379,6 +407,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessActivityEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -386,7 +436,28 @@ public void write(JsonWriter out, ProcessActivityEntry value) throws IOException public ProcessActivityEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProcessActivityEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessMemdumps.java b/src/main/java/ai/reveng/model/ProcessMemdumps.java index c395acab..45932ce5 100644 --- a/src/main/java/ai/reveng/model/ProcessMemdumps.java +++ b/src/main/java/ai/reveng/model/ProcessMemdumps.java @@ -111,6 +111,50 @@ public void setProcessSeqid(@javax.annotation.Nonnull Long processSeqid) { this.processSeqid = processSeqid; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProcessMemdumps instance itself + */ + public ProcessMemdumps putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,7 +167,8 @@ public boolean equals(Object o) { } ProcessMemdumps processMemdumps = (ProcessMemdumps) o; return Objects.equals(this.dumps, processMemdumps.dumps) && - Objects.equals(this.processSeqid, processMemdumps.processSeqid); + Objects.equals(this.processSeqid, processMemdumps.processSeqid)&& + Objects.equals(this.additionalProperties, processMemdumps.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -132,7 +177,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(dumps, processSeqid); + return Objects.hash(dumps, processSeqid, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -148,6 +193,7 @@ public String toString() { sb.append("class ProcessMemdumps {\n"); sb.append(" dumps: ").append(toIndentedString(dumps)).append("\n"); sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -185,14 +231,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessMemdumps.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessMemdumps` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessMemdumps.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,19 +238,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("dumps") != null && !jsonObj.get("dumps").isJsonNull()) { - JsonArray jsonArraydumps = jsonObj.getAsJsonArray("dumps"); - if (jsonArraydumps != null) { - // ensure the json data is an array - if (!jsonObj.get("dumps").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dumps` to be an array in the JSON string but got `%s`", jsonObj.get("dumps").toString())); - } - - // validate the optional field `dumps` (array) - for (int i = 0; i < jsonArraydumps.size(); i++) { - MemdumpEntry.validateJsonElement(jsonArraydumps.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("dumps") != null && !jsonObj.get("dumps").isJsonNull() && !jsonObj.get("dumps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dumps` to be an array in the JSON string but got `%s`", jsonObj.get("dumps").toString())); } } @@ -231,6 +259,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessMemdumps value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -238,7 +288,28 @@ public void write(JsonWriter out, ProcessMemdumps value) throws IOException { public ProcessMemdumps read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProcessMemdumps instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessNode.java b/src/main/java/ai/reveng/model/ProcessNode.java index 8a8df65a..c345c875 100644 --- a/src/main/java/ai/reveng/model/ProcessNode.java +++ b/src/main/java/ai/reveng/model/ProcessNode.java @@ -334,6 +334,50 @@ public void setStartedAt(@javax.annotation.Nullable Double startedAt) { this.startedAt = startedAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProcessNode instance itself + */ + public ProcessNode putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -355,7 +399,8 @@ public boolean equals(Object o) { Objects.equals(this.name, processNode.name) && Objects.equals(this.pid, processNode.pid) && Objects.equals(this.seqid, processNode.seqid) && - Objects.equals(this.startedAt, processNode.startedAt); + Objects.equals(this.startedAt, processNode.startedAt)&& + Objects.equals(this.additionalProperties, processNode.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -364,7 +409,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(args, attributed, children, exitCode, exitCodeStr, exitedAt, killedBy, name, pid, seqid, startedAt); + return Objects.hash(args, attributed, children, exitCode, exitCodeStr, exitedAt, killedBy, name, pid, seqid, startedAt, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -389,6 +434,7 @@ public String toString() { sb.append(" pid: ").append(toIndentedString(pid)).append("\n"); sb.append(" seqid: ").append(toIndentedString(seqid)).append("\n"); sb.append(" startedAt: ").append(toIndentedString(startedAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -426,14 +472,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessNode.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessNode` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessNode.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -445,19 +483,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("args") != null && !jsonObj.get("args").isJsonNull() && !jsonObj.get("args").isJsonArray()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `args` to be an array in the JSON string but got `%s`", jsonObj.get("args").toString())); } - if (jsonObj.get("children") != null && !jsonObj.get("children").isJsonNull()) { - JsonArray jsonArraychildren = jsonObj.getAsJsonArray("children"); - if (jsonArraychildren != null) { - // ensure the json data is an array - if (!jsonObj.get("children").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); - } - - // validate the optional field `children` (array) - for (int i = 0; i < jsonArraychildren.size(); i++) { - ProcessNode.validateJsonElement(jsonArraychildren.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("children") != null && !jsonObj.get("children").isJsonNull() && !jsonObj.get("children").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); } if ((jsonObj.get("exit_code_str") != null && !jsonObj.get("exit_code_str").isJsonNull()) && !jsonObj.get("exit_code_str").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `exit_code_str` to be a primitive type in the JSON string but got `%s`", jsonObj.get("exit_code_str").toString())); @@ -482,6 +510,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessNode value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -489,7 +539,28 @@ public void write(JsonWriter out, ProcessNode value) throws IOException { public ProcessNode read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProcessNode instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessTree.java b/src/main/java/ai/reveng/model/ProcessTree.java index f05f2472..adf0dcf6 100644 --- a/src/main/java/ai/reveng/model/ProcessTree.java +++ b/src/main/java/ai/reveng/model/ProcessTree.java @@ -111,6 +111,50 @@ public void setSampleSeqid(@javax.annotation.Nullable Long sampleSeqid) { this.sampleSeqid = sampleSeqid; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProcessTree instance itself + */ + public ProcessTree putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,7 +167,8 @@ public boolean equals(Object o) { } ProcessTree processTree = (ProcessTree) o; return Objects.equals(this.nodes, processTree.nodes) && - Objects.equals(this.sampleSeqid, processTree.sampleSeqid); + Objects.equals(this.sampleSeqid, processTree.sampleSeqid)&& + Objects.equals(this.additionalProperties, processTree.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -132,7 +177,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(nodes, sampleSeqid); + return Objects.hash(nodes, sampleSeqid, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -148,6 +193,7 @@ public String toString() { sb.append("class ProcessTree {\n"); sb.append(" nodes: ").append(toIndentedString(nodes)).append("\n"); sb.append(" sampleSeqid: ").append(toIndentedString(sampleSeqid)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -184,28 +230,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProcessTree is not found in the empty JSON string", ProcessTree.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessTree.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessTree` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("nodes") != null && !jsonObj.get("nodes").isJsonNull()) { - JsonArray jsonArraynodes = jsonObj.getAsJsonArray("nodes"); - if (jsonArraynodes != null) { - // ensure the json data is an array - if (!jsonObj.get("nodes").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `nodes` to be an array in the JSON string but got `%s`", jsonObj.get("nodes").toString())); - } - - // validate the optional field `nodes` (array) - for (int i = 0; i < jsonArraynodes.size(); i++) { - ProcessNode.validateJsonElement(jsonArraynodes.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("nodes") != null && !jsonObj.get("nodes").isJsonNull() && !jsonObj.get("nodes").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `nodes` to be an array in the JSON string but got `%s`", jsonObj.get("nodes").toString())); } } @@ -224,6 +252,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessTree value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -231,7 +281,28 @@ public void write(JsonWriter out, ProcessTree value) throws IOException { public ProcessTree read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProcessTree instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProductOutput.java b/src/main/java/ai/reveng/model/ProductOutput.java index ec3e8b8d..f17c3389 100644 --- a/src/main/java/ai/reveng/model/ProductOutput.java +++ b/src/main/java/ai/reveng/model/ProductOutput.java @@ -262,6 +262,50 @@ public void setTier(@javax.annotation.Nullable String tier) { this.tier = tier; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProductOutput instance itself + */ + public ProductOutput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -280,12 +324,13 @@ public boolean equals(Object o) { Objects.equals(this.name, productOutput.name) && Objects.equals(this.prices, productOutput.prices) && Objects.equals(this.salesOnly, productOutput.salesOnly) && - Objects.equals(this.tier, productOutput.tier); + Objects.equals(this.tier, productOutput.tier)&& + Objects.equals(this.additionalProperties, productOutput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(creditsPerMonth, description, features, id, name, prices, salesOnly, tier); + return Objects.hash(creditsPerMonth, description, features, id, name, prices, salesOnly, tier, additionalProperties); } @Override @@ -300,6 +345,7 @@ public String toString() { sb.append(" prices: ").append(toIndentedString(prices)).append("\n"); sb.append(" salesOnly: ").append(toIndentedString(salesOnly)).append("\n"); sb.append(" tier: ").append(toIndentedString(tier)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -337,14 +383,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProductOutput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProductOutput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProductOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -367,15 +405,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - if (jsonObj.get("prices") != null && !jsonObj.get("prices").isJsonNull()) { - if (!jsonObj.get("prices").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `prices` to be an array in the JSON string but got `%s`", jsonObj.get("prices").toString())); - } - JsonArray jsonArrayprices = jsonObj.getAsJsonArray("prices"); - // validate the required field `prices` (array) - for (int i = 0; i < jsonArrayprices.size(); i++) { - PriceOutput.validateJsonElement(jsonArrayprices.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("prices") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("prices").isJsonArray() && !jsonObj.get("prices").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `prices` to be an array in the JSON string but got `%s`", jsonObj.get("prices").toString())); } if ((jsonObj.get("tier") != null && !jsonObj.get("tier").isJsonNull()) && !jsonObj.get("tier").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tier` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tier").toString())); @@ -397,6 +431,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProductOutput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -404,7 +460,28 @@ public void write(JsonWriter out, ProductOutput value) throws IOException { public ProductOutput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProductOutput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProductSummary.java b/src/main/java/ai/reveng/model/ProductSummary.java index cdd6fb96..72378f97 100644 --- a/src/main/java/ai/reveng/model/ProductSummary.java +++ b/src/main/java/ai/reveng/model/ProductSummary.java @@ -75,6 +75,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProductSummary instance itself + */ + public ProductSummary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } ProductSummary productSummary = (ProductSummary) o; - return Objects.equals(this.name, productSummary.name); + return Objects.equals(this.name, productSummary.name)&& + Objects.equals(this.additionalProperties, productSummary.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ProductSummary {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProductSummary.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProductSummary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProductSummary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -171,6 +209,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProductSummary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -178,7 +238,28 @@ public void write(JsonWriter out, ProductSummary value) throws IOException { public ProductSummary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProductSummary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProgressMessage.java b/src/main/java/ai/reveng/model/ProgressMessage.java index ce0ee39e..576ed2af 100644 --- a/src/main/java/ai/reveng/model/ProgressMessage.java +++ b/src/main/java/ai/reveng/model/ProgressMessage.java @@ -204,6 +204,50 @@ public void setTimestamp(@javax.annotation.Nonnull OffsetDateTime timestamp) { this.timestamp = timestamp; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProgressMessage instance itself + */ + public ProgressMessage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -218,12 +262,13 @@ public boolean equals(Object o) { return Objects.equals(this.level, progressMessage.level) && Objects.equals(this.step, progressMessage.step) && Objects.equals(this.text, progressMessage.text) && - Objects.equals(this.timestamp, progressMessage.timestamp); + Objects.equals(this.timestamp, progressMessage.timestamp)&& + Objects.equals(this.additionalProperties, progressMessage.additionalProperties); } @Override public int hashCode() { - return Objects.hash(level, step, text, timestamp); + return Objects.hash(level, step, text, timestamp, additionalProperties); } @Override @@ -234,6 +279,7 @@ public String toString() { sb.append(" step: ").append(toIndentedString(step)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -271,14 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProgressMessage.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProgressMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProgressMessage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -314,6 +352,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProgressMessage value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -321,7 +381,28 @@ public void write(JsonWriter out, ProgressMessage value) throws IOException { public ProgressMessage read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProgressMessage instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProseEvent.java b/src/main/java/ai/reveng/model/ProseEvent.java index b0a57aa2..4f248d90 100644 --- a/src/main/java/ai/reveng/model/ProseEvent.java +++ b/src/main/java/ai/reveng/model/ProseEvent.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProseEvent instance itself + */ + public ProseEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.attempt, proseEvent.attempt) && Objects.equals(this.seq, proseEvent.seq) && Objects.equals(this.text, proseEvent.text) && - Objects.equals(this.type, proseEvent.type); + Objects.equals(this.type, proseEvent.type)&& + Objects.equals(this.additionalProperties, proseEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(attempt, seq, text, type); + return Objects.hash(attempt, seq, text, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProseEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProseEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProseEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProseEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, ProseEvent value) throws IOException { public ProseEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProseEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProtocolsAgentResponse.java b/src/main/java/ai/reveng/model/ProtocolsAgentResponse.java new file mode 100644 index 00000000..fd21a402 --- /dev/null +++ b/src/main/java/ai/reveng/model/ProtocolsAgentResponse.java @@ -0,0 +1,321 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Finding; +import ai.reveng.model.Meta; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Full protocols report, including metadata, findings, and evidence. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ProtocolsAgentResponse { + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + @javax.annotation.Nullable + private Meta meta; + + public static final String SERIALIZED_NAME_FINDINGS = "findings"; + @SerializedName(SERIALIZED_NAME_FINDINGS) + @javax.annotation.Nullable + private List findings = new ArrayList<>(); + + public ProtocolsAgentResponse() { + } + + public ProtocolsAgentResponse meta(@javax.annotation.Nullable Meta meta) { + this.meta = meta; + return this; + } + + /** + * Get meta + * @return meta + */ + @javax.annotation.Nullable + public Meta getMeta() { + return meta; + } + + public void setMeta(@javax.annotation.Nullable Meta meta) { + this.meta = meta; + } + + + public ProtocolsAgentResponse findings(@javax.annotation.Nullable List findings) { + this.findings = findings; + return this; + } + + public ProtocolsAgentResponse addFindingsItem(Finding findingsItem) { + if (this.findings == null) { + this.findings = new ArrayList<>(); + } + this.findings.add(findingsItem); + return this; + } + + /** + * Get findings + * @return findings + */ + @javax.annotation.Nullable + public List getFindings() { + return findings; + } + + public void setFindings(@javax.annotation.Nullable List findings) { + this.findings = findings; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ProtocolsAgentResponse instance itself + */ + public ProtocolsAgentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ProtocolsAgentResponse protocolsAgentResponse = (ProtocolsAgentResponse) o; + return Objects.equals(this.meta, protocolsAgentResponse.meta) && + Objects.equals(this.findings, protocolsAgentResponse.findings)&& + Objects.equals(this.additionalProperties, protocolsAgentResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(meta, findings, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ProtocolsAgentResponse {\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" findings: ").append(toIndentedString(findings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("meta", "findings")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ProtocolsAgentResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ProtocolsAgentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProtocolsAgentResponse is not found in the empty JSON string", ProtocolsAgentResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("findings") != null && !jsonObj.get("findings").isJsonNull() && !jsonObj.get("findings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `findings` to be an array in the JSON string but got `%s`", jsonObj.get("findings").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ProtocolsAgentResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ProtocolsAgentResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ProtocolsAgentResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ProtocolsAgentResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ProtocolsAgentResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ProtocolsAgentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ProtocolsAgentResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ProtocolsAgentResponse + * @throws IOException if the JSON string is invalid with respect to ProtocolsAgentResponse + */ + public static ProtocolsAgentResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ProtocolsAgentResponse.class); + } + + /** + * Convert an instance of ProtocolsAgentResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ReferencedConstant.java b/src/main/java/ai/reveng/model/ReferencedConstant.java new file mode 100644 index 00000000..6362c69f --- /dev/null +++ b/src/main/java/ai/reveng/model/ReferencedConstant.java @@ -0,0 +1,359 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.BytesConstant; +import ai.reveng.model.Display; +import ai.reveng.model.Subject; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ReferencedConstant + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ReferencedConstant { + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + @javax.annotation.Nonnull + private Subject subject; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + @javax.annotation.Nonnull + private BytesConstant value; + + public static final String SERIALIZED_NAME_DISPLAY = "display"; + @SerializedName(SERIALIZED_NAME_DISPLAY) + @javax.annotation.Nullable + private Display display; + + public ReferencedConstant() { + } + + public ReferencedConstant subject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + return this; + } + + /** + * Get subject + * @return subject + */ + @javax.annotation.Nonnull + public Subject getSubject() { + return subject; + } + + public void setSubject(@javax.annotation.Nonnull Subject subject) { + this.subject = subject; + } + + + public ReferencedConstant value(@javax.annotation.Nonnull BytesConstant value) { + this.value = value; + return this; + } + + /** + * Get value + * @return value + */ + @javax.annotation.Nonnull + public BytesConstant getValue() { + return value; + } + + public void setValue(@javax.annotation.Nonnull BytesConstant value) { + this.value = value; + } + + + public ReferencedConstant display(@javax.annotation.Nullable Display display) { + this.display = display; + return this; + } + + /** + * Get display + * @return display + */ + @javax.annotation.Nullable + public Display getDisplay() { + return display; + } + + public void setDisplay(@javax.annotation.Nullable Display display) { + this.display = display; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReferencedConstant instance itself + */ + public ReferencedConstant putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReferencedConstant referencedConstant = (ReferencedConstant) o; + return Objects.equals(this.subject, referencedConstant.subject) && + Objects.equals(this.value, referencedConstant.value) && + Objects.equals(this.display, referencedConstant.display)&& + Objects.equals(this.additionalProperties, referencedConstant.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(subject, value, display, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReferencedConstant {\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" display: ").append(toIndentedString(display)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("subject", "value", "display")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("subject", "value")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ReferencedConstant + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ReferencedConstant.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReferencedConstant is not found in the empty JSON string", ReferencedConstant.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ReferencedConstant.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `subject` + Subject.validateJsonElement(jsonObj.get("subject")); + // validate the optional field `display` + if (jsonObj.get("display") != null && !jsonObj.get("display").isJsonNull()) { + Display.validateJsonElement(jsonObj.get("display")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ReferencedConstant.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ReferencedConstant' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ReferencedConstant.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ReferencedConstant value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ReferencedConstant read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReferencedConstant instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ReferencedConstant given an JSON string + * + * @param jsonString JSON string + * @return An instance of ReferencedConstant + * @throws IOException if the JSON string is invalid with respect to ReferencedConstant + */ + public static ReferencedConstant fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ReferencedConstant.class); + } + + /** + * Convert an instance of ReferencedConstant to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ReferencedConstantEvidence.java b/src/main/java/ai/reveng/model/ReferencedConstantEvidence.java new file mode 100644 index 00000000..f2eda9bb --- /dev/null +++ b/src/main/java/ai/reveng/model/ReferencedConstantEvidence.java @@ -0,0 +1,591 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceEffect; +import ai.reveng.model.ReferencedConstant; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Constants and the instructions that reference them. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ReferencedConstantEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + REFERENCED_CONSTANT("referenced_constant"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.REFERENCED_CONSTANT; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + DIRECT("direct"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.DIRECT; + + public static final String SERIALIZED_NAME_CONSTANTS = "constants"; + @SerializedName(SERIALIZED_NAME_CONSTANTS) + @javax.annotation.Nonnull + private List constants = new ArrayList<>(); + + public ReferencedConstantEvidence() { + } + + public ReferencedConstantEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public ReferencedConstantEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public ReferencedConstantEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public ReferencedConstantEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public ReferencedConstantEvidence constants(@javax.annotation.Nonnull List constants) { + this.constants = constants; + return this; + } + + public ReferencedConstantEvidence addConstantsItem(ReferencedConstant constantsItem) { + if (this.constants == null) { + this.constants = new ArrayList<>(); + } + this.constants.add(constantsItem); + return this; + } + + /** + * Get constants + * @return constants + */ + @javax.annotation.Nonnull + public List getConstants() { + return constants; + } + + public void setConstants(@javax.annotation.Nonnull List constants) { + this.constants = constants; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReferencedConstantEvidence instance itself + */ + public ReferencedConstantEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReferencedConstantEvidence referencedConstantEvidence = (ReferencedConstantEvidence) o; + return Objects.equals(this.evidenceKind, referencedConstantEvidence.evidenceKind) && + Objects.equals(this.kind, referencedConstantEvidence.kind) && + Objects.equals(this.effect, referencedConstantEvidence.effect) && + Objects.equals(this.strength, referencedConstantEvidence.strength) && + Objects.equals(this.constants, referencedConstantEvidence.constants)&& + Objects.equals(this.additionalProperties, referencedConstantEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, constants, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReferencedConstantEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" constants: ").append(toIndentedString(constants)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "constants")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "constants")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ReferencedConstantEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ReferencedConstantEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReferencedConstantEvidence is not found in the empty JSON string", ReferencedConstantEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ReferencedConstantEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + if (jsonObj.get("constants") != null) { + if (!jsonObj.get("constants").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `constants` to be an array in the JSON string but got `%s`", jsonObj.get("constants").toString())); + } + JsonArray jsonArrayconstants = jsonObj.getAsJsonArray("constants"); + // validate the required field `constants` (array) + for (int i = 0; i < jsonArrayconstants.size(); i++) { + ReferencedConstant.validateJsonElement(jsonArrayconstants.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ReferencedConstantEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ReferencedConstantEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ReferencedConstantEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ReferencedConstantEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ReferencedConstantEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReferencedConstantEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ReferencedConstantEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of ReferencedConstantEvidence + * @throws IOException if the JSON string is invalid with respect to ReferencedConstantEvidence + */ + public static ReferencedConstantEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ReferencedConstantEvidence.class); + } + + /** + * Convert an instance of ReferencedConstantEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/RegenerateOutputBody.java b/src/main/java/ai/reveng/model/RegenerateOutputBody.java index 3299d351..a151927c 100644 --- a/src/main/java/ai/reveng/model/RegenerateOutputBody.java +++ b/src/main/java/ai/reveng/model/RegenerateOutputBody.java @@ -75,6 +75,50 @@ public void setStatus(@javax.annotation.Nonnull Boolean status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RegenerateOutputBody instance itself + */ + public RegenerateOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } RegenerateOutputBody regenerateOutputBody = (RegenerateOutputBody) o; - return Objects.equals(this.status, regenerateOutputBody.status); + return Objects.equals(this.status, regenerateOutputBody.status)&& + Objects.equals(this.additionalProperties, regenerateOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RegenerateOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RegenerateOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RegenerateOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RegenerateOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -168,6 +206,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RegenerateOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -175,7 +235,28 @@ public void write(JsonWriter out, RegenerateOutputBody value) throws IOException public RegenerateOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RegenerateOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RegistryOperation.java b/src/main/java/ai/reveng/model/RegistryOperation.java index 7af6ebe8..a91de492 100644 --- a/src/main/java/ai/reveng/model/RegistryOperation.java +++ b/src/main/java/ai/reveng/model/RegistryOperation.java @@ -111,6 +111,50 @@ public void setKey(@javax.annotation.Nonnull String key) { this.key = key; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RegistryOperation instance itself + */ + public RegistryOperation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,7 +167,8 @@ public boolean equals(Object o) { } RegistryOperation registryOperation = (RegistryOperation) o; return Objects.equals(this.events, registryOperation.events) && - Objects.equals(this.key, registryOperation.key); + Objects.equals(this.key, registryOperation.key)&& + Objects.equals(this.additionalProperties, registryOperation.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -132,7 +177,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, key); + return Objects.hash(events, key, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -148,6 +193,7 @@ public String toString() { sb.append("class RegistryOperation {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -185,14 +231,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RegistryOperation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RegistryOperation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RegistryOperation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -200,19 +238,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if (!jsonObj.get("key").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); @@ -234,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RegistryOperation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +291,28 @@ public void write(JsonWriter out, RegistryOperation value) throws IOException { public RegistryOperation read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RegistryOperation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RelatedBinary.java b/src/main/java/ai/reveng/model/RelatedBinary.java new file mode 100644 index 00000000..7b3c89b0 --- /dev/null +++ b/src/main/java/ai/reveng/model/RelatedBinary.java @@ -0,0 +1,370 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * RelatedBinary + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RelatedBinary { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nullable + private Long analysisId; + + public static final String SERIALIZED_NAME_BINARY_ID = "binary_id"; + @SerializedName(SERIALIZED_NAME_BINARY_ID) + @javax.annotation.Nonnull + private Long binaryId; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_SHA256 = "sha256"; + @SerializedName(SERIALIZED_NAME_SHA256) + @javax.annotation.Nonnull + private String sha256; + + public RelatedBinary() { + } + + public RelatedBinary analysisId(@javax.annotation.Nullable Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Most recent analysis of the related binary, null when it has never been analysed + * @return analysisId + */ + @javax.annotation.Nullable + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nullable Long analysisId) { + this.analysisId = analysisId; + } + + + public RelatedBinary binaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + return this; + } + + /** + * ID of the related binary + * @return binaryId + */ + @javax.annotation.Nonnull + public Long getBinaryId() { + return binaryId; + } + + public void setBinaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + } + + + public RelatedBinary name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Name of the related binary + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public RelatedBinary sha256(@javax.annotation.Nonnull String sha256) { + this.sha256 = sha256; + return this; + } + + /** + * SHA-256 of the related binary + * @return sha256 + */ + @javax.annotation.Nonnull + public String getSha256() { + return sha256; + } + + public void setSha256(@javax.annotation.Nonnull String sha256) { + this.sha256 = sha256; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RelatedBinary instance itself + */ + public RelatedBinary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RelatedBinary relatedBinary = (RelatedBinary) o; + return Objects.equals(this.analysisId, relatedBinary.analysisId) && + Objects.equals(this.binaryId, relatedBinary.binaryId) && + Objects.equals(this.name, relatedBinary.name) && + Objects.equals(this.sha256, relatedBinary.sha256)&& + Objects.equals(this.additionalProperties, relatedBinary.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, binaryId, name, sha256, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RelatedBinary {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "binary_id", "name", "sha256")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "binary_id", "name", "sha256")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RelatedBinary + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RelatedBinary.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RelatedBinary is not found in the empty JSON string", RelatedBinary.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RelatedBinary.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("sha256").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RelatedBinary.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RelatedBinary' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RelatedBinary.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RelatedBinary value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RelatedBinary read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RelatedBinary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RelatedBinary given an JSON string + * + * @param jsonString JSON string + * @return An instance of RelatedBinary + * @throws IOException if the JSON string is invalid with respect to RelatedBinary + */ + public static RelatedBinary fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RelatedBinary.class); + } + + /** + * Convert an instance of RelatedBinary to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/RemediationResult.java b/src/main/java/ai/reveng/model/RemediationResult.java new file mode 100644 index 00000000..bb6fc8a9 --- /dev/null +++ b/src/main/java/ai/reveng/model/RemediationResult.java @@ -0,0 +1,382 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * RemediationResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RemediationResult { + public static final String SERIALIZED_NAME_SNORT_RULES = "snort_rules"; + @SerializedName(SERIALIZED_NAME_SNORT_RULES) + @javax.annotation.Nullable + private List snortRules; + + public static final String SERIALIZED_NAME_STIX_RULES = "stix_rules"; + @SerializedName(SERIALIZED_NAME_STIX_RULES) + @javax.annotation.Nullable + private List stixRules; + + public static final String SERIALIZED_NAME_YARA_RULES = "yara_rules"; + @SerializedName(SERIALIZED_NAME_YARA_RULES) + @javax.annotation.Nullable + private List yaraRules; + + public RemediationResult() { + } + + public RemediationResult snortRules(@javax.annotation.Nullable List snortRules) { + this.snortRules = snortRules; + return this; + } + + public RemediationResult addSnortRulesItem(String snortRulesItem) { + if (this.snortRules == null) { + this.snortRules = new ArrayList<>(); + } + this.snortRules.add(snortRulesItem); + return this; + } + + /** + * Generated Snort rules + * @return snortRules + */ + @javax.annotation.Nullable + public List getSnortRules() { + return snortRules; + } + + public void setSnortRules(@javax.annotation.Nullable List snortRules) { + this.snortRules = snortRules; + } + + + public RemediationResult stixRules(@javax.annotation.Nullable List stixRules) { + this.stixRules = stixRules; + return this; + } + + public RemediationResult addStixRulesItem(String stixRulesItem) { + if (this.stixRules == null) { + this.stixRules = new ArrayList<>(); + } + this.stixRules.add(stixRulesItem); + return this; + } + + /** + * Generated STIX rules + * @return stixRules + */ + @javax.annotation.Nullable + public List getStixRules() { + return stixRules; + } + + public void setStixRules(@javax.annotation.Nullable List stixRules) { + this.stixRules = stixRules; + } + + + public RemediationResult yaraRules(@javax.annotation.Nullable List yaraRules) { + this.yaraRules = yaraRules; + return this; + } + + public RemediationResult addYaraRulesItem(String yaraRulesItem) { + if (this.yaraRules == null) { + this.yaraRules = new ArrayList<>(); + } + this.yaraRules.add(yaraRulesItem); + return this; + } + + /** + * Generated YARA rules + * @return yaraRules + */ + @javax.annotation.Nullable + public List getYaraRules() { + return yaraRules; + } + + public void setYaraRules(@javax.annotation.Nullable List yaraRules) { + this.yaraRules = yaraRules; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RemediationResult instance itself + */ + public RemediationResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RemediationResult remediationResult = (RemediationResult) o; + return Objects.equals(this.snortRules, remediationResult.snortRules) && + Objects.equals(this.stixRules, remediationResult.stixRules) && + Objects.equals(this.yaraRules, remediationResult.yaraRules)&& + Objects.equals(this.additionalProperties, remediationResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(snortRules, stixRules, yaraRules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RemediationResult {\n"); + sb.append(" snortRules: ").append(toIndentedString(snortRules)).append("\n"); + sb.append(" stixRules: ").append(toIndentedString(stixRules)).append("\n"); + sb.append(" yaraRules: ").append(toIndentedString(yaraRules)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("snort_rules", "stix_rules", "yara_rules")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("snort_rules", "stix_rules", "yara_rules")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RemediationResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RemediationResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RemediationResult is not found in the empty JSON string", RemediationResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RemediationResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("snort_rules") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("snort_rules").isJsonArray() && !jsonObj.get("snort_rules").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `snort_rules` to be an array in the JSON string but got `%s`", jsonObj.get("snort_rules").toString())); + } + // ensure the required json array is present + if (jsonObj.get("stix_rules") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("stix_rules").isJsonArray() && !jsonObj.get("stix_rules").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `stix_rules` to be an array in the JSON string but got `%s`", jsonObj.get("stix_rules").toString())); + } + // ensure the required json array is present + if (jsonObj.get("yara_rules") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("yara_rules").isJsonArray() && !jsonObj.get("yara_rules").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `yara_rules` to be an array in the JSON string but got `%s`", jsonObj.get("yara_rules").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RemediationResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RemediationResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RemediationResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RemediationResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RemediationResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RemediationResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RemediationResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of RemediationResult + * @throws IOException if the JSON string is invalid with respect to RemediationResult + */ + public static RemediationResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RemediationResult.class); + } + + /** + * Convert an instance of RemediationResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/RemoveCollectionBinariesInputBody.java b/src/main/java/ai/reveng/model/RemoveCollectionBinariesInputBody.java index c79737c3..51e19d94 100644 --- a/src/main/java/ai/reveng/model/RemoveCollectionBinariesInputBody.java +++ b/src/main/java/ai/reveng/model/RemoveCollectionBinariesInputBody.java @@ -85,6 +85,50 @@ public void setBinaries(@javax.annotation.Nullable List binaries) { this.binaries = binaries; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RemoveCollectionBinariesInputBody instance itself + */ + public RemoveCollectionBinariesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -96,12 +140,13 @@ public boolean equals(Object o) { return false; } RemoveCollectionBinariesInputBody removeCollectionBinariesInputBody = (RemoveCollectionBinariesInputBody) o; - return Objects.equals(this.binaries, removeCollectionBinariesInputBody.binaries); + return Objects.equals(this.binaries, removeCollectionBinariesInputBody.binaries)&& + Objects.equals(this.additionalProperties, removeCollectionBinariesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaries); + return Objects.hash(binaries, additionalProperties); } @Override @@ -109,6 +154,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RemoveCollectionBinariesInputBody {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RemoveCollectionBinariesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RemoveCollectionBinariesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RemoveCollectionBinariesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -184,6 +222,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RemoveCollectionBinariesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -191,7 +251,28 @@ public void write(JsonWriter out, RemoveCollectionBinariesInputBody value) throw public RemoveCollectionBinariesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RemoveCollectionBinariesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RenameAppliedEvent.java b/src/main/java/ai/reveng/model/RenameAppliedEvent.java index bfc56487..12d697f9 100644 --- a/src/main/java/ai/reveng/model/RenameAppliedEvent.java +++ b/src/main/java/ai/reveng/model/RenameAppliedEvent.java @@ -195,6 +195,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RenameAppliedEvent instance itself + */ + public RenameAppliedEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -211,12 +255,13 @@ public boolean equals(Object o) { Objects.equals(this.newName, renameAppliedEvent.newName) && Objects.equals(this.oldName, renameAppliedEvent.oldName) && Objects.equals(this.seq, renameAppliedEvent.seq) && - Objects.equals(this.type, renameAppliedEvent.type); + Objects.equals(this.type, renameAppliedEvent.type)&& + Objects.equals(this.additionalProperties, renameAppliedEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(addrHex, attempt, newName, oldName, seq, type); + return Objects.hash(addrHex, attempt, newName, oldName, seq, type, additionalProperties); } @Override @@ -229,6 +274,7 @@ public String toString() { sb.append(" oldName: ").append(toIndentedString(oldName)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -266,14 +312,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RenameAppliedEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenameAppliedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenameAppliedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenameAppliedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, RenameAppliedEvent value) throws IOException { public RenameAppliedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RenameAppliedEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RenameInputBody.java b/src/main/java/ai/reveng/model/RenameInputBody.java index 228fb626..c227e75d 100644 --- a/src/main/java/ai/reveng/model/RenameInputBody.java +++ b/src/main/java/ai/reveng/model/RenameInputBody.java @@ -59,10 +59,72 @@ public class RenameInputBody { @javax.annotation.Nonnull private String newName; - public static final String SERIALIZED_NAME_PRESERVE_AI_DECOMPILATION = "preserve_ai_decompilation"; - @SerializedName(SERIALIZED_NAME_PRESERVE_AI_DECOMPILATION) + /** + * Source that triggered the rename + */ + @JsonAdapter(SourceTypeEnum.Adapter.class) + public enum SourceTypeEnum { + SYSTEM("SYSTEM"), + + USER("USER"), + + EXTERNAL("EXTERNAL"), + + AUTO_UNSTRIP("AUTO_UNSTRIP"), + + AI_UNSTRIP("AI_UNSTRIP"), + + AI_AGENT("AI_AGENT"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourceTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceTypeEnum fromValue(String value) { + for (SourceTypeEnum b : SourceTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceTypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceTypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceTypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourceTypeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCE_TYPE = "source_type"; + @SerializedName(SERIALIZED_NAME_SOURCE_TYPE) @javax.annotation.Nullable - private Boolean preserveAiDecompilation; + private SourceTypeEnum sourceType; public RenameInputBody() { } @@ -105,24 +167,68 @@ public void setNewName(@javax.annotation.Nonnull String newName) { } - public RenameInputBody preserveAiDecompilation(@javax.annotation.Nullable Boolean preserveAiDecompilation) { - this.preserveAiDecompilation = preserveAiDecompilation; + public RenameInputBody sourceType(@javax.annotation.Nullable SourceTypeEnum sourceType) { + this.sourceType = sourceType; return this; } /** - * Keep the cached AI decompilation, summary and inline comments. Set when the new name comes from the model's own prediction (e.g. Transfer Name) so existing AI output is not discarded and regenerated. - * @return preserveAiDecompilation + * Source that triggered the rename + * @return sourceType */ @javax.annotation.Nullable - public Boolean getPreserveAiDecompilation() { - return preserveAiDecompilation; + public SourceTypeEnum getSourceType() { + return sourceType; + } + + public void setSourceType(@javax.annotation.Nullable SourceTypeEnum sourceType) { + this.sourceType = sourceType; } - public void setPreserveAiDecompilation(@javax.annotation.Nullable Boolean preserveAiDecompilation) { - this.preserveAiDecompilation = preserveAiDecompilation; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RenameInputBody instance itself + */ + public RenameInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; } + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -136,12 +242,13 @@ public boolean equals(Object o) { RenameInputBody renameInputBody = (RenameInputBody) o; return Objects.equals(this.newMangledName, renameInputBody.newMangledName) && Objects.equals(this.newName, renameInputBody.newName) && - Objects.equals(this.preserveAiDecompilation, renameInputBody.preserveAiDecompilation); + Objects.equals(this.sourceType, renameInputBody.sourceType)&& + Objects.equals(this.additionalProperties, renameInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(newMangledName, newName, preserveAiDecompilation); + return Objects.hash(newMangledName, newName, sourceType, additionalProperties); } @Override @@ -150,7 +257,8 @@ public String toString() { sb.append("class RenameInputBody {\n"); sb.append(" newMangledName: ").append(toIndentedString(newMangledName)).append("\n"); sb.append(" newName: ").append(toIndentedString(newName)).append("\n"); - sb.append(" preserveAiDecompilation: ").append(toIndentedString(preserveAiDecompilation)).append("\n"); + sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -169,7 +277,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("new_mangled_name", "new_name", "preserve_ai_decompilation")); + openapiFields = new HashSet(Arrays.asList("new_mangled_name", "new_name", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("new_name")); @@ -188,14 +296,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RenameInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenameInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenameInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -209,6 +309,13 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("new_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); } + if ((jsonObj.get("source_type") != null && !jsonObj.get("source_type").isJsonNull()) && !jsonObj.get("source_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_type").toString())); + } + // validate the optional field `source_type` + if (jsonObj.get("source_type") != null && !jsonObj.get("source_type").isJsonNull()) { + SourceTypeEnum.validateJsonElement(jsonObj.get("source_type")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -226,6 +333,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenameInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -233,7 +362,28 @@ public void write(JsonWriter out, RenameInputBody value) throws IOException { public RenameInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RenameInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RenameOutputBody.java b/src/main/java/ai/reveng/model/RenameOutputBody.java index 5eae25ca..2da0923e 100644 --- a/src/main/java/ai/reveng/model/RenameOutputBody.java +++ b/src/main/java/ai/reveng/model/RenameOutputBody.java @@ -75,6 +75,50 @@ public void setRenamedCount(@javax.annotation.Nonnull Long renamedCount) { this.renamedCount = renamedCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RenameOutputBody instance itself + */ + public RenameOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } RenameOutputBody renameOutputBody = (RenameOutputBody) o; - return Objects.equals(this.renamedCount, renameOutputBody.renamedCount); + return Objects.equals(this.renamedCount, renameOutputBody.renamedCount)&& + Objects.equals(this.additionalProperties, renameOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(renamedCount); + return Objects.hash(renamedCount, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RenameOutputBody {\n"); sb.append(" renamedCount: ").append(toIndentedString(renamedCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RenameOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenameOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenameOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -168,6 +206,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenameOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -175,7 +235,28 @@ public void write(JsonWriter out, RenameOutputBody value) throws IOException { public RenameOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RenameOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RenameUnnamedFunctionsResult.java b/src/main/java/ai/reveng/model/RenameUnnamedFunctionsResult.java index 872e8329..7e35c1b3 100644 --- a/src/main/java/ai/reveng/model/RenameUnnamedFunctionsResult.java +++ b/src/main/java/ai/reveng/model/RenameUnnamedFunctionsResult.java @@ -171,6 +171,50 @@ public void setTotal(@javax.annotation.Nonnull Long total) { this.total = total; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RenameUnnamedFunctionsResult instance itself + */ + public RenameUnnamedFunctionsResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -186,12 +230,13 @@ public boolean equals(Object o) { Objects.equals(this.failed, renameUnnamedFunctionsResult.failed) && Objects.equals(this.renamed, renameUnnamedFunctionsResult.renamed) && Objects.equals(this.skipped, renameUnnamedFunctionsResult.skipped) && - Objects.equals(this.total, renameUnnamedFunctionsResult.total); + Objects.equals(this.total, renameUnnamedFunctionsResult.total)&& + Objects.equals(this.additionalProperties, renameUnnamedFunctionsResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, failed, renamed, skipped, total); + return Objects.hash(analysisId, failed, renamed, skipped, total, additionalProperties); } @Override @@ -203,6 +248,7 @@ public String toString() { sb.append(" renamed: ").append(toIndentedString(renamed)).append("\n"); sb.append(" skipped: ").append(toIndentedString(skipped)).append("\n"); sb.append(" total: ").append(toIndentedString(total)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -240,14 +286,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RenameUnnamedFunctionsResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenameUnnamedFunctionsResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenameUnnamedFunctionsResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -272,6 +310,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenameUnnamedFunctionsResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -279,7 +339,28 @@ public void write(JsonWriter out, RenameUnnamedFunctionsResult value) throws IOE public RenameUnnamedFunctionsResult read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RenameUnnamedFunctionsResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RenderedToken.java b/src/main/java/ai/reveng/model/RenderedToken.java index f8a46dd3..0ea9495a 100644 --- a/src/main/java/ai/reveng/model/RenderedToken.java +++ b/src/main/java/ai/reveng/model/RenderedToken.java @@ -269,6 +269,50 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RenderedToken instance itself + */ + public RenderedToken putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -285,12 +329,13 @@ public boolean equals(Object o) { Objects.equals(this.importedFunctionId, renderedToken.importedFunctionId) && Objects.equals(this.kind, renderedToken.kind) && Objects.equals(this.vaddr, renderedToken.vaddr) && - Objects.equals(this.value, renderedToken.value); + Objects.equals(this.value, renderedToken.value)&& + Objects.equals(this.additionalProperties, renderedToken.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, functionId, importedFunctionId, kind, vaddr, value); + return Objects.hash(dataTypeId, functionId, importedFunctionId, kind, vaddr, value, additionalProperties); } @Override @@ -303,6 +348,7 @@ public String toString() { sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); sb.append(" vaddr: ").append(toIndentedString(vaddr)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -340,14 +386,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RenderedToken.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenderedToken` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenderedToken.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -380,6 +418,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenderedToken value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -387,7 +447,28 @@ public void write(JsonWriter out, RenderedToken value) throws IOException { public RenderedToken read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RenderedToken instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReportAnalysisResponse.java b/src/main/java/ai/reveng/model/ReportAnalysisResponse.java index 5722c0de..189dd602 100644 --- a/src/main/java/ai/reveng/model/ReportAnalysisResponse.java +++ b/src/main/java/ai/reveng/model/ReportAnalysisResponse.java @@ -462,15 +462,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("attack_flow_summary").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `attack_flow_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attack_flow_summary").toString())); } - if (jsonObj.get("IOCs") != null) { - if (!jsonObj.get("IOCs").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `IOCs` to be an array in the JSON string but got `%s`", jsonObj.get("IOCs").toString())); - } - JsonArray jsonArrayioCs = jsonObj.getAsJsonArray("IOCs"); - // validate the required field `IOCs` (array) - for (int i = 0; i < jsonArrayioCs.size(); i++) { - IOC.validateJsonElement(jsonArrayioCs.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("IOCs") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("IOCs").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `IOCs` to be an array in the JSON string but got `%s`", jsonObj.get("IOCs").toString())); } if (jsonObj.get("executable_techniques") != null) { if (!jsonObj.get("executable_techniques").isJsonArray()) { diff --git a/src/main/java/ai/reveng/model/ReportEvent.java b/src/main/java/ai/reveng/model/ReportEvent.java index 49738af9..e04baa76 100644 --- a/src/main/java/ai/reveng/model/ReportEvent.java +++ b/src/main/java/ai/reveng/model/ReportEvent.java @@ -263,6 +263,50 @@ public void setValueName(@javax.annotation.Nullable String valueName) { this.valueName = valueName; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReportEvent instance itself + */ + public ReportEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -281,7 +325,8 @@ public boolean equals(Object o) { Objects.equals(this.totalBytes, reportEvent.totalBytes) && Objects.equals(this.type, reportEvent.type) && Objects.equals(this.value, reportEvent.value) && - Objects.equals(this.valueName, reportEvent.valueName); + Objects.equals(this.valueName, reportEvent.valueName)&& + Objects.equals(this.additionalProperties, reportEvent.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -290,7 +335,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(apiCalls, count, desiredAccess, processSeqid, totalBytes, type, value, valueName); + return Objects.hash(apiCalls, count, desiredAccess, processSeqid, totalBytes, type, value, valueName, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -312,6 +357,7 @@ public String toString() { sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" valueName: ").append(toIndentedString(valueName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -349,14 +395,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReportEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReportEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReportEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -364,19 +402,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("api_calls") != null && !jsonObj.get("api_calls").isJsonNull()) { - JsonArray jsonArrayapiCalls = jsonObj.getAsJsonArray("api_calls"); - if (jsonArrayapiCalls != null) { - // ensure the json data is an array - if (!jsonObj.get("api_calls").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `api_calls` to be an array in the JSON string but got `%s`", jsonObj.get("api_calls").toString())); - } - - // validate the optional field `api_calls` (array) - for (int i = 0; i < jsonArrayapiCalls.size(); i++) { - ApiCall.validateJsonElement(jsonArrayapiCalls.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("api_calls") != null && !jsonObj.get("api_calls").isJsonNull() && !jsonObj.get("api_calls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `api_calls` to be an array in the JSON string but got `%s`", jsonObj.get("api_calls").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("desired_access") != null && !jsonObj.get("desired_access").isJsonNull() && !jsonObj.get("desired_access").isJsonArray()) { @@ -408,6 +436,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReportEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -415,7 +465,28 @@ public void write(JsonWriter out, ReportEvent value) throws IOException { public ReportEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReportEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReportInfo.java b/src/main/java/ai/reveng/model/ReportInfo.java index 7ae8efc4..c9d1eb21 100644 --- a/src/main/java/ai/reveng/model/ReportInfo.java +++ b/src/main/java/ai/reveng/model/ReportInfo.java @@ -245,6 +245,50 @@ public void setTimeStarted(@javax.annotation.Nullable String timeStarted) { this.timeStarted = timeStarted; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReportInfo instance itself + */ + public ReportInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -263,12 +307,13 @@ public boolean equals(Object o) { Objects.equals(this.status, reportInfo.status) && Objects.equals(this.timeAnalysisFinished, reportInfo.timeAnalysisFinished) && Objects.equals(this.timeExecutionStarted, reportInfo.timeExecutionStarted) && - Objects.equals(this.timeStarted, reportInfo.timeStarted); + Objects.equals(this.timeStarted, reportInfo.timeStarted)&& + Objects.equals(this.additionalProperties, reportInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(_file, id, options, osProfile, status, timeAnalysisFinished, timeExecutionStarted, timeStarted); + return Objects.hash(_file, id, options, osProfile, status, timeAnalysisFinished, timeExecutionStarted, timeStarted, additionalProperties); } @Override @@ -283,6 +328,7 @@ public String toString() { sb.append(" timeAnalysisFinished: ").append(toIndentedString(timeAnalysisFinished)).append("\n"); sb.append(" timeExecutionStarted: ").append(toIndentedString(timeExecutionStarted)).append("\n"); sb.append(" timeStarted: ").append(toIndentedString(timeStarted)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -320,14 +366,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReportInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReportInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReportInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -335,17 +373,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `file` - if (jsonObj.get("file") != null && !jsonObj.get("file").isJsonNull()) { - DrakvufFileMetadata.validateJsonElement(jsonObj.get("file")); - } if (!jsonObj.get("id").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); } - // validate the optional field `options` - if (jsonObj.get("options") != null && !jsonObj.get("options").isJsonNull()) { - ReportOptions.validateJsonElement(jsonObj.get("options")); - } if ((jsonObj.get("os_profile") != null && !jsonObj.get("os_profile").isJsonNull()) && !jsonObj.get("os_profile").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `os_profile` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os_profile").toString())); } @@ -378,6 +408,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReportInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -385,7 +437,28 @@ public void write(JsonWriter out, ReportInfo value) throws IOException { public ReportInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReportInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReportOptions.java b/src/main/java/ai/reveng/model/ReportOptions.java index 80e4dcaf..34b94a6c 100644 --- a/src/main/java/ai/reveng/model/ReportOptions.java +++ b/src/main/java/ai/reveng/model/ReportOptions.java @@ -350,6 +350,50 @@ public void setTimeout(@javax.annotation.Nullable Long timeout) { this.timeout = timeout; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReportOptions instance itself + */ + public ReportOptions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -372,7 +416,8 @@ public boolean equals(Object o) { Objects.equals(this.sampleFilename, reportOptions.sampleFilename) && Objects.equals(this.startCommand, reportOptions.startCommand) && Objects.equals(this.startMethod, reportOptions.startMethod) && - Objects.equals(this.timeout, reportOptions.timeout); + Objects.equals(this.timeout, reportOptions.timeout)&& + Objects.equals(this.additionalProperties, reportOptions.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -381,7 +426,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(archiveEntryPath, extractArchive, guestTargetDirectory, guestWorkingDirectory, netEnable, osProfile, plugins, preset, sampleFilename, startCommand, startMethod, timeout); + return Objects.hash(archiveEntryPath, extractArchive, guestTargetDirectory, guestWorkingDirectory, netEnable, osProfile, plugins, preset, sampleFilename, startCommand, startMethod, timeout, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -407,6 +452,7 @@ public String toString() { sb.append(" startCommand: ").append(toIndentedString(startCommand)).append("\n"); sb.append(" startMethod: ").append(toIndentedString(startMethod)).append("\n"); sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -443,14 +489,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReportOptions is not found in the empty JSON string", ReportOptions.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReportOptions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReportOptions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("archive_entry_path") != null && !jsonObj.get("archive_entry_path").isJsonNull()) && !jsonObj.get("archive_entry_path").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `archive_entry_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("archive_entry_path").toString())); @@ -497,6 +535,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReportOptions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -504,7 +564,28 @@ public void write(JsonWriter out, ReportOptions value) throws IOException { public ReportOptions read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReportOptions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReportReachabilityStatus.java b/src/main/java/ai/reveng/model/ReportReachabilityStatus.java new file mode 100644 index 00000000..d593b8a2 --- /dev/null +++ b/src/main/java/ai/reveng/model/ReportReachabilityStatus.java @@ -0,0 +1,81 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets ReportReachabilityStatus + */ +@JsonAdapter(ReportReachabilityStatus.Adapter.class) +public enum ReportReachabilityStatus { + + UNDETERMINED("undetermined"), + + REACHABLE("reachable"), + + UNREACHABLE("unreachable"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ReportReachabilityStatus(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ReportReachabilityStatus fromValue(String value) { + for (ReportReachabilityStatus b : ReportReachabilityStatus.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ReportReachabilityStatus enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ReportReachabilityStatus read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ReportReachabilityStatus.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ReportReachabilityStatus.fromValue(value); + } +} + diff --git a/src/main/java/ai/reveng/model/ReportResult.java b/src/main/java/ai/reveng/model/ReportResult.java new file mode 100644 index 00000000..cd427df5 --- /dev/null +++ b/src/main/java/ai/reveng/model/ReportResult.java @@ -0,0 +1,312 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ReportResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ReportResult { + public static final String SERIALIZED_NAME_FINDINGS = "findings"; + @SerializedName(SERIALIZED_NAME_FINDINGS) + @javax.annotation.Nullable + private Object findings = null; + + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + @javax.annotation.Nullable + private Object meta = null; + + public ReportResult() { + } + + public ReportResult findings(@javax.annotation.Nullable Object findings) { + this.findings = findings; + return this; + } + + /** + * Get findings + * @return findings + */ + @javax.annotation.Nullable + public Object getFindings() { + return findings; + } + + public void setFindings(@javax.annotation.Nullable Object findings) { + this.findings = findings; + } + + + public ReportResult meta(@javax.annotation.Nullable Object meta) { + this.meta = meta; + return this; + } + + /** + * Get meta + * @return meta + */ + @javax.annotation.Nullable + public Object getMeta() { + return meta; + } + + public void setMeta(@javax.annotation.Nullable Object meta) { + this.meta = meta; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReportResult instance itself + */ + public ReportResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportResult reportResult = (ReportResult) o; + return Objects.equals(this.findings, reportResult.findings) && + Objects.equals(this.meta, reportResult.meta)&& + Objects.equals(this.additionalProperties, reportResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(findings, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReportResult {\n"); + sb.append(" findings: ").append(toIndentedString(findings)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("findings", "meta")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("findings", "meta")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ReportResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ReportResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReportResult is not found in the empty JSON string", ReportResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ReportResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ReportResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ReportResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ReportResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ReportResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ReportResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReportResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ReportResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of ReportResult + * @throws IOException if the JSON string is invalid with respect to ReportResult + */ + public static ReportResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ReportResult.class); + } + + /** + * Convert an instance of ReportResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ResolvedEntity.java b/src/main/java/ai/reveng/model/ResolvedEntity.java index 0c407a0e..c3a46f88 100644 --- a/src/main/java/ai/reveng/model/ResolvedEntity.java +++ b/src/main/java/ai/reveng/model/ResolvedEntity.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -182,6 +183,8 @@ public enum NameSourceEnum { DEFAULT("default"), + SUGGESTED("suggested"), + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -247,6 +250,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private String resolvedName; + public static final String SERIALIZED_NAME_SUGGESTED_NAME = "suggested_name"; + @SerializedName(SERIALIZED_NAME_SUGGESTED_NAME) + @javax.annotation.Nullable + private String suggestedName; + public static final String SERIALIZED_NAME_SUGGESTED_TYPE = "suggested_type"; @SerializedName(SERIALIZED_NAME_SUGGESTED_TYPE) @javax.annotation.Nullable @@ -602,6 +610,25 @@ public void setResolvedName(@javax.annotation.Nullable String resolvedName) { } + public ResolvedEntity suggestedName(@javax.annotation.Nullable String suggestedName) { + this.suggestedName = suggestedName; + return this; + } + + /** + * Search is applied to string value + * @return suggestedName + */ + @javax.annotation.Nullable + public String getSuggestedName() { + return suggestedName; + } + + public void setSuggestedName(@javax.annotation.Nullable String suggestedName) { + this.suggestedName = suggestedName; + } + + public ResolvedEntity suggestedType(@javax.annotation.Nullable String suggestedType) { this.suggestedType = suggestedType; return this; @@ -824,6 +851,7 @@ public boolean equals(Object o) { Objects.equals(this.needsNaming, resolvedEntity.needsNaming) && Objects.equals(this.provenance, resolvedEntity.provenance) && Objects.equals(this.resolvedName, resolvedEntity.resolvedName) && + Objects.equals(this.suggestedName, resolvedEntity.suggestedName) && Objects.equals(this.suggestedType, resolvedEntity.suggestedType) && Objects.equals(this.suggestionConfidence, resolvedEntity.suggestionConfidence) && Objects.equals(this.token, resolvedEntity.token) && @@ -835,9 +863,20 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, resolvedEntity.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + @Override public int hashCode() { - return Objects.hash(addrToken, allAddrTokens, bitOffset, byteOffset, byteSize, count, dataTypeIndex, fieldStatus, functionId, importedFunctionId, kind, name, nameSource, needsNaming, provenance, resolvedName, suggestedType, suggestionConfidence, token, typeIndex, vaddr, value, valueConfidence, valueType, additionalProperties); + return Objects.hash(addrToken, allAddrTokens, bitOffset, byteOffset, byteSize, count, dataTypeIndex, fieldStatus, functionId, importedFunctionId, kind, name, nameSource, needsNaming, provenance, resolvedName, suggestedName, suggestedType, suggestionConfidence, token, typeIndex, vaddr, value, valueConfidence, valueType, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; } @Override @@ -860,6 +899,7 @@ public String toString() { sb.append(" needsNaming: ").append(toIndentedString(needsNaming)).append("\n"); sb.append(" provenance: ").append(toIndentedString(provenance)).append("\n"); sb.append(" resolvedName: ").append(toIndentedString(resolvedName)).append("\n"); + sb.append(" suggestedName: ").append(toIndentedString(suggestedName)).append("\n"); sb.append(" suggestedType: ").append(toIndentedString(suggestedType)).append("\n"); sb.append(" suggestionConfidence: ").append(toIndentedString(suggestionConfidence)).append("\n"); sb.append(" token: ").append(toIndentedString(token)).append("\n"); @@ -887,7 +927,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("addr_token", "all_addr_tokens", "bit_offset", "byte_offset", "byte_size", "count", "data_type_index", "field_status", "function_id", "imported_function_id", "kind", "name", "name_source", "needs_naming", "provenance", "resolved_name", "suggested_type", "suggestion_confidence", "token", "type_index", "vaddr", "value", "value_confidence", "value_type")); + openapiFields = new HashSet(Arrays.asList("addr_token", "all_addr_tokens", "bit_offset", "byte_offset", "byte_size", "count", "data_type_index", "field_status", "function_id", "imported_function_id", "kind", "name", "name_source", "needs_naming", "provenance", "resolved_name", "suggested_name", "suggested_type", "suggestion_confidence", "token", "type_index", "vaddr", "value", "value_confidence", "value_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("addr_token", "all_addr_tokens", "bit_offset", "byte_offset", "byte_size", "count", "data_type_index", "kind", "name", "name_source", "needs_naming", "provenance", "resolved_name", "suggested_type", "suggestion_confidence", "token", "type_index", "vaddr", "value", "value_confidence", "value_type")); @@ -946,6 +986,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("resolved_name") != null && !jsonObj.get("resolved_name").isJsonNull()) && !jsonObj.get("resolved_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `resolved_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("resolved_name").toString())); } + if ((jsonObj.get("suggested_name") != null && !jsonObj.get("suggested_name").isJsonNull()) && !jsonObj.get("suggested_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `suggested_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suggested_name").toString())); + } if ((jsonObj.get("suggested_type") != null && !jsonObj.get("suggested_type").isJsonNull()) && !jsonObj.get("suggested_type").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `suggested_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suggested_type").toString())); } diff --git a/src/main/java/ai/reveng/model/ResultBody.java b/src/main/java/ai/reveng/model/ResultBody.java new file mode 100644 index 00000000..d4431d85 --- /dev/null +++ b/src/main/java/ai/reveng/model/ResultBody.java @@ -0,0 +1,392 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ExtractedBinary; +import ai.reveng.model.ExtractionFailure; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ResultBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ResultBody { + public static final String SERIALIZED_NAME_BINARIES = "binaries"; + @SerializedName(SERIALIZED_NAME_BINARIES) + @javax.annotation.Nullable + private List binaries; + + public static final String SERIALIZED_NAME_EXTRACTION_DEPTH = "extraction_depth"; + @SerializedName(SERIALIZED_NAME_EXTRACTION_DEPTH) + @javax.annotation.Nonnull + private Long extractionDepth; + + public static final String SERIALIZED_NAME_FILENAME_TO_FAILURE = "filename_to_failure"; + @SerializedName(SERIALIZED_NAME_FILENAME_TO_FAILURE) + @javax.annotation.Nonnull + private Map filenameToFailure = new HashMap<>(); + + public static final String SERIALIZED_NAME_SKIPPED_FILES = "skipped_files"; + @SerializedName(SERIALIZED_NAME_SKIPPED_FILES) + @javax.annotation.Nonnull + private Long skippedFiles; + + public ResultBody() { + } + + public ResultBody binaries(@javax.annotation.Nullable List binaries) { + this.binaries = binaries; + return this; + } + + public ResultBody addBinariesItem(ExtractedBinary binariesItem) { + if (this.binaries == null) { + this.binaries = new ArrayList<>(); + } + this.binaries.add(binariesItem); + return this; + } + + /** + * Child binaries recovered from the extraction. + * @return binaries + */ + @javax.annotation.Nullable + public List getBinaries() { + return binaries; + } + + public void setBinaries(@javax.annotation.Nullable List binaries) { + this.binaries = binaries; + } + + + public ResultBody extractionDepth(@javax.annotation.Nonnull Long extractionDepth) { + this.extractionDepth = extractionDepth; + return this; + } + + /** + * Number of nested-archive extraction passes taken. + * @return extractionDepth + */ + @javax.annotation.Nonnull + public Long getExtractionDepth() { + return extractionDepth; + } + + public void setExtractionDepth(@javax.annotation.Nonnull Long extractionDepth) { + this.extractionDepth = extractionDepth; + } + + + public ResultBody filenameToFailure(@javax.annotation.Nonnull Map filenameToFailure) { + this.filenameToFailure = filenameToFailure; + return this; + } + + public ResultBody putFilenameToFailureItem(String key, ExtractionFailure filenameToFailureItem) { + if (this.filenameToFailure == null) { + this.filenameToFailure = new HashMap<>(); + } + this.filenameToFailure.put(key, filenameToFailureItem); + return this; + } + + /** + * Per-file extraction failures, keyed by filename. + * @return filenameToFailure + */ + @javax.annotation.Nonnull + public Map getFilenameToFailure() { + return filenameToFailure; + } + + public void setFilenameToFailure(@javax.annotation.Nonnull Map filenameToFailure) { + this.filenameToFailure = filenameToFailure; + } + + + public ResultBody skippedFiles(@javax.annotation.Nonnull Long skippedFiles) { + this.skippedFiles = skippedFiles; + return this; + } + + /** + * Files skipped because they were not recognised as binaries. + * @return skippedFiles + */ + @javax.annotation.Nonnull + public Long getSkippedFiles() { + return skippedFiles; + } + + public void setSkippedFiles(@javax.annotation.Nonnull Long skippedFiles) { + this.skippedFiles = skippedFiles; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ResultBody instance itself + */ + public ResultBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResultBody resultBody = (ResultBody) o; + return Objects.equals(this.binaries, resultBody.binaries) && + Objects.equals(this.extractionDepth, resultBody.extractionDepth) && + Objects.equals(this.filenameToFailure, resultBody.filenameToFailure) && + Objects.equals(this.skippedFiles, resultBody.skippedFiles)&& + Objects.equals(this.additionalProperties, resultBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(binaries, extractionDepth, filenameToFailure, skippedFiles, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResultBody {\n"); + sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" extractionDepth: ").append(toIndentedString(extractionDepth)).append("\n"); + sb.append(" filenameToFailure: ").append(toIndentedString(filenameToFailure)).append("\n"); + sb.append(" skippedFiles: ").append(toIndentedString(skippedFiles)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("binaries", "extraction_depth", "filename_to_failure", "skipped_files")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("binaries", "extraction_depth", "filename_to_failure", "skipped_files")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ResultBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ResultBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ResultBody is not found in the empty JSON string", ResultBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ResultBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("binaries") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("binaries").isJsonArray() && !jsonObj.get("binaries").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ResultBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ResultBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ResultBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ResultBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ResultBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ResultBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ResultBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResultBody + * @throws IOException if the JSON string is invalid with respect to ResultBody + */ + public static ResultBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ResultBody.class); + } + + /** + * Convert an instance of ResultBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/RuleKind.java b/src/main/java/ai/reveng/model/RuleKind.java new file mode 100644 index 00000000..adac1e43 --- /dev/null +++ b/src/main/java/ai/reveng/model/RuleKind.java @@ -0,0 +1,93 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets RuleKind + */ +@JsonAdapter(RuleKind.Adapter.class) +public enum RuleKind { + + CREDENTIALS("credentials"), + + API_CREDENTIALS("api-credentials"), + + OAUTH_CREDENTIALS("oauth-credentials"), + + ENCRYPTION_KEY("encryption-key"), + + JWT_TOKEN("jwt-token"), + + WEBHOOK_URL("webhook-url"), + + PRIVATE_KEY("private-key"), + + SIGNED_URL("signed-url"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + RuleKind(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RuleKind fromValue(String value) { + for (RuleKind b : RuleKind.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final RuleKind enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public RuleKind read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return RuleKind.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + RuleKind.fromValue(value); + } +} + diff --git a/src/main/java/ai/reveng/model/SSOProvidersOutputBody.java b/src/main/java/ai/reveng/model/SSOProvidersOutputBody.java index 8bebffda..ad57ed82 100644 --- a/src/main/java/ai/reveng/model/SSOProvidersOutputBody.java +++ b/src/main/java/ai/reveng/model/SSOProvidersOutputBody.java @@ -200,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("providers") != null && !jsonObj.get("providers").isJsonNull()) { - if (!jsonObj.get("providers").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `providers` to be an array in the JSON string but got `%s`", jsonObj.get("providers").toString())); - } - JsonArray jsonArrayproviders = jsonObj.getAsJsonArray("providers"); - // validate the required field `providers` (array) - for (int i = 0; i < jsonArrayproviders.size(); i++) { - SSOProvider.validateJsonElement(jsonArrayproviders.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("providers") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("providers").isJsonArray() && !jsonObj.get("providers").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `providers` to be an array in the JSON string but got `%s`", jsonObj.get("providers").toString())); } } diff --git a/src/main/java/ai/reveng/model/SandboxConfig.java b/src/main/java/ai/reveng/model/SandboxConfig.java new file mode 100644 index 00000000..dfb9fe5f --- /dev/null +++ b/src/main/java/ai/reveng/model/SandboxConfig.java @@ -0,0 +1,570 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SandboxConfig + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SandboxConfig { + public static final String SERIALIZED_NAME_ARCHIVE_ENTRY_PATH = "archive_entry_path"; + @SerializedName(SERIALIZED_NAME_ARCHIVE_ENTRY_PATH) + @javax.annotation.Nullable + private String archiveEntryPath; + + public static final String SERIALIZED_NAME_ARCHIVE_PASSWORD = "archive_password"; + @SerializedName(SERIALIZED_NAME_ARCHIVE_PASSWORD) + @javax.annotation.Nullable + private String archivePassword; + + public static final String SERIALIZED_NAME_ARCHIVE_SHA256_HASH = "archive_sha_256_hash"; + @SerializedName(SERIALIZED_NAME_ARCHIVE_SHA256_HASH) + @javax.annotation.Nullable + private String archiveSha256Hash; + + public static final String SERIALIZED_NAME_COMMAND_LINE_ARGS = "command_line_args"; + @SerializedName(SERIALIZED_NAME_COMMAND_LINE_ARGS) + @javax.annotation.Nullable + private String commandLineArgs; + + public static final String SERIALIZED_NAME_ENABLED = "enabled"; + @SerializedName(SERIALIZED_NAME_ENABLED) + @javax.annotation.Nullable + private Boolean enabled; + + /** + * Gets or Sets startMethod + */ + @JsonAdapter(StartMethodEnum.Adapter.class) + public enum StartMethodEnum { + STANDARD_USER_PROCESS("standard_user_process"), + + ADMINISTRATOR_PROCESS("administrator_process"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StartMethodEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StartMethodEnum fromValue(String value) { + for (StartMethodEnum b : StartMethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StartMethodEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StartMethodEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StartMethodEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StartMethodEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_START_METHOD = "start_method"; + @SerializedName(SERIALIZED_NAME_START_METHOD) + @javax.annotation.Nullable + private StartMethodEnum startMethod; + + /** + * Gets or Sets timeout + */ + @JsonAdapter(TimeoutEnum.Adapter.class) + public enum TimeoutEnum { + NUMBER_120(120l), + + NUMBER_180(180l), + + NUMBER_300(300l), + + NUMBER_600(600l), + + NUMBER_unknown_default_open_api(11184809l); + + private Long value; + + TimeoutEnum(Long value) { + this.value = value; + } + + public Long getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TimeoutEnum fromValue(Long value) { + for (TimeoutEnum b : TimeoutEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return NUMBER_unknown_default_open_api; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TimeoutEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TimeoutEnum read(final JsonReader jsonReader) throws IOException { + Long value = jsonReader.nextLong(); + return TimeoutEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Long value = jsonElement.getAsLong(); + TimeoutEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_TIMEOUT = "timeout"; + @SerializedName(SERIALIZED_NAME_TIMEOUT) + @javax.annotation.Nullable + private TimeoutEnum timeout = TimeoutEnum.NUMBER_120; + + public SandboxConfig() { + } + + public SandboxConfig archiveEntryPath(@javax.annotation.Nullable String archiveEntryPath) { + this.archiveEntryPath = archiveEntryPath; + return this; + } + + /** + * Get archiveEntryPath + * @return archiveEntryPath + */ + @javax.annotation.Nullable + public String getArchiveEntryPath() { + return archiveEntryPath; + } + + public void setArchiveEntryPath(@javax.annotation.Nullable String archiveEntryPath) { + this.archiveEntryPath = archiveEntryPath; + } + + + public SandboxConfig archivePassword(@javax.annotation.Nullable String archivePassword) { + this.archivePassword = archivePassword; + return this; + } + + /** + * Get archivePassword + * @return archivePassword + */ + @javax.annotation.Nullable + public String getArchivePassword() { + return archivePassword; + } + + public void setArchivePassword(@javax.annotation.Nullable String archivePassword) { + this.archivePassword = archivePassword; + } + + + public SandboxConfig archiveSha256Hash(@javax.annotation.Nullable String archiveSha256Hash) { + this.archiveSha256Hash = archiveSha256Hash; + return this; + } + + /** + * Get archiveSha256Hash + * @return archiveSha256Hash + */ + @javax.annotation.Nullable + public String getArchiveSha256Hash() { + return archiveSha256Hash; + } + + public void setArchiveSha256Hash(@javax.annotation.Nullable String archiveSha256Hash) { + this.archiveSha256Hash = archiveSha256Hash; + } + + + public SandboxConfig commandLineArgs(@javax.annotation.Nullable String commandLineArgs) { + this.commandLineArgs = commandLineArgs; + return this; + } + + /** + * Get commandLineArgs + * @return commandLineArgs + */ + @javax.annotation.Nullable + public String getCommandLineArgs() { + return commandLineArgs; + } + + public void setCommandLineArgs(@javax.annotation.Nullable String commandLineArgs) { + this.commandLineArgs = commandLineArgs; + } + + + public SandboxConfig enabled(@javax.annotation.Nullable Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get enabled + * @return enabled + */ + @javax.annotation.Nullable + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(@javax.annotation.Nullable Boolean enabled) { + this.enabled = enabled; + } + + + public SandboxConfig startMethod(@javax.annotation.Nullable StartMethodEnum startMethod) { + this.startMethod = startMethod; + return this; + } + + /** + * Get startMethod + * @return startMethod + */ + @javax.annotation.Nullable + public StartMethodEnum getStartMethod() { + return startMethod; + } + + public void setStartMethod(@javax.annotation.Nullable StartMethodEnum startMethod) { + this.startMethod = startMethod; + } + + + public SandboxConfig timeout(@javax.annotation.Nullable TimeoutEnum timeout) { + this.timeout = timeout; + return this; + } + + /** + * Get timeout + * @return timeout + */ + @javax.annotation.Nullable + public TimeoutEnum getTimeout() { + return timeout; + } + + public void setTimeout(@javax.annotation.Nullable TimeoutEnum timeout) { + this.timeout = timeout; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxConfig instance itself + */ + public SandboxConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxConfig sandboxConfig = (SandboxConfig) o; + return Objects.equals(this.archiveEntryPath, sandboxConfig.archiveEntryPath) && + Objects.equals(this.archivePassword, sandboxConfig.archivePassword) && + Objects.equals(this.archiveSha256Hash, sandboxConfig.archiveSha256Hash) && + Objects.equals(this.commandLineArgs, sandboxConfig.commandLineArgs) && + Objects.equals(this.enabled, sandboxConfig.enabled) && + Objects.equals(this.startMethod, sandboxConfig.startMethod) && + Objects.equals(this.timeout, sandboxConfig.timeout)&& + Objects.equals(this.additionalProperties, sandboxConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(archiveEntryPath, archivePassword, archiveSha256Hash, commandLineArgs, enabled, startMethod, timeout, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxConfig {\n"); + sb.append(" archiveEntryPath: ").append(toIndentedString(archiveEntryPath)).append("\n"); + sb.append(" archivePassword: ").append(toIndentedString(archivePassword)).append("\n"); + sb.append(" archiveSha256Hash: ").append(toIndentedString(archiveSha256Hash)).append("\n"); + sb.append(" commandLineArgs: ").append(toIndentedString(commandLineArgs)).append("\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" startMethod: ").append(toIndentedString(startMethod)).append("\n"); + sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("archive_entry_path", "archive_password", "archive_sha_256_hash", "command_line_args", "enabled", "start_method", "timeout")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SandboxConfig + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SandboxConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SandboxConfig is not found in the empty JSON string", SandboxConfig.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("archive_entry_path") != null && !jsonObj.get("archive_entry_path").isJsonNull()) && !jsonObj.get("archive_entry_path").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `archive_entry_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("archive_entry_path").toString())); + } + if ((jsonObj.get("archive_password") != null && !jsonObj.get("archive_password").isJsonNull()) && !jsonObj.get("archive_password").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `archive_password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("archive_password").toString())); + } + if ((jsonObj.get("archive_sha_256_hash") != null && !jsonObj.get("archive_sha_256_hash").isJsonNull()) && !jsonObj.get("archive_sha_256_hash").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `archive_sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("archive_sha_256_hash").toString())); + } + if ((jsonObj.get("command_line_args") != null && !jsonObj.get("command_line_args").isJsonNull()) && !jsonObj.get("command_line_args").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `command_line_args` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command_line_args").toString())); + } + if ((jsonObj.get("start_method") != null && !jsonObj.get("start_method").isJsonNull()) && !jsonObj.get("start_method").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_method").toString())); + } + // validate the optional field `start_method` + if (jsonObj.get("start_method") != null && !jsonObj.get("start_method").isJsonNull()) { + StartMethodEnum.validateJsonElement(jsonObj.get("start_method")); + } + // validate the optional field `timeout` + if (jsonObj.get("timeout") != null && !jsonObj.get("timeout").isJsonNull()) { + TimeoutEnum.validateJsonElement(jsonObj.get("timeout")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxConfig.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxConfig' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxConfig.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxConfig value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxConfig read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SandboxConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxConfig + * @throws IOException if the JSON string is invalid with respect to SandboxConfig + */ + public static SandboxConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxConfig.class); + } + + /** + * Convert an instance of SandboxConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ScheduledTaskEntry.java b/src/main/java/ai/reveng/model/ScheduledTaskEntry.java index 1b2325ba..2a108410 100644 --- a/src/main/java/ai/reveng/model/ScheduledTaskEntry.java +++ b/src/main/java/ai/reveng/model/ScheduledTaskEntry.java @@ -327,6 +327,50 @@ public void setTaskName(@javax.annotation.Nullable String taskName) { this.taskName = taskName; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ScheduledTaskEntry instance itself + */ + public ScheduledTaskEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -348,7 +392,8 @@ public boolean equals(Object o) { Objects.equals(this.scheduleType, scheduledTaskEntry.scheduleType) && Objects.equals(this.startDate, scheduledTaskEntry.startDate) && Objects.equals(this.startTime, scheduledTaskEntry.startTime) && - Objects.equals(this.taskName, scheduledTaskEntry.taskName); + Objects.equals(this.taskName, scheduledTaskEntry.taskName)&& + Objects.equals(this.additionalProperties, scheduledTaskEntry.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -357,7 +402,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(command, day, endDate, events, executable, modifier, runAs, scheduleType, startDate, startTime, taskName); + return Objects.hash(command, day, endDate, events, executable, modifier, runAs, scheduleType, startDate, startTime, taskName, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -382,6 +427,7 @@ public String toString() { sb.append(" startDate: ").append(toIndentedString(startDate)).append("\n"); sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); sb.append(" taskName: ").append(toIndentedString(taskName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -418,14 +464,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ScheduledTaskEntry is not found in the empty JSON string", ScheduledTaskEntry.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ScheduledTaskEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ScheduledTaskEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("command") != null && !jsonObj.get("command").isJsonNull()) && !jsonObj.get("command").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `command` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command").toString())); @@ -436,19 +474,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("end_date") != null && !jsonObj.get("end_date").isJsonNull()) && !jsonObj.get("end_date").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `end_date` to be a primitive type in the JSON string but got `%s`", jsonObj.get("end_date").toString())); } - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if ((jsonObj.get("executable") != null && !jsonObj.get("executable").isJsonNull()) && !jsonObj.get("executable").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `executable` to be a primitive type in the JSON string but got `%s`", jsonObj.get("executable").toString())); @@ -488,6 +516,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ScheduledTaskEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -495,7 +545,28 @@ public void write(JsonWriter out, ScheduledTaskEntry value) throws IOException { public ScheduledTaskEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ScheduledTaskEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java b/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java index 0549e4d5..632ee0a1 100644 --- a/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java +++ b/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java @@ -52,7 +52,7 @@ public class ScrapeThirdPartyConfig { public static final String SERIALIZED_NAME_ENABLED = "enabled"; @SerializedName(SERIALIZED_NAME_ENABLED) @javax.annotation.Nullable - private Boolean enabled = false; + private Boolean enabled; public ScrapeThirdPartyConfig() { } diff --git a/src/main/java/ai/reveng/model/ScreenshotEntry.java b/src/main/java/ai/reveng/model/ScreenshotEntry.java new file mode 100644 index 00000000..5e4bdf5a --- /dev/null +++ b/src/main/java/ai/reveng/model/ScreenshotEntry.java @@ -0,0 +1,286 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ScreenshotEntry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ScreenshotEntry { + public static final String SERIALIZED_NAME_INDEX = "index"; + @SerializedName(SERIALIZED_NAME_INDEX) + @javax.annotation.Nonnull + private Long index; + + public ScreenshotEntry() { + } + + public ScreenshotEntry index(@javax.annotation.Nonnull Long index) { + this.index = index; + return this; + } + + /** + * Get index + * @return index + */ + @javax.annotation.Nonnull + public Long getIndex() { + return index; + } + + public void setIndex(@javax.annotation.Nonnull Long index) { + this.index = index; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ScreenshotEntry instance itself + */ + public ScreenshotEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScreenshotEntry screenshotEntry = (ScreenshotEntry) o; + return Objects.equals(this.index, screenshotEntry.index)&& + Objects.equals(this.additionalProperties, screenshotEntry.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(index, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScreenshotEntry {\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("index")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("index")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ScreenshotEntry + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ScreenshotEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ScreenshotEntry is not found in the empty JSON string", ScreenshotEntry.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ScreenshotEntry.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ScreenshotEntry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ScreenshotEntry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ScreenshotEntry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ScreenshotEntry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ScreenshotEntry read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ScreenshotEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ScreenshotEntry given an JSON string + * + * @param jsonString JSON string + * @return An instance of ScreenshotEntry + * @throws IOException if the JSON string is invalid with respect to ScreenshotEntry + */ + public static ScreenshotEntry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ScreenshotEntry.class); + } + + /** + * Convert an instance of ScreenshotEntry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ScreenshotsIndex.java b/src/main/java/ai/reveng/model/ScreenshotsIndex.java new file mode 100644 index 00000000..4fcd75f7 --- /dev/null +++ b/src/main/java/ai/reveng/model/ScreenshotsIndex.java @@ -0,0 +1,329 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.ScreenshotEntry; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ScreenshotsIndex + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ScreenshotsIndex { + public static final String SERIALIZED_NAME_COUNT = "count"; + @SerializedName(SERIALIZED_NAME_COUNT) + @javax.annotation.Nonnull + private Long count; + + public static final String SERIALIZED_NAME_SCREENSHOTS = "screenshots"; + @SerializedName(SERIALIZED_NAME_SCREENSHOTS) + @javax.annotation.Nullable + private List screenshots; + + public ScreenshotsIndex() { + } + + public ScreenshotsIndex count(@javax.annotation.Nonnull Long count) { + this.count = count; + return this; + } + + /** + * Get count + * @return count + */ + @javax.annotation.Nonnull + public Long getCount() { + return count; + } + + public void setCount(@javax.annotation.Nonnull Long count) { + this.count = count; + } + + + public ScreenshotsIndex screenshots(@javax.annotation.Nullable List screenshots) { + this.screenshots = screenshots; + return this; + } + + public ScreenshotsIndex addScreenshotsItem(ScreenshotEntry screenshotsItem) { + if (this.screenshots == null) { + this.screenshots = new ArrayList<>(); + } + this.screenshots.add(screenshotsItem); + return this; + } + + /** + * Get screenshots + * @return screenshots + */ + @javax.annotation.Nullable + public List getScreenshots() { + return screenshots; + } + + public void setScreenshots(@javax.annotation.Nullable List screenshots) { + this.screenshots = screenshots; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ScreenshotsIndex instance itself + */ + public ScreenshotsIndex putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScreenshotsIndex screenshotsIndex = (ScreenshotsIndex) o; + return Objects.equals(this.count, screenshotsIndex.count) && + Objects.equals(this.screenshots, screenshotsIndex.screenshots)&& + Objects.equals(this.additionalProperties, screenshotsIndex.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(count, screenshots, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScreenshotsIndex {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" screenshots: ").append(toIndentedString(screenshots)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("count", "screenshots")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("count", "screenshots")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ScreenshotsIndex + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ScreenshotsIndex.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ScreenshotsIndex is not found in the empty JSON string", ScreenshotsIndex.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ScreenshotsIndex.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("screenshots") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("screenshots").isJsonArray() && !jsonObj.get("screenshots").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `screenshots` to be an array in the JSON string but got `%s`", jsonObj.get("screenshots").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ScreenshotsIndex.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ScreenshotsIndex' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ScreenshotsIndex.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ScreenshotsIndex value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ScreenshotsIndex read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ScreenshotsIndex instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ScreenshotsIndex given an JSON string + * + * @param jsonString JSON string + * @return An instance of ScreenshotsIndex + * @throws IOException if the JSON string is invalid with respect to ScreenshotsIndex + */ + public static ScreenshotsIndex fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ScreenshotsIndex.class); + } + + /** + * Convert an instance of ScreenshotsIndex to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SecretsAgentResponse.java b/src/main/java/ai/reveng/model/SecretsAgentResponse.java new file mode 100644 index 00000000..91c0ab0f --- /dev/null +++ b/src/main/java/ai/reveng/model/SecretsAgentResponse.java @@ -0,0 +1,321 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Finding; +import ai.reveng.model.Meta; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Full secrets report, including metadata, findings, and evidence. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SecretsAgentResponse { + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + @javax.annotation.Nullable + private Meta meta; + + public static final String SERIALIZED_NAME_FINDINGS = "findings"; + @SerializedName(SERIALIZED_NAME_FINDINGS) + @javax.annotation.Nullable + private List findings = new ArrayList<>(); + + public SecretsAgentResponse() { + } + + public SecretsAgentResponse meta(@javax.annotation.Nullable Meta meta) { + this.meta = meta; + return this; + } + + /** + * Get meta + * @return meta + */ + @javax.annotation.Nullable + public Meta getMeta() { + return meta; + } + + public void setMeta(@javax.annotation.Nullable Meta meta) { + this.meta = meta; + } + + + public SecretsAgentResponse findings(@javax.annotation.Nullable List findings) { + this.findings = findings; + return this; + } + + public SecretsAgentResponse addFindingsItem(Finding findingsItem) { + if (this.findings == null) { + this.findings = new ArrayList<>(); + } + this.findings.add(findingsItem); + return this; + } + + /** + * Get findings + * @return findings + */ + @javax.annotation.Nullable + public List getFindings() { + return findings; + } + + public void setFindings(@javax.annotation.Nullable List findings) { + this.findings = findings; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SecretsAgentResponse instance itself + */ + public SecretsAgentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecretsAgentResponse secretsAgentResponse = (SecretsAgentResponse) o; + return Objects.equals(this.meta, secretsAgentResponse.meta) && + Objects.equals(this.findings, secretsAgentResponse.findings)&& + Objects.equals(this.additionalProperties, secretsAgentResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(meta, findings, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecretsAgentResponse {\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" findings: ").append(toIndentedString(findings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("meta", "findings")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SecretsAgentResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SecretsAgentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SecretsAgentResponse is not found in the empty JSON string", SecretsAgentResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("findings") != null && !jsonObj.get("findings").isJsonNull() && !jsonObj.get("findings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `findings` to be an array in the JSON string but got `%s`", jsonObj.get("findings").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SecretsAgentResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SecretsAgentResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SecretsAgentResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SecretsAgentResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SecretsAgentResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SecretsAgentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SecretsAgentResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of SecretsAgentResponse + * @throws IOException if the JSON string is invalid with respect to SecretsAgentResponse + */ + public static SecretsAgentResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SecretsAgentResponse.class); + } + + /** + * Convert an instance of SecretsAgentResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SecurityFinding.java b/src/main/java/ai/reveng/model/SecurityFinding.java new file mode 100644 index 00000000..d0318184 --- /dev/null +++ b/src/main/java/ai/reveng/model/SecurityFinding.java @@ -0,0 +1,803 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SecurityFinding + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SecurityFinding { + public static final String SERIALIZED_NAME_CHECK_ID = "check_id"; + @SerializedName(SERIALIZED_NAME_CHECK_ID) + @javax.annotation.Nullable + private String checkId; + + /** + * Semgrep's confidence in the finding + */ + @JsonAdapter(ConfidenceEnum.Adapter.class) + public enum ConfidenceEnum { + LOW("LOW"), + + MEDIUM("MEDIUM"), + + HIGH("HIGH"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ConfidenceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ConfidenceEnum fromValue(String value) { + for (ConfidenceEnum b : ConfidenceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ConfidenceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ConfidenceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ConfidenceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ConfidenceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CONFIDENCE = "confidence"; + @SerializedName(SERIALIZED_NAME_CONFIDENCE) + @javax.annotation.Nullable + private ConfidenceEnum confidence; + + public static final String SERIALIZED_NAME_CWE = "cwe"; + @SerializedName(SERIALIZED_NAME_CWE) + @javax.annotation.Nullable + private List cwe; + + public static final String SERIALIZED_NAME_END_LINE = "end_line"; + @SerializedName(SERIALIZED_NAME_END_LINE) + @javax.annotation.Nullable + private Long endLine; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nullable + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nullable + private String functionName; + + /** + * Estimated impact of the finding + */ + @JsonAdapter(ImpactEnum.Adapter.class) + public enum ImpactEnum { + LOW("LOW"), + + MEDIUM("MEDIUM"), + + HIGH("HIGH"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ImpactEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ImpactEnum fromValue(String value) { + for (ImpactEnum b : ImpactEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ImpactEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ImpactEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ImpactEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ImpactEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_IMPACT = "impact"; + @SerializedName(SERIALIZED_NAME_IMPACT) + @javax.annotation.Nullable + private ImpactEnum impact; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable + private String message; + + /** + * Severity of the finding + */ + @JsonAdapter(SeverityEnum.Adapter.class) + public enum SeverityEnum { + LOW("LOW"), + + MEDIUM("MEDIUM"), + + HIGH("HIGH"), + + CRITICAL("CRITICAL"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SeverityEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SeverityEnum fromValue(String value) { + for (SeverityEnum b : SeverityEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SeverityEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SeverityEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SeverityEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SeverityEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SEVERITY = "severity"; + @SerializedName(SERIALIZED_NAME_SEVERITY) + @javax.annotation.Nullable + private SeverityEnum severity; + + public static final String SERIALIZED_NAME_SNIPPET_LINES = "snippet_lines"; + @SerializedName(SERIALIZED_NAME_SNIPPET_LINES) + @javax.annotation.Nullable + private List snippetLines; + + public static final String SERIALIZED_NAME_SNIPPET_START_LINE = "snippet_start_line"; + @SerializedName(SERIALIZED_NAME_SNIPPET_START_LINE) + @javax.annotation.Nullable + private Long snippetStartLine; + + public static final String SERIALIZED_NAME_START_LINE = "start_line"; + @SerializedName(SERIALIZED_NAME_START_LINE) + @javax.annotation.Nullable + private Long startLine; + + public SecurityFinding() { + } + + public SecurityFinding checkId(@javax.annotation.Nullable String checkId) { + this.checkId = checkId; + return this; + } + + /** + * Semgrep rule ID that matched + * @return checkId + */ + @javax.annotation.Nullable + public String getCheckId() { + return checkId; + } + + public void setCheckId(@javax.annotation.Nullable String checkId) { + this.checkId = checkId; + } + + + public SecurityFinding confidence(@javax.annotation.Nullable ConfidenceEnum confidence) { + this.confidence = confidence; + return this; + } + + /** + * Semgrep's confidence in the finding + * @return confidence + */ + @javax.annotation.Nullable + public ConfidenceEnum getConfidence() { + return confidence; + } + + public void setConfidence(@javax.annotation.Nullable ConfidenceEnum confidence) { + this.confidence = confidence; + } + + + public SecurityFinding cwe(@javax.annotation.Nullable List cwe) { + this.cwe = cwe; + return this; + } + + public SecurityFinding addCweItem(String cweItem) { + if (this.cwe == null) { + this.cwe = new ArrayList<>(); + } + this.cwe.add(cweItem); + return this; + } + + /** + * CWE identifiers associated with the finding + * @return cwe + */ + @javax.annotation.Nullable + public List getCwe() { + return cwe; + } + + public void setCwe(@javax.annotation.Nullable List cwe) { + this.cwe = cwe; + } + + + public SecurityFinding endLine(@javax.annotation.Nullable Long endLine) { + this.endLine = endLine; + return this; + } + + /** + * Line the finding ends on + * @return endLine + */ + @javax.annotation.Nullable + public Long getEndLine() { + return endLine; + } + + public void setEndLine(@javax.annotation.Nullable Long endLine) { + this.endLine = endLine; + } + + + public SecurityFinding functionId(@javax.annotation.Nullable Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the function the finding was reported in + * @return functionId + */ + @javax.annotation.Nullable + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nullable Long functionId) { + this.functionId = functionId; + } + + + public SecurityFinding functionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the function the finding was reported in + * @return functionName + */ + @javax.annotation.Nullable + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nullable String functionName) { + this.functionName = functionName; + } + + + public SecurityFinding impact(@javax.annotation.Nullable ImpactEnum impact) { + this.impact = impact; + return this; + } + + /** + * Estimated impact of the finding + * @return impact + */ + @javax.annotation.Nullable + public ImpactEnum getImpact() { + return impact; + } + + public void setImpact(@javax.annotation.Nullable ImpactEnum impact) { + this.impact = impact; + } + + + public SecurityFinding message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Human-readable description of the finding + * @return message + */ + @javax.annotation.Nullable + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + public SecurityFinding severity(@javax.annotation.Nullable SeverityEnum severity) { + this.severity = severity; + return this; + } + + /** + * Severity of the finding + * @return severity + */ + @javax.annotation.Nullable + public SeverityEnum getSeverity() { + return severity; + } + + public void setSeverity(@javax.annotation.Nullable SeverityEnum severity) { + this.severity = severity; + } + + + public SecurityFinding snippetLines(@javax.annotation.Nullable List snippetLines) { + this.snippetLines = snippetLines; + return this; + } + + public SecurityFinding addSnippetLinesItem(String snippetLinesItem) { + if (this.snippetLines == null) { + this.snippetLines = new ArrayList<>(); + } + this.snippetLines.add(snippetLinesItem); + return this; + } + + /** + * Source lines making up the reported snippet + * @return snippetLines + */ + @javax.annotation.Nullable + public List getSnippetLines() { + return snippetLines; + } + + public void setSnippetLines(@javax.annotation.Nullable List snippetLines) { + this.snippetLines = snippetLines; + } + + + public SecurityFinding snippetStartLine(@javax.annotation.Nullable Long snippetStartLine) { + this.snippetStartLine = snippetStartLine; + return this; + } + + /** + * Line the reported snippet starts on + * @return snippetStartLine + */ + @javax.annotation.Nullable + public Long getSnippetStartLine() { + return snippetStartLine; + } + + public void setSnippetStartLine(@javax.annotation.Nullable Long snippetStartLine) { + this.snippetStartLine = snippetStartLine; + } + + + public SecurityFinding startLine(@javax.annotation.Nullable Long startLine) { + this.startLine = startLine; + return this; + } + + /** + * Line the finding starts on + * @return startLine + */ + @javax.annotation.Nullable + public Long getStartLine() { + return startLine; + } + + public void setStartLine(@javax.annotation.Nullable Long startLine) { + this.startLine = startLine; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SecurityFinding instance itself + */ + public SecurityFinding putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityFinding securityFinding = (SecurityFinding) o; + return Objects.equals(this.checkId, securityFinding.checkId) && + Objects.equals(this.confidence, securityFinding.confidence) && + Objects.equals(this.cwe, securityFinding.cwe) && + Objects.equals(this.endLine, securityFinding.endLine) && + Objects.equals(this.functionId, securityFinding.functionId) && + Objects.equals(this.functionName, securityFinding.functionName) && + Objects.equals(this.impact, securityFinding.impact) && + Objects.equals(this.message, securityFinding.message) && + Objects.equals(this.severity, securityFinding.severity) && + Objects.equals(this.snippetLines, securityFinding.snippetLines) && + Objects.equals(this.snippetStartLine, securityFinding.snippetStartLine) && + Objects.equals(this.startLine, securityFinding.startLine)&& + Objects.equals(this.additionalProperties, securityFinding.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(checkId, confidence, cwe, endLine, functionId, functionName, impact, message, severity, snippetLines, snippetStartLine, startLine, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityFinding {\n"); + sb.append(" checkId: ").append(toIndentedString(checkId)).append("\n"); + sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" cwe: ").append(toIndentedString(cwe)).append("\n"); + sb.append(" endLine: ").append(toIndentedString(endLine)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" impact: ").append(toIndentedString(impact)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" severity: ").append(toIndentedString(severity)).append("\n"); + sb.append(" snippetLines: ").append(toIndentedString(snippetLines)).append("\n"); + sb.append(" snippetStartLine: ").append(toIndentedString(snippetStartLine)).append("\n"); + sb.append(" startLine: ").append(toIndentedString(startLine)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("check_id", "confidence", "cwe", "end_line", "function_id", "function_name", "impact", "message", "severity", "snippet_lines", "snippet_start_line", "start_line")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SecurityFinding + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SecurityFinding.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SecurityFinding is not found in the empty JSON string", SecurityFinding.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("check_id") != null && !jsonObj.get("check_id").isJsonNull()) && !jsonObj.get("check_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `check_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("check_id").toString())); + } + if ((jsonObj.get("confidence") != null && !jsonObj.get("confidence").isJsonNull()) && !jsonObj.get("confidence").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidence` to be a primitive type in the JSON string but got `%s`", jsonObj.get("confidence").toString())); + } + // validate the optional field `confidence` + if (jsonObj.get("confidence") != null && !jsonObj.get("confidence").isJsonNull()) { + ConfidenceEnum.validateJsonElement(jsonObj.get("confidence")); + } + // ensure the optional json data is an array if present + if (jsonObj.get("cwe") != null && !jsonObj.get("cwe").isJsonNull() && !jsonObj.get("cwe").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `cwe` to be an array in the JSON string but got `%s`", jsonObj.get("cwe").toString())); + } + if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + if ((jsonObj.get("impact") != null && !jsonObj.get("impact").isJsonNull()) && !jsonObj.get("impact").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `impact` to be a primitive type in the JSON string but got `%s`", jsonObj.get("impact").toString())); + } + // validate the optional field `impact` + if (jsonObj.get("impact") != null && !jsonObj.get("impact").isJsonNull()) { + ImpactEnum.validateJsonElement(jsonObj.get("impact")); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + if ((jsonObj.get("severity") != null && !jsonObj.get("severity").isJsonNull()) && !jsonObj.get("severity").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `severity` to be a primitive type in the JSON string but got `%s`", jsonObj.get("severity").toString())); + } + // validate the optional field `severity` + if (jsonObj.get("severity") != null && !jsonObj.get("severity").isJsonNull()) { + SeverityEnum.validateJsonElement(jsonObj.get("severity")); + } + // ensure the optional json data is an array if present + if (jsonObj.get("snippet_lines") != null && !jsonObj.get("snippet_lines").isJsonNull() && !jsonObj.get("snippet_lines").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `snippet_lines` to be an array in the JSON string but got `%s`", jsonObj.get("snippet_lines").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SecurityFinding.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SecurityFinding' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SecurityFinding.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SecurityFinding value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SecurityFinding read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SecurityFinding instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SecurityFinding given an JSON string + * + * @param jsonString JSON string + * @return An instance of SecurityFinding + * @throws IOException if the JSON string is invalid with respect to SecurityFinding + */ + public static SecurityFinding fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SecurityFinding.class); + } + + /** + * Convert an instance of SecurityFinding to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SecurityScanMetadata.java b/src/main/java/ai/reveng/model/SecurityScanMetadata.java new file mode 100644 index 00000000..d2ff01a6 --- /dev/null +++ b/src/main/java/ai/reveng/model/SecurityScanMetadata.java @@ -0,0 +1,403 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SecurityScanMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SecurityScanMetadata { + public static final String SERIALIZED_NAME_LOG_HISTORY = "log_history"; + @SerializedName(SERIALIZED_NAME_LOG_HISTORY) + @javax.annotation.Nullable + private List> logHistory; + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public SecurityScanMetadata() { + } + + public SecurityScanMetadata logHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + return this; + } + + public SecurityScanMetadata addLogHistoryItem(List logHistoryItem) { + if (this.logHistory == null) { + this.logHistory = new ArrayList<>(); + } + this.logHistory.add(logHistoryItem); + return this; + } + + /** + * Progress messages the run recorded, oldest first. + * @return logHistory + */ + @javax.annotation.Nullable + public List> getLogHistory() { + return logHistory; + } + + public void setLogHistory(@javax.annotation.Nullable List> logHistory) { + this.logHistory = logHistory; + } + + + public SecurityScanMetadata status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Run status. UNINITIALISED means the agent has never been triggered for this analysis. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SecurityScanMetadata instance itself + */ + public SecurityScanMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityScanMetadata securityScanMetadata = (SecurityScanMetadata) o; + return Objects.equals(this.logHistory, securityScanMetadata.logHistory) && + Objects.equals(this.status, securityScanMetadata.status)&& + Objects.equals(this.additionalProperties, securityScanMetadata.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(logHistory, status, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityScanMetadata {\n"); + sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("log_history", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SecurityScanMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SecurityScanMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SecurityScanMetadata is not found in the empty JSON string", SecurityScanMetadata.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SecurityScanMetadata.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SecurityScanMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SecurityScanMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SecurityScanMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SecurityScanMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SecurityScanMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SecurityScanMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SecurityScanMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of SecurityScanMetadata + * @throws IOException if the JSON string is invalid with respect to SecurityScanMetadata + */ + public static SecurityScanMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SecurityScanMetadata.class); + } + + /** + * Convert an instance of SecurityScanMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SecurityScanResult.java b/src/main/java/ai/reveng/model/SecurityScanResult.java new file mode 100644 index 00000000..4e7fd588 --- /dev/null +++ b/src/main/java/ai/reveng/model/SecurityScanResult.java @@ -0,0 +1,443 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.SecurityFinding; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SecurityScanResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SecurityScanResult { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_CANCELLED = "cancelled"; + @SerializedName(SERIALIZED_NAME_CANCELLED) + @javax.annotation.Nonnull + private Boolean cancelled; + + public static final String SERIALIZED_NAME_DECOMPILED = "decompiled"; + @SerializedName(SERIALIZED_NAME_DECOMPILED) + @javax.annotation.Nonnull + private Long decompiled; + + public static final String SERIALIZED_NAME_FAILED = "failed"; + @SerializedName(SERIALIZED_NAME_FAILED) + @javax.annotation.Nonnull + private Long failed; + + public static final String SERIALIZED_NAME_SECURITY_SCAN = "security_scan"; + @SerializedName(SERIALIZED_NAME_SECURITY_SCAN) + @javax.annotation.Nullable + private List securityScan; + + public static final String SERIALIZED_NAME_TOTAL = "total"; + @SerializedName(SERIALIZED_NAME_TOTAL) + @javax.annotation.Nonnull + private Long total; + + public SecurityScanResult() { + } + + public SecurityScanResult analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * Analysis the run was performed against + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public SecurityScanResult cancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + return this; + } + + /** + * Whether the run was cancelled before it covered every function + * @return cancelled + */ + @javax.annotation.Nonnull + public Boolean getCancelled() { + return cancelled; + } + + public void setCancelled(@javax.annotation.Nonnull Boolean cancelled) { + this.cancelled = cancelled; + } + + + public SecurityScanResult decompiled(@javax.annotation.Nonnull Long decompiled) { + this.decompiled = decompiled; + return this; + } + + /** + * Functions successfully decompiled and scanned + * @return decompiled + */ + @javax.annotation.Nonnull + public Long getDecompiled() { + return decompiled; + } + + public void setDecompiled(@javax.annotation.Nonnull Long decompiled) { + this.decompiled = decompiled; + } + + + public SecurityScanResult failed(@javax.annotation.Nonnull Long failed) { + this.failed = failed; + return this; + } + + /** + * Functions whose decompilation or scan attempt errored + * @return failed + */ + @javax.annotation.Nonnull + public Long getFailed() { + return failed; + } + + public void setFailed(@javax.annotation.Nonnull Long failed) { + this.failed = failed; + } + + + public SecurityScanResult securityScan(@javax.annotation.Nullable List securityScan) { + this.securityScan = securityScan; + return this; + } + + public SecurityScanResult addSecurityScanItem(SecurityFinding securityScanItem) { + if (this.securityScan == null) { + this.securityScan = new ArrayList<>(); + } + this.securityScan.add(securityScanItem); + return this; + } + + /** + * Shaped semgrep findings, one per result + * @return securityScan + */ + @javax.annotation.Nullable + public List getSecurityScan() { + return securityScan; + } + + public void setSecurityScan(@javax.annotation.Nullable List securityScan) { + this.securityScan = securityScan; + } + + + public SecurityScanResult total(@javax.annotation.Nonnull Long total) { + this.total = total; + return this; + } + + /** + * Functions the run considered + * @return total + */ + @javax.annotation.Nonnull + public Long getTotal() { + return total; + } + + public void setTotal(@javax.annotation.Nonnull Long total) { + this.total = total; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SecurityScanResult instance itself + */ + public SecurityScanResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityScanResult securityScanResult = (SecurityScanResult) o; + return Objects.equals(this.analysisId, securityScanResult.analysisId) && + Objects.equals(this.cancelled, securityScanResult.cancelled) && + Objects.equals(this.decompiled, securityScanResult.decompiled) && + Objects.equals(this.failed, securityScanResult.failed) && + Objects.equals(this.securityScan, securityScanResult.securityScan) && + Objects.equals(this.total, securityScanResult.total)&& + Objects.equals(this.additionalProperties, securityScanResult.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, cancelled, decompiled, failed, securityScan, total, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityScanResult {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" cancelled: ").append(toIndentedString(cancelled)).append("\n"); + sb.append(" decompiled: ").append(toIndentedString(decompiled)).append("\n"); + sb.append(" failed: ").append(toIndentedString(failed)).append("\n"); + sb.append(" securityScan: ").append(toIndentedString(securityScan)).append("\n"); + sb.append(" total: ").append(toIndentedString(total)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "cancelled", "decompiled", "failed", "security_scan", "total")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "cancelled", "decompiled", "failed", "total")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SecurityScanResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SecurityScanResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SecurityScanResult is not found in the empty JSON string", SecurityScanResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SecurityScanResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("security_scan") != null && !jsonObj.get("security_scan").isJsonNull() && !jsonObj.get("security_scan").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `security_scan` to be an array in the JSON string but got `%s`", jsonObj.get("security_scan").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SecurityScanResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SecurityScanResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SecurityScanResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SecurityScanResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SecurityScanResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SecurityScanResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SecurityScanResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of SecurityScanResult + * @throws IOException if the JSON string is invalid with respect to SecurityScanResult + */ + public static SecurityScanResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SecurityScanResult.class); + } + + /** + * Convert an instance of SecurityScanResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SegmentInfo.java b/src/main/java/ai/reveng/model/SegmentInfo.java index 1b84f2f1..95b72d2b 100644 --- a/src/main/java/ai/reveng/model/SegmentInfo.java +++ b/src/main/java/ai/reveng/model/SegmentInfo.java @@ -46,7 +46,7 @@ import ai.reveng.invoker.JSON; /** - * Represents the information about a segment. Attributes: name: The name of the segment. r: Determines if the segment has read permission. w: Determines if the segment has write permission. x: Determines if the segment has execute permission. start: The start address of the segment. end: The end address of the segment (inclusive). kind: Coarse classification of the segment: \"code\", \"data\", or \"other\". + * Represents the information about a segment. This is the per-xref view, carried on :class:`XRef.segment`. The binary-wide ``AnalysisModel.segments`` list is written by a different producer with a different shape -- see :class:`MemorySegment`. Attributes: name: The name of the segment. r: Determines if the segment has read permission. w: Determines if the segment has write permission. x: Determines if the segment has execute permission. start: The start address of the segment. end: The end address of the segment (inclusive). kind: Coarse classification of the segment: \"code\", \"data\", or \"other\". */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class SegmentInfo { diff --git a/src/main/java/ai/reveng/model/SendMessageRequest.java b/src/main/java/ai/reveng/model/SendMessageRequest.java index 1def1d06..de615197 100644 --- a/src/main/java/ai/reveng/model/SendMessageRequest.java +++ b/src/main/java/ai/reveng/model/SendMessageRequest.java @@ -100,6 +100,50 @@ public void setContext(@javax.annotation.Nullable ConversationContext context) { this.context = context; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SendMessageRequest instance itself + */ + public SendMessageRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } SendMessageRequest sendMessageRequest = (SendMessageRequest) o; return Objects.equals(this.content, sendMessageRequest.content) && - Objects.equals(this.context, sendMessageRequest.context); + Objects.equals(this.context, sendMessageRequest.context)&& + Objects.equals(this.additionalProperties, sendMessageRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(content, context); + return Objects.hash(content, context, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class SendMessageRequest {\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SendMessageRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SendMessageRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SendMessageRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -181,10 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("content").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); } - // validate the optional field `context` - if (jsonObj.get("context") != null && !jsonObj.get("context").isJsonNull()) { - ConversationContext.validateJsonElement(jsonObj.get("context")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -202,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SendMessageRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +265,28 @@ public void write(JsonWriter out, SendMessageRequest value) throws IOException { public SendMessageRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SendMessageRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ServerSentEventsInner1.java b/src/main/java/ai/reveng/model/ServerSentEventsInner1.java index 74f47afb..2945a352 100644 --- a/src/main/java/ai/reveng/model/ServerSentEventsInner1.java +++ b/src/main/java/ai/reveng/model/ServerSentEventsInner1.java @@ -17,10 +17,12 @@ import ai.reveng.model.EventAttemptStarted; import ai.reveng.model.EventDecompFailed; import ai.reveng.model.EventDecompFinished; +import ai.reveng.model.EventNamesFinished; import ai.reveng.model.EventProse; import ai.reveng.model.EventRenameApplied; import ai.reveng.model.EventSourceDelta; import ai.reveng.model.EventSourceReset; +import ai.reveng.model.EventTypesSuggested; import ai.reveng.model.EventWarning; import ai.reveng.model.WarningEvent; import com.google.gson.TypeAdapter; @@ -82,10 +84,12 @@ public TypeAdapter create(Gson gson, TypeToken type) { final TypeAdapter adapterEventAttemptStarted = gson.getDelegateAdapter(this, TypeToken.get(EventAttemptStarted.class)); final TypeAdapter adapterEventDecompFailed = gson.getDelegateAdapter(this, TypeToken.get(EventDecompFailed.class)); final TypeAdapter adapterEventDecompFinished = gson.getDelegateAdapter(this, TypeToken.get(EventDecompFinished.class)); + final TypeAdapter adapterEventNamesFinished = gson.getDelegateAdapter(this, TypeToken.get(EventNamesFinished.class)); final TypeAdapter adapterEventProse = gson.getDelegateAdapter(this, TypeToken.get(EventProse.class)); final TypeAdapter adapterEventRenameApplied = gson.getDelegateAdapter(this, TypeToken.get(EventRenameApplied.class)); final TypeAdapter adapterEventSourceDelta = gson.getDelegateAdapter(this, TypeToken.get(EventSourceDelta.class)); final TypeAdapter adapterEventSourceReset = gson.getDelegateAdapter(this, TypeToken.get(EventSourceReset.class)); + final TypeAdapter adapterEventTypesSuggested = gson.getDelegateAdapter(this, TypeToken.get(EventTypesSuggested.class)); final TypeAdapter adapterEventWarning = gson.getDelegateAdapter(this, TypeToken.get(EventWarning.class)); return (TypeAdapter) new TypeAdapter() { @@ -120,6 +124,12 @@ public void write(JsonWriter out, ServerSentEventsInner1 value) throws IOExcepti elementAdapter.write(out, element); return; } + // check if the actual instance is of the type `EventNamesFinished` + if (value.getActualInstance() instanceof EventNamesFinished) { + JsonElement element = adapterEventNamesFinished.toJsonTree((EventNamesFinished)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } // check if the actual instance is of the type `EventProse` if (value.getActualInstance() instanceof EventProse) { JsonElement element = adapterEventProse.toJsonTree((EventProse)value.getActualInstance()); @@ -144,13 +154,19 @@ public void write(JsonWriter out, ServerSentEventsInner1 value) throws IOExcepti elementAdapter.write(out, element); return; } + // check if the actual instance is of the type `EventTypesSuggested` + if (value.getActualInstance() instanceof EventTypesSuggested) { + JsonElement element = adapterEventTypesSuggested.toJsonTree((EventTypesSuggested)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } // check if the actual instance is of the type `EventWarning` if (value.getActualInstance() instanceof EventWarning) { JsonElement element = adapterEventWarning.toJsonTree((EventWarning)value.getActualInstance()); elementAdapter.write(out, element); return; } - throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning"); + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventNamesFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventTypesSuggested, EventWarning"); } @Override @@ -210,6 +226,18 @@ public ServerSentEventsInner1 read(JsonReader in) throws IOException { errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventDecompFinished failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventDecompFinished'", e); } + // deserialize EventNamesFinished + try { + // validate the JSON object to see if any exception is thrown + EventNamesFinished.validateJsonElement(jsonElement); + actualAdapter = adapterEventNamesFinished; + match++; + log.log(Level.FINER, "Input data matches schema 'EventNamesFinished'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventNamesFinished failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'EventNamesFinished'", e); + } // deserialize EventProse try { // validate the JSON object to see if any exception is thrown @@ -258,6 +286,18 @@ public ServerSentEventsInner1 read(JsonReader in) throws IOException { errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSourceReset failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventSourceReset'", e); } + // deserialize EventTypesSuggested + try { + // validate the JSON object to see if any exception is thrown + EventTypesSuggested.validateJsonElement(jsonElement); + actualAdapter = adapterEventTypesSuggested; + match++; + log.log(Level.FINER, "Input data matches schema 'EventTypesSuggested'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTypesSuggested failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'EventTypesSuggested'", e); + } // deserialize EventWarning try { // validate the JSON object to see if any exception is thrown @@ -300,10 +340,12 @@ public ServerSentEventsInner1(Object o) { schemas.put("EventAttemptStarted", EventAttemptStarted.class); schemas.put("EventDecompFailed", EventDecompFailed.class); schemas.put("EventDecompFinished", EventDecompFinished.class); + schemas.put("EventNamesFinished", EventNamesFinished.class); schemas.put("EventProse", EventProse.class); schemas.put("EventRenameApplied", EventRenameApplied.class); schemas.put("EventSourceDelta", EventSourceDelta.class); schemas.put("EventSourceReset", EventSourceReset.class); + schemas.put("EventTypesSuggested", EventTypesSuggested.class); schemas.put("EventWarning", EventWarning.class); } @@ -315,7 +357,7 @@ public Map> getSchemas() { /** * Set the instance that matches the oneOf child schema, check * the instance parameter is valid against the oneOf child schemas: - * EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning + * EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventNamesFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventTypesSuggested, EventWarning * * It could be an instance of the 'oneOf' schemas. */ @@ -341,6 +383,11 @@ public void setActualInstance(Object instance) { return; } + if (instance instanceof EventNamesFinished) { + super.setActualInstance(instance); + return; + } + if (instance instanceof EventProse) { super.setActualInstance(instance); return; @@ -361,19 +408,24 @@ public void setActualInstance(Object instance) { return; } + if (instance instanceof EventTypesSuggested) { + super.setActualInstance(instance); + return; + } + if (instance instanceof EventWarning) { super.setActualInstance(instance); return; } - throw new RuntimeException("Invalid instance type. Must be EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning"); + throw new RuntimeException("Invalid instance type. Must be EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventNamesFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventTypesSuggested, EventWarning"); } /** * Get the actual instance, which can be the following: - * EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning + * EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventNamesFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventTypesSuggested, EventWarning * - * @return The actual instance (EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning) + * @return The actual instance (EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventNamesFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventTypesSuggested, EventWarning) */ @SuppressWarnings("unchecked") @Override @@ -429,6 +481,18 @@ public EventDecompFinished getEventDecompFinished() throws ClassCastException { return (EventDecompFinished)super.getActualInstance(); } + /** + * Get the actual instance of `EventNamesFinished`. If the actual instance is not `EventNamesFinished`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `EventNamesFinished` + * @throws ClassCastException if the instance is not `EventNamesFinished` + */ + @SuppressWarnings("unchecked") + public EventNamesFinished getEventNamesFinished() throws ClassCastException { + return (EventNamesFinished)super.getActualInstance(); + } + /** * Get the actual instance of `EventProse`. If the actual instance is not `EventProse`, * the ClassCastException will be thrown. @@ -477,6 +541,18 @@ public EventSourceReset getEventSourceReset() throws ClassCastException { return (EventSourceReset)super.getActualInstance(); } + /** + * Get the actual instance of `EventTypesSuggested`. If the actual instance is not `EventTypesSuggested`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `EventTypesSuggested` + * @throws ClassCastException if the instance is not `EventTypesSuggested` + */ + @SuppressWarnings("unchecked") + public EventTypesSuggested getEventTypesSuggested() throws ClassCastException { + return (EventTypesSuggested)super.getActualInstance(); + } + /** * Get the actual instance of `EventWarning`. If the actual instance is not `EventWarning`, * the ClassCastException will be thrown. @@ -531,6 +607,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventDecompFinished failed with `%s`.", e.getMessage())); // continue to the next one } + // validate the json string with EventNamesFinished + try { + EventNamesFinished.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventNamesFinished failed with `%s`.", e.getMessage())); + // continue to the next one + } // validate the json string with EventProse try { EventProse.validateJsonElement(jsonElement); @@ -563,6 +647,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSourceReset failed with `%s`.", e.getMessage())); // continue to the next one } + // validate the json string with EventTypesSuggested + try { + EventTypesSuggested.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTypesSuggested failed with `%s`.", e.getMessage())); + // continue to the next one + } // validate the json string with EventWarning try { EventWarning.validateJsonElement(jsonElement); @@ -572,7 +664,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // continue to the next one } if (validCount != 1) { - throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for ServerSentEventsInner1 with oneOf schemas: EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for ServerSentEventsInner1 with oneOf schemas: EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventNamesFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventTypesSuggested, EventWarning. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); } } diff --git a/src/main/java/ai/reveng/model/ServiceEntry.java b/src/main/java/ai/reveng/model/ServiceEntry.java index 869a5a61..63917b92 100644 --- a/src/main/java/ai/reveng/model/ServiceEntry.java +++ b/src/main/java/ai/reveng/model/ServiceEntry.java @@ -207,6 +207,50 @@ public void setStartType(@javax.annotation.Nullable String startType) { this.startType = startType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ServiceEntry instance itself + */ + public ServiceEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -223,7 +267,8 @@ public boolean equals(Object o) { Objects.equals(this.events, serviceEntry.events) && Objects.equals(this.name, serviceEntry.name) && Objects.equals(this.serviceType, serviceEntry.serviceType) && - Objects.equals(this.startType, serviceEntry.startType); + Objects.equals(this.startType, serviceEntry.startType)&& + Objects.equals(this.additionalProperties, serviceEntry.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -232,7 +277,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaryPath, displayName, events, name, serviceType, startType); + return Objects.hash(binaryPath, displayName, events, name, serviceType, startType, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -252,6 +297,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" serviceType: ").append(toIndentedString(serviceType)).append("\n"); sb.append(" startType: ").append(toIndentedString(startType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -288,14 +334,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ServiceEntry is not found in the empty JSON string", ServiceEntry.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ServiceEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ServiceEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("binary_path") != null && !jsonObj.get("binary_path").isJsonNull()) && !jsonObj.get("binary_path").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_path").toString())); @@ -303,19 +341,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("display_name") != null && !jsonObj.get("display_name").isJsonNull()) && !jsonObj.get("display_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `display_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display_name").toString())); } - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { - JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); - if (jsonArrayevents != null) { - // ensure the json data is an array - if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); - } - - // validate the optional field `events` (array) - for (int i = 0; i < jsonArrayevents.size(); i++) { - ReportEvent.validateJsonElement(jsonArrayevents.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); } if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -343,6 +371,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ServiceEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -350,7 +400,28 @@ public void write(JsonWriter out, ServiceEntry value) throws IOException { public ServiceEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ServiceEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SignatureParameterEntry.java b/src/main/java/ai/reveng/model/SignatureParameterEntry.java index 8d666de2..ee725921 100644 --- a/src/main/java/ai/reveng/model/SignatureParameterEntry.java +++ b/src/main/java/ai/reveng/model/SignatureParameterEntry.java @@ -172,6 +172,50 @@ public void setStorage(@javax.annotation.Nullable SignatureStorageEntry storage) this.storage = storage; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SignatureParameterEntry instance itself + */ + public SignatureParameterEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -187,12 +231,13 @@ public boolean equals(Object o) { Objects.equals(this.dataTypeId, signatureParameterEntry.dataTypeId) && Objects.equals(this.name, signatureParameterEntry.name) && Objects.equals(this.ordinal, signatureParameterEntry.ordinal) && - Objects.equals(this.storage, signatureParameterEntry.storage); + Objects.equals(this.storage, signatureParameterEntry.storage)&& + Objects.equals(this.additionalProperties, signatureParameterEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(bitLength, dataTypeId, name, ordinal, storage); + return Objects.hash(bitLength, dataTypeId, name, ordinal, storage, additionalProperties); } @Override @@ -204,6 +249,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" ordinal: ").append(toIndentedString(ordinal)).append("\n"); sb.append(" storage: ").append(toIndentedString(storage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -241,14 +287,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SignatureParameterEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SignatureParameterEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SignatureParameterEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -259,10 +297,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `storage` - if (jsonObj.get("storage") != null && !jsonObj.get("storage").isJsonNull()) { - SignatureStorageEntry.validateJsonElement(jsonObj.get("storage")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -280,6 +314,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SignatureParameterEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -287,7 +343,28 @@ public void write(JsonWriter out, SignatureParameterEntry value) throws IOExcept public SignatureParameterEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SignatureParameterEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SignatureParameterInput.java b/src/main/java/ai/reveng/model/SignatureParameterInput.java index 538f5293..9eb5cffa 100644 --- a/src/main/java/ai/reveng/model/SignatureParameterInput.java +++ b/src/main/java/ai/reveng/model/SignatureParameterInput.java @@ -175,6 +175,50 @@ public void setStorage(@javax.annotation.Nullable SignatureStorageInput storage) this.storage = storage; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SignatureParameterInput instance itself + */ + public SignatureParameterInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -190,12 +234,13 @@ public boolean equals(Object o) { Objects.equals(this.dataTypeId, signatureParameterInput.dataTypeId) && Objects.equals(this.name, signatureParameterInput.name) && Objects.equals(this.ordinal, signatureParameterInput.ordinal) && - Objects.equals(this.storage, signatureParameterInput.storage); + Objects.equals(this.storage, signatureParameterInput.storage)&& + Objects.equals(this.additionalProperties, signatureParameterInput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(bitLength, dataTypeId, name, ordinal, storage); + return Objects.hash(bitLength, dataTypeId, name, ordinal, storage, additionalProperties); } @Override @@ -207,6 +252,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" ordinal: ").append(toIndentedString(ordinal)).append("\n"); sb.append(" storage: ").append(toIndentedString(storage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -244,14 +290,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SignatureParameterInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SignatureParameterInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SignatureParameterInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -262,10 +300,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `storage` - if (jsonObj.get("storage") != null && !jsonObj.get("storage").isJsonNull()) { - SignatureStorageInput.validateJsonElement(jsonObj.get("storage")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -283,6 +317,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SignatureParameterInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -290,7 +346,28 @@ public void write(JsonWriter out, SignatureParameterInput value) throws IOExcept public SignatureParameterInput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SignatureParameterInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SignatureStorageEntry.java b/src/main/java/ai/reveng/model/SignatureStorageEntry.java index 07d28d07..528ae897 100644 --- a/src/main/java/ai/reveng/model/SignatureStorageEntry.java +++ b/src/main/java/ai/reveng/model/SignatureStorageEntry.java @@ -99,6 +99,50 @@ public void setLocation(@javax.annotation.Nullable String location) { this.location = location; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SignatureStorageEntry instance itself + */ + public SignatureStorageEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } SignatureStorageEntry signatureStorageEntry = (SignatureStorageEntry) o; return Objects.equals(this.kind, signatureStorageEntry.kind) && - Objects.equals(this.location, signatureStorageEntry.location); + Objects.equals(this.location, signatureStorageEntry.location)&& + Objects.equals(this.additionalProperties, signatureStorageEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(kind, location); + return Objects.hash(kind, location, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class SignatureStorageEntry {\n"); sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -161,14 +207,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SignatureStorageEntry is not found in the empty JSON string", SignatureStorageEntry.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SignatureStorageEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SignatureStorageEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); @@ -193,6 +231,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SignatureStorageEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -200,7 +260,28 @@ public void write(JsonWriter out, SignatureStorageEntry value) throws IOExceptio public SignatureStorageEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SignatureStorageEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SignatureStorageInput.java b/src/main/java/ai/reveng/model/SignatureStorageInput.java index 57716971..1475a34e 100644 --- a/src/main/java/ai/reveng/model/SignatureStorageInput.java +++ b/src/main/java/ai/reveng/model/SignatureStorageInput.java @@ -99,6 +99,50 @@ public void setLocation(@javax.annotation.Nullable String location) { this.location = location; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SignatureStorageInput instance itself + */ + public SignatureStorageInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -111,12 +155,13 @@ public boolean equals(Object o) { } SignatureStorageInput signatureStorageInput = (SignatureStorageInput) o; return Objects.equals(this.kind, signatureStorageInput.kind) && - Objects.equals(this.location, signatureStorageInput.location); + Objects.equals(this.location, signatureStorageInput.location)&& + Objects.equals(this.additionalProperties, signatureStorageInput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(kind, location); + return Objects.hash(kind, location, additionalProperties); } @Override @@ -125,6 +170,7 @@ public String toString() { sb.append("class SignatureStorageInput {\n"); sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -161,14 +207,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SignatureStorageInput is not found in the empty JSON string", SignatureStorageInput.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SignatureStorageInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SignatureStorageInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); @@ -193,6 +231,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SignatureStorageInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -200,7 +260,28 @@ public void write(JsonWriter out, SignatureStorageInput value) throws IOExceptio public SignatureStorageInput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SignatureStorageInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SourceDeltaEvent.java b/src/main/java/ai/reveng/model/SourceDeltaEvent.java index af85414e..94bd8d1f 100644 --- a/src/main/java/ai/reveng/model/SourceDeltaEvent.java +++ b/src/main/java/ai/reveng/model/SourceDeltaEvent.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SourceDeltaEvent instance itself + */ + public SourceDeltaEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.attempt, sourceDeltaEvent.attempt) && Objects.equals(this.content, sourceDeltaEvent.content) && Objects.equals(this.seq, sourceDeltaEvent.seq) && - Objects.equals(this.type, sourceDeltaEvent.type); + Objects.equals(this.type, sourceDeltaEvent.type)&& + Objects.equals(this.additionalProperties, sourceDeltaEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(attempt, content, seq, type); + return Objects.hash(attempt, content, seq, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" content: ").append(toIndentedString(content)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SourceDeltaEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SourceDeltaEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SourceDeltaEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SourceDeltaEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SourceDeltaEvent value) throws IOException { public SourceDeltaEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SourceDeltaEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SourceResetEvent.java b/src/main/java/ai/reveng/model/SourceResetEvent.java index d8ab225c..29cff99e 100644 --- a/src/main/java/ai/reveng/model/SourceResetEvent.java +++ b/src/main/java/ai/reveng/model/SourceResetEvent.java @@ -123,6 +123,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SourceResetEvent instance itself + */ + public SourceResetEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -136,12 +180,13 @@ public boolean equals(Object o) { SourceResetEvent sourceResetEvent = (SourceResetEvent) o; return Objects.equals(this.attempt, sourceResetEvent.attempt) && Objects.equals(this.seq, sourceResetEvent.seq) && - Objects.equals(this.type, sourceResetEvent.type); + Objects.equals(this.type, sourceResetEvent.type)&& + Objects.equals(this.additionalProperties, sourceResetEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(attempt, seq, type); + return Objects.hash(attempt, seq, type, additionalProperties); } @Override @@ -151,6 +196,7 @@ public String toString() { sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -188,14 +234,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SourceResetEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SourceResetEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SourceResetEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -223,6 +261,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SourceResetEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -230,7 +290,28 @@ public void write(JsonWriter out, SourceResetEvent value) throws IOException { public SourceResetEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SourceResetEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventContextCompactedData.java b/src/main/java/ai/reveng/model/SseEventContextCompactedData.java index 7e62a9c5..f62d7e51 100644 --- a/src/main/java/ai/reveng/model/SseEventContextCompactedData.java +++ b/src/main/java/ai/reveng/model/SseEventContextCompactedData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventContextCompactedData instance itself + */ + public SseEventContextCompactedData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventContextCompactedData.data) && Objects.equals(this.eventId, sseEventContextCompactedData.eventId) && Objects.equals(this.sourceRunId, sseEventContextCompactedData.sourceRunId) && - Objects.equals(this.type, sseEventContextCompactedData.type); + Objects.equals(this.type, sseEventContextCompactedData.type)&& + Objects.equals(this.additionalProperties, sseEventContextCompactedData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventContextCompactedData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventContextCompactedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventContextCompactedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventContextCompactedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventContextCompactedData value) throws IOE public SseEventContextCompactedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventContextCompactedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunCancelledData.java b/src/main/java/ai/reveng/model/SseEventRunCancelledData.java index d933b117..13fdbc15 100644 --- a/src/main/java/ai/reveng/model/SseEventRunCancelledData.java +++ b/src/main/java/ai/reveng/model/SseEventRunCancelledData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventRunCancelledData instance itself + */ + public SseEventRunCancelledData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunCancelledData.data) && Objects.equals(this.eventId, sseEventRunCancelledData.eventId) && Objects.equals(this.sourceRunId, sseEventRunCancelledData.sourceRunId) && - Objects.equals(this.type, sseEventRunCancelledData.type); + Objects.equals(this.type, sseEventRunCancelledData.type)&& + Objects.equals(this.additionalProperties, sseEventRunCancelledData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventRunCancelledData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunCancelledData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunCancelledData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunCancelledData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventRunCancelledData value) throws IOExcep public SseEventRunCancelledData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventRunCancelledData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunErrorData.java b/src/main/java/ai/reveng/model/SseEventRunErrorData.java index b46fa790..dd875d4c 100644 --- a/src/main/java/ai/reveng/model/SseEventRunErrorData.java +++ b/src/main/java/ai/reveng/model/SseEventRunErrorData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventRunErrorData instance itself + */ + public SseEventRunErrorData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunErrorData.data) && Objects.equals(this.eventId, sseEventRunErrorData.eventId) && Objects.equals(this.sourceRunId, sseEventRunErrorData.sourceRunId) && - Objects.equals(this.type, sseEventRunErrorData.type); + Objects.equals(this.type, sseEventRunErrorData.type)&& + Objects.equals(this.additionalProperties, sseEventRunErrorData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventRunErrorData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunErrorData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunErrorData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunErrorData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventRunErrorData value) throws IOException public SseEventRunErrorData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventRunErrorData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunFinishedData.java b/src/main/java/ai/reveng/model/SseEventRunFinishedData.java index b573d2b4..85d100ba 100644 --- a/src/main/java/ai/reveng/model/SseEventRunFinishedData.java +++ b/src/main/java/ai/reveng/model/SseEventRunFinishedData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventRunFinishedData instance itself + */ + public SseEventRunFinishedData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunFinishedData.data) && Objects.equals(this.eventId, sseEventRunFinishedData.eventId) && Objects.equals(this.sourceRunId, sseEventRunFinishedData.sourceRunId) && - Objects.equals(this.type, sseEventRunFinishedData.type); + Objects.equals(this.type, sseEventRunFinishedData.type)&& + Objects.equals(this.additionalProperties, sseEventRunFinishedData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventRunFinishedData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunFinishedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunFinishedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunFinishedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventRunFinishedData value) throws IOExcept public SseEventRunFinishedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventRunFinishedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunStartedData.java b/src/main/java/ai/reveng/model/SseEventRunStartedData.java index f69526ca..1ddbb11e 100644 --- a/src/main/java/ai/reveng/model/SseEventRunStartedData.java +++ b/src/main/java/ai/reveng/model/SseEventRunStartedData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventRunStartedData instance itself + */ + public SseEventRunStartedData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunStartedData.data) && Objects.equals(this.eventId, sseEventRunStartedData.eventId) && Objects.equals(this.sourceRunId, sseEventRunStartedData.sourceRunId) && - Objects.equals(this.type, sseEventRunStartedData.type); + Objects.equals(this.type, sseEventRunStartedData.type)&& + Objects.equals(this.additionalProperties, sseEventRunStartedData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventRunStartedData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunStartedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunStartedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunStartedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventRunStartedData value) throws IOExcepti public SseEventRunStartedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventRunStartedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventStepFinishedData.java b/src/main/java/ai/reveng/model/SseEventStepFinishedData.java index e4fabb46..c22667cf 100644 --- a/src/main/java/ai/reveng/model/SseEventStepFinishedData.java +++ b/src/main/java/ai/reveng/model/SseEventStepFinishedData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventStepFinishedData instance itself + */ + public SseEventStepFinishedData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventStepFinishedData.data) && Objects.equals(this.eventId, sseEventStepFinishedData.eventId) && Objects.equals(this.sourceRunId, sseEventStepFinishedData.sourceRunId) && - Objects.equals(this.type, sseEventStepFinishedData.type); + Objects.equals(this.type, sseEventStepFinishedData.type)&& + Objects.equals(this.additionalProperties, sseEventStepFinishedData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventStepFinishedData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventStepFinishedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventStepFinishedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventStepFinishedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventStepFinishedData value) throws IOExcep public SseEventStepFinishedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventStepFinishedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventStepStartedData.java b/src/main/java/ai/reveng/model/SseEventStepStartedData.java index ec2d8f73..7a337479 100644 --- a/src/main/java/ai/reveng/model/SseEventStepStartedData.java +++ b/src/main/java/ai/reveng/model/SseEventStepStartedData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventStepStartedData instance itself + */ + public SseEventStepStartedData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventStepStartedData.data) && Objects.equals(this.eventId, sseEventStepStartedData.eventId) && Objects.equals(this.sourceRunId, sseEventStepStartedData.sourceRunId) && - Objects.equals(this.type, sseEventStepStartedData.type); + Objects.equals(this.type, sseEventStepStartedData.type)&& + Objects.equals(this.additionalProperties, sseEventStepStartedData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventStepStartedData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventStepStartedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventStepStartedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventStepStartedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventStepStartedData value) throws IOExcept public SseEventStepStartedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventStepStartedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java b/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java index e4beeddb..70ede3b7 100644 --- a/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java +++ b/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventTextMessageContentData instance itself + */ + public SseEventTextMessageContentData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTextMessageContentData.data) && Objects.equals(this.eventId, sseEventTextMessageContentData.eventId) && Objects.equals(this.sourceRunId, sseEventTextMessageContentData.sourceRunId) && - Objects.equals(this.type, sseEventTextMessageContentData.type); + Objects.equals(this.type, sseEventTextMessageContentData.type)&& + Objects.equals(this.additionalProperties, sseEventTextMessageContentData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventTextMessageContentData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTextMessageContentData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTextMessageContentData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTextMessageContentData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventTextMessageContentData value) throws I public SseEventTextMessageContentData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventTextMessageContentData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java b/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java index a6960476..84f01920 100644 --- a/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java +++ b/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventTextMessageEndData instance itself + */ + public SseEventTextMessageEndData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTextMessageEndData.data) && Objects.equals(this.eventId, sseEventTextMessageEndData.eventId) && Objects.equals(this.sourceRunId, sseEventTextMessageEndData.sourceRunId) && - Objects.equals(this.type, sseEventTextMessageEndData.type); + Objects.equals(this.type, sseEventTextMessageEndData.type)&& + Objects.equals(this.additionalProperties, sseEventTextMessageEndData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventTextMessageEndData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTextMessageEndData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTextMessageEndData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTextMessageEndData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventTextMessageEndData value) throws IOExc public SseEventTextMessageEndData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventTextMessageEndData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java b/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java index c82339a0..0326d8d5 100644 --- a/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java +++ b/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventTextMessageStartData instance itself + */ + public SseEventTextMessageStartData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTextMessageStartData.data) && Objects.equals(this.eventId, sseEventTextMessageStartData.eventId) && Objects.equals(this.sourceRunId, sseEventTextMessageStartData.sourceRunId) && - Objects.equals(this.type, sseEventTextMessageStartData.type); + Objects.equals(this.type, sseEventTextMessageStartData.type)&& + Objects.equals(this.additionalProperties, sseEventTextMessageStartData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventTextMessageStartData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTextMessageStartData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTextMessageStartData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTextMessageStartData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventTextMessageStartData value) throws IOE public SseEventTextMessageStartData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventTextMessageStartData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java b/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java index 5ec54178..9cadd2c2 100644 --- a/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java +++ b/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventTitleUpdatedData instance itself + */ + public SseEventTitleUpdatedData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTitleUpdatedData.data) && Objects.equals(this.eventId, sseEventTitleUpdatedData.eventId) && Objects.equals(this.sourceRunId, sseEventTitleUpdatedData.sourceRunId) && - Objects.equals(this.type, sseEventTitleUpdatedData.type); + Objects.equals(this.type, sseEventTitleUpdatedData.type)&& + Objects.equals(this.additionalProperties, sseEventTitleUpdatedData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventTitleUpdatedData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTitleUpdatedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTitleUpdatedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTitleUpdatedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventTitleUpdatedData value) throws IOExcep public SseEventTitleUpdatedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventTitleUpdatedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java b/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java index 3395bd14..49116e1c 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventToolCallArgsDeltaData instance itself + */ + public SseEventToolCallArgsDeltaData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallArgsDeltaData.data) && Objects.equals(this.eventId, sseEventToolCallArgsDeltaData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallArgsDeltaData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallArgsDeltaData.type); + Objects.equals(this.type, sseEventToolCallArgsDeltaData.type)&& + Objects.equals(this.additionalProperties, sseEventToolCallArgsDeltaData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventToolCallArgsDeltaData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallArgsDeltaData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallArgsDeltaData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallArgsDeltaData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventToolCallArgsDeltaData value) throws IO public SseEventToolCallArgsDeltaData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventToolCallArgsDeltaData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallEndData.java b/src/main/java/ai/reveng/model/SseEventToolCallEndData.java index a885cf9b..953ada71 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallEndData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallEndData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventToolCallEndData instance itself + */ + public SseEventToolCallEndData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallEndData.data) && Objects.equals(this.eventId, sseEventToolCallEndData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallEndData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallEndData.type); + Objects.equals(this.type, sseEventToolCallEndData.type)&& + Objects.equals(this.additionalProperties, sseEventToolCallEndData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventToolCallEndData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallEndData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallEndData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallEndData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventToolCallEndData value) throws IOExcept public SseEventToolCallEndData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventToolCallEndData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallProgressData.java b/src/main/java/ai/reveng/model/SseEventToolCallProgressData.java index 2f77f3b9..b1d4576e 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallProgressData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallProgressData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventToolCallProgressData instance itself + */ + public SseEventToolCallProgressData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallProgressData.data) && Objects.equals(this.eventId, sseEventToolCallProgressData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallProgressData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallProgressData.type); + Objects.equals(this.type, sseEventToolCallProgressData.type)&& + Objects.equals(this.additionalProperties, sseEventToolCallProgressData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventToolCallProgressData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallProgressData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallProgressData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallProgressData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventToolCallProgressData value) throws IOE public SseEventToolCallProgressData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventToolCallProgressData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallResultData.java b/src/main/java/ai/reveng/model/SseEventToolCallResultData.java index 69a18e67..eb64c266 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallResultData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallResultData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventToolCallResultData instance itself + */ + public SseEventToolCallResultData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallResultData.data) && Objects.equals(this.eventId, sseEventToolCallResultData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallResultData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallResultData.type); + Objects.equals(this.type, sseEventToolCallResultData.type)&& + Objects.equals(this.additionalProperties, sseEventToolCallResultData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventToolCallResultData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallResultData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallResultData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallResultData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventToolCallResultData value) throws IOExc public SseEventToolCallResultData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventToolCallResultData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallStartData.java b/src/main/java/ai/reveng/model/SseEventToolCallStartData.java index 7b026ca2..58c977e2 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallStartData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallStartData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventToolCallStartData instance itself + */ + public SseEventToolCallStartData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallStartData.data) && Objects.equals(this.eventId, sseEventToolCallStartData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallStartData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallStartData.type); + Objects.equals(this.type, sseEventToolCallStartData.type)&& + Objects.equals(this.additionalProperties, sseEventToolCallStartData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventToolCallStartData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallStartData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallStartData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallStartData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventToolCallStartData value) throws IOExce public SseEventToolCallStartData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventToolCallStartData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java b/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java index f23b8cc2..83c5b468 100644 --- a/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java +++ b/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java @@ -147,6 +147,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SseEventToolConfirmationRequiredData instance itself + */ + public SseEventToolConfirmationRequiredData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -161,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolConfirmationRequiredData.data) && Objects.equals(this.eventId, sseEventToolConfirmationRequiredData.eventId) && Objects.equals(this.sourceRunId, sseEventToolConfirmationRequiredData.sourceRunId) && - Objects.equals(this.type, sseEventToolConfirmationRequiredData.type); + Objects.equals(this.type, sseEventToolConfirmationRequiredData.type)&& + Objects.equals(this.additionalProperties, sseEventToolConfirmationRequiredData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type); + return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SseEventToolConfirmationRequiredData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolConfirmationRequiredData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolConfirmationRequiredData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolConfirmationRequiredData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, SseEventToolConfirmationRequiredData value) th public SseEventToolConfirmationRequiredData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SseEventToolConfirmationRequiredData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StartBatchMatchingInputBody.java b/src/main/java/ai/reveng/model/StartBatchMatchingInputBody.java index 91b8e04f..39f63948 100644 --- a/src/main/java/ai/reveng/model/StartBatchMatchingInputBody.java +++ b/src/main/java/ai/reveng/model/StartBatchMatchingInputBody.java @@ -67,6 +67,11 @@ public class StartBatchMatchingInputBody { @javax.annotation.Nullable private Double minSimilarity; + public static final String SERIALIZED_NAME_NO_CACHE = "no_cache"; + @SerializedName(SERIALIZED_NAME_NO_CACHE) + @javax.annotation.Nullable + private Boolean noCache; + public static final String SERIALIZED_NAME_RESULTS_PER_FUNCTION = "results_per_function"; @SerializedName(SERIALIZED_NAME_RESULTS_PER_FUNCTION) @javax.annotation.Nullable @@ -150,6 +155,25 @@ public void setMinSimilarity(@javax.annotation.Nullable Double minSimilarity) { } + public StartBatchMatchingInputBody noCache(@javax.annotation.Nullable Boolean noCache) { + this.noCache = noCache; + return this; + } + + /** + * By default a completed matching run is reused per binary (that binary reports status=COMPLETED, no new run). Set true to force fresh runs for every binary. + * @return noCache + */ + @javax.annotation.Nullable + public Boolean getNoCache() { + return noCache; + } + + public void setNoCache(@javax.annotation.Nullable Boolean noCache) { + this.noCache = noCache; + } + + public StartBatchMatchingInputBody resultsPerFunction(@javax.annotation.Nullable Long resultsPerFunction) { this.resultsPerFunction = resultsPerFunction; return this; @@ -228,6 +252,7 @@ public boolean equals(Object o) { return Objects.equals(this.binaryIds, startBatchMatchingInputBody.binaryIds) && Objects.equals(this.debugTypes, startBatchMatchingInputBody.debugTypes) && Objects.equals(this.minSimilarity, startBatchMatchingInputBody.minSimilarity) && + Objects.equals(this.noCache, startBatchMatchingInputBody.noCache) && Objects.equals(this.resultsPerFunction, startBatchMatchingInputBody.resultsPerFunction)&& Objects.equals(this.additionalProperties, startBatchMatchingInputBody.additionalProperties); } @@ -238,7 +263,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaryIds, debugTypes, minSimilarity, resultsPerFunction, additionalProperties); + return Objects.hash(binaryIds, debugTypes, minSimilarity, noCache, resultsPerFunction, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -255,6 +280,7 @@ public String toString() { sb.append(" binaryIds: ").append(toIndentedString(binaryIds)).append("\n"); sb.append(" debugTypes: ").append(toIndentedString(debugTypes)).append("\n"); sb.append(" minSimilarity: ").append(toIndentedString(minSimilarity)).append("\n"); + sb.append(" noCache: ").append(toIndentedString(noCache)).append("\n"); sb.append(" resultsPerFunction: ").append(toIndentedString(resultsPerFunction)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); @@ -275,7 +301,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("binary_ids", "debug_types", "min_similarity", "results_per_function")); + openapiFields = new HashSet(Arrays.asList("binary_ids", "debug_types", "min_similarity", "no_cache", "results_per_function")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("binary_ids")); diff --git a/src/main/java/ai/reveng/model/StartMatchingForAnalysisInputBody.java b/src/main/java/ai/reveng/model/StartMatchingForAnalysisInputBody.java index 5ed77741..6f1d92af 100644 --- a/src/main/java/ai/reveng/model/StartMatchingForAnalysisInputBody.java +++ b/src/main/java/ai/reveng/model/StartMatchingForAnalysisInputBody.java @@ -265,10 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `filters` - if (jsonObj.get("filters") != null && !jsonObj.get("filters").isJsonNull()) { - MatchFilters.validateJsonElement(jsonObj.get("filters")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/ai/reveng/model/StartMatchingForFunctionsInputBody.java b/src/main/java/ai/reveng/model/StartMatchingForFunctionsInputBody.java index b354ee39..b5a0cc93 100644 --- a/src/main/java/ai/reveng/model/StartMatchingForFunctionsInputBody.java +++ b/src/main/java/ai/reveng/model/StartMatchingForFunctionsInputBody.java @@ -334,10 +334,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `filters` - if (jsonObj.get("filters") != null && !jsonObj.get("filters").isJsonNull()) { - MatchFilters.validateJsonElement(jsonObj.get("filters")); - } // ensure the required json array is present if (jsonObj.get("function_ids") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); diff --git a/src/main/java/ai/reveng/model/StartMatchingOutputBody.java b/src/main/java/ai/reveng/model/StartMatchingOutputBody.java index 6a70827e..1da9aae8 100644 --- a/src/main/java/ai/reveng/model/StartMatchingOutputBody.java +++ b/src/main/java/ai/reveng/model/StartMatchingOutputBody.java @@ -62,6 +62,11 @@ public class StartMatchingOutputBody { @javax.annotation.Nullable private List messages; + public static final String SERIALIZED_NAME_PERCENT = "percent"; + @SerializedName(SERIALIZED_NAME_PERCENT) + @javax.annotation.Nonnull + private Long percent; + /** * Current workflow status */ @@ -137,11 +142,31 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nonnull private Long stepIndex; + public static final String SERIALIZED_NAME_STEP_SHARE = "step_share"; + @SerializedName(SERIALIZED_NAME_STEP_SHARE) + @javax.annotation.Nonnull + private Long stepShare; + public static final String SERIALIZED_NAME_STEPS_TOTAL = "steps_total"; @SerializedName(SERIALIZED_NAME_STEPS_TOTAL) @javax.annotation.Nonnull private Long stepsTotal; + public static final String SERIALIZED_NAME_SUB_STEP = "sub_step"; + @SerializedName(SERIALIZED_NAME_SUB_STEP) + @javax.annotation.Nullable + private String subStep; + + public static final String SERIALIZED_NAME_SUB_STEP_DONE = "sub_step_done"; + @SerializedName(SERIALIZED_NAME_SUB_STEP_DONE) + @javax.annotation.Nullable + private Long subStepDone; + + public static final String SERIALIZED_NAME_SUB_STEP_TOTAL = "sub_step_total"; + @SerializedName(SERIALIZED_NAME_SUB_STEP_TOTAL) + @javax.annotation.Nullable + private Long subStepTotal; + public StartMatchingOutputBody() { } @@ -191,6 +216,25 @@ public void setMessages(@javax.annotation.Nullable List message } + public StartMatchingOutputBody percent(@javax.annotation.Nonnull Long percent) { + this.percent = percent; + return this; + } + + /** + * Overall completion as a percentage, weighted by step duration + * @return percent + */ + @javax.annotation.Nonnull + public Long getPercent() { + return percent; + } + + public void setPercent(@javax.annotation.Nonnull Long percent) { + this.percent = percent; + } + + public StartMatchingOutputBody status(@javax.annotation.Nonnull StatusEnum status) { this.status = status; return this; @@ -248,6 +292,25 @@ public void setStepIndex(@javax.annotation.Nonnull Long stepIndex) { } + public StartMatchingOutputBody stepShare(@javax.annotation.Nonnull Long stepShare) { + this.stepShare = stepShare; + return this; + } + + /** + * Percentage points the current step contributes when it completes + * @return stepShare + */ + @javax.annotation.Nonnull + public Long getStepShare() { + return stepShare; + } + + public void setStepShare(@javax.annotation.Nonnull Long stepShare) { + this.stepShare = stepShare; + } + + public StartMatchingOutputBody stepsTotal(@javax.annotation.Nonnull Long stepsTotal) { this.stepsTotal = stepsTotal; return this; @@ -267,6 +330,107 @@ public void setStepsTotal(@javax.annotation.Nonnull Long stepsTotal) { } + public StartMatchingOutputBody subStep(@javax.annotation.Nullable String subStep) { + this.subStep = subStep; + return this; + } + + /** + * Phase within the current step, when the step reports one + * @return subStep + */ + @javax.annotation.Nullable + public String getSubStep() { + return subStep; + } + + public void setSubStep(@javax.annotation.Nullable String subStep) { + this.subStep = subStep; + } + + + public StartMatchingOutputBody subStepDone(@javax.annotation.Nullable Long subStepDone) { + this.subStepDone = subStepDone; + return this; + } + + /** + * Items completed in the current phase + * @return subStepDone + */ + @javax.annotation.Nullable + public Long getSubStepDone() { + return subStepDone; + } + + public void setSubStepDone(@javax.annotation.Nullable Long subStepDone) { + this.subStepDone = subStepDone; + } + + + public StartMatchingOutputBody subStepTotal(@javax.annotation.Nullable Long subStepTotal) { + this.subStepTotal = subStepTotal; + return this; + } + + /** + * Items the current phase will process, 0 when unknown + * @return subStepTotal + */ + @javax.annotation.Nullable + public Long getSubStepTotal() { + return subStepTotal; + } + + public void setSubStepTotal(@javax.annotation.Nullable Long subStepTotal) { + this.subStepTotal = subStepTotal; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StartMatchingOutputBody instance itself + */ + public StartMatchingOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + @Override public boolean equals(Object o) { @@ -279,15 +443,21 @@ public boolean equals(Object o) { StartMatchingOutputBody startMatchingOutputBody = (StartMatchingOutputBody) o; return Objects.equals(this.matchId, startMatchingOutputBody.matchId) && Objects.equals(this.messages, startMatchingOutputBody.messages) && + Objects.equals(this.percent, startMatchingOutputBody.percent) && Objects.equals(this.status, startMatchingOutputBody.status) && Objects.equals(this.step, startMatchingOutputBody.step) && Objects.equals(this.stepIndex, startMatchingOutputBody.stepIndex) && - Objects.equals(this.stepsTotal, startMatchingOutputBody.stepsTotal); + Objects.equals(this.stepShare, startMatchingOutputBody.stepShare) && + Objects.equals(this.stepsTotal, startMatchingOutputBody.stepsTotal) && + Objects.equals(this.subStep, startMatchingOutputBody.subStep) && + Objects.equals(this.subStepDone, startMatchingOutputBody.subStepDone) && + Objects.equals(this.subStepTotal, startMatchingOutputBody.subStepTotal)&& + Objects.equals(this.additionalProperties, startMatchingOutputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(matchId, messages, status, step, stepIndex, stepsTotal); + return Objects.hash(matchId, messages, percent, status, step, stepIndex, stepShare, stepsTotal, subStep, subStepDone, subStepTotal, additionalProperties); } @Override @@ -296,10 +466,16 @@ public String toString() { sb.append("class StartMatchingOutputBody {\n"); sb.append(" matchId: ").append(toIndentedString(matchId)).append("\n"); sb.append(" messages: ").append(toIndentedString(messages)).append("\n"); + sb.append(" percent: ").append(toIndentedString(percent)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" step: ").append(toIndentedString(step)).append("\n"); sb.append(" stepIndex: ").append(toIndentedString(stepIndex)).append("\n"); + sb.append(" stepShare: ").append(toIndentedString(stepShare)).append("\n"); sb.append(" stepsTotal: ").append(toIndentedString(stepsTotal)).append("\n"); + sb.append(" subStep: ").append(toIndentedString(subStep)).append("\n"); + sb.append(" subStepDone: ").append(toIndentedString(subStepDone)).append("\n"); + sb.append(" subStepTotal: ").append(toIndentedString(subStepTotal)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -318,10 +494,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("match_id", "messages", "status", "step", "step_index", "steps_total")); + openapiFields = new HashSet(Arrays.asList("match_id", "messages", "percent", "status", "step", "step_index", "step_share", "steps_total", "sub_step", "sub_step_done", "sub_step_total")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("match_id", "messages", "status", "step", "step_index", "steps_total")); + openapiRequiredFields = new HashSet(Arrays.asList("match_id", "messages", "percent", "status", "step", "step_index", "step_share", "steps_total")); } /** @@ -337,14 +513,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StartMatchingOutputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StartMatchingOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StartMatchingOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -355,15 +523,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("match_id").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `match_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("match_id").toString())); } - if (jsonObj.get("messages") != null && !jsonObj.get("messages").isJsonNull()) { - if (!jsonObj.get("messages").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); - } - JsonArray jsonArraymessages = jsonObj.getAsJsonArray("messages"); - // validate the required field `messages` (array) - for (int i = 0; i < jsonArraymessages.size(); i++) { - ProgressMessage.validateJsonElement(jsonArraymessages.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("messages") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("messages").isJsonArray() && !jsonObj.get("messages").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); @@ -373,6 +537,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("step").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); } + if ((jsonObj.get("sub_step") != null && !jsonObj.get("sub_step").isJsonNull()) && !jsonObj.get("sub_step").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sub_step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_step").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -390,6 +557,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StartMatchingOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -397,7 +586,28 @@ public void write(JsonWriter out, StartMatchingOutputBody value) throws IOExcept public StartMatchingOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StartMatchingOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StartupInfo.java b/src/main/java/ai/reveng/model/StartupInfo.java index b13847e3..cae32f0d 100644 --- a/src/main/java/ai/reveng/model/StartupInfo.java +++ b/src/main/java/ai/reveng/model/StartupInfo.java @@ -219,6 +219,50 @@ public void setStatus(@javax.annotation.Nullable String status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StartupInfo instance itself + */ + public StartupInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -236,12 +280,13 @@ public boolean equals(Object o) { Objects.equals(this.pid, startupInfo.pid) && Objects.equals(this.process, startupInfo.process) && Objects.equals(this.processName, startupInfo.processName) && - Objects.equals(this.status, startupInfo.status); + Objects.equals(this.status, startupInfo.status)&& + Objects.equals(this.additionalProperties, startupInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(arguments, error, errorCode, pid, process, processName, status); + return Objects.hash(arguments, error, errorCode, pid, process, processName, status, additionalProperties); } @Override @@ -255,6 +300,7 @@ public String toString() { sb.append(" process: ").append(toIndentedString(process)).append("\n"); sb.append(" processName: ").append(toIndentedString(processName)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -291,14 +337,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in StartupInfo is not found in the empty JSON string", StartupInfo.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StartupInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StartupInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("arguments") != null && !jsonObj.get("arguments").isJsonNull()) && !jsonObj.get("arguments").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `arguments` to be a primitive type in the JSON string but got `%s`", jsonObj.get("arguments").toString())); @@ -332,6 +370,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StartupInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -339,7 +399,28 @@ public void write(JsonWriter out, StartupInfo value) throws IOException { public StartupInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StartupInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Status.java b/src/main/java/ai/reveng/model/Status.java new file mode 100644 index 00000000..5c95e6a4 --- /dev/null +++ b/src/main/java/ai/reveng/model/Status.java @@ -0,0 +1,550 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Status + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Status { + /** + * Machine-readable error code, shared with synchronous API errors. + */ + @JsonAdapter(CodeEnum.Adapter.class) + public enum CodeEnum { + ACCESS_DENIED("ACCESS_DENIED"), + + ALREADY_EXISTS("ALREADY_EXISTS"), + + ANALYSIS_NOT_READY("ANALYSIS_NOT_READY"), + + BAD_REQUEST("BAD_REQUEST"), + + CLIENT_CLOSED_REQUEST("CLIENT_CLOSED_REQUEST"), + + CONFLICT("CONFLICT"), + + CONVERSATION_NOT_FOUND("CONVERSATION_NOT_FOUND"), + + DOMAIN_ALREADY_CLAIMED("DOMAIN_ALREADY_CLAIMED"), + + DOMAIN_VERIFICATION_PENDING("DOMAIN_VERIFICATION_PENDING"), + + DYNAMIC_EXECUTION_INCOMPLETE("DYNAMIC_EXECUTION_INCOMPLETE"), + + EMAIL_NOT_VERIFIED("EMAIL_NOT_VERIFIED"), + + EXTERNAL_USER("EXTERNAL_USER"), + + FORBIDDEN("FORBIDDEN"), + + GATEWAY_TIMEOUT("GATEWAY_TIMEOUT"), + + GROUP_HAS_MEMBERS("GROUP_HAS_MEMBERS"), + + INSUFFICIENT_CREDITS("INSUFFICIENT_CREDITS"), + + INTERNAL_ERROR("INTERNAL_ERROR"), + + INTERNAL_ISSUER("INTERNAL_ISSUER"), + + INVALID_CONVERSATION_ID("INVALID_CONVERSATION_ID"), + + INVALID_CREDENTIALS("INVALID_CREDENTIALS"), + + INVALID_INVITE_CODE("INVALID_INVITE_CODE"), + + INVALID_RESET_CODE("INVALID_RESET_CODE"), + + LAST_ORG_OWNER("LAST_ORG_OWNER"), + + LAST_TEAM_ADMIN("LAST_TEAM_ADMIN"), + + LAST_TEAM_MEMBER("LAST_TEAM_MEMBER"), + + LINKED_TO_ORG("LINKED_TO_ORG"), + + METHOD_NOT_ALLOWED("METHOD_NOT_ALLOWED"), + + NOT_ACCEPTABLE("NOT_ACCEPTABLE"), + + NOT_FOUND("NOT_FOUND"), + + NOT_IMPLEMENTED("NOT_IMPLEMENTED"), + + NO_ACTIVE_RUN("NO_ACTIVE_RUN"), + + NO_PENDING_CONFIRMATION("NO_PENDING_CONFIRMATION"), + + OIDC_DISCOVERY_FAILED("OIDC_DISCOVERY_FAILED"), + + PASSWORD_RESET_REQUIRED("PASSWORD_RESET_REQUIRED"), + + PAYMENT_REQUIRED("PAYMENT_REQUIRED"), + + REPORT_RENDER_FAILED("REPORT_RENDER_FAILED"), + + REQUEST_ENTITY_TOO_LARGE("REQUEST_ENTITY_TOO_LARGE"), + + RUN_ALREADY_ACTIVE("RUN_ALREADY_ACTIVE"), + + SELF_DELETION_NOT_ALLOWED("SELF_DELETION_NOT_ALLOWED"), + + SERVICE_UNAVAILABLE("SERVICE_UNAVAILABLE"), + + TOKEN_EXPIRED("TOKEN_EXPIRED"), + + TOKEN_REUSED("TOKEN_REUSED"), + + TOO_MANY_REQUESTS("TOO_MANY_REQUESTS"), + + UNAUTHORIZED("UNAUTHORIZED"), + + UNSUPPORTED_MEDIA_TYPE("UNSUPPORTED_MEDIA_TYPE"), + + VALIDATION_FAILED("VALIDATION_FAILED"), + + VERIFICATION_EXPIRED("VERIFICATION_EXPIRED"), + + VERIFICATION_NOT_FOUND("VERIFICATION_NOT_FOUND"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CodeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CodeEnum fromValue(String value) { + for (CodeEnum b : CodeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CodeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CodeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CodeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CodeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CODE = "code"; + @SerializedName(SERIALIZED_NAME_CODE) + @javax.annotation.Nonnull + private CodeEnum code; + + public static final String SERIALIZED_NAME_DETAIL = "detail"; + @SerializedName(SERIALIZED_NAME_DETAIL) + @javax.annotation.Nullable + private String detail; + + public static final String SERIALIZED_NAME_DOC_URL = "doc_url"; + @SerializedName(SERIALIZED_NAME_DOC_URL) + @javax.annotation.Nonnull + private String docUrl; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nonnull + private String message; + + public static final String SERIALIZED_NAME_RETRYABLE = "retryable"; + @SerializedName(SERIALIZED_NAME_RETRYABLE) + @javax.annotation.Nonnull + private Boolean retryable; + + public Status() { + } + + public Status code(@javax.annotation.Nonnull CodeEnum code) { + this.code = code; + return this; + } + + /** + * Machine-readable error code, shared with synchronous API errors. + * @return code + */ + @javax.annotation.Nonnull + public CodeEnum getCode() { + return code; + } + + public void setCode(@javax.annotation.Nonnull CodeEnum code) { + this.code = code; + } + + + public Status detail(@javax.annotation.Nullable String detail) { + this.detail = detail; + return this; + } + + /** + * Additional context where helpful (quota numbers, validation specifics, etc.). + * @return detail + */ + @javax.annotation.Nullable + public String getDetail() { + return detail; + } + + public void setDetail(@javax.annotation.Nullable String detail) { + this.detail = detail; + } + + + public Status docUrl(@javax.annotation.Nonnull String docUrl) { + this.docUrl = docUrl; + return this; + } + + /** + * Link to documentation explaining this error and resolution steps. + * @return docUrl + */ + @javax.annotation.Nonnull + public String getDocUrl() { + return docUrl; + } + + public void setDocUrl(@javax.annotation.Nonnull String docUrl) { + this.docUrl = docUrl; + } + + + public Status message(@javax.annotation.Nonnull String message) { + this.message = message; + return this; + } + + /** + * Brief description of the failure. + * @return message + */ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nonnull String message) { + this.message = message; + } + + + public Status retryable(@javax.annotation.Nonnull Boolean retryable) { + this.retryable = retryable; + return this; + } + + /** + * Whether retrying the operation might succeed. + * @return retryable + */ + @javax.annotation.Nonnull + public Boolean getRetryable() { + return retryable; + } + + public void setRetryable(@javax.annotation.Nonnull Boolean retryable) { + this.retryable = retryable; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Status instance itself + */ + public Status putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Status status = (Status) o; + return Objects.equals(this.code, status.code) && + Objects.equals(this.detail, status.detail) && + Objects.equals(this.docUrl, status.docUrl) && + Objects.equals(this.message, status.message) && + Objects.equals(this.retryable, status.retryable)&& + Objects.equals(this.additionalProperties, status.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, detail, docUrl, message, retryable, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Status {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" detail: ").append(toIndentedString(detail)).append("\n"); + sb.append(" docUrl: ").append(toIndentedString(docUrl)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" retryable: ").append(toIndentedString(retryable)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("code", "detail", "doc_url", "message", "retryable")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("code", "doc_url", "message", "retryable")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Status + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Status.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Status is not found in the empty JSON string", Status.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Status.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("code").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); + } + // validate the required field `code` + CodeEnum.validateJsonElement(jsonObj.get("code")); + if ((jsonObj.get("detail") != null && !jsonObj.get("detail").isJsonNull()) && !jsonObj.get("detail").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `detail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("detail").toString())); + } + if (!jsonObj.get("doc_url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `doc_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("doc_url").toString())); + } + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Status.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Status' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Status.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Status value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Status read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Status instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Status given an JSON string + * + * @param jsonString JSON string + * @return An instance of Status + * @throws IOException if the JSON string is invalid with respect to Status + */ + public static Status fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Status.class); + } + + /** + * Convert an instance of Status to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/StatusBody.java b/src/main/java/ai/reveng/model/StatusBody.java index 409c5bcc..94a94fa6 100644 --- a/src/main/java/ai/reveng/model/StatusBody.java +++ b/src/main/java/ai/reveng/model/StatusBody.java @@ -194,6 +194,50 @@ public void setStatus(@javax.annotation.Nonnull StatusEnum status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StatusBody instance itself + */ + public StatusBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -207,7 +251,8 @@ public boolean equals(Object o) { StatusBody statusBody = (StatusBody) o; return Objects.equals(this.errorMessage, statusBody.errorMessage) && Objects.equals(this.logHistory, statusBody.logHistory) && - Objects.equals(this.status, statusBody.status); + Objects.equals(this.status, statusBody.status)&& + Objects.equals(this.additionalProperties, statusBody.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -216,7 +261,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(errorMessage, logHistory, status); + return Objects.hash(errorMessage, logHistory, status, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -233,6 +278,7 @@ public String toString() { sb.append(" errorMessage: ").append(toIndentedString(errorMessage)).append("\n"); sb.append(" logHistory: ").append(toIndentedString(logHistory)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -270,14 +316,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StatusBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StatusBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StatusBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -314,6 +352,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StatusBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -321,7 +381,28 @@ public void write(JsonWriter out, StatusBody value) throws IOException { public StatusBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StatusBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StatusResponse.java b/src/main/java/ai/reveng/model/StatusResponse.java index 7abb90a6..a4e42360 100644 --- a/src/main/java/ai/reveng/model/StatusResponse.java +++ b/src/main/java/ai/reveng/model/StatusResponse.java @@ -124,6 +124,50 @@ public void setTraceId(@javax.annotation.Nullable String traceId) { this.traceId = traceId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StatusResponse instance itself + */ + public StatusResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { StatusResponse statusResponse = (StatusResponse) o; return Objects.equals(this.conversationUuid, statusResponse.conversationUuid) && Objects.equals(this.status, statusResponse.status) && - Objects.equals(this.traceId, statusResponse.traceId); + Objects.equals(this.traceId, statusResponse.traceId)&& + Objects.equals(this.additionalProperties, statusResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(conversationUuid, status, traceId); + return Objects.hash(conversationUuid, status, traceId, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" conversationUuid: ").append(toIndentedString(conversationUuid)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StatusResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StatusResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -230,6 +268,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StatusResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -237,7 +297,28 @@ public void write(JsonWriter out, StatusResponse value) throws IOException { public StatusResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StatusResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StructDataType.java b/src/main/java/ai/reveng/model/StructDataType.java index 65c9df92..7fbbd534 100644 --- a/src/main/java/ai/reveng/model/StructDataType.java +++ b/src/main/java/ai/reveng/model/StructDataType.java @@ -143,6 +143,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -366,6 +371,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public StructDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public StructDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -466,6 +490,7 @@ public boolean equals(Object o) { Objects.equals(this.name, structDataType.name) && Objects.equals(this.namespace, structDataType.namespace) && Objects.equals(this.size, structDataType.size) && + Objects.equals(this.sourceAnalysisId, structDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, structDataType.sourceFunctionId) && Objects.equals(this.sourceType, structDataType.sourceType)&& Objects.equals(this.additionalProperties, structDataType.additionalProperties); @@ -473,7 +498,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType, additionalProperties); + return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -488,6 +513,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); @@ -509,7 +535,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -535,10 +561,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `definition` - if (jsonObj.get("definition") != null && !jsonObj.get("definition").isJsonNull()) { - StructDefinition.validateJsonElement(jsonObj.get("definition")); - } if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } diff --git a/src/main/java/ai/reveng/model/StructDefinition.java b/src/main/java/ai/reveng/model/StructDefinition.java index c24e9c91..5a808e5a 100644 --- a/src/main/java/ai/reveng/model/StructDefinition.java +++ b/src/main/java/ai/reveng/model/StructDefinition.java @@ -86,6 +86,50 @@ public void setMembers(@javax.annotation.Nullable List memb this.members = members; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StructDefinition instance itself + */ + public StructDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } StructDefinition structDefinition = (StructDefinition) o; - return Objects.equals(this.members, structDefinition.members); + return Objects.equals(this.members, structDefinition.members)&& + Objects.equals(this.additionalProperties, structDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(members); + return Objects.hash(members, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class StructDefinition {\n"); sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StructDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StructDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StructDefinition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("members") != null && !jsonObj.get("members").isJsonNull()) { - if (!jsonObj.get("members").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); - } - JsonArray jsonArraymembers = jsonObj.getAsJsonArray("members"); - // validate the required field `members` (array) - for (int i = 0; i < jsonArraymembers.size(); i++) { - DataTypeMemberEntry.validateJsonElement(jsonArraymembers.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("members") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("members").isJsonArray() && !jsonObj.get("members").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StructDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, StructDefinition value) throws IOException { public StructDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StructDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Subject.java b/src/main/java/ai/reveng/model/Subject.java new file mode 100644 index 00000000..ab720048 --- /dev/null +++ b/src/main/java/ai/reveng/model/Subject.java @@ -0,0 +1,358 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.SubjectAnyOf; +import ai.reveng.model.SubjectAnyOf1; +import ai.reveng.model.SubjectAnyOf2; +import ai.reveng.model.SubjectAnyOf3; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + + + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; + +import ai.reveng.invoker.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Subject extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(Subject.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Subject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Subject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterSubjectAnyOf = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf.class)); + final TypeAdapter adapterSubjectAnyOf1 = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf1.class)); + final TypeAdapter adapterSubjectAnyOf2 = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf2.class)); + final TypeAdapter adapterSubjectAnyOf3 = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf3.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Subject value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `SubjectAnyOf` + if (value.getActualInstance() instanceof SubjectAnyOf) { + JsonElement element = adapterSubjectAnyOf.toJsonTree((SubjectAnyOf)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `SubjectAnyOf1` + if (value.getActualInstance() instanceof SubjectAnyOf1) { + JsonElement element = adapterSubjectAnyOf1.toJsonTree((SubjectAnyOf1)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `SubjectAnyOf2` + if (value.getActualInstance() instanceof SubjectAnyOf2) { + JsonElement element = adapterSubjectAnyOf2.toJsonTree((SubjectAnyOf2)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `SubjectAnyOf3` + if (value.getActualInstance() instanceof SubjectAnyOf3) { + JsonElement element = adapterSubjectAnyOf3.toJsonTree((SubjectAnyOf3)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: SubjectAnyOf, SubjectAnyOf1, SubjectAnyOf2, SubjectAnyOf3"); + } + + @Override + public Subject read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize SubjectAnyOf + try { + // validate the JSON object to see if any exception is thrown + SubjectAnyOf.validateJsonElement(jsonElement); + actualAdapter = adapterSubjectAnyOf; + Subject ret = new Subject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SubjectAnyOf'", e); + } + // deserialize SubjectAnyOf1 + try { + // validate the JSON object to see if any exception is thrown + SubjectAnyOf1.validateJsonElement(jsonElement); + actualAdapter = adapterSubjectAnyOf1; + Subject ret = new Subject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf1 failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SubjectAnyOf1'", e); + } + // deserialize SubjectAnyOf2 + try { + // validate the JSON object to see if any exception is thrown + SubjectAnyOf2.validateJsonElement(jsonElement); + actualAdapter = adapterSubjectAnyOf2; + Subject ret = new Subject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf2 failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SubjectAnyOf2'", e); + } + // deserialize SubjectAnyOf3 + try { + // validate the JSON object to see if any exception is thrown + SubjectAnyOf3.validateJsonElement(jsonElement); + actualAdapter = adapterSubjectAnyOf3; + Subject ret = new Subject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf3 failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SubjectAnyOf3'", e); + } + + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for Subject: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map> schemas = new HashMap>(); + + public Subject() { + super("anyOf", Boolean.FALSE); + } + + public Subject(Object o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("SubjectAnyOf", SubjectAnyOf.class); + schemas.put("SubjectAnyOf1", SubjectAnyOf1.class); + schemas.put("SubjectAnyOf2", SubjectAnyOf2.class); + schemas.put("SubjectAnyOf3", SubjectAnyOf3.class); + } + + @Override + public Map> getSchemas() { + return Subject.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * SubjectAnyOf, SubjectAnyOf1, SubjectAnyOf2, SubjectAnyOf3 + * + * It could be an instance of the 'anyOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof SubjectAnyOf) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SubjectAnyOf1) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SubjectAnyOf2) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SubjectAnyOf3) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be SubjectAnyOf, SubjectAnyOf1, SubjectAnyOf2, SubjectAnyOf3"); + } + + /** + * Get the actual instance, which can be the following: + * SubjectAnyOf, SubjectAnyOf1, SubjectAnyOf2, SubjectAnyOf3 + * + * @return The actual instance (SubjectAnyOf, SubjectAnyOf1, SubjectAnyOf2, SubjectAnyOf3) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `SubjectAnyOf`. If the actual instance is not `SubjectAnyOf`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SubjectAnyOf` + * @throws ClassCastException if the instance is not `SubjectAnyOf` + */ + public SubjectAnyOf getSubjectAnyOf() throws ClassCastException { + return (SubjectAnyOf)super.getActualInstance(); + } + + /** + * Get the actual instance of `SubjectAnyOf1`. If the actual instance is not `SubjectAnyOf1`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SubjectAnyOf1` + * @throws ClassCastException if the instance is not `SubjectAnyOf1` + */ + public SubjectAnyOf1 getSubjectAnyOf1() throws ClassCastException { + return (SubjectAnyOf1)super.getActualInstance(); + } + + /** + * Get the actual instance of `SubjectAnyOf2`. If the actual instance is not `SubjectAnyOf2`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SubjectAnyOf2` + * @throws ClassCastException if the instance is not `SubjectAnyOf2` + */ + public SubjectAnyOf2 getSubjectAnyOf2() throws ClassCastException { + return (SubjectAnyOf2)super.getActualInstance(); + } + + /** + * Get the actual instance of `SubjectAnyOf3`. If the actual instance is not `SubjectAnyOf3`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SubjectAnyOf3` + * @throws ClassCastException if the instance is not `SubjectAnyOf3` + */ + public SubjectAnyOf3 getSubjectAnyOf3() throws ClassCastException { + return (SubjectAnyOf3)super.getActualInstance(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Subject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate anyOf schemas one by one + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with SubjectAnyOf + try { + SubjectAnyOf.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with SubjectAnyOf1 + try { + SubjectAnyOf1.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf1 failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with SubjectAnyOf2 + try { + SubjectAnyOf2.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf2 failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with SubjectAnyOf3 + try { + SubjectAnyOf3.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for SubjectAnyOf3 failed with `%s`.", e.getMessage())); + // continue to the next one + } + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for Subject with anyOf schemas: SubjectAnyOf, SubjectAnyOf1, SubjectAnyOf2, SubjectAnyOf3. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + } + + /** + * Create an instance of Subject given an JSON string + * + * @param jsonString JSON string + * @return An instance of Subject + * @throws IOException if the JSON string is invalid with respect to Subject + */ + public static Subject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Subject.class); + } + + /** + * Convert an instance of Subject to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SubjectAnyOf.java b/src/main/java/ai/reveng/model/SubjectAnyOf.java new file mode 100644 index 00000000..cce7c5ac --- /dev/null +++ b/src/main/java/ai/reveng/model/SubjectAnyOf.java @@ -0,0 +1,287 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SubjectAnyOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SubjectAnyOf { + public static final String SERIALIZED_NAME_FUNCTION = "function"; + @SerializedName(SERIALIZED_NAME_FUNCTION) + @javax.annotation.Nonnull + private Integer function; + + public SubjectAnyOf() { + } + + public SubjectAnyOf function(@javax.annotation.Nonnull Integer function) { + this.function = function; + return this; + } + + /** + * Function entry address. + * minimum: 0 + * @return function + */ + @javax.annotation.Nonnull + public Integer getFunction() { + return function; + } + + public void setFunction(@javax.annotation.Nonnull Integer function) { + this.function = function; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubjectAnyOf instance itself + */ + public SubjectAnyOf putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubjectAnyOf subjectAnyOf = (SubjectAnyOf) o; + return Objects.equals(this.function, subjectAnyOf.function)&& + Objects.equals(this.additionalProperties, subjectAnyOf.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(function, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubjectAnyOf {\n"); + sb.append(" function: ").append(toIndentedString(function)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("function")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("function")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SubjectAnyOf + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SubjectAnyOf.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SubjectAnyOf is not found in the empty JSON string", SubjectAnyOf.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SubjectAnyOf.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SubjectAnyOf.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SubjectAnyOf' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SubjectAnyOf value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SubjectAnyOf read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubjectAnyOf instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SubjectAnyOf given an JSON string + * + * @param jsonString JSON string + * @return An instance of SubjectAnyOf + * @throws IOException if the JSON string is invalid with respect to SubjectAnyOf + */ + public static SubjectAnyOf fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SubjectAnyOf.class); + } + + /** + * Convert an instance of SubjectAnyOf to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SubjectAnyOf1.java b/src/main/java/ai/reveng/model/SubjectAnyOf1.java new file mode 100644 index 00000000..8c297595 --- /dev/null +++ b/src/main/java/ai/reveng/model/SubjectAnyOf1.java @@ -0,0 +1,287 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SubjectAnyOf1 + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SubjectAnyOf1 { + public static final String SERIALIZED_NAME_CALL_SITE = "call_site"; + @SerializedName(SERIALIZED_NAME_CALL_SITE) + @javax.annotation.Nonnull + private Integer callSite; + + public SubjectAnyOf1() { + } + + public SubjectAnyOf1 callSite(@javax.annotation.Nonnull Integer callSite) { + this.callSite = callSite; + return this; + } + + /** + * Get callSite + * minimum: 0 + * @return callSite + */ + @javax.annotation.Nonnull + public Integer getCallSite() { + return callSite; + } + + public void setCallSite(@javax.annotation.Nonnull Integer callSite) { + this.callSite = callSite; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubjectAnyOf1 instance itself + */ + public SubjectAnyOf1 putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubjectAnyOf1 subjectAnyOf1 = (SubjectAnyOf1) o; + return Objects.equals(this.callSite, subjectAnyOf1.callSite)&& + Objects.equals(this.additionalProperties, subjectAnyOf1.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(callSite, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubjectAnyOf1 {\n"); + sb.append(" callSite: ").append(toIndentedString(callSite)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("call_site")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("call_site")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SubjectAnyOf1 + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SubjectAnyOf1.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SubjectAnyOf1 is not found in the empty JSON string", SubjectAnyOf1.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SubjectAnyOf1.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SubjectAnyOf1.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SubjectAnyOf1' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf1.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SubjectAnyOf1 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SubjectAnyOf1 read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubjectAnyOf1 instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SubjectAnyOf1 given an JSON string + * + * @param jsonString JSON string + * @return An instance of SubjectAnyOf1 + * @throws IOException if the JSON string is invalid with respect to SubjectAnyOf1 + */ + public static SubjectAnyOf1 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SubjectAnyOf1.class); + } + + /** + * Convert an instance of SubjectAnyOf1 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SubjectAnyOf2.java b/src/main/java/ai/reveng/model/SubjectAnyOf2.java new file mode 100644 index 00000000..dce7ca02 --- /dev/null +++ b/src/main/java/ai/reveng/model/SubjectAnyOf2.java @@ -0,0 +1,287 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SubjectAnyOf2 + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SubjectAnyOf2 { + public static final String SERIALIZED_NAME_INSTRUCTION = "instruction"; + @SerializedName(SERIALIZED_NAME_INSTRUCTION) + @javax.annotation.Nonnull + private Integer instruction; + + public SubjectAnyOf2() { + } + + public SubjectAnyOf2 instruction(@javax.annotation.Nonnull Integer instruction) { + this.instruction = instruction; + return this; + } + + /** + * Get instruction + * minimum: 0 + * @return instruction + */ + @javax.annotation.Nonnull + public Integer getInstruction() { + return instruction; + } + + public void setInstruction(@javax.annotation.Nonnull Integer instruction) { + this.instruction = instruction; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubjectAnyOf2 instance itself + */ + public SubjectAnyOf2 putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubjectAnyOf2 subjectAnyOf2 = (SubjectAnyOf2) o; + return Objects.equals(this.instruction, subjectAnyOf2.instruction)&& + Objects.equals(this.additionalProperties, subjectAnyOf2.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(instruction, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubjectAnyOf2 {\n"); + sb.append(" instruction: ").append(toIndentedString(instruction)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("instruction")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("instruction")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SubjectAnyOf2 + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SubjectAnyOf2.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SubjectAnyOf2 is not found in the empty JSON string", SubjectAnyOf2.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SubjectAnyOf2.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SubjectAnyOf2.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SubjectAnyOf2' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf2.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SubjectAnyOf2 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SubjectAnyOf2 read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubjectAnyOf2 instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SubjectAnyOf2 given an JSON string + * + * @param jsonString JSON string + * @return An instance of SubjectAnyOf2 + * @throws IOException if the JSON string is invalid with respect to SubjectAnyOf2 + */ + public static SubjectAnyOf2 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SubjectAnyOf2.class); + } + + /** + * Convert an instance of SubjectAnyOf2 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SubjectAnyOf3.java b/src/main/java/ai/reveng/model/SubjectAnyOf3.java new file mode 100644 index 00000000..e1da130e --- /dev/null +++ b/src/main/java/ai/reveng/model/SubjectAnyOf3.java @@ -0,0 +1,287 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SubjectAnyOf3 + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SubjectAnyOf3 { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private Integer data; + + public SubjectAnyOf3() { + } + + public SubjectAnyOf3 data(@javax.annotation.Nonnull Integer data) { + this.data = data; + return this; + } + + /** + * Get data + * minimum: 0 + * @return data + */ + @javax.annotation.Nonnull + public Integer getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull Integer data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubjectAnyOf3 instance itself + */ + public SubjectAnyOf3 putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubjectAnyOf3 subjectAnyOf3 = (SubjectAnyOf3) o; + return Objects.equals(this.data, subjectAnyOf3.data)&& + Objects.equals(this.additionalProperties, subjectAnyOf3.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubjectAnyOf3 {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("data")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SubjectAnyOf3 + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SubjectAnyOf3.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SubjectAnyOf3 is not found in the empty JSON string", SubjectAnyOf3.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SubjectAnyOf3.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SubjectAnyOf3.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SubjectAnyOf3' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SubjectAnyOf3.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SubjectAnyOf3 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SubjectAnyOf3 read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubjectAnyOf3 instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SubjectAnyOf3 given an JSON string + * + * @param jsonString JSON string + * @return An instance of SubjectAnyOf3 + * @throws IOException if the JSON string is invalid with respect to SubjectAnyOf3 + */ + public static SubjectAnyOf3 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SubjectAnyOf3.class); + } + + /** + * Convert an instance of SubjectAnyOf3 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SubmitFeedbackInputBody.java b/src/main/java/ai/reveng/model/SubmitFeedbackInputBody.java new file mode 100644 index 00000000..a32faaf0 --- /dev/null +++ b/src/main/java/ai/reveng/model/SubmitFeedbackInputBody.java @@ -0,0 +1,347 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SubmitFeedbackInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SubmitFeedbackInputBody { + /** + * How useful the caller found this agent's output + */ + @JsonAdapter(SentimentEnum.Adapter.class) + public enum SentimentEnum { + POSITIVE("POSITIVE"), + + NEUTRAL("NEUTRAL"), + + NEGATIVE("NEGATIVE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SentimentEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SentimentEnum fromValue(String value) { + for (SentimentEnum b : SentimentEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SentimentEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SentimentEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SentimentEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SentimentEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SENTIMENT = "sentiment"; + @SerializedName(SERIALIZED_NAME_SENTIMENT) + @javax.annotation.Nonnull + private SentimentEnum sentiment; + + public SubmitFeedbackInputBody() { + } + + public SubmitFeedbackInputBody sentiment(@javax.annotation.Nonnull SentimentEnum sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * How useful the caller found this agent's output + * @return sentiment + */ + @javax.annotation.Nonnull + public SentimentEnum getSentiment() { + return sentiment; + } + + public void setSentiment(@javax.annotation.Nonnull SentimentEnum sentiment) { + this.sentiment = sentiment; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubmitFeedbackInputBody instance itself + */ + public SubmitFeedbackInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubmitFeedbackInputBody submitFeedbackInputBody = (SubmitFeedbackInputBody) o; + return Objects.equals(this.sentiment, submitFeedbackInputBody.sentiment)&& + Objects.equals(this.additionalProperties, submitFeedbackInputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(sentiment, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubmitFeedbackInputBody {\n"); + sb.append(" sentiment: ").append(toIndentedString(sentiment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("sentiment")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("sentiment")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SubmitFeedbackInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SubmitFeedbackInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SubmitFeedbackInputBody is not found in the empty JSON string", SubmitFeedbackInputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SubmitFeedbackInputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("sentiment").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sentiment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sentiment").toString())); + } + // validate the required field `sentiment` + SentimentEnum.validateJsonElement(jsonObj.get("sentiment")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SubmitFeedbackInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SubmitFeedbackInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SubmitFeedbackInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SubmitFeedbackInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SubmitFeedbackInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubmitFeedbackInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SubmitFeedbackInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of SubmitFeedbackInputBody + * @throws IOException if the JSON string is invalid with respect to SubmitFeedbackInputBody + */ + public static SubmitFeedbackInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SubmitFeedbackInputBody.class); + } + + /** + * Convert an instance of SubmitFeedbackInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SuggestedHole.java b/src/main/java/ai/reveng/model/SuggestedHole.java new file mode 100644 index 00000000..b111be34 --- /dev/null +++ b/src/main/java/ai/reveng/model/SuggestedHole.java @@ -0,0 +1,312 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SuggestedHole + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SuggestedHole { + public static final String SERIALIZED_NAME_BYTE_OFFSET = "byte_offset"; + @SerializedName(SERIALIZED_NAME_BYTE_OFFSET) + @javax.annotation.Nonnull + private Long byteOffset; + + public static final String SERIALIZED_NAME_BYTE_SIZE = "byte_size"; + @SerializedName(SERIALIZED_NAME_BYTE_SIZE) + @javax.annotation.Nonnull + private Long byteSize; + + public SuggestedHole() { + } + + public SuggestedHole byteOffset(@javax.annotation.Nonnull Long byteOffset) { + this.byteOffset = byteOffset; + return this; + } + + /** + * Get byteOffset + * @return byteOffset + */ + @javax.annotation.Nonnull + public Long getByteOffset() { + return byteOffset; + } + + public void setByteOffset(@javax.annotation.Nonnull Long byteOffset) { + this.byteOffset = byteOffset; + } + + + public SuggestedHole byteSize(@javax.annotation.Nonnull Long byteSize) { + this.byteSize = byteSize; + return this; + } + + /** + * Get byteSize + * @return byteSize + */ + @javax.annotation.Nonnull + public Long getByteSize() { + return byteSize; + } + + public void setByteSize(@javax.annotation.Nonnull Long byteSize) { + this.byteSize = byteSize; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SuggestedHole instance itself + */ + public SuggestedHole putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SuggestedHole suggestedHole = (SuggestedHole) o; + return Objects.equals(this.byteOffset, suggestedHole.byteOffset) && + Objects.equals(this.byteSize, suggestedHole.byteSize)&& + Objects.equals(this.additionalProperties, suggestedHole.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(byteOffset, byteSize, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SuggestedHole {\n"); + sb.append(" byteOffset: ").append(toIndentedString(byteOffset)).append("\n"); + sb.append(" byteSize: ").append(toIndentedString(byteSize)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("byte_offset", "byte_size")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("byte_offset", "byte_size")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SuggestedHole + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SuggestedHole.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SuggestedHole is not found in the empty JSON string", SuggestedHole.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SuggestedHole.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SuggestedHole.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SuggestedHole' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SuggestedHole.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SuggestedHole value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SuggestedHole read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SuggestedHole instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SuggestedHole given an JSON string + * + * @param jsonString JSON string + * @return An instance of SuggestedHole + * @throws IOException if the JSON string is invalid with respect to SuggestedHole + */ + public static SuggestedHole fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SuggestedHole.class); + } + + /** + * Convert an instance of SuggestedHole to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SuggestedMemberView.java b/src/main/java/ai/reveng/model/SuggestedMemberView.java new file mode 100644 index 00000000..ce9a062e --- /dev/null +++ b/src/main/java/ai/reveng/model/SuggestedMemberView.java @@ -0,0 +1,658 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SuggestedMemberView + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SuggestedMemberView { + public static final String SERIALIZED_NAME_BIT_OFFSET = "bit_offset"; + @SerializedName(SERIALIZED_NAME_BIT_OFFSET) + @javax.annotation.Nullable + private Long bitOffset; + + public static final String SERIALIZED_NAME_BYTE_OFFSET = "byte_offset"; + @SerializedName(SERIALIZED_NAME_BYTE_OFFSET) + @javax.annotation.Nullable + private Long byteOffset; + + public static final String SERIALIZED_NAME_BYTE_SIZE = "byte_size"; + @SerializedName(SERIALIZED_NAME_BYTE_SIZE) + @javax.annotation.Nullable + private Long byteSize; + + /** + * Where suggested_type came from. declared and inferred were observed; width knows only the access width; model is the language model's proposal. + */ + @JsonAdapter(ConfidenceEnum.Adapter.class) + public enum ConfidenceEnum { + DECLARED("declared"), + + INFERRED("inferred"), + + WIDTH("width"), + + MODEL("model"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ConfidenceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ConfidenceEnum fromValue(String value) { + for (ConfidenceEnum b : ConfidenceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ConfidenceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ConfidenceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ConfidenceEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ConfidenceEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CONFIDENCE = "confidence"; + @SerializedName(SERIALIZED_NAME_CONFIDENCE) + @javax.annotation.Nullable + private ConfidenceEnum confidence; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_ORIGIN = "origin"; + @SerializedName(SERIALIZED_NAME_ORIGIN) + @javax.annotation.Nonnull + private String origin; + + public static final String SERIALIZED_NAME_PACKED = "packed"; + @SerializedName(SERIALIZED_NAME_PACKED) + @javax.annotation.Nonnull + private Boolean packed; + + /** + * observed means the offset was read off an access; guessed means the model proposed it; unplaced means the member has no offset. + */ + @JsonAdapter(PlacementEnum.Adapter.class) + public enum PlacementEnum { + OBSERVED("observed"), + + GUESSED("guessed"), + + UNPLACED("unplaced"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + PlacementEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static PlacementEnum fromValue(String value) { + for (PlacementEnum b : PlacementEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final PlacementEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public PlacementEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return PlacementEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + PlacementEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_PLACEMENT = "placement"; + @SerializedName(SERIALIZED_NAME_PLACEMENT) + @javax.annotation.Nonnull + private PlacementEnum placement; + + public static final String SERIALIZED_NAME_SUGGESTED_TYPE = "suggested_type"; + @SerializedName(SERIALIZED_NAME_SUGGESTED_TYPE) + @javax.annotation.Nullable + private String suggestedType; + + public static final String SERIALIZED_NAME_TOKEN = "token"; + @SerializedName(SERIALIZED_NAME_TOKEN) + @javax.annotation.Nullable + private String token; + + public SuggestedMemberView() { + } + + public SuggestedMemberView bitOffset(@javax.annotation.Nullable Long bitOffset) { + this.bitOffset = bitOffset; + return this; + } + + /** + * Bit offset within the containing word for a bitfield member. + * @return bitOffset + */ + @javax.annotation.Nullable + public Long getBitOffset() { + return bitOffset; + } + + public void setBitOffset(@javax.annotation.Nullable Long bitOffset) { + this.bitOffset = bitOffset; + } + + + public SuggestedMemberView byteOffset(@javax.annotation.Nullable Long byteOffset) { + this.byteOffset = byteOffset; + return this; + } + + /** + * Offset within the type. Null when no placement could be established. + * @return byteOffset + */ + @javax.annotation.Nullable + public Long getByteOffset() { + return byteOffset; + } + + public void setByteOffset(@javax.annotation.Nullable Long byteOffset) { + this.byteOffset = byteOffset; + } + + + public SuggestedMemberView byteSize(@javax.annotation.Nullable Long byteSize) { + this.byteSize = byteSize; + return this; + } + + /** + * Width of the access in bytes. + * @return byteSize + */ + @javax.annotation.Nullable + public Long getByteSize() { + return byteSize; + } + + public void setByteSize(@javax.annotation.Nullable Long byteSize) { + this.byteSize = byteSize; + } + + + public SuggestedMemberView confidence(@javax.annotation.Nullable ConfidenceEnum confidence) { + this.confidence = confidence; + return this; + } + + /** + * Where suggested_type came from. declared and inferred were observed; width knows only the access width; model is the language model's proposal. + * @return confidence + */ + @javax.annotation.Nullable + public ConfidenceEnum getConfidence() { + return confidence; + } + + public void setConfidence(@javax.annotation.Nullable ConfidenceEnum confidence) { + this.confidence = confidence; + } + + + public SuggestedMemberView name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Name the member renders as: a database or frozen name where one exists, else the suggested one. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public SuggestedMemberView origin(@javax.annotation.Nonnull String origin) { + this.origin = origin; + return this; + } + + /** + * Which function revealed this member: self, caller:<function_id> or callee:<function_id>. + * @return origin + */ + @javax.annotation.Nonnull + public String getOrigin() { + return origin; + } + + public void setOrigin(@javax.annotation.Nonnull String origin) { + this.origin = origin; + } + + + public SuggestedMemberView packed(@javax.annotation.Nonnull Boolean packed) { + this.packed = packed; + return this; + } + + /** + * The member sits at an offset its own width does not divide. + * @return packed + */ + @javax.annotation.Nonnull + public Boolean getPacked() { + return packed; + } + + public void setPacked(@javax.annotation.Nonnull Boolean packed) { + this.packed = packed; + } + + + public SuggestedMemberView placement(@javax.annotation.Nonnull PlacementEnum placement) { + this.placement = placement; + return this; + } + + /** + * observed means the offset was read off an access; guessed means the model proposed it; unplaced means the member has no offset. + * @return placement + */ + @javax.annotation.Nonnull + public PlacementEnum getPlacement() { + return placement; + } + + public void setPlacement(@javax.annotation.Nonnull PlacementEnum placement) { + this.placement = placement; + } + + + public SuggestedMemberView suggestedType(@javax.annotation.Nullable String suggestedType) { + this.suggestedType = suggestedType; + return this; + } + + /** + * Type expression for the member. + * @return suggestedType + */ + @javax.annotation.Nullable + public String getSuggestedType() { + return suggestedType; + } + + public void setSuggestedType(@javax.annotation.Nullable String suggestedType) { + this.suggestedType = suggestedType; + } + + + public SuggestedMemberView token(@javax.annotation.Nullable String token) { + this.token = token; + return this; + } + + /** + * Placeholder this member renders as in the tokenised source. Absent for a member no access in this function revealed. + * @return token + */ + @javax.annotation.Nullable + public String getToken() { + return token; + } + + public void setToken(@javax.annotation.Nullable String token) { + this.token = token; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SuggestedMemberView instance itself + */ + public SuggestedMemberView putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SuggestedMemberView suggestedMemberView = (SuggestedMemberView) o; + return Objects.equals(this.bitOffset, suggestedMemberView.bitOffset) && + Objects.equals(this.byteOffset, suggestedMemberView.byteOffset) && + Objects.equals(this.byteSize, suggestedMemberView.byteSize) && + Objects.equals(this.confidence, suggestedMemberView.confidence) && + Objects.equals(this.name, suggestedMemberView.name) && + Objects.equals(this.origin, suggestedMemberView.origin) && + Objects.equals(this.packed, suggestedMemberView.packed) && + Objects.equals(this.placement, suggestedMemberView.placement) && + Objects.equals(this.suggestedType, suggestedMemberView.suggestedType) && + Objects.equals(this.token, suggestedMemberView.token)&& + Objects.equals(this.additionalProperties, suggestedMemberView.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(bitOffset, byteOffset, byteSize, confidence, name, origin, packed, placement, suggestedType, token, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SuggestedMemberView {\n"); + sb.append(" bitOffset: ").append(toIndentedString(bitOffset)).append("\n"); + sb.append(" byteOffset: ").append(toIndentedString(byteOffset)).append("\n"); + sb.append(" byteSize: ").append(toIndentedString(byteSize)).append("\n"); + sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" origin: ").append(toIndentedString(origin)).append("\n"); + sb.append(" packed: ").append(toIndentedString(packed)).append("\n"); + sb.append(" placement: ").append(toIndentedString(placement)).append("\n"); + sb.append(" suggestedType: ").append(toIndentedString(suggestedType)).append("\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("bit_offset", "byte_offset", "byte_size", "confidence", "name", "origin", "packed", "placement", "suggested_type", "token")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("bit_offset", "byte_offset", "byte_size", "confidence", "name", "origin", "packed", "placement", "suggested_type")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SuggestedMemberView + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SuggestedMemberView.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SuggestedMemberView is not found in the empty JSON string", SuggestedMemberView.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SuggestedMemberView.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("confidence") != null && !jsonObj.get("confidence").isJsonNull()) && !jsonObj.get("confidence").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidence` to be a primitive type in the JSON string but got `%s`", jsonObj.get("confidence").toString())); + } + if (jsonObj.get("confidence") != null && !jsonObj.get("confidence").isJsonNull()) { + // validate the required field `confidence` + ConfidenceEnum.validateJsonElement(jsonObj.get("confidence")); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("origin").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `origin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("origin").toString())); + } + if (!jsonObj.get("placement").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `placement` to be a primitive type in the JSON string but got `%s`", jsonObj.get("placement").toString())); + } + // validate the required field `placement` + PlacementEnum.validateJsonElement(jsonObj.get("placement")); + if ((jsonObj.get("suggested_type") != null && !jsonObj.get("suggested_type").isJsonNull()) && !jsonObj.get("suggested_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `suggested_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suggested_type").toString())); + } + if ((jsonObj.get("token") != null && !jsonObj.get("token").isJsonNull()) && !jsonObj.get("token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("token").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SuggestedMemberView.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SuggestedMemberView' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SuggestedMemberView.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SuggestedMemberView value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SuggestedMemberView read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SuggestedMemberView instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SuggestedMemberView given an JSON string + * + * @param jsonString JSON string + * @return An instance of SuggestedMemberView + * @throws IOException if the JSON string is invalid with respect to SuggestedMemberView + */ + public static SuggestedMemberView fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SuggestedMemberView.class); + } + + /** + * Convert an instance of SuggestedMemberView to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SuggestedTypeView.java b/src/main/java/ai/reveng/model/SuggestedTypeView.java new file mode 100644 index 00000000..1412abeb --- /dev/null +++ b/src/main/java/ai/reveng/model/SuggestedTypeView.java @@ -0,0 +1,512 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.SuggestedHole; +import ai.reveng.model.SuggestedMemberView; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SuggestedTypeView + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SuggestedTypeView { + public static final String SERIALIZED_NAME_DATA_TYPE_ID = "data_type_id"; + @SerializedName(SERIALIZED_NAME_DATA_TYPE_ID) + @javax.annotation.Nullable + private Long dataTypeId; + + public static final String SERIALIZED_NAME_HOLES = "holes"; + @SerializedName(SERIALIZED_NAME_HOLES) + @javax.annotation.Nullable + private List holes; + + public static final String SERIALIZED_NAME_IMPLIED_SIZE = "implied_size"; + @SerializedName(SERIALIZED_NAME_IMPLIED_SIZE) + @javax.annotation.Nullable + private Long impliedSize; + + public static final String SERIALIZED_NAME_KEY = "key"; + @SerializedName(SERIALIZED_NAME_KEY) + @javax.annotation.Nonnull + private String key; + + public static final String SERIALIZED_NAME_MEMBERS = "members"; + @SerializedName(SERIALIZED_NAME_MEMBERS) + @javax.annotation.Nullable + private List members; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_TYPE_TOKEN = "type_token"; + @SerializedName(SERIALIZED_NAME_TYPE_TOKEN) + @javax.annotation.Nullable + private String typeToken; + + public static final String SERIALIZED_NAME_UNDERLYING_TYPE = "underlying_type"; + @SerializedName(SERIALIZED_NAME_UNDERLYING_TYPE) + @javax.annotation.Nullable + private String underlyingType; + + public SuggestedTypeView() { + } + + public SuggestedTypeView dataTypeId(@javax.annotation.Nullable Long dataTypeId) { + this.dataTypeId = dataTypeId; + return this; + } + + /** + * Existing data type the members were accessed through. Null when nothing resolved to a row; never minted for a suggestion. + * @return dataTypeId + */ + @javax.annotation.Nullable + public Long getDataTypeId() { + return dataTypeId; + } + + public void setDataTypeId(@javax.annotation.Nullable Long dataTypeId) { + this.dataTypeId = dataTypeId; + } + + + public SuggestedTypeView holes(@javax.annotation.Nullable List holes) { + this.holes = holes; + return this; + } + + public SuggestedTypeView addHolesItem(SuggestedHole holesItem) { + if (this.holes == null) { + this.holes = new ArrayList<>(); + } + this.holes.add(holesItem); + return this; + } + + /** + * Gaps between consecutive placed members, in offset order. + * @return holes + */ + @javax.annotation.Nullable + public List getHoles() { + return holes; + } + + public void setHoles(@javax.annotation.Nullable List holes) { + this.holes = holes; + } + + + public SuggestedTypeView impliedSize(@javax.annotation.Nullable Long impliedSize) { + this.impliedSize = impliedSize; + return this; + } + + /** + * Highest byte_offset+byte_size across the members. A lower bound on the type's size, not its size. + * @return impliedSize + */ + @javax.annotation.Nullable + public Long getImpliedSize() { + return impliedSize; + } + + public void setImpliedSize(@javax.annotation.Nullable Long impliedSize) { + this.impliedSize = impliedSize; + } + + + public SuggestedTypeView key(@javax.annotation.Nonnull String key) { + this.key = key; + return this; + } + + /** + * Identity of the suggestion: index:<data_type_id> where the access named a row, else token:<type_token>. + * @return key + */ + @javax.annotation.Nonnull + public String getKey() { + return key; + } + + public void setKey(@javax.annotation.Nonnull String key) { + this.key = key; + } + + + public SuggestedTypeView members(@javax.annotation.Nullable List members) { + this.members = members; + return this; + } + + public SuggestedTypeView addMembersItem(SuggestedMemberView membersItem) { + if (this.members == null) { + this.members = new ArrayList<>(); + } + this.members.add(membersItem); + return this; + } + + /** + * Members in offset order, unplaced ones last. + * @return members + */ + @javax.annotation.Nullable + public List getMembers() { + return members; + } + + public void setMembers(@javax.annotation.Nullable List members) { + this.members = members; + } + + + public SuggestedTypeView name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Name the type renders as: a database or frozen name where one exists, else the suggested one. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public SuggestedTypeView typeToken(@javax.annotation.Nullable String typeToken) { + this.typeToken = typeToken; + return this; + } + + /** + * Placeholder the type renders as, when it appears in this function's source. + * @return typeToken + */ + @javax.annotation.Nullable + public String getTypeToken() { + return typeToken; + } + + public void setTypeToken(@javax.annotation.Nullable String typeToken) { + this.typeToken = typeToken; + } + + + public SuggestedTypeView underlyingType(@javax.annotation.Nullable String underlyingType) { + this.underlyingType = underlyingType; + return this; + } + + /** + * Set only for a type with no observed members, where the suggestion is a name and a scalar type rather than a layout. + * @return underlyingType + */ + @javax.annotation.Nullable + public String getUnderlyingType() { + return underlyingType; + } + + public void setUnderlyingType(@javax.annotation.Nullable String underlyingType) { + this.underlyingType = underlyingType; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SuggestedTypeView instance itself + */ + public SuggestedTypeView putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SuggestedTypeView suggestedTypeView = (SuggestedTypeView) o; + return Objects.equals(this.dataTypeId, suggestedTypeView.dataTypeId) && + Objects.equals(this.holes, suggestedTypeView.holes) && + Objects.equals(this.impliedSize, suggestedTypeView.impliedSize) && + Objects.equals(this.key, suggestedTypeView.key) && + Objects.equals(this.members, suggestedTypeView.members) && + Objects.equals(this.name, suggestedTypeView.name) && + Objects.equals(this.typeToken, suggestedTypeView.typeToken) && + Objects.equals(this.underlyingType, suggestedTypeView.underlyingType)&& + Objects.equals(this.additionalProperties, suggestedTypeView.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(dataTypeId, holes, impliedSize, key, members, name, typeToken, underlyingType, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SuggestedTypeView {\n"); + sb.append(" dataTypeId: ").append(toIndentedString(dataTypeId)).append("\n"); + sb.append(" holes: ").append(toIndentedString(holes)).append("\n"); + sb.append(" impliedSize: ").append(toIndentedString(impliedSize)).append("\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" typeToken: ").append(toIndentedString(typeToken)).append("\n"); + sb.append(" underlyingType: ").append(toIndentedString(underlyingType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("data_type_id", "holes", "implied_size", "key", "members", "name", "type_token", "underlying_type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("holes", "key", "members", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SuggestedTypeView + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SuggestedTypeView.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SuggestedTypeView is not found in the empty JSON string", SuggestedTypeView.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SuggestedTypeView.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("holes") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("holes").isJsonArray() && !jsonObj.get("holes").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `holes` to be an array in the JSON string but got `%s`", jsonObj.get("holes").toString())); + } + if (!jsonObj.get("key").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); + } + // ensure the required json array is present + if (jsonObj.get("members") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("members").isJsonArray() && !jsonObj.get("members").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("type_token") != null && !jsonObj.get("type_token").isJsonNull()) && !jsonObj.get("type_token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type_token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type_token").toString())); + } + if ((jsonObj.get("underlying_type") != null && !jsonObj.get("underlying_type").isJsonNull()) && !jsonObj.get("underlying_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `underlying_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("underlying_type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SuggestedTypeView.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SuggestedTypeView' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SuggestedTypeView.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SuggestedTypeView value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SuggestedTypeView read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SuggestedTypeView instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SuggestedTypeView given an JSON string + * + * @param jsonString JSON string + * @return An instance of SuggestedTypeView + * @throws IOException if the JSON string is invalid with respect to SuggestedTypeView + */ + public static SuggestedTypeView fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SuggestedTypeView.class); + } + + /** + * Convert an instance of SuggestedTypeView to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SummaryData.java b/src/main/java/ai/reveng/model/SummaryData.java index dd8ed43f..a7824e7a 100644 --- a/src/main/java/ai/reveng/model/SummaryData.java +++ b/src/main/java/ai/reveng/model/SummaryData.java @@ -54,6 +54,11 @@ public class SummaryData { @javax.annotation.Nonnull private String aiSummary; + public static final String SERIALIZED_NAME_PREDICTED_FUNCTION_NAME = "predicted_function_name"; + @SerializedName(SERIALIZED_NAME_PREDICTED_FUNCTION_NAME) + @javax.annotation.Nullable + private String predictedFunctionName; + public static final String SERIALIZED_NAME_SUMMARY = "summary"; @SerializedName(SERIALIZED_NAME_SUMMARY) @javax.annotation.Nonnull @@ -142,6 +147,25 @@ public void setAiSummary(@javax.annotation.Nonnull String aiSummary) { } + public SummaryData predictedFunctionName(@javax.annotation.Nullable String predictedFunctionName) { + this.predictedFunctionName = predictedFunctionName; + return this; + } + + /** + * Name the model proposes for this function, produced alongside the summary. + * @return predictedFunctionName + */ + @javax.annotation.Nullable + public String getPredictedFunctionName() { + return predictedFunctionName; + } + + public void setPredictedFunctionName(@javax.annotation.Nullable String predictedFunctionName) { + this.predictedFunctionName = predictedFunctionName; + } + + public SummaryData summary(@javax.annotation.Nonnull String summary) { this.summary = summary; return this; @@ -179,6 +203,50 @@ public void setTaskStatus(@javax.annotation.Nonnull TaskStatusEnum taskStatus) { this.taskStatus = taskStatus; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SummaryData instance itself + */ + public SummaryData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -191,13 +259,15 @@ public boolean equals(Object o) { } SummaryData summaryData = (SummaryData) o; return Objects.equals(this.aiSummary, summaryData.aiSummary) && + Objects.equals(this.predictedFunctionName, summaryData.predictedFunctionName) && Objects.equals(this.summary, summaryData.summary) && - Objects.equals(this.taskStatus, summaryData.taskStatus); + Objects.equals(this.taskStatus, summaryData.taskStatus)&& + Objects.equals(this.additionalProperties, summaryData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(aiSummary, summary, taskStatus); + return Objects.hash(aiSummary, predictedFunctionName, summary, taskStatus, additionalProperties); } @Override @@ -205,8 +275,10 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SummaryData {\n"); sb.append(" aiSummary: ").append(toIndentedString(aiSummary)).append("\n"); + sb.append(" predictedFunctionName: ").append(toIndentedString(predictedFunctionName)).append("\n"); sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); sb.append(" taskStatus: ").append(toIndentedString(taskStatus)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -225,7 +297,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("ai_summary", "summary", "task_status")); + openapiFields = new HashSet(Arrays.asList("ai_summary", "predicted_function_name", "summary", "task_status")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("ai_summary", "summary", "task_status")); @@ -244,14 +316,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SummaryData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SummaryData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SummaryData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -262,6 +326,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("ai_summary").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ai_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ai_summary").toString())); } + if ((jsonObj.get("predicted_function_name") != null && !jsonObj.get("predicted_function_name").isJsonNull()) && !jsonObj.get("predicted_function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `predicted_function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("predicted_function_name").toString())); + } if (!jsonObj.get("summary").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); } @@ -287,6 +354,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SummaryData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -294,7 +383,28 @@ public void write(JsonWriter out, SummaryData value) throws IOException { public SummaryData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SummaryData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SuspiciousString.java b/src/main/java/ai/reveng/model/SuspiciousString.java new file mode 100644 index 00000000..944af88c --- /dev/null +++ b/src/main/java/ai/reveng/model/SuspiciousString.java @@ -0,0 +1,332 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.Subject; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * SuspiciousString + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SuspiciousString { + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + @javax.annotation.Nonnull + private String value; + + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + @javax.annotation.Nullable + private Subject subject; + + public SuspiciousString() { + } + + public SuspiciousString value(@javax.annotation.Nonnull String value) { + this.value = value; + return this; + } + + /** + * Get value + * @return value + */ + @javax.annotation.Nonnull + public String getValue() { + return value; + } + + public void setValue(@javax.annotation.Nonnull String value) { + this.value = value; + } + + + public SuspiciousString subject(@javax.annotation.Nullable Subject subject) { + this.subject = subject; + return this; + } + + /** + * Get subject + * @return subject + */ + @javax.annotation.Nullable + public Subject getSubject() { + return subject; + } + + public void setSubject(@javax.annotation.Nullable Subject subject) { + this.subject = subject; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SuspiciousString instance itself + */ + public SuspiciousString putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SuspiciousString suspiciousString = (SuspiciousString) o; + return Objects.equals(this.value, suspiciousString.value) && + Objects.equals(this.subject, suspiciousString.subject)&& + Objects.equals(this.additionalProperties, suspiciousString.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(value, subject, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SuspiciousString {\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("value", "subject")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("value")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SuspiciousString + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SuspiciousString.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SuspiciousString is not found in the empty JSON string", SuspiciousString.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SuspiciousString.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("value").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + } + // validate the optional field `subject` + if (jsonObj.get("subject") != null && !jsonObj.get("subject").isJsonNull()) { + Subject.validateJsonElement(jsonObj.get("subject")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SuspiciousString.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SuspiciousString' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SuspiciousString.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SuspiciousString value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SuspiciousString read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SuspiciousString instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SuspiciousString given an JSON string + * + * @param jsonString JSON string + * @return An instance of SuspiciousString + * @throws IOException if the JSON string is invalid with respect to SuspiciousString + */ + public static SuspiciousString fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SuspiciousString.class); + } + + /** + * Convert an instance of SuspiciousString to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/SuspiciousStringEvidence.java b/src/main/java/ai/reveng/model/SuspiciousStringEvidence.java new file mode 100644 index 00000000..b4ebc627 --- /dev/null +++ b/src/main/java/ai/reveng/model/SuspiciousStringEvidence.java @@ -0,0 +1,591 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.EvidenceEffect; +import ai.reveng.model.SuspiciousString; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Suspicious strings without demonstrated semantic use. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SuspiciousStringEvidence { + /** + * Gets or Sets evidenceKind + */ + @JsonAdapter(EvidenceKindEnum.Adapter.class) + public enum EvidenceKindEnum { + SUSPICIOUS_STRING("suspicious_string"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EvidenceKindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EvidenceKindEnum fromValue(String value) { + for (EvidenceKindEnum b : EvidenceKindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EvidenceKindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EvidenceKindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EvidenceKindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EvidenceKindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_EVIDENCE_KIND = "evidence_kind"; + @SerializedName(SERIALIZED_NAME_EVIDENCE_KIND) + @javax.annotation.Nullable + private EvidenceKindEnum evidenceKind = EvidenceKindEnum.SUSPICIOUS_STRING; + + /** + * Gets or Sets kind + */ + @JsonAdapter(KindEnum.Adapter.class) + public enum KindEnum { + DETERMINISTIC_DERIVATION("deterministic_derivation"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KindEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KindEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nullable + private KindEnum kind = KindEnum.DETERMINISTIC_DERIVATION; + + public static final String SERIALIZED_NAME_EFFECT = "effect"; + @SerializedName(SERIALIZED_NAME_EFFECT) + @javax.annotation.Nonnull + private EvidenceEffect effect; + + /** + * Gets or Sets strength + */ + @JsonAdapter(StrengthEnum.Adapter.class) + public enum StrengthEnum { + INDIRECT("indirect"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StrengthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrengthEnum fromValue(String value) { + for (StrengthEnum b : StrengthEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StrengthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrengthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrengthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StrengthEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STRENGTH = "strength"; + @SerializedName(SERIALIZED_NAME_STRENGTH) + @javax.annotation.Nullable + private StrengthEnum strength = StrengthEnum.INDIRECT; + + public static final String SERIALIZED_NAME_STRINGS = "strings"; + @SerializedName(SERIALIZED_NAME_STRINGS) + @javax.annotation.Nonnull + private List strings = new ArrayList<>(); + + public SuspiciousStringEvidence() { + } + + public SuspiciousStringEvidence evidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + return this; + } + + /** + * Get evidenceKind + * @return evidenceKind + */ + @javax.annotation.Nullable + public EvidenceKindEnum getEvidenceKind() { + return evidenceKind; + } + + public void setEvidenceKind(@javax.annotation.Nullable EvidenceKindEnum evidenceKind) { + this.evidenceKind = evidenceKind; + } + + + public SuspiciousStringEvidence kind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @javax.annotation.Nullable + public KindEnum getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nullable KindEnum kind) { + this.kind = kind; + } + + + public SuspiciousStringEvidence effect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + return this; + } + + /** + * Get effect + * @return effect + */ + @javax.annotation.Nonnull + public EvidenceEffect getEffect() { + return effect; + } + + public void setEffect(@javax.annotation.Nonnull EvidenceEffect effect) { + this.effect = effect; + } + + + public SuspiciousStringEvidence strength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + return this; + } + + /** + * Get strength + * @return strength + */ + @javax.annotation.Nullable + public StrengthEnum getStrength() { + return strength; + } + + public void setStrength(@javax.annotation.Nullable StrengthEnum strength) { + this.strength = strength; + } + + + public SuspiciousStringEvidence strings(@javax.annotation.Nonnull List strings) { + this.strings = strings; + return this; + } + + public SuspiciousStringEvidence addStringsItem(SuspiciousString stringsItem) { + if (this.strings == null) { + this.strings = new ArrayList<>(); + } + this.strings.add(stringsItem); + return this; + } + + /** + * Get strings + * @return strings + */ + @javax.annotation.Nonnull + public List getStrings() { + return strings; + } + + public void setStrings(@javax.annotation.Nonnull List strings) { + this.strings = strings; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SuspiciousStringEvidence instance itself + */ + public SuspiciousStringEvidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SuspiciousStringEvidence suspiciousStringEvidence = (SuspiciousStringEvidence) o; + return Objects.equals(this.evidenceKind, suspiciousStringEvidence.evidenceKind) && + Objects.equals(this.kind, suspiciousStringEvidence.kind) && + Objects.equals(this.effect, suspiciousStringEvidence.effect) && + Objects.equals(this.strength, suspiciousStringEvidence.strength) && + Objects.equals(this.strings, suspiciousStringEvidence.strings)&& + Objects.equals(this.additionalProperties, suspiciousStringEvidence.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evidenceKind, kind, effect, strength, strings, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SuspiciousStringEvidence {\n"); + sb.append(" evidenceKind: ").append(toIndentedString(evidenceKind)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" strength: ").append(toIndentedString(strength)).append("\n"); + sb.append(" strings: ").append(toIndentedString(strings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("evidence_kind", "kind", "effect", "strength", "strings")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("effect", "strings")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SuspiciousStringEvidence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SuspiciousStringEvidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SuspiciousStringEvidence is not found in the empty JSON string", SuspiciousStringEvidence.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SuspiciousStringEvidence.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) && !jsonObj.get("evidence_kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `evidence_kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("evidence_kind").toString())); + } + // validate the optional field `evidence_kind` + if (jsonObj.get("evidence_kind") != null && !jsonObj.get("evidence_kind").isJsonNull()) { + EvidenceKindEnum.validateJsonElement(jsonObj.get("evidence_kind")); + } + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + } + // validate the optional field `kind` + if (jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) { + KindEnum.validateJsonElement(jsonObj.get("kind")); + } + // validate the required field `effect` + EvidenceEffect.validateJsonElement(jsonObj.get("effect")); + if ((jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) && !jsonObj.get("strength").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strength` to be a primitive type in the JSON string but got `%s`", jsonObj.get("strength").toString())); + } + // validate the optional field `strength` + if (jsonObj.get("strength") != null && !jsonObj.get("strength").isJsonNull()) { + StrengthEnum.validateJsonElement(jsonObj.get("strength")); + } + if (jsonObj.get("strings") != null) { + if (!jsonObj.get("strings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + } + JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); + // validate the required field `strings` (array) + for (int i = 0; i < jsonArraystrings.size(); i++) { + SuspiciousString.validateJsonElement(jsonArraystrings.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SuspiciousStringEvidence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SuspiciousStringEvidence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SuspiciousStringEvidence.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SuspiciousStringEvidence value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SuspiciousStringEvidence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SuspiciousStringEvidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SuspiciousStringEvidence given an JSON string + * + * @param jsonString JSON string + * @return An instance of SuspiciousStringEvidence + * @throws IOException if the JSON string is invalid with respect to SuspiciousStringEvidence + */ + public static SuspiciousStringEvidence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SuspiciousStringEvidence.class); + } + + /** + * Convert an instance of SuspiciousStringEvidence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Symbols.java b/src/main/java/ai/reveng/model/Symbols.java index abdd4bdb..71668aab 100644 --- a/src/main/java/ai/reveng/model/Symbols.java +++ b/src/main/java/ai/reveng/model/Symbols.java @@ -20,10 +20,10 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -56,31 +56,32 @@ public class Symbols { public static final String SERIALIZED_NAME_BASE_ADDRESS = "base_address"; @SerializedName(SERIALIZED_NAME_BASE_ADDRESS) @javax.annotation.Nonnull - private BigInteger baseAddress; + private Long baseAddress; public static final String SERIALIZED_NAME_FUNCTION_BOUNDARIES = "function_boundaries"; @SerializedName(SERIALIZED_NAME_FUNCTION_BOUNDARIES) @javax.annotation.Nullable - private List functionBoundaries = new ArrayList<>(); + private List functionBoundaries; public Symbols() { } - public Symbols baseAddress(@javax.annotation.Nonnull BigInteger baseAddress) { + public Symbols baseAddress(@javax.annotation.Nonnull Long baseAddress) { this.baseAddress = baseAddress; return this; } /** - * The starting address of the execution + * Get baseAddress + * minimum: 0 * @return baseAddress */ @javax.annotation.Nonnull - public BigInteger getBaseAddress() { + public Long getBaseAddress() { return baseAddress; } - public void setBaseAddress(@javax.annotation.Nonnull BigInteger baseAddress) { + public void setBaseAddress(@javax.annotation.Nonnull Long baseAddress) { this.baseAddress = baseAddress; } @@ -99,7 +100,7 @@ public Symbols addFunctionBoundariesItem(FunctionBoundary functionBoundariesItem } /** - * List of user defined function boundaries + * Get functionBoundaries * @return functionBoundaries */ @javax.annotation.Nullable @@ -171,11 +172,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, symbols.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + @Override public int hashCode() { return Objects.hash(baseAddress, functionBoundaries, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -227,19 +239,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("function_boundaries") != null && !jsonObj.get("function_boundaries").isJsonNull()) { - JsonArray jsonArrayfunctionBoundaries = jsonObj.getAsJsonArray("function_boundaries"); - if (jsonArrayfunctionBoundaries != null) { - // ensure the json data is an array - if (!jsonObj.get("function_boundaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_boundaries` to be an array in the JSON string but got `%s`", jsonObj.get("function_boundaries").toString())); - } - - // validate the optional field `function_boundaries` (array) - for (int i = 0; i < jsonArrayfunctionBoundaries.size(); i++) { - FunctionBoundary.validateJsonElement(jsonArrayfunctionBoundaries.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("function_boundaries") != null && !jsonObj.get("function_boundaries").isJsonNull() && !jsonObj.get("function_boundaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_boundaries` to be an array in the JSON string but got `%s`", jsonObj.get("function_boundaries").toString())); } } diff --git a/src/main/java/ai/reveng/model/TcpCarvedFile.java b/src/main/java/ai/reveng/model/TcpCarvedFile.java index 09dca965..15ca567d 100644 --- a/src/main/java/ai/reveng/model/TcpCarvedFile.java +++ b/src/main/java/ai/reveng/model/TcpCarvedFile.java @@ -254,6 +254,50 @@ public void setYaraHits(@javax.annotation.Nullable List yaraHits) { this.yaraHits = yaraHits; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TcpCarvedFile instance itself + */ + public TcpCarvedFile putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -272,7 +316,8 @@ public boolean equals(Object o) { Objects.equals(this.offset, tcpCarvedFile.offset) && Objects.equals(this.sha256, tcpCarvedFile.sha256) && Objects.equals(this.size, tcpCarvedFile.size) && - Objects.equals(this.yaraHits, tcpCarvedFile.yaraHits); + Objects.equals(this.yaraHits, tcpCarvedFile.yaraHits)&& + Objects.equals(this.additionalProperties, tcpCarvedFile.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -281,7 +326,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(direction, filename, isPe, mimeType, offset, sha256, size, yaraHits); + return Objects.hash(direction, filename, isPe, mimeType, offset, sha256, size, yaraHits, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -303,6 +348,7 @@ public String toString() { sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" yaraHits: ").append(toIndentedString(yaraHits)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -340,14 +386,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TcpCarvedFile.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TcpCarvedFile` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TcpCarvedFile.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -388,6 +426,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TcpCarvedFile value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -395,7 +455,28 @@ public void write(JsonWriter out, TcpCarvedFile value) throws IOException { public TcpCarvedFile read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TcpCarvedFile instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Team.java b/src/main/java/ai/reveng/model/Team.java index 96ca79e0..c0396790 100644 --- a/src/main/java/ai/reveng/model/Team.java +++ b/src/main/java/ai/reveng/model/Team.java @@ -205,6 +205,50 @@ public void setTeamName(@javax.annotation.Nonnull String teamName) { this.teamName = teamName; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Team instance itself + */ + public Team putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -219,12 +263,13 @@ public boolean equals(Object o) { return Objects.equals(this.organisationId, team.organisationId) && Objects.equals(this.plan, team.plan) && Objects.equals(this.teamId, team.teamId) && - Objects.equals(this.teamName, team.teamName); + Objects.equals(this.teamName, team.teamName)&& + Objects.equals(this.additionalProperties, team.additionalProperties); } @Override public int hashCode() { - return Objects.hash(organisationId, plan, teamId, teamName); + return Objects.hash(organisationId, plan, teamId, teamName, additionalProperties); } @Override @@ -235,6 +280,7 @@ public String toString() { sb.append(" plan: ").append(toIndentedString(plan)).append("\n"); sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" teamName: ").append(toIndentedString(teamName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -272,14 +318,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Team.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Team` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Team.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -312,6 +350,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Team value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -319,7 +379,28 @@ public void write(JsonWriter out, Team value) throws IOException { public Team read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Team instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Technique.java b/src/main/java/ai/reveng/model/Technique.java new file mode 100644 index 00000000..43bb168a --- /dev/null +++ b/src/main/java/ai/reveng/model/Technique.java @@ -0,0 +1,547 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Technique + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Technique { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_END_ADDR = "end_addr"; + @SerializedName(SERIALIZED_NAME_END_ADDR) + @javax.annotation.Nonnull + private String endAddr; + + public static final String SERIALIZED_NAME_FUNCTION_ADDR = "function_addr"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ADDR) + @javax.annotation.Nonnull + private String functionAddr; + + public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; + @SerializedName(SERIALIZED_NAME_FUNCTION_ID) + @javax.annotation.Nonnull + private Long functionId; + + public static final String SERIALIZED_NAME_FUNCTION_NAME = "function_name"; + @SerializedName(SERIALIZED_NAME_FUNCTION_NAME) + @javax.annotation.Nonnull + private String functionName; + + public static final String SERIALIZED_NAME_START_ADDR = "start_addr"; + @SerializedName(SERIALIZED_NAME_START_ADDR) + @javax.annotation.Nonnull + private String startAddr; + + public static final String SERIALIZED_NAME_TECHNIQUE_DESCRIPTION = "technique_description"; + @SerializedName(SERIALIZED_NAME_TECHNIQUE_DESCRIPTION) + @javax.annotation.Nonnull + private String techniqueDescription; + + public static final String SERIALIZED_NAME_TECHNIQUE_ID = "technique_id"; + @SerializedName(SERIALIZED_NAME_TECHNIQUE_ID) + @javax.annotation.Nonnull + private String techniqueId; + + public static final String SERIALIZED_NAME_TECHNIQUE_NAME = "technique_name"; + @SerializedName(SERIALIZED_NAME_TECHNIQUE_NAME) + @javax.annotation.Nonnull + private String techniqueName; + + public static final String SERIALIZED_NAME_TECHNIQUE_URL = "technique_url"; + @SerializedName(SERIALIZED_NAME_TECHNIQUE_URL) + @javax.annotation.Nonnull + private String techniqueUrl; + + public Technique() { + } + + public Technique description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * How the technique appears in this binary + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public Technique endAddr(@javax.annotation.Nonnull String endAddr) { + this.endAddr = endAddr; + return this; + } + + /** + * End address of the containing function, hex-encoded + * @return endAddr + */ + @javax.annotation.Nonnull + public String getEndAddr() { + return endAddr; + } + + public void setEndAddr(@javax.annotation.Nonnull String endAddr) { + this.endAddr = endAddr; + } + + + public Technique functionAddr(@javax.annotation.Nonnull String functionAddr) { + this.functionAddr = functionAddr; + return this; + } + + /** + * Address of the containing function, hex-encoded + * @return functionAddr + */ + @javax.annotation.Nonnull + public String getFunctionAddr() { + return functionAddr; + } + + public void setFunctionAddr(@javax.annotation.Nonnull String functionAddr) { + this.functionAddr = functionAddr; + } + + + public Technique functionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + return this; + } + + /** + * ID of the containing function + * @return functionId + */ + @javax.annotation.Nonnull + public Long getFunctionId() { + return functionId; + } + + public void setFunctionId(@javax.annotation.Nonnull Long functionId) { + this.functionId = functionId; + } + + + public Technique functionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Name of the containing function + * @return functionName + */ + @javax.annotation.Nonnull + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(@javax.annotation.Nonnull String functionName) { + this.functionName = functionName; + } + + + public Technique startAddr(@javax.annotation.Nonnull String startAddr) { + this.startAddr = startAddr; + return this; + } + + /** + * Start address of the containing function, hex-encoded + * @return startAddr + */ + @javax.annotation.Nonnull + public String getStartAddr() { + return startAddr; + } + + public void setStartAddr(@javax.annotation.Nonnull String startAddr) { + this.startAddr = startAddr; + } + + + public Technique techniqueDescription(@javax.annotation.Nonnull String techniqueDescription) { + this.techniqueDescription = techniqueDescription; + return this; + } + + /** + * Full ATT&CK description of the technique + * @return techniqueDescription + */ + @javax.annotation.Nonnull + public String getTechniqueDescription() { + return techniqueDescription; + } + + public void setTechniqueDescription(@javax.annotation.Nonnull String techniqueDescription) { + this.techniqueDescription = techniqueDescription; + } + + + public Technique techniqueId(@javax.annotation.Nonnull String techniqueId) { + this.techniqueId = techniqueId; + return this; + } + + /** + * MITRE ATT&CK technique ID + * @return techniqueId + */ + @javax.annotation.Nonnull + public String getTechniqueId() { + return techniqueId; + } + + public void setTechniqueId(@javax.annotation.Nonnull String techniqueId) { + this.techniqueId = techniqueId; + } + + + public Technique techniqueName(@javax.annotation.Nonnull String techniqueName) { + this.techniqueName = techniqueName; + return this; + } + + /** + * MITRE ATT&CK technique name + * @return techniqueName + */ + @javax.annotation.Nonnull + public String getTechniqueName() { + return techniqueName; + } + + public void setTechniqueName(@javax.annotation.Nonnull String techniqueName) { + this.techniqueName = techniqueName; + } + + + public Technique techniqueUrl(@javax.annotation.Nonnull String techniqueUrl) { + this.techniqueUrl = techniqueUrl; + return this; + } + + /** + * Link to the technique in the ATT&CK catalogue + * @return techniqueUrl + */ + @javax.annotation.Nonnull + public String getTechniqueUrl() { + return techniqueUrl; + } + + public void setTechniqueUrl(@javax.annotation.Nonnull String techniqueUrl) { + this.techniqueUrl = techniqueUrl; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Technique instance itself + */ + public Technique putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Technique technique = (Technique) o; + return Objects.equals(this.description, technique.description) && + Objects.equals(this.endAddr, technique.endAddr) && + Objects.equals(this.functionAddr, technique.functionAddr) && + Objects.equals(this.functionId, technique.functionId) && + Objects.equals(this.functionName, technique.functionName) && + Objects.equals(this.startAddr, technique.startAddr) && + Objects.equals(this.techniqueDescription, technique.techniqueDescription) && + Objects.equals(this.techniqueId, technique.techniqueId) && + Objects.equals(this.techniqueName, technique.techniqueName) && + Objects.equals(this.techniqueUrl, technique.techniqueUrl)&& + Objects.equals(this.additionalProperties, technique.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(description, endAddr, functionAddr, functionId, functionName, startAddr, techniqueDescription, techniqueId, techniqueName, techniqueUrl, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Technique {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" endAddr: ").append(toIndentedString(endAddr)).append("\n"); + sb.append(" functionAddr: ").append(toIndentedString(functionAddr)).append("\n"); + sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" startAddr: ").append(toIndentedString(startAddr)).append("\n"); + sb.append(" techniqueDescription: ").append(toIndentedString(techniqueDescription)).append("\n"); + sb.append(" techniqueId: ").append(toIndentedString(techniqueId)).append("\n"); + sb.append(" techniqueName: ").append(toIndentedString(techniqueName)).append("\n"); + sb.append(" techniqueUrl: ").append(toIndentedString(techniqueUrl)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("description", "end_addr", "function_addr", "function_id", "function_name", "start_addr", "technique_description", "technique_id", "technique_name", "technique_url")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("description", "end_addr", "function_addr", "function_id", "function_name", "start_addr", "technique_description", "technique_id", "technique_name", "technique_url")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Technique + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Technique.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Technique is not found in the empty JSON string", Technique.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Technique.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("end_addr").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `end_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("end_addr").toString())); + } + if (!jsonObj.get("function_addr").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_addr").toString())); + } + if (!jsonObj.get("function_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + } + if (!jsonObj.get("start_addr").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_addr").toString())); + } + if (!jsonObj.get("technique_description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_description").toString())); + } + if (!jsonObj.get("technique_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_id").toString())); + } + if (!jsonObj.get("technique_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_name").toString())); + } + if (!jsonObj.get("technique_url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_url").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Technique.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Technique' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Technique.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Technique value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Technique read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Technique instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Technique given an JSON string + * + * @param jsonString JSON string + * @return An instance of Technique + * @throws IOException if the JSON string is invalid with respect to Technique + */ + public static Technique fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Technique.class); + } + + /** + * Convert an instance of Technique to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/ThreatReportResult.java b/src/main/java/ai/reveng/model/ThreatReportResult.java new file mode 100644 index 00000000..11202a38 --- /dev/null +++ b/src/main/java/ai/reveng/model/ThreatReportResult.java @@ -0,0 +1,512 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.IOC; +import ai.reveng.model.Technique; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ThreatReportResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ThreatReportResult { + public static final String SERIALIZED_NAME_IO_CS = "IOCs"; + @SerializedName(SERIALIZED_NAME_IO_CS) + @javax.annotation.Nullable + private List ioCs; + + public static final String SERIALIZED_NAME_ATTACK_FLOW_SUMMARY = "attack_flow_summary"; + @SerializedName(SERIALIZED_NAME_ATTACK_FLOW_SUMMARY) + @javax.annotation.Nonnull + private String attackFlowSummary; + + public static final String SERIALIZED_NAME_EXECUTABLE_TECHNIQUES = "executable_techniques"; + @SerializedName(SERIALIZED_NAME_EXECUTABLE_TECHNIQUES) + @javax.annotation.Nullable + private List executableTechniques; + + public static final String SERIALIZED_NAME_NUMBER_OF_ANALYSED_FUNCTIONS = "number_of_analysed_functions"; + @SerializedName(SERIALIZED_NAME_NUMBER_OF_ANALYSED_FUNCTIONS) + @javax.annotation.Nonnull + private Long numberOfAnalysedFunctions; + + public static final String SERIALIZED_NAME_SOFTWARE_TYPE = "software_type"; + @SerializedName(SERIALIZED_NAME_SOFTWARE_TYPE) + @javax.annotation.Nonnull + private String softwareType; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nonnull + private String summary; + + public static final String SERIALIZED_NAME_TOTAL_NUMBER_OF_FUNCTIONS = "total_number_of_functions"; + @SerializedName(SERIALIZED_NAME_TOTAL_NUMBER_OF_FUNCTIONS) + @javax.annotation.Nonnull + private Long totalNumberOfFunctions; + + public static final String SERIALIZED_NAME_YARA_RULE = "yara_rule"; + @SerializedName(SERIALIZED_NAME_YARA_RULE) + @javax.annotation.Nonnull + private String yaraRule; + + public ThreatReportResult() { + } + + public ThreatReportResult ioCs(@javax.annotation.Nullable List ioCs) { + this.ioCs = ioCs; + return this; + } + + public ThreatReportResult addIoCsItem(IOC ioCsItem) { + if (this.ioCs == null) { + this.ioCs = new ArrayList<>(); + } + this.ioCs.add(ioCsItem); + return this; + } + + /** + * Indicators of compromise found. An indicator whose source does not resolve to a function is still listed, without function details. + * @return ioCs + */ + @javax.annotation.Nullable + public List getIoCs() { + return ioCs; + } + + public void setIoCs(@javax.annotation.Nullable List ioCs) { + this.ioCs = ioCs; + } + + + public ThreatReportResult attackFlowSummary(@javax.annotation.Nonnull String attackFlowSummary) { + this.attackFlowSummary = attackFlowSummary; + return this; + } + + /** + * Markdown summary of the attack flow + * @return attackFlowSummary + */ + @javax.annotation.Nonnull + public String getAttackFlowSummary() { + return attackFlowSummary; + } + + public void setAttackFlowSummary(@javax.annotation.Nonnull String attackFlowSummary) { + this.attackFlowSummary = attackFlowSummary; + } + + + public ThreatReportResult executableTechniques(@javax.annotation.Nullable List executableTechniques) { + this.executableTechniques = executableTechniques; + return this; + } + + public ThreatReportResult addExecutableTechniquesItem(Technique executableTechniquesItem) { + if (this.executableTechniques == null) { + this.executableTechniques = new ArrayList<>(); + } + this.executableTechniques.add(executableTechniquesItem); + return this; + } + + /** + * MITRE ATT&CK techniques found. A technique is listed only when both its function and its ATT&CK catalogue entry resolve. + * @return executableTechniques + */ + @javax.annotation.Nullable + public List getExecutableTechniques() { + return executableTechniques; + } + + public void setExecutableTechniques(@javax.annotation.Nullable List executableTechniques) { + this.executableTechniques = executableTechniques; + } + + + public ThreatReportResult numberOfAnalysedFunctions(@javax.annotation.Nonnull Long numberOfAnalysedFunctions) { + this.numberOfAnalysedFunctions = numberOfAnalysedFunctions; + return this; + } + + /** + * Functions the agent analysed + * @return numberOfAnalysedFunctions + */ + @javax.annotation.Nonnull + public Long getNumberOfAnalysedFunctions() { + return numberOfAnalysedFunctions; + } + + public void setNumberOfAnalysedFunctions(@javax.annotation.Nonnull Long numberOfAnalysedFunctions) { + this.numberOfAnalysedFunctions = numberOfAnalysedFunctions; + } + + + public ThreatReportResult softwareType(@javax.annotation.Nonnull String softwareType) { + this.softwareType = softwareType; + return this; + } + + /** + * Classification of the binary + * @return softwareType + */ + @javax.annotation.Nonnull + public String getSoftwareType() { + return softwareType; + } + + public void setSoftwareType(@javax.annotation.Nonnull String softwareType) { + this.softwareType = softwareType; + } + + + public ThreatReportResult summary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + return this; + } + + /** + * Summary of the analysis findings + * @return summary + */ + @javax.annotation.Nonnull + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + } + + + public ThreatReportResult totalNumberOfFunctions(@javax.annotation.Nonnull Long totalNumberOfFunctions) { + this.totalNumberOfFunctions = totalNumberOfFunctions; + return this; + } + + /** + * Functions identified in the binary + * @return totalNumberOfFunctions + */ + @javax.annotation.Nonnull + public Long getTotalNumberOfFunctions() { + return totalNumberOfFunctions; + } + + public void setTotalNumberOfFunctions(@javax.annotation.Nonnull Long totalNumberOfFunctions) { + this.totalNumberOfFunctions = totalNumberOfFunctions; + } + + + public ThreatReportResult yaraRule(@javax.annotation.Nonnull String yaraRule) { + this.yaraRule = yaraRule; + return this; + } + + /** + * YARA rule generated for the binary + * @return yaraRule + */ + @javax.annotation.Nonnull + public String getYaraRule() { + return yaraRule; + } + + public void setYaraRule(@javax.annotation.Nonnull String yaraRule) { + this.yaraRule = yaraRule; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ThreatReportResult instance itself + */ + public ThreatReportResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThreatReportResult threatReportResult = (ThreatReportResult) o; + return Objects.equals(this.ioCs, threatReportResult.ioCs) && + Objects.equals(this.attackFlowSummary, threatReportResult.attackFlowSummary) && + Objects.equals(this.executableTechniques, threatReportResult.executableTechniques) && + Objects.equals(this.numberOfAnalysedFunctions, threatReportResult.numberOfAnalysedFunctions) && + Objects.equals(this.softwareType, threatReportResult.softwareType) && + Objects.equals(this.summary, threatReportResult.summary) && + Objects.equals(this.totalNumberOfFunctions, threatReportResult.totalNumberOfFunctions) && + Objects.equals(this.yaraRule, threatReportResult.yaraRule)&& + Objects.equals(this.additionalProperties, threatReportResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ioCs, attackFlowSummary, executableTechniques, numberOfAnalysedFunctions, softwareType, summary, totalNumberOfFunctions, yaraRule, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ThreatReportResult {\n"); + sb.append(" ioCs: ").append(toIndentedString(ioCs)).append("\n"); + sb.append(" attackFlowSummary: ").append(toIndentedString(attackFlowSummary)).append("\n"); + sb.append(" executableTechniques: ").append(toIndentedString(executableTechniques)).append("\n"); + sb.append(" numberOfAnalysedFunctions: ").append(toIndentedString(numberOfAnalysedFunctions)).append("\n"); + sb.append(" softwareType: ").append(toIndentedString(softwareType)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" totalNumberOfFunctions: ").append(toIndentedString(totalNumberOfFunctions)).append("\n"); + sb.append(" yaraRule: ").append(toIndentedString(yaraRule)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("IOCs", "attack_flow_summary", "executable_techniques", "number_of_analysed_functions", "software_type", "summary", "total_number_of_functions", "yara_rule")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("IOCs", "attack_flow_summary", "executable_techniques", "number_of_analysed_functions", "software_type", "summary", "total_number_of_functions", "yara_rule")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ThreatReportResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ThreatReportResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ThreatReportResult is not found in the empty JSON string", ThreatReportResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ThreatReportResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("IOCs") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("IOCs").isJsonArray() && !jsonObj.get("IOCs").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `IOCs` to be an array in the JSON string but got `%s`", jsonObj.get("IOCs").toString())); + } + if (!jsonObj.get("attack_flow_summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `attack_flow_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attack_flow_summary").toString())); + } + // ensure the required json array is present + if (jsonObj.get("executable_techniques") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("executable_techniques").isJsonArray() && !jsonObj.get("executable_techniques").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `executable_techniques` to be an array in the JSON string but got `%s`", jsonObj.get("executable_techniques").toString())); + } + if (!jsonObj.get("software_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `software_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("software_type").toString())); + } + if (!jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + if (!jsonObj.get("yara_rule").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `yara_rule` to be a primitive type in the JSON string but got `%s`", jsonObj.get("yara_rule").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ThreatReportResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ThreatReportResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ThreatReportResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ThreatReportResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ThreatReportResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ThreatReportResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ThreatReportResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of ThreatReportResult + * @throws IOException if the JSON string is invalid with respect to ThreatReportResult + */ + public static ThreatReportResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ThreatReportResult.class); + } + + /** + * Convert an instance of ThreatReportResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Token.java b/src/main/java/ai/reveng/model/Token.java index ed0eb2d0..df39744c 100644 --- a/src/main/java/ai/reveng/model/Token.java +++ b/src/main/java/ai/reveng/model/Token.java @@ -75,6 +75,50 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Token instance itself + */ + public Token putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } Token token = (Token) o; - return Objects.equals(this.value, token.value); + return Objects.equals(this.value, token.value)&& + Objects.equals(this.additionalProperties, token.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value); + return Objects.hash(value, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Token {\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Token.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Token` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Token.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -171,6 +209,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Token value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -178,7 +238,28 @@ public void write(JsonWriter out, Token value) throws IOException { public Token read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Token instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/TokenisedData.java b/src/main/java/ai/reveng/model/TokenisedData.java index 7f74fb76..048b72ed 100644 --- a/src/main/java/ai/reveng/model/TokenisedData.java +++ b/src/main/java/ai/reveng/model/TokenisedData.java @@ -376,19 +376,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { - JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); - if (jsonArrayentities != null) { - // ensure the json data is an array - if (!jsonObj.get("entities").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); - } - - // validate the optional field `entities` (array) - for (int i = 0; i < jsonArrayentities.size(); i++) { - ResolvedEntity.validateJsonElement(jsonArrayentities.get(i)); - }; - } + // ensure the optional json data is an array if present + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull() && !jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); } if ((jsonObj.get("predicted_function_name") != null && !jsonObj.get("predicted_function_name").isJsonNull()) && !jsonObj.get("predicted_function_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `predicted_function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("predicted_function_name").toString())); diff --git a/src/main/java/ai/reveng/model/TriageFunction.java b/src/main/java/ai/reveng/model/TriageFunction.java new file mode 100644 index 00000000..c8a7f6f9 --- /dev/null +++ b/src/main/java/ai/reveng/model/TriageFunction.java @@ -0,0 +1,409 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriageFunction + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriageFunction { + public static final String SERIALIZED_NAME_ADDRESS = "address"; + @SerializedName(SERIALIZED_NAME_ADDRESS) + @javax.annotation.Nonnull + private Long address; + + public static final String SERIALIZED_NAME_CAPABILITIES = "capabilities"; + @SerializedName(SERIALIZED_NAME_CAPABILITIES) + @javax.annotation.Nullable + private List capabilities; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private Long id; + + public static final String SERIALIZED_NAME_SCORE = "score"; + @SerializedName(SERIALIZED_NAME_SCORE) + @javax.annotation.Nonnull + private Double score; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nonnull + private String summary; + + public TriageFunction() { + } + + public TriageFunction address(@javax.annotation.Nonnull Long address) { + this.address = address; + return this; + } + + /** + * Virtual address of the function + * @return address + */ + @javax.annotation.Nonnull + public Long getAddress() { + return address; + } + + public void setAddress(@javax.annotation.Nonnull Long address) { + this.address = address; + } + + + public TriageFunction capabilities(@javax.annotation.Nullable List capabilities) { + this.capabilities = capabilities; + return this; + } + + public TriageFunction addCapabilitiesItem(String capabilitiesItem) { + if (this.capabilities == null) { + this.capabilities = new ArrayList<>(); + } + this.capabilities.add(capabilitiesItem); + return this; + } + + /** + * Capability categories the function exhibits + * @return capabilities + */ + @javax.annotation.Nullable + public List getCapabilities() { + return capabilities; + } + + public void setCapabilities(@javax.annotation.Nullable List capabilities) { + this.capabilities = capabilities; + } + + + public TriageFunction id(@javax.annotation.Nonnull Long id) { + this.id = id; + return this; + } + + /** + * ID of the function + * @return id + */ + @javax.annotation.Nonnull + public Long getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull Long id) { + this.id = id; + } + + + public TriageFunction score(@javax.annotation.Nonnull Double score) { + this.score = score; + return this; + } + + /** + * Maliciousness score for the function, 0 to 1 + * @return score + */ + @javax.annotation.Nonnull + public Double getScore() { + return score; + } + + public void setScore(@javax.annotation.Nonnull Double score) { + this.score = score; + } + + + public TriageFunction summary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + return this; + } + + /** + * What the function does + * @return summary + */ + @javax.annotation.Nonnull + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriageFunction instance itself + */ + public TriageFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriageFunction triageFunction = (TriageFunction) o; + return Objects.equals(this.address, triageFunction.address) && + Objects.equals(this.capabilities, triageFunction.capabilities) && + Objects.equals(this.id, triageFunction.id) && + Objects.equals(this.score, triageFunction.score) && + Objects.equals(this.summary, triageFunction.summary)&& + Objects.equals(this.additionalProperties, triageFunction.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(address, capabilities, id, score, summary, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriageFunction {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" capabilities: ").append(toIndentedString(capabilities)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" score: ").append(toIndentedString(score)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("address", "capabilities", "id", "score", "summary")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("address", "capabilities", "id", "score", "summary")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriageFunction + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriageFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriageFunction is not found in the empty JSON string", TriageFunction.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TriageFunction.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("capabilities") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("capabilities").isJsonArray() && !jsonObj.get("capabilities").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + } + if (!jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriageFunction.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriageFunction' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriageFunction.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriageFunction value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriageFunction read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriageFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriageFunction given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriageFunction + * @throws IOException if the JSON string is invalid with respect to TriageFunction + */ + public static TriageFunction fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriageFunction.class); + } + + /** + * Convert an instance of TriageFunction to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriageResult.java b/src/main/java/ai/reveng/model/TriageResult.java new file mode 100644 index 00000000..aa1e233b --- /dev/null +++ b/src/main/java/ai/reveng/model/TriageResult.java @@ -0,0 +1,358 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.TriageFunction; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriageResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriageResult { + public static final String SERIALIZED_NAME_FUNCTIONS = "functions"; + @SerializedName(SERIALIZED_NAME_FUNCTIONS) + @javax.annotation.Nullable + private List functions; + + public static final String SERIALIZED_NAME_SOFTWARE_SCORE = "software_score"; + @SerializedName(SERIALIZED_NAME_SOFTWARE_SCORE) + @javax.annotation.Nonnull + private Double softwareScore; + + public static final String SERIALIZED_NAME_SUMMARY = "summary"; + @SerializedName(SERIALIZED_NAME_SUMMARY) + @javax.annotation.Nonnull + private String summary; + + public TriageResult() { + } + + public TriageResult functions(@javax.annotation.Nullable List functions) { + this.functions = functions; + return this; + } + + public TriageResult addFunctionsItem(TriageFunction functionsItem) { + if (this.functions == null) { + this.functions = new ArrayList<>(); + } + this.functions.add(functionsItem); + return this; + } + + /** + * Per-function assessments. A function whose address no longer resolves within the analysis is omitted. + * @return functions + */ + @javax.annotation.Nullable + public List getFunctions() { + return functions; + } + + public void setFunctions(@javax.annotation.Nullable List functions) { + this.functions = functions; + } + + + public TriageResult softwareScore(@javax.annotation.Nonnull Double softwareScore) { + this.softwareScore = softwareScore; + return this; + } + + /** + * Maliciousness score for the binary, 0 to 1 + * @return softwareScore + */ + @javax.annotation.Nonnull + public Double getSoftwareScore() { + return softwareScore; + } + + public void setSoftwareScore(@javax.annotation.Nonnull Double softwareScore) { + this.softwareScore = softwareScore; + } + + + public TriageResult summary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + return this; + } + + /** + * Summary of the triage assessment + * @return summary + */ + @javax.annotation.Nonnull + public String getSummary() { + return summary; + } + + public void setSummary(@javax.annotation.Nonnull String summary) { + this.summary = summary; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriageResult instance itself + */ + public TriageResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriageResult triageResult = (TriageResult) o; + return Objects.equals(this.functions, triageResult.functions) && + Objects.equals(this.softwareScore, triageResult.softwareScore) && + Objects.equals(this.summary, triageResult.summary)&& + Objects.equals(this.additionalProperties, triageResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(functions, softwareScore, summary, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriageResult {\n"); + sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); + sb.append(" softwareScore: ").append(toIndentedString(softwareScore)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("functions", "software_score", "summary")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("functions", "software_score", "summary")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriageResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriageResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriageResult is not found in the empty JSON string", TriageResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TriageResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("functions") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("functions").isJsonArray() && !jsonObj.get("functions").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + if (!jsonObj.get("summary").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriageResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriageResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriageResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriageResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriageResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriageResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriageResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriageResult + * @throws IOException if the JSON string is invalid with respect to TriageResult + */ + public static TriageResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriageResult.class); + } + + /** + * Convert an instance of TriageResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerCryptoScanInputBody.java b/src/main/java/ai/reveng/model/TriggerCryptoScanInputBody.java new file mode 100644 index 00000000..ac165fb0 --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerCryptoScanInputBody.java @@ -0,0 +1,501 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerCryptoScanInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerCryptoScanInputBody { + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + SYMMETRIC("symmetric"), + + ASYMMETRIC("asymmetric"), + + HASHING("hashing"), + + MAC("mac"), + + KDF("kdf"), + + RNG("rng"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + public static final String SERIALIZED_NAME_DIRECT_ONLY = "direct_only"; + @SerializedName(SERIALIZED_NAME_DIRECT_ONLY) + @javax.annotation.Nullable + private Boolean directOnly; + + /** + * Gets or Sets libraries + */ + @JsonAdapter(LibrariesEnum.Adapter.class) + public enum LibrariesEnum { + OPENSSL("openssl"), + + MBEDTLS("mbedtls"), + + WOLFSSL("wolfssl"), + + LIBSODIUM("libsodium"), + + LIBGCRYPT("libgcrypt"), + + WINDOWS_CRYPTO_API("windows_crypto_api"), + + CRYPTOPP("cryptopp"), + + CPP_CRYPTO("cpp-crypto"), + + GENERIC("generic"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + LibrariesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LibrariesEnum fromValue(String value) { + for (LibrariesEnum b : LibrariesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LibrariesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LibrariesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LibrariesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + LibrariesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_LIBRARIES = "libraries"; + @SerializedName(SERIALIZED_NAME_LIBRARIES) + @javax.annotation.Nullable + private List libraries; + + public TriggerCryptoScanInputBody() { + } + + public TriggerCryptoScanInputBody categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public TriggerCryptoScanInputBody addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Restrict findings to these categories. Omit to scan every category. + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public TriggerCryptoScanInputBody directOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + return this; + } + + /** + * Only report functions whose own name matches a known crypto API; skips the calls-into-crypto pass, avoiding a bulk call-graph fetch. + * @return directOnly + */ + @javax.annotation.Nullable + public Boolean getDirectOnly() { + return directOnly; + } + + public void setDirectOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + } + + + public TriggerCryptoScanInputBody libraries(@javax.annotation.Nullable List libraries) { + this.libraries = libraries; + return this; + } + + public TriggerCryptoScanInputBody addLibrariesItem(LibrariesEnum librariesItem) { + if (this.libraries == null) { + this.libraries = new ArrayList<>(); + } + this.libraries.add(librariesItem); + return this; + } + + /** + * Restrict findings to these libraries. Omit to scan every library. + * @return libraries + */ + @javax.annotation.Nullable + public List getLibraries() { + return libraries; + } + + public void setLibraries(@javax.annotation.Nullable List libraries) { + this.libraries = libraries; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerCryptoScanInputBody instance itself + */ + public TriggerCryptoScanInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerCryptoScanInputBody triggerCryptoScanInputBody = (TriggerCryptoScanInputBody) o; + return Objects.equals(this.categories, triggerCryptoScanInputBody.categories) && + Objects.equals(this.directOnly, triggerCryptoScanInputBody.directOnly) && + Objects.equals(this.libraries, triggerCryptoScanInputBody.libraries)&& + Objects.equals(this.additionalProperties, triggerCryptoScanInputBody.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(categories, directOnly, libraries, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerCryptoScanInputBody {\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" directOnly: ").append(toIndentedString(directOnly)).append("\n"); + sb.append(" libraries: ").append(toIndentedString(libraries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("categories", "direct_only", "libraries")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerCryptoScanInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerCryptoScanInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerCryptoScanInputBody is not found in the empty JSON string", TriggerCryptoScanInputBody.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("categories") != null && !jsonObj.get("categories").isJsonNull() && !jsonObj.get("categories").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("libraries") != null && !jsonObj.get("libraries").isJsonNull() && !jsonObj.get("libraries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `libraries` to be an array in the JSON string but got `%s`", jsonObj.get("libraries").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerCryptoScanInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerCryptoScanInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerCryptoScanInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerCryptoScanInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerCryptoScanInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerCryptoScanInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerCryptoScanInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerCryptoScanInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerCryptoScanInputBody + */ + public static TriggerCryptoScanInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerCryptoScanInputBody.class); + } + + /** + * Convert an instance of TriggerCryptoScanInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerExecutionExplainInputBody.java b/src/main/java/ai/reveng/model/TriggerExecutionExplainInputBody.java new file mode 100644 index 00000000..bd8d2788 --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerExecutionExplainInputBody.java @@ -0,0 +1,361 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerExecutionExplainInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerExecutionExplainInputBody { + /** + * Execution category to focus the explanation on. + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + DYNAMIC_RESOLVE("dynamic-resolve"), + + HOOKING("hooking"), + + INJECTION("injection"), + + MEMORY_EXEC("memory-exec"), + + MODULE_LOAD("module-load"), + + PROCESS_CONTROL("process-control"), + + PROCESS_CREATE("process-create"), + + SCRIPT_EXEC("script-exec"), + + SHELLCODE("shellcode"), + + THREAD_CREATE("thread-create"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + public TriggerExecutionExplainInputBody() { + } + + public TriggerExecutionExplainInputBody category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Execution category to focus the explanation on. + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerExecutionExplainInputBody instance itself + */ + public TriggerExecutionExplainInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerExecutionExplainInputBody triggerExecutionExplainInputBody = (TriggerExecutionExplainInputBody) o; + return Objects.equals(this.category, triggerExecutionExplainInputBody.category)&& + Objects.equals(this.additionalProperties, triggerExecutionExplainInputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerExecutionExplainInputBody {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("category")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("category")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerExecutionExplainInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerExecutionExplainInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerExecutionExplainInputBody is not found in the empty JSON string", TriggerExecutionExplainInputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TriggerExecutionExplainInputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerExecutionExplainInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerExecutionExplainInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerExecutionExplainInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerExecutionExplainInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerExecutionExplainInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerExecutionExplainInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerExecutionExplainInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerExecutionExplainInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerExecutionExplainInputBody + */ + public static TriggerExecutionExplainInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerExecutionExplainInputBody.class); + } + + /** + * Convert an instance of TriggerExecutionExplainInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerExecutionScanInputBody.java b/src/main/java/ai/reveng/model/TriggerExecutionScanInputBody.java new file mode 100644 index 00000000..5248f507 --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerExecutionScanInputBody.java @@ -0,0 +1,505 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerExecutionScanInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerExecutionScanInputBody { + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + DYNAMIC_RESOLVE("dynamic-resolve"), + + HOOKING("hooking"), + + INJECTION("injection"), + + MEMORY_EXEC("memory-exec"), + + MODULE_LOAD("module-load"), + + PROCESS_CONTROL("process-control"), + + PROCESS_CREATE("process-create"), + + SCRIPT_EXEC("script-exec"), + + SHELLCODE("shellcode"), + + THREAD_CREATE("thread-create"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + public static final String SERIALIZED_NAME_DIRECT_ONLY = "direct_only"; + @SerializedName(SERIALIZED_NAME_DIRECT_ONLY) + @javax.annotation.Nullable + private Boolean directOnly; + + /** + * Gets or Sets sources + */ + @JsonAdapter(SourcesEnum.Adapter.class) + public enum SourcesEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + SCRIPT_ENGINE("script-engine"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourcesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourcesEnum fromValue(String value) { + for (SourcesEnum b : SourcesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourcesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourcesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourcesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourcesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCES = "sources"; + @SerializedName(SERIALIZED_NAME_SOURCES) + @javax.annotation.Nullable + private List sources; + + public TriggerExecutionScanInputBody() { + } + + public TriggerExecutionScanInputBody categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public TriggerExecutionScanInputBody addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Restrict findings to these categories. Omit to scan the default executes-code set. + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public TriggerExecutionScanInputBody directOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + return this; + } + + /** + * Only report functions whose own name matches a known execution API; skips the calls-into-execution pass, avoiding a bulk call-graph fetch. + * @return directOnly + */ + @javax.annotation.Nullable + public Boolean getDirectOnly() { + return directOnly; + } + + public void setDirectOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + } + + + public TriggerExecutionScanInputBody sources(@javax.annotation.Nullable List sources) { + this.sources = sources; + return this; + } + + public TriggerExecutionScanInputBody addSourcesItem(SourcesEnum sourcesItem) { + if (this.sources == null) { + this.sources = new ArrayList<>(); + } + this.sources.add(sourcesItem); + return this; + } + + /** + * Restrict findings to these sources. Omit to scan every source. + * @return sources + */ + @javax.annotation.Nullable + public List getSources() { + return sources; + } + + public void setSources(@javax.annotation.Nullable List sources) { + this.sources = sources; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerExecutionScanInputBody instance itself + */ + public TriggerExecutionScanInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerExecutionScanInputBody triggerExecutionScanInputBody = (TriggerExecutionScanInputBody) o; + return Objects.equals(this.categories, triggerExecutionScanInputBody.categories) && + Objects.equals(this.directOnly, triggerExecutionScanInputBody.directOnly) && + Objects.equals(this.sources, triggerExecutionScanInputBody.sources)&& + Objects.equals(this.additionalProperties, triggerExecutionScanInputBody.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(categories, directOnly, sources, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerExecutionScanInputBody {\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" directOnly: ").append(toIndentedString(directOnly)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("categories", "direct_only", "sources")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerExecutionScanInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerExecutionScanInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerExecutionScanInputBody is not found in the empty JSON string", TriggerExecutionScanInputBody.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("categories") != null && !jsonObj.get("categories").isJsonNull() && !jsonObj.get("categories").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("sources") != null && !jsonObj.get("sources").isJsonNull() && !jsonObj.get("sources").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sources` to be an array in the JSON string but got `%s`", jsonObj.get("sources").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerExecutionScanInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerExecutionScanInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerExecutionScanInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerExecutionScanInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerExecutionScanInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerExecutionScanInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerExecutionScanInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerExecutionScanInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerExecutionScanInputBody + */ + public static TriggerExecutionScanInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerExecutionScanInputBody.class); + } + + /** + * Convert an instance of TriggerExecutionScanInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerFilesystemAnalyseInputBody.java b/src/main/java/ai/reveng/model/TriggerFilesystemAnalyseInputBody.java new file mode 100644 index 00000000..e090ba2e --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerFilesystemAnalyseInputBody.java @@ -0,0 +1,373 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerFilesystemAnalyseInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerFilesystemAnalyseInputBody { + /** + * Filesystem category to focus the explanation on. + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + DIR_READ("dir-read"), + + DIR_WRITE("dir-write"), + + ENVIRONMENT("environment"), + + FILE_DELETE("file-delete"), + + FILE_OPEN("file-open"), + + FILE_PERMS("file-perms"), + + FILE_READ("file-read"), + + FILE_STAT("file-stat"), + + FILE_WRITE("file-write"), + + MODULE("module"), + + PATH_WRITE("path-write"), + + PROCESS("process"), + + REGISTRY_READ("registry-read"), + + REGISTRY_WRITE("registry-write"), + + SERVICE("service"), + + SYSTEM("system"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + public TriggerFilesystemAnalyseInputBody() { + } + + public TriggerFilesystemAnalyseInputBody category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Filesystem category to focus the explanation on. + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerFilesystemAnalyseInputBody instance itself + */ + public TriggerFilesystemAnalyseInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerFilesystemAnalyseInputBody triggerFilesystemAnalyseInputBody = (TriggerFilesystemAnalyseInputBody) o; + return Objects.equals(this.category, triggerFilesystemAnalyseInputBody.category)&& + Objects.equals(this.additionalProperties, triggerFilesystemAnalyseInputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerFilesystemAnalyseInputBody {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("category")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("category")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerFilesystemAnalyseInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerFilesystemAnalyseInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerFilesystemAnalyseInputBody is not found in the empty JSON string", TriggerFilesystemAnalyseInputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TriggerFilesystemAnalyseInputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerFilesystemAnalyseInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerFilesystemAnalyseInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerFilesystemAnalyseInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerFilesystemAnalyseInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerFilesystemAnalyseInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerFilesystemAnalyseInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerFilesystemAnalyseInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerFilesystemAnalyseInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerFilesystemAnalyseInputBody + */ + public static TriggerFilesystemAnalyseInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerFilesystemAnalyseInputBody.class); + } + + /** + * Convert an instance of TriggerFilesystemAnalyseInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerFilesystemScanInputBody.java b/src/main/java/ai/reveng/model/TriggerFilesystemScanInputBody.java new file mode 100644 index 00000000..95b05376 --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerFilesystemScanInputBody.java @@ -0,0 +1,515 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerFilesystemScanInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerFilesystemScanInputBody { + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + DIR_READ("dir-read"), + + DIR_WRITE("dir-write"), + + ENVIRONMENT("environment"), + + FILE_DELETE("file-delete"), + + FILE_OPEN("file-open"), + + FILE_PERMS("file-perms"), + + FILE_READ("file-read"), + + FILE_STAT("file-stat"), + + FILE_WRITE("file-write"), + + MODULE("module"), + + PATH_WRITE("path-write"), + + PROCESS("process"), + + REGISTRY_READ("registry-read"), + + REGISTRY_WRITE("registry-write"), + + SERVICE("service"), + + SYSTEM("system"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + public static final String SERIALIZED_NAME_DIRECT_ONLY = "direct_only"; + @SerializedName(SERIALIZED_NAME_DIRECT_ONLY) + @javax.annotation.Nullable + private Boolean directOnly; + + /** + * Gets or Sets sources + */ + @JsonAdapter(SourcesEnum.Adapter.class) + public enum SourcesEnum { + BOOST("boost"), + + CPP("cpp"), + + CPP_STDLIB("cpp-stdlib"), + + GENERIC("generic"), + + LIBC("libc"), + + QT("qt"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourcesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourcesEnum fromValue(String value) { + for (SourcesEnum b : SourcesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourcesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourcesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourcesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourcesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCES = "sources"; + @SerializedName(SERIALIZED_NAME_SOURCES) + @javax.annotation.Nullable + private List sources; + + public TriggerFilesystemScanInputBody() { + } + + public TriggerFilesystemScanInputBody categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public TriggerFilesystemScanInputBody addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Restrict findings to these categories. Omit to scan the default filesystem-modifying set. + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public TriggerFilesystemScanInputBody directOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + return this; + } + + /** + * Only report functions whose own name matches a known filesystem API; skips the calls-into-filesystem pass, avoiding a bulk call-graph fetch. + * @return directOnly + */ + @javax.annotation.Nullable + public Boolean getDirectOnly() { + return directOnly; + } + + public void setDirectOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + } + + + public TriggerFilesystemScanInputBody sources(@javax.annotation.Nullable List sources) { + this.sources = sources; + return this; + } + + public TriggerFilesystemScanInputBody addSourcesItem(SourcesEnum sourcesItem) { + if (this.sources == null) { + this.sources = new ArrayList<>(); + } + this.sources.add(sourcesItem); + return this; + } + + /** + * Restrict findings to these sources. Omit to scan every source. + * @return sources + */ + @javax.annotation.Nullable + public List getSources() { + return sources; + } + + public void setSources(@javax.annotation.Nullable List sources) { + this.sources = sources; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerFilesystemScanInputBody instance itself + */ + public TriggerFilesystemScanInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerFilesystemScanInputBody triggerFilesystemScanInputBody = (TriggerFilesystemScanInputBody) o; + return Objects.equals(this.categories, triggerFilesystemScanInputBody.categories) && + Objects.equals(this.directOnly, triggerFilesystemScanInputBody.directOnly) && + Objects.equals(this.sources, triggerFilesystemScanInputBody.sources)&& + Objects.equals(this.additionalProperties, triggerFilesystemScanInputBody.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(categories, directOnly, sources, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerFilesystemScanInputBody {\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" directOnly: ").append(toIndentedString(directOnly)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("categories", "direct_only", "sources")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerFilesystemScanInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerFilesystemScanInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerFilesystemScanInputBody is not found in the empty JSON string", TriggerFilesystemScanInputBody.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("categories") != null && !jsonObj.get("categories").isJsonNull() && !jsonObj.get("categories").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("sources") != null && !jsonObj.get("sources").isJsonNull() && !jsonObj.get("sources").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sources` to be an array in the JSON string but got `%s`", jsonObj.get("sources").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerFilesystemScanInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerFilesystemScanInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerFilesystemScanInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerFilesystemScanInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerFilesystemScanInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerFilesystemScanInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerFilesystemScanInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerFilesystemScanInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerFilesystemScanInputBody + */ + public static TriggerFilesystemScanInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerFilesystemScanInputBody.class); + } + + /** + * Convert an instance of TriggerFilesystemScanInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerNetworkingExplainInputBody.java b/src/main/java/ai/reveng/model/TriggerNetworkingExplainInputBody.java new file mode 100644 index 00000000..085e2e44 --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerNetworkingExplainInputBody.java @@ -0,0 +1,365 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerNetworkingExplainInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerNetworkingExplainInputBody { + /** + * Networking category to focus the explanation on. + */ + @JsonAdapter(CategoryEnum.Adapter.class) + public enum CategoryEnum { + ACCEPT("accept"), + + ADDRESS("address"), + + CONNECT("connect"), + + DNS("dns"), + + HTTP("http"), + + NETINFO("netinfo"), + + RAW_PACKET("raw-packet"), + + RECV("recv"), + + SEND("send"), + + SOCKET("socket"), + + TLS("tls"), + + URL("url"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoryEnum fromValue(String value) { + for (CategoryEnum b : CategoryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoryEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoryEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoryEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + @javax.annotation.Nonnull + private CategoryEnum category; + + public TriggerNetworkingExplainInputBody() { + } + + public TriggerNetworkingExplainInputBody category(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + return this; + } + + /** + * Networking category to focus the explanation on. + * @return category + */ + @javax.annotation.Nonnull + public CategoryEnum getCategory() { + return category; + } + + public void setCategory(@javax.annotation.Nonnull CategoryEnum category) { + this.category = category; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerNetworkingExplainInputBody instance itself + */ + public TriggerNetworkingExplainInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerNetworkingExplainInputBody triggerNetworkingExplainInputBody = (TriggerNetworkingExplainInputBody) o; + return Objects.equals(this.category, triggerNetworkingExplainInputBody.category)&& + Objects.equals(this.additionalProperties, triggerNetworkingExplainInputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerNetworkingExplainInputBody {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("category")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("category")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerNetworkingExplainInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerNetworkingExplainInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerNetworkingExplainInputBody is not found in the empty JSON string", TriggerNetworkingExplainInputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TriggerNetworkingExplainInputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + // validate the required field `category` + CategoryEnum.validateJsonElement(jsonObj.get("category")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerNetworkingExplainInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerNetworkingExplainInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerNetworkingExplainInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerNetworkingExplainInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerNetworkingExplainInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerNetworkingExplainInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerNetworkingExplainInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerNetworkingExplainInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerNetworkingExplainInputBody + */ + public static TriggerNetworkingExplainInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerNetworkingExplainInputBody.class); + } + + /** + * Convert an instance of TriggerNetworkingExplainInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerNetworkingScanInputBody.java b/src/main/java/ai/reveng/model/TriggerNetworkingScanInputBody.java new file mode 100644 index 00000000..247f62a9 --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerNetworkingScanInputBody.java @@ -0,0 +1,513 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerNetworkingScanInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerNetworkingScanInputBody { + /** + * Gets or Sets categories + */ + @JsonAdapter(CategoriesEnum.Adapter.class) + public enum CategoriesEnum { + ACCEPT("accept"), + + ADDRESS("address"), + + CONNECT("connect"), + + DNS("dns"), + + HTTP("http"), + + NETINFO("netinfo"), + + RAW_PACKET("raw-packet"), + + RECV("recv"), + + SEND("send"), + + SOCKET("socket"), + + TLS("tls"), + + URL("url"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CategoriesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CategoriesEnum fromValue(String value) { + for (CategoriesEnum b : CategoriesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CategoriesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CategoriesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CategoriesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CategoriesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + @javax.annotation.Nullable + private List categories; + + public static final String SERIALIZED_NAME_DIRECT_ONLY = "direct_only"; + @SerializedName(SERIALIZED_NAME_DIRECT_ONLY) + @javax.annotation.Nullable + private Boolean directOnly; + + /** + * Gets or Sets sources + */ + @JsonAdapter(SourcesEnum.Adapter.class) + public enum SourcesEnum { + BOOST("boost"), + + CPP("cpp"), + + CURL("curl"), + + GENERIC("generic"), + + LIBC("libc"), + + PCAP("pcap"), + + POCO("poco"), + + QT("qt"), + + TLS("tls"), + + WINDOWS("windows"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SourcesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourcesEnum fromValue(String value) { + for (SourcesEnum b : SourcesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourcesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourcesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourcesEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + SourcesEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_SOURCES = "sources"; + @SerializedName(SERIALIZED_NAME_SOURCES) + @javax.annotation.Nullable + private List sources; + + public TriggerNetworkingScanInputBody() { + } + + public TriggerNetworkingScanInputBody categories(@javax.annotation.Nullable List categories) { + this.categories = categories; + return this; + } + + public TriggerNetworkingScanInputBody addCategoriesItem(CategoriesEnum categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); + } + this.categories.add(categoriesItem); + return this; + } + + /** + * Restrict findings to these categories. Omit to scan the default remote-communication set. + * @return categories + */ + @javax.annotation.Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@javax.annotation.Nullable List categories) { + this.categories = categories; + } + + + public TriggerNetworkingScanInputBody directOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + return this; + } + + /** + * Only report functions whose own name matches a known networking API; skips the calls-into-networking pass, avoiding a bulk call-graph fetch. + * @return directOnly + */ + @javax.annotation.Nullable + public Boolean getDirectOnly() { + return directOnly; + } + + public void setDirectOnly(@javax.annotation.Nullable Boolean directOnly) { + this.directOnly = directOnly; + } + + + public TriggerNetworkingScanInputBody sources(@javax.annotation.Nullable List sources) { + this.sources = sources; + return this; + } + + public TriggerNetworkingScanInputBody addSourcesItem(SourcesEnum sourcesItem) { + if (this.sources == null) { + this.sources = new ArrayList<>(); + } + this.sources.add(sourcesItem); + return this; + } + + /** + * Restrict findings to these sources. Omit to scan every source. + * @return sources + */ + @javax.annotation.Nullable + public List getSources() { + return sources; + } + + public void setSources(@javax.annotation.Nullable List sources) { + this.sources = sources; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerNetworkingScanInputBody instance itself + */ + public TriggerNetworkingScanInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerNetworkingScanInputBody triggerNetworkingScanInputBody = (TriggerNetworkingScanInputBody) o; + return Objects.equals(this.categories, triggerNetworkingScanInputBody.categories) && + Objects.equals(this.directOnly, triggerNetworkingScanInputBody.directOnly) && + Objects.equals(this.sources, triggerNetworkingScanInputBody.sources)&& + Objects.equals(this.additionalProperties, triggerNetworkingScanInputBody.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(categories, directOnly, sources, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerNetworkingScanInputBody {\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" directOnly: ").append(toIndentedString(directOnly)).append("\n"); + sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("categories", "direct_only", "sources")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerNetworkingScanInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerNetworkingScanInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerNetworkingScanInputBody is not found in the empty JSON string", TriggerNetworkingScanInputBody.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("categories") != null && !jsonObj.get("categories").isJsonNull() && !jsonObj.get("categories").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("sources") != null && !jsonObj.get("sources").isJsonNull() && !jsonObj.get("sources").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sources` to be an array in the JSON string but got `%s`", jsonObj.get("sources").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerNetworkingScanInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerNetworkingScanInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerNetworkingScanInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerNetworkingScanInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerNetworkingScanInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerNetworkingScanInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerNetworkingScanInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerNetworkingScanInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerNetworkingScanInputBody + */ + public static TriggerNetworkingScanInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerNetworkingScanInputBody.class); + } + + /** + * Convert an instance of TriggerNetworkingScanInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TriggerRenameUnnamedFunctionsInputBody.java b/src/main/java/ai/reveng/model/TriggerRenameUnnamedFunctionsInputBody.java index cb60c4e5..11a0eb88 100644 --- a/src/main/java/ai/reveng/model/TriggerRenameUnnamedFunctionsInputBody.java +++ b/src/main/java/ai/reveng/model/TriggerRenameUnnamedFunctionsInputBody.java @@ -76,6 +76,50 @@ public void setLimit(@javax.annotation.Nullable Long limit) { this.limit = limit; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerRenameUnnamedFunctionsInputBody instance itself + */ + public TriggerRenameUnnamedFunctionsInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } TriggerRenameUnnamedFunctionsInputBody triggerRenameUnnamedFunctionsInputBody = (TriggerRenameUnnamedFunctionsInputBody) o; - return Objects.equals(this.limit, triggerRenameUnnamedFunctionsInputBody.limit); + return Objects.equals(this.limit, triggerRenameUnnamedFunctionsInputBody.limit)&& + Objects.equals(this.additionalProperties, triggerRenameUnnamedFunctionsInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(limit); + return Objects.hash(limit, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class TriggerRenameUnnamedFunctionsInputBody {\n"); sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerRenameUnnamedFunctionsInputBody is not found in the empty JSON string", TriggerRenameUnnamedFunctionsInputBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TriggerRenameUnnamedFunctionsInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TriggerRenameUnnamedFunctionsInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -162,6 +200,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TriggerRenameUnnamedFunctionsInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -169,7 +229,28 @@ public void write(JsonWriter out, TriggerRenameUnnamedFunctionsInputBody value) public TriggerRenameUnnamedFunctionsInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerRenameUnnamedFunctionsInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/TriggerSecurityScanInputBody.java b/src/main/java/ai/reveng/model/TriggerSecurityScanInputBody.java new file mode 100644 index 00000000..2e2793ec --- /dev/null +++ b/src/main/java/ai/reveng/model/TriggerSecurityScanInputBody.java @@ -0,0 +1,280 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TriggerSecurityScanInputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TriggerSecurityScanInputBody { + public static final String SERIALIZED_NAME_MAX_FUNCTIONS_TO_SCAN = "max_functions_to_scan"; + @SerializedName(SERIALIZED_NAME_MAX_FUNCTIONS_TO_SCAN) + @javax.annotation.Nullable + private Long maxFunctionsToScan; + + public TriggerSecurityScanInputBody() { + } + + public TriggerSecurityScanInputBody maxFunctionsToScan(@javax.annotation.Nullable Long maxFunctionsToScan) { + this.maxFunctionsToScan = maxFunctionsToScan; + return this; + } + + /** + * Stop after decompiling and scanning this many functions. Omit to process every function in the analysis. + * minimum: 1 + * @return maxFunctionsToScan + */ + @javax.annotation.Nullable + public Long getMaxFunctionsToScan() { + return maxFunctionsToScan; + } + + public void setMaxFunctionsToScan(@javax.annotation.Nullable Long maxFunctionsToScan) { + this.maxFunctionsToScan = maxFunctionsToScan; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TriggerSecurityScanInputBody instance itself + */ + public TriggerSecurityScanInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerSecurityScanInputBody triggerSecurityScanInputBody = (TriggerSecurityScanInputBody) o; + return Objects.equals(this.maxFunctionsToScan, triggerSecurityScanInputBody.maxFunctionsToScan)&& + Objects.equals(this.additionalProperties, triggerSecurityScanInputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(maxFunctionsToScan, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TriggerSecurityScanInputBody {\n"); + sb.append(" maxFunctionsToScan: ").append(toIndentedString(maxFunctionsToScan)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("max_functions_to_scan")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TriggerSecurityScanInputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TriggerSecurityScanInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriggerSecurityScanInputBody is not found in the empty JSON string", TriggerSecurityScanInputBody.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TriggerSecurityScanInputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TriggerSecurityScanInputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TriggerSecurityScanInputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TriggerSecurityScanInputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TriggerSecurityScanInputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TriggerSecurityScanInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TriggerSecurityScanInputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of TriggerSecurityScanInputBody + * @throws IOException if the JSON string is invalid with respect to TriggerSecurityScanInputBody + */ + public static TriggerSecurityScanInputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TriggerSecurityScanInputBody.class); + } + + /** + * Convert an instance of TriggerSecurityScanInputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Ttp.java b/src/main/java/ai/reveng/model/Ttp.java index 4e7c700e..6ee665b1 100644 --- a/src/main/java/ai/reveng/model/Ttp.java +++ b/src/main/java/ai/reveng/model/Ttp.java @@ -222,6 +222,50 @@ public void setScore(@javax.annotation.Nonnull Long score) { this.score = score; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Ttp instance itself + */ + public Ttp putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -238,7 +282,8 @@ public boolean equals(Object o) { Objects.equals(this.name, ttp.name) && Objects.equals(this.namespace, ttp.namespace) && Objects.equals(this.processSeqids, ttp.processSeqids) && - Objects.equals(this.score, ttp.score); + Objects.equals(this.score, ttp.score)&& + Objects.equals(this.additionalProperties, ttp.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -247,7 +292,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(attAmpersandCk, mbc, name, namespace, processSeqids, score); + return Objects.hash(attAmpersandCk, mbc, name, namespace, processSeqids, score, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -267,6 +312,7 @@ public String toString() { sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" processSeqids: ").append(toIndentedString(processSeqids)).append("\n"); sb.append(" score: ").append(toIndentedString(score)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -304,14 +350,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Ttp.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Ttp` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Ttp.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -354,6 +392,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Ttp value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -361,7 +421,28 @@ public void write(JsonWriter out, Ttp value) throws IOException { public Ttp read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Ttp instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/TypeSuggestionsData.java b/src/main/java/ai/reveng/model/TypeSuggestionsData.java new file mode 100644 index 00000000..691fb3c5 --- /dev/null +++ b/src/main/java/ai/reveng/model/TypeSuggestionsData.java @@ -0,0 +1,423 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.SuggestedTypeView; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TypeSuggestionsData + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TypeSuggestionsData { + public static final String SERIALIZED_NAME_MODEL = "model"; + @SerializedName(SERIALIZED_NAME_MODEL) + @javax.annotation.Nullable + private String model; + + /** + * Status of the AI decompilation run that would have produced these suggestions. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + UNINITIALISED("UNINITIALISED"), + + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public static final String SERIALIZED_NAME_TYPES = "types"; + @SerializedName(SERIALIZED_NAME_TYPES) + @javax.annotation.Nullable + private List types; + + public TypeSuggestionsData() { + } + + public TypeSuggestionsData model(@javax.annotation.Nullable String model) { + this.model = model; + return this; + } + + /** + * Language model that produced the suggestions. + * @return model + */ + @javax.annotation.Nullable + public String getModel() { + return model; + } + + public void setModel(@javax.annotation.Nullable String model) { + this.model = model; + } + + + public TypeSuggestionsData status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Status of the AI decompilation run that would have produced these suggestions. + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + + public TypeSuggestionsData types(@javax.annotation.Nullable List types) { + this.types = types; + return this; + } + + public TypeSuggestionsData addTypesItem(SuggestedTypeView typesItem) { + if (this.types == null) { + this.types = new ArrayList<>(); + } + this.types.add(typesItem); + return this; + } + + /** + * One entry per suggested type. Empty for a run that produced none, and for a run that predates type suggestion — the two are not distinguished. + * @return types + */ + @javax.annotation.Nullable + public List getTypes() { + return types; + } + + public void setTypes(@javax.annotation.Nullable List types) { + this.types = types; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TypeSuggestionsData instance itself + */ + public TypeSuggestionsData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeSuggestionsData typeSuggestionsData = (TypeSuggestionsData) o; + return Objects.equals(this.model, typeSuggestionsData.model) && + Objects.equals(this.status, typeSuggestionsData.status) && + Objects.equals(this.types, typeSuggestionsData.types)&& + Objects.equals(this.additionalProperties, typeSuggestionsData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(model, status, types, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeSuggestionsData {\n"); + sb.append(" model: ").append(toIndentedString(model)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" types: ").append(toIndentedString(types)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("model", "status", "types")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status", "types")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TypeSuggestionsData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TypeSuggestionsData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TypeSuggestionsData is not found in the empty JSON string", TypeSuggestionsData.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TypeSuggestionsData.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("model") != null && !jsonObj.get("model").isJsonNull()) && !jsonObj.get("model").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + // ensure the required json array is present + if (jsonObj.get("types") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("types").isJsonArray() && !jsonObj.get("types").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `types` to be an array in the JSON string but got `%s`", jsonObj.get("types").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TypeSuggestionsData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TypeSuggestionsData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TypeSuggestionsData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TypeSuggestionsData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TypeSuggestionsData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TypeSuggestionsData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TypeSuggestionsData given an JSON string + * + * @param jsonString JSON string + * @return An instance of TypeSuggestionsData + * @throws IOException if the JSON string is invalid with respect to TypeSuggestionsData + */ + public static TypeSuggestionsData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TypeSuggestionsData.class); + } + + /** + * Convert an instance of TypeSuggestionsData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TypedefDataType.java b/src/main/java/ai/reveng/model/TypedefDataType.java index d84e895e..63c009bb 100644 --- a/src/main/java/ai/reveng/model/TypedefDataType.java +++ b/src/main/java/ai/reveng/model/TypedefDataType.java @@ -143,6 +143,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -366,6 +371,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public TypedefDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public TypedefDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -403,6 +427,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TypedefDataType instance itself + */ + public TypedefDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -422,13 +490,15 @@ public boolean equals(Object o) { Objects.equals(this.name, typedefDataType.name) && Objects.equals(this.namespace, typedefDataType.namespace) && Objects.equals(this.size, typedefDataType.size) && + Objects.equals(this.sourceAnalysisId, typedefDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, typedefDataType.sourceFunctionId) && - Objects.equals(this.sourceType, typedefDataType.sourceType); + Objects.equals(this.sourceType, typedefDataType.sourceType)&& + Objects.equals(this.additionalProperties, typedefDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -443,8 +513,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -463,7 +535,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -482,14 +554,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TypedefDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TypedefDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TypedefDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -497,10 +561,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `definition` - if (jsonObj.get("definition") != null && !jsonObj.get("definition").isJsonNull()) { - TypedefDefinition.validateJsonElement(jsonObj.get("definition")); - } if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -534,6 +594,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TypedefDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -541,7 +623,28 @@ public void write(JsonWriter out, TypedefDataType value) throws IOException { public TypedefDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TypedefDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/TypedefDefinition.java b/src/main/java/ai/reveng/model/TypedefDefinition.java index 8e87d4c3..669263a3 100644 --- a/src/main/java/ai/reveng/model/TypedefDefinition.java +++ b/src/main/java/ai/reveng/model/TypedefDefinition.java @@ -75,6 +75,50 @@ public void setTargetDataTypeId(@javax.annotation.Nullable Long targetDataTypeId this.targetDataTypeId = targetDataTypeId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TypedefDefinition instance itself + */ + public TypedefDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -86,12 +130,13 @@ public boolean equals(Object o) { return false; } TypedefDefinition typedefDefinition = (TypedefDefinition) o; - return Objects.equals(this.targetDataTypeId, typedefDefinition.targetDataTypeId); + return Objects.equals(this.targetDataTypeId, typedefDefinition.targetDataTypeId)&& + Objects.equals(this.additionalProperties, typedefDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(targetDataTypeId); + return Objects.hash(targetDataTypeId, additionalProperties); } @Override @@ -99,6 +144,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class TypedefDefinition {\n"); sb.append(" targetDataTypeId: ").append(toIndentedString(targetDataTypeId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -135,14 +181,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TypedefDefinition is not found in the empty JSON string", TypedefDefinition.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TypedefDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TypedefDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -161,6 +199,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TypedefDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -168,7 +228,28 @@ public void write(JsonWriter out, TypedefDefinition value) throws IOException { public TypedefDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TypedefDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/TypesSuggestedEvent.java b/src/main/java/ai/reveng/model/TypesSuggestedEvent.java new file mode 100644 index 00000000..52237ffa --- /dev/null +++ b/src/main/java/ai/reveng/model/TypesSuggestedEvent.java @@ -0,0 +1,393 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TypesSuggestedEvent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TypesSuggestedEvent { + public static final String SERIALIZED_NAME_ATTEMPT = "attempt"; + @SerializedName(SERIALIZED_NAME_ATTEMPT) + @javax.annotation.Nonnull + private Integer attempt; + + public static final String SERIALIZED_NAME_MEMBERS = "members"; + @SerializedName(SERIALIZED_NAME_MEMBERS) + @javax.annotation.Nonnull + private Integer members; + + public static final String SERIALIZED_NAME_SEQ = "seq"; + @SerializedName(SERIALIZED_NAME_SEQ) + @javax.annotation.Nonnull + private Integer seq; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public static final String SERIALIZED_NAME_TYPES = "types"; + @SerializedName(SERIALIZED_NAME_TYPES) + @javax.annotation.Nonnull + private Integer types; + + public TypesSuggestedEvent() { + } + + public TypesSuggestedEvent attempt(@javax.annotation.Nonnull Integer attempt) { + this.attempt = attempt; + return this; + } + + /** + * Get attempt + * @return attempt + */ + @javax.annotation.Nonnull + public Integer getAttempt() { + return attempt; + } + + public void setAttempt(@javax.annotation.Nonnull Integer attempt) { + this.attempt = attempt; + } + + + public TypesSuggestedEvent members(@javax.annotation.Nonnull Integer members) { + this.members = members; + return this; + } + + /** + * Get members + * @return members + */ + @javax.annotation.Nonnull + public Integer getMembers() { + return members; + } + + public void setMembers(@javax.annotation.Nonnull Integer members) { + this.members = members; + } + + + public TypesSuggestedEvent seq(@javax.annotation.Nonnull Integer seq) { + this.seq = seq; + return this; + } + + /** + * Get seq + * @return seq + */ + @javax.annotation.Nonnull + public Integer getSeq() { + return seq; + } + + public void setSeq(@javax.annotation.Nonnull Integer seq) { + this.seq = seq; + } + + + public TypesSuggestedEvent type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; + } + + + public TypesSuggestedEvent types(@javax.annotation.Nonnull Integer types) { + this.types = types; + return this; + } + + /** + * Get types + * @return types + */ + @javax.annotation.Nonnull + public Integer getTypes() { + return types; + } + + public void setTypes(@javax.annotation.Nonnull Integer types) { + this.types = types; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TypesSuggestedEvent instance itself + */ + public TypesSuggestedEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypesSuggestedEvent typesSuggestedEvent = (TypesSuggestedEvent) o; + return Objects.equals(this.attempt, typesSuggestedEvent.attempt) && + Objects.equals(this.members, typesSuggestedEvent.members) && + Objects.equals(this.seq, typesSuggestedEvent.seq) && + Objects.equals(this.type, typesSuggestedEvent.type) && + Objects.equals(this.types, typesSuggestedEvent.types)&& + Objects.equals(this.additionalProperties, typesSuggestedEvent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attempt, members, seq, type, types, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypesSuggestedEvent {\n"); + sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" types: ").append(toIndentedString(types)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("attempt", "members", "seq", "type", "types")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("attempt", "members", "seq", "type", "types")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TypesSuggestedEvent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TypesSuggestedEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TypesSuggestedEvent is not found in the empty JSON string", TypesSuggestedEvent.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TypesSuggestedEvent.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TypesSuggestedEvent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TypesSuggestedEvent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TypesSuggestedEvent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TypesSuggestedEvent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TypesSuggestedEvent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TypesSuggestedEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TypesSuggestedEvent given an JSON string + * + * @param jsonString JSON string + * @return An instance of TypesSuggestedEvent + * @throws IOException if the JSON string is invalid with respect to TypesSuggestedEvent + */ + public static TypesSuggestedEvent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TypesSuggestedEvent.class); + } + + /** + * Convert an instance of TypesSuggestedEvent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/UnionDataType.java b/src/main/java/ai/reveng/model/UnionDataType.java index 98e9328c..e9e94d0f 100644 --- a/src/main/java/ai/reveng/model/UnionDataType.java +++ b/src/main/java/ai/reveng/model/UnionDataType.java @@ -143,6 +143,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -366,6 +371,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public UnionDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public UnionDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -403,6 +427,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UnionDataType instance itself + */ + public UnionDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -422,13 +490,15 @@ public boolean equals(Object o) { Objects.equals(this.name, unionDataType.name) && Objects.equals(this.namespace, unionDataType.namespace) && Objects.equals(this.size, unionDataType.size) && + Objects.equals(this.sourceAnalysisId, unionDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, unionDataType.sourceFunctionId) && - Objects.equals(this.sourceType, unionDataType.sourceType); + Objects.equals(this.sourceType, unionDataType.sourceType)&& + Objects.equals(this.additionalProperties, unionDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, definition, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -443,8 +513,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -463,7 +535,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "definition", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -482,14 +554,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UnionDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UnionDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UnionDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -497,10 +561,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `definition` - if (jsonObj.get("definition") != null && !jsonObj.get("definition").isJsonNull()) { - UnionDefinition.validateJsonElement(jsonObj.get("definition")); - } if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -534,6 +594,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UnionDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -541,7 +623,28 @@ public void write(JsonWriter out, UnionDataType value) throws IOException { public UnionDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UnionDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UnionDefinition.java b/src/main/java/ai/reveng/model/UnionDefinition.java index 2ff33f01..09bedf6f 100644 --- a/src/main/java/ai/reveng/model/UnionDefinition.java +++ b/src/main/java/ai/reveng/model/UnionDefinition.java @@ -86,6 +86,50 @@ public void setMembers(@javax.annotation.Nullable List memb this.members = members; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UnionDefinition instance itself + */ + public UnionDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } UnionDefinition unionDefinition = (UnionDefinition) o; - return Objects.equals(this.members, unionDefinition.members); + return Objects.equals(this.members, unionDefinition.members)&& + Objects.equals(this.additionalProperties, unionDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(members); + return Objects.hash(members, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UnionDefinition {\n"); sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UnionDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UnionDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UnionDefinition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -162,15 +200,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("members") != null && !jsonObj.get("members").isJsonNull()) { - if (!jsonObj.get("members").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); - } - JsonArray jsonArraymembers = jsonObj.getAsJsonArray("members"); - // validate the required field `members` (array) - for (int i = 0; i < jsonArraymembers.size(); i++) { - DataTypeMemberEntry.validateJsonElement(jsonArraymembers.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("members") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("members").isJsonArray() && !jsonObj.get("members").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); } } @@ -189,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UnionDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +252,28 @@ public void write(JsonWriter out, UnionDefinition value) throws IOException { public UnionDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UnionDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UnknownDataType.java b/src/main/java/ai/reveng/model/UnknownDataType.java index 5ef301de..586d568d 100644 --- a/src/main/java/ai/reveng/model/UnknownDataType.java +++ b/src/main/java/ai/reveng/model/UnknownDataType.java @@ -137,6 +137,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Long size; + public static final String SERIALIZED_NAME_SOURCE_ANALYSIS_ID = "source_analysis_id"; + @SerializedName(SERIALIZED_NAME_SOURCE_ANALYSIS_ID) + @javax.annotation.Nullable + private Long sourceAnalysisId; + public static final String SERIALIZED_NAME_SOURCE_FUNCTION_ID = "source_function_id"; @SerializedName(SERIALIZED_NAME_SOURCE_FUNCTION_ID) @javax.annotation.Nullable @@ -341,6 +346,25 @@ public void setSize(@javax.annotation.Nullable Long size) { } + public UnknownDataType sourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + return this; + } + + /** + * ID of the analysis the source function belongs to, when it could be resolved. + * @return sourceAnalysisId + */ + @javax.annotation.Nullable + public Long getSourceAnalysisId() { + return sourceAnalysisId; + } + + public void setSourceAnalysisId(@javax.annotation.Nullable Long sourceAnalysisId) { + this.sourceAnalysisId = sourceAnalysisId; + } + + public UnknownDataType sourceFunctionId(@javax.annotation.Nullable Long sourceFunctionId) { this.sourceFunctionId = sourceFunctionId; return this; @@ -378,6 +402,50 @@ public void setSourceType(@javax.annotation.Nonnull SourceTypeEnum sourceType) { this.sourceType = sourceType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UnknownDataType instance itself + */ + public UnknownDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -396,13 +464,15 @@ public boolean equals(Object o) { Objects.equals(this.name, unknownDataType.name) && Objects.equals(this.namespace, unknownDataType.namespace) && Objects.equals(this.size, unknownDataType.size) && + Objects.equals(this.sourceAnalysisId, unknownDataType.sourceAnalysisId) && Objects.equals(this.sourceFunctionId, unknownDataType.sourceFunctionId) && - Objects.equals(this.sourceType, unknownDataType.sourceType); + Objects.equals(this.sourceType, unknownDataType.sourceType)&& + Objects.equals(this.additionalProperties, unknownDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, dataTypeId, hasDefinition, kind, name, namespace, size, sourceFunctionId, sourceType); + return Objects.hash(createdAt, dataTypeId, hasDefinition, kind, name, namespace, size, sourceAnalysisId, sourceFunctionId, sourceType, additionalProperties); } @Override @@ -416,8 +486,10 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sourceAnalysisId: ").append(toIndentedString(sourceAnalysisId)).append("\n"); sb.append(" sourceFunctionId: ").append(toIndentedString(sourceFunctionId)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -436,7 +508,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "size", "source_function_id", "source_type")); + openapiFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "size", "source_analysis_id", "source_function_id", "source_type")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("created_at", "data_type_id", "has_definition", "kind", "name", "namespace", "source_type")); @@ -455,14 +527,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UnknownDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UnknownDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UnknownDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -503,6 +567,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UnknownDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -510,7 +596,28 @@ public void write(JsonWriter out, UnknownDataType value) throws IOException { public UnknownDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UnknownDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateAnalysisDataTypesInputBody.java b/src/main/java/ai/reveng/model/UpdateAnalysisDataTypesInputBody.java index 637cdddc..94aebf45 100644 --- a/src/main/java/ai/reveng/model/UpdateAnalysisDataTypesInputBody.java +++ b/src/main/java/ai/reveng/model/UpdateAnalysisDataTypesInputBody.java @@ -86,6 +86,50 @@ public void setDataTypes(@javax.annotation.Nullable List da this.dataTypes = dataTypes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateAnalysisDataTypesInputBody instance itself + */ + public UpdateAnalysisDataTypesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } UpdateAnalysisDataTypesInputBody updateAnalysisDataTypesInputBody = (UpdateAnalysisDataTypesInputBody) o; - return Objects.equals(this.dataTypes, updateAnalysisDataTypesInputBody.dataTypes); + return Objects.equals(this.dataTypes, updateAnalysisDataTypesInputBody.dataTypes)&& + Objects.equals(this.additionalProperties, updateAnalysisDataTypesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypes); + return Objects.hash(dataTypes, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpdateAnalysisDataTypesInputBody {\n"); sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateAnalysisDataTypesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateAnalysisDataTypesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateAnalysisDataTypesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateAnalysisDataTypesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, UpdateAnalysisDataTypesInputBody value) throws public UpdateAnalysisDataTypesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateAnalysisDataTypesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateArrayDataType.java b/src/main/java/ai/reveng/model/UpdateArrayDataType.java index 5c759e0e..3ce4a1d2 100644 --- a/src/main/java/ai/reveng/model/UpdateArrayDataType.java +++ b/src/main/java/ai/reveng/model/UpdateArrayDataType.java @@ -250,6 +250,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateArrayDataType instance itself + */ + public UpdateArrayDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateArrayDataType.kind) && Objects.equals(this.name, updateArrayDataType.name) && Objects.equals(this.namespace, updateArrayDataType.namespace) && - Objects.equals(this.size, updateArrayDataType.size); + Objects.equals(this.size, updateArrayDataType.size)&& + Objects.equals(this.additionalProperties, updateArrayDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, definition, kind, name, namespace, size); + return Objects.hash(dataTypeId, definition, kind, name, namespace, size, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateArrayDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateArrayDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateArrayDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -336,8 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - ArrayDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -366,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateArrayDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +431,28 @@ public void write(JsonWriter out, UpdateArrayDataType value) throws IOException public UpdateArrayDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateArrayDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateBaseDataType.java b/src/main/java/ai/reveng/model/UpdateBaseDataType.java index 7db329f7..9011fdc5 100644 --- a/src/main/java/ai/reveng/model/UpdateBaseDataType.java +++ b/src/main/java/ai/reveng/model/UpdateBaseDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateBaseDataType instance itself + */ + public UpdateBaseDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateBaseDataType.kind) && Objects.equals(this.name, updateBaseDataType.name) && Objects.equals(this.namespace, updateBaseDataType.namespace) && - Objects.equals(this.size, updateBaseDataType.size); + Objects.equals(this.size, updateBaseDataType.size)&& + Objects.equals(this.additionalProperties, updateBaseDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, kind, name, namespace, size); + return Objects.hash(dataTypeId, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateBaseDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateBaseDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateBaseDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -337,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateBaseDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -344,7 +404,28 @@ public void write(JsonWriter out, UpdateBaseDataType value) throws IOException { public UpdateBaseDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateBaseDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateBitfieldDataType.java b/src/main/java/ai/reveng/model/UpdateBitfieldDataType.java index 9bcae302..8c8b7aa0 100644 --- a/src/main/java/ai/reveng/model/UpdateBitfieldDataType.java +++ b/src/main/java/ai/reveng/model/UpdateBitfieldDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateBitfieldDataType instance itself + */ + public UpdateBitfieldDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateBitfieldDataType.kind) && Objects.equals(this.name, updateBitfieldDataType.name) && Objects.equals(this.namespace, updateBitfieldDataType.namespace) && - Objects.equals(this.size, updateBitfieldDataType.size); + Objects.equals(this.size, updateBitfieldDataType.size)&& + Objects.equals(this.additionalProperties, updateBitfieldDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, kind, name, namespace, size); + return Objects.hash(dataTypeId, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateBitfieldDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateBitfieldDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateBitfieldDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -337,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateBitfieldDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -344,7 +404,28 @@ public void write(JsonWriter out, UpdateBitfieldDataType value) throws IOExcepti public UpdateBitfieldDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateBitfieldDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateEnumDataType.java b/src/main/java/ai/reveng/model/UpdateEnumDataType.java index 37c6ddbd..7485ff33 100644 --- a/src/main/java/ai/reveng/model/UpdateEnumDataType.java +++ b/src/main/java/ai/reveng/model/UpdateEnumDataType.java @@ -250,6 +250,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateEnumDataType instance itself + */ + public UpdateEnumDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateEnumDataType.kind) && Objects.equals(this.name, updateEnumDataType.name) && Objects.equals(this.namespace, updateEnumDataType.namespace) && - Objects.equals(this.size, updateEnumDataType.size); + Objects.equals(this.size, updateEnumDataType.size)&& + Objects.equals(this.additionalProperties, updateEnumDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, definition, kind, name, namespace, size); + return Objects.hash(dataTypeId, definition, kind, name, namespace, size, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateEnumDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateEnumDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateEnumDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -336,8 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - EnumDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -366,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateEnumDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +431,28 @@ public void write(JsonWriter out, UpdateEnumDataType value) throws IOException { public UpdateEnumDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateEnumDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateFunctionDataType.java b/src/main/java/ai/reveng/model/UpdateFunctionDataType.java index 68e9b011..5555ae07 100644 --- a/src/main/java/ai/reveng/model/UpdateFunctionDataType.java +++ b/src/main/java/ai/reveng/model/UpdateFunctionDataType.java @@ -250,6 +250,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateFunctionDataType instance itself + */ + public UpdateFunctionDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateFunctionDataType.kind) && Objects.equals(this.name, updateFunctionDataType.name) && Objects.equals(this.namespace, updateFunctionDataType.namespace) && - Objects.equals(this.size, updateFunctionDataType.size); + Objects.equals(this.size, updateFunctionDataType.size)&& + Objects.equals(this.additionalProperties, updateFunctionDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, definition, kind, name, namespace, size); + return Objects.hash(dataTypeId, definition, kind, name, namespace, size, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateFunctionDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateFunctionDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateFunctionDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -336,8 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - FunctionTypeDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -366,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateFunctionDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +431,28 @@ public void write(JsonWriter out, UpdateFunctionDataType value) throws IOExcepti public UpdateFunctionDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateFunctionDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateFunctionSignatureInputBody.java b/src/main/java/ai/reveng/model/UpdateFunctionSignatureInputBody.java index acba993c..a292a0bd 100644 --- a/src/main/java/ai/reveng/model/UpdateFunctionSignatureInputBody.java +++ b/src/main/java/ai/reveng/model/UpdateFunctionSignatureInputBody.java @@ -135,6 +135,50 @@ public void setReturnDataTypeId(@javax.annotation.Nullable Long returnDataTypeId this.returnDataTypeId = returnDataTypeId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateFunctionSignatureInputBody instance itself + */ + public UpdateFunctionSignatureInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -148,12 +192,13 @@ public boolean equals(Object o) { UpdateFunctionSignatureInputBody updateFunctionSignatureInputBody = (UpdateFunctionSignatureInputBody) o; return Objects.equals(this.callingConvention, updateFunctionSignatureInputBody.callingConvention) && Objects.equals(this.parameters, updateFunctionSignatureInputBody.parameters) && - Objects.equals(this.returnDataTypeId, updateFunctionSignatureInputBody.returnDataTypeId); + Objects.equals(this.returnDataTypeId, updateFunctionSignatureInputBody.returnDataTypeId)&& + Objects.equals(this.additionalProperties, updateFunctionSignatureInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(callingConvention, parameters, returnDataTypeId); + return Objects.hash(callingConvention, parameters, returnDataTypeId, additionalProperties); } @Override @@ -163,6 +208,7 @@ public String toString() { sb.append(" callingConvention: ").append(toIndentedString(callingConvention)).append("\n"); sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); sb.append(" returnDataTypeId: ").append(toIndentedString(returnDataTypeId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -200,14 +246,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateFunctionSignatureInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateFunctionSignatureInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateFunctionSignatureInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -218,15 +256,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("calling_convention") != null && !jsonObj.get("calling_convention").isJsonNull()) && !jsonObj.get("calling_convention").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `calling_convention` to be a primitive type in the JSON string but got `%s`", jsonObj.get("calling_convention").toString())); } - if (jsonObj.get("parameters") != null && !jsonObj.get("parameters").isJsonNull()) { - if (!jsonObj.get("parameters").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); - } - JsonArray jsonArrayparameters = jsonObj.getAsJsonArray("parameters"); - // validate the required field `parameters` (array) - for (int i = 0; i < jsonArrayparameters.size(); i++) { - SignatureParameterInput.validateJsonElement(jsonArrayparameters.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("parameters") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("parameters").isJsonArray() && !jsonObj.get("parameters").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `parameters` to be an array in the JSON string but got `%s`", jsonObj.get("parameters").toString())); } } @@ -245,6 +279,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateFunctionSignatureInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -252,7 +308,28 @@ public void write(JsonWriter out, UpdateFunctionSignatureInputBody value) throws public UpdateFunctionSignatureInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateFunctionSignatureInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdatePointerDataType.java b/src/main/java/ai/reveng/model/UpdatePointerDataType.java index 364f6523..a091f657 100644 --- a/src/main/java/ai/reveng/model/UpdatePointerDataType.java +++ b/src/main/java/ai/reveng/model/UpdatePointerDataType.java @@ -250,6 +250,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdatePointerDataType instance itself + */ + public UpdatePointerDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updatePointerDataType.kind) && Objects.equals(this.name, updatePointerDataType.name) && Objects.equals(this.namespace, updatePointerDataType.namespace) && - Objects.equals(this.size, updatePointerDataType.size); + Objects.equals(this.size, updatePointerDataType.size)&& + Objects.equals(this.additionalProperties, updatePointerDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, definition, kind, name, namespace, size); + return Objects.hash(dataTypeId, definition, kind, name, namespace, size, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdatePointerDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdatePointerDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdatePointerDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -336,8 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - PointerDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -366,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdatePointerDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +431,28 @@ public void write(JsonWriter out, UpdatePointerDataType value) throws IOExceptio public UpdatePointerDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdatePointerDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateStructDataType.java b/src/main/java/ai/reveng/model/UpdateStructDataType.java index 1d71795f..fd88da9f 100644 --- a/src/main/java/ai/reveng/model/UpdateStructDataType.java +++ b/src/main/java/ai/reveng/model/UpdateStructDataType.java @@ -250,6 +250,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateStructDataType instance itself + */ + public UpdateStructDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateStructDataType.kind) && Objects.equals(this.name, updateStructDataType.name) && Objects.equals(this.namespace, updateStructDataType.namespace) && - Objects.equals(this.size, updateStructDataType.size); + Objects.equals(this.size, updateStructDataType.size)&& + Objects.equals(this.additionalProperties, updateStructDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, definition, kind, name, namespace, size); + return Objects.hash(dataTypeId, definition, kind, name, namespace, size, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateStructDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateStructDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateStructDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -336,8 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - StructDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -366,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateStructDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +431,28 @@ public void write(JsonWriter out, UpdateStructDataType value) throws IOException public UpdateStructDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateStructDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateTypedefDataType.java b/src/main/java/ai/reveng/model/UpdateTypedefDataType.java index e0223d21..fb182360 100644 --- a/src/main/java/ai/reveng/model/UpdateTypedefDataType.java +++ b/src/main/java/ai/reveng/model/UpdateTypedefDataType.java @@ -250,6 +250,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateTypedefDataType instance itself + */ + public UpdateTypedefDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateTypedefDataType.kind) && Objects.equals(this.name, updateTypedefDataType.name) && Objects.equals(this.namespace, updateTypedefDataType.namespace) && - Objects.equals(this.size, updateTypedefDataType.size); + Objects.equals(this.size, updateTypedefDataType.size)&& + Objects.equals(this.additionalProperties, updateTypedefDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, definition, kind, name, namespace, size); + return Objects.hash(dataTypeId, definition, kind, name, namespace, size, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateTypedefDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateTypedefDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateTypedefDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -336,8 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - TypedefDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -366,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateTypedefDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +431,28 @@ public void write(JsonWriter out, UpdateTypedefDataType value) throws IOExceptio public UpdateTypedefDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateTypedefDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateUnionDataType.java b/src/main/java/ai/reveng/model/UpdateUnionDataType.java index 301935eb..fac6470b 100644 --- a/src/main/java/ai/reveng/model/UpdateUnionDataType.java +++ b/src/main/java/ai/reveng/model/UpdateUnionDataType.java @@ -250,6 +250,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateUnionDataType instance itself + */ + public UpdateUnionDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateUnionDataType.kind) && Objects.equals(this.name, updateUnionDataType.name) && Objects.equals(this.namespace, updateUnionDataType.namespace) && - Objects.equals(this.size, updateUnionDataType.size); + Objects.equals(this.size, updateUnionDataType.size)&& + Objects.equals(this.additionalProperties, updateUnionDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, definition, kind, name, namespace, size); + return Objects.hash(dataTypeId, definition, kind, name, namespace, size, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateUnionDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateUnionDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateUnionDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -336,8 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the required field `definition` - UnionDefinition.validateJsonElement(jsonObj.get("definition")); if (!jsonObj.get("kind").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } @@ -366,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateUnionDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +431,28 @@ public void write(JsonWriter out, UpdateUnionDataType value) throws IOException public UpdateUnionDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateUnionDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpdateUnknownDataType.java b/src/main/java/ai/reveng/model/UpdateUnknownDataType.java index 9e54690e..0c3a03ca 100644 --- a/src/main/java/ai/reveng/model/UpdateUnknownDataType.java +++ b/src/main/java/ai/reveng/model/UpdateUnknownDataType.java @@ -225,6 +225,50 @@ public void setSize(@javax.annotation.Nullable Long size) { this.size = size; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateUnknownDataType instance itself + */ + public UpdateUnknownDataType putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.kind, updateUnknownDataType.kind) && Objects.equals(this.name, updateUnknownDataType.name) && Objects.equals(this.namespace, updateUnknownDataType.namespace) && - Objects.equals(this.size, updateUnknownDataType.size); + Objects.equals(this.size, updateUnknownDataType.size)&& + Objects.equals(this.additionalProperties, updateUnknownDataType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypeId, kind, name, namespace, size); + return Objects.hash(dataTypeId, kind, name, namespace, size, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateUnknownDataType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateUnknownDataType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateUnknownDataType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -337,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateUnknownDataType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -344,7 +404,28 @@ public void write(JsonWriter out, UpdateUnknownDataType value) throws IOExceptio public UpdateUnknownDataType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateUnknownDataType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpgradeAnalysisModelOutputBody.java b/src/main/java/ai/reveng/model/UpgradeAnalysisModelOutputBody.java new file mode 100644 index 00000000..5003cd53 --- /dev/null +++ b/src/main/java/ai/reveng/model/UpgradeAnalysisModelOutputBody.java @@ -0,0 +1,338 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * UpgradeAnalysisModelOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpgradeAnalysisModelOutputBody { + public static final String SERIALIZED_NAME_ANALYSIS_ID = "analysis_id"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_ID) + @javax.annotation.Nonnull + private Long analysisId; + + public static final String SERIALIZED_NAME_BINARY_ID = "binary_id"; + @SerializedName(SERIALIZED_NAME_BINARY_ID) + @javax.annotation.Nonnull + private Long binaryId; + + public static final String SERIALIZED_NAME_MODEL_ID = "model_id"; + @SerializedName(SERIALIZED_NAME_MODEL_ID) + @javax.annotation.Nonnull + private Long modelId; + + public UpgradeAnalysisModelOutputBody() { + } + + public UpgradeAnalysisModelOutputBody analysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + return this; + } + + /** + * ID of the re-queued analysis. Unchanged — the upgrade moves the existing analysis rather than creating a new one. + * @return analysisId + */ + @javax.annotation.Nonnull + public Long getAnalysisId() { + return analysisId; + } + + public void setAnalysisId(@javax.annotation.Nonnull Long analysisId) { + this.analysisId = analysisId; + } + + + public UpgradeAnalysisModelOutputBody binaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + return this; + } + + /** + * ID of the binary the analysis belongs to + * @return binaryId + */ + @javax.annotation.Nonnull + public Long getBinaryId() { + return binaryId; + } + + public void setBinaryId(@javax.annotation.Nonnull Long binaryId) { + this.binaryId = binaryId; + } + + + public UpgradeAnalysisModelOutputBody modelId(@javax.annotation.Nonnull Long modelId) { + this.modelId = modelId; + return this; + } + + /** + * Model the analysis is now queued against + * @return modelId + */ + @javax.annotation.Nonnull + public Long getModelId() { + return modelId; + } + + public void setModelId(@javax.annotation.Nonnull Long modelId) { + this.modelId = modelId; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpgradeAnalysisModelOutputBody instance itself + */ + public UpgradeAnalysisModelOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpgradeAnalysisModelOutputBody upgradeAnalysisModelOutputBody = (UpgradeAnalysisModelOutputBody) o; + return Objects.equals(this.analysisId, upgradeAnalysisModelOutputBody.analysisId) && + Objects.equals(this.binaryId, upgradeAnalysisModelOutputBody.binaryId) && + Objects.equals(this.modelId, upgradeAnalysisModelOutputBody.modelId)&& + Objects.equals(this.additionalProperties, upgradeAnalysisModelOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(analysisId, binaryId, modelId, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpgradeAnalysisModelOutputBody {\n"); + sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); + sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); + sb.append(" modelId: ").append(toIndentedString(modelId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_id", "binary_id", "model_id")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_id", "binary_id", "model_id")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpgradeAnalysisModelOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpgradeAnalysisModelOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpgradeAnalysisModelOutputBody is not found in the empty JSON string", UpgradeAnalysisModelOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpgradeAnalysisModelOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpgradeAnalysisModelOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpgradeAnalysisModelOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpgradeAnalysisModelOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpgradeAnalysisModelOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public UpgradeAnalysisModelOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpgradeAnalysisModelOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpgradeAnalysisModelOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpgradeAnalysisModelOutputBody + * @throws IOException if the JSON string is invalid with respect to UpgradeAnalysisModelOutputBody + */ + public static UpgradeAnalysisModelOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpgradeAnalysisModelOutputBody.class); + } + + /** + * Convert an instance of UpgradeAnalysisModelOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/UploadOutputBody.java b/src/main/java/ai/reveng/model/UploadOutputBody.java new file mode 100644 index 00000000..36a6cbe7 --- /dev/null +++ b/src/main/java/ai/reveng/model/UploadOutputBody.java @@ -0,0 +1,557 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import ai.reveng.model.AnalysisRequirement; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * UploadOutputBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UploadOutputBody { + public static final String SERIALIZED_NAME_ANALYSIS_REQUIREMENTS = "analysis_requirements"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_REQUIREMENTS) + @javax.annotation.Nullable + private List analysisRequirements; + + public static final String SERIALIZED_NAME_CAN_EXTRACT = "can_extract"; + @SerializedName(SERIALIZED_NAME_CAN_EXTRACT) + @javax.annotation.Nonnull + private Boolean canExtract; + + public static final String SERIALIZED_NAME_CAN_SANDBOX = "can_sandbox"; + @SerializedName(SERIALIZED_NAME_CAN_SANDBOX) + @javax.annotation.Nonnull + private Boolean canSandbox; + + /** + * The kind of file that was uploaded. + */ + @JsonAdapter(FileTypeEnum.Adapter.class) + public enum FileTypeEnum { + BINARY("BINARY"), + + DEBUG("DEBUG"), + + PACKED("PACKED"), + + FIRMWARE("FIRMWARE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + FileTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FileTypeEnum fromValue(String value) { + for (FileTypeEnum b : FileTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FileTypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public FileTypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return FileTypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + FileTypeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_FILE_TYPE = "file_type"; + @SerializedName(SERIALIZED_NAME_FILE_TYPE) + @javax.annotation.Nonnull + private FileTypeEnum fileType; + + public static final String SERIALIZED_NAME_FILENAME = "filename"; + @SerializedName(SERIALIZED_NAME_FILENAME) + @javax.annotation.Nonnull + private String filename; + + public static final String SERIALIZED_NAME_IS_ARCHIVE = "is_archive"; + @SerializedName(SERIALIZED_NAME_IS_ARCHIVE) + @javax.annotation.Nonnull + private Boolean isArchive; + + public static final String SERIALIZED_NAME_MIME = "mime"; + @SerializedName(SERIALIZED_NAME_MIME) + @javax.annotation.Nonnull + private String mime; + + public static final String SERIALIZED_NAME_SHA256_HASH = "sha_256_hash"; + @SerializedName(SERIALIZED_NAME_SHA256_HASH) + @javax.annotation.Nonnull + private String sha256Hash; + + public UploadOutputBody() { + } + + public UploadOutputBody analysisRequirements(@javax.annotation.Nullable List analysisRequirements) { + this.analysisRequirements = analysisRequirements; + return this; + } + + public UploadOutputBody addAnalysisRequirementsItem(AnalysisRequirement analysisRequirementsItem) { + if (this.analysisRequirements == null) { + this.analysisRequirements = new ArrayList<>(); + } + this.analysisRequirements.add(analysisRequirementsItem); + return this; + } + + /** + * Ways to unblock POST /v3/analyses for this file if it cannot be statically analysed as-is; empty if no requirement applies. + * @return analysisRequirements + */ + @javax.annotation.Nullable + public List getAnalysisRequirements() { + return analysisRequirements; + } + + public void setAnalysisRequirements(@javax.annotation.Nullable List analysisRequirements) { + this.analysisRequirements = analysisRequirements; + } + + + public UploadOutputBody canExtract(@javax.annotation.Nonnull Boolean canExtract) { + this.canExtract = canExtract; + return this; + } + + /** + * Whether the firmware/extraction flow can accept this file. + * @return canExtract + */ + @javax.annotation.Nonnull + public Boolean getCanExtract() { + return canExtract; + } + + public void setCanExtract(@javax.annotation.Nonnull Boolean canExtract) { + this.canExtract = canExtract; + } + + + public UploadOutputBody canSandbox(@javax.annotation.Nonnull Boolean canSandbox) { + this.canSandbox = canSandbox; + return this; + } + + /** + * Whether the file can be extracted and run in the Windows sandbox. + * @return canSandbox + */ + @javax.annotation.Nonnull + public Boolean getCanSandbox() { + return canSandbox; + } + + public void setCanSandbox(@javax.annotation.Nonnull Boolean canSandbox) { + this.canSandbox = canSandbox; + } + + + public UploadOutputBody fileType(@javax.annotation.Nonnull FileTypeEnum fileType) { + this.fileType = fileType; + return this; + } + + /** + * The kind of file that was uploaded. + * @return fileType + */ + @javax.annotation.Nonnull + public FileTypeEnum getFileType() { + return fileType; + } + + public void setFileType(@javax.annotation.Nonnull FileTypeEnum fileType) { + this.fileType = fileType; + } + + + public UploadOutputBody filename(@javax.annotation.Nonnull String filename) { + this.filename = filename; + return this; + } + + /** + * The filename as given by the caller. + * @return filename + */ + @javax.annotation.Nonnull + public String getFilename() { + return filename; + } + + public void setFilename(@javax.annotation.Nonnull String filename) { + this.filename = filename; + } + + + public UploadOutputBody isArchive(@javax.annotation.Nonnull Boolean isArchive) { + this.isArchive = isArchive; + return this; + } + + /** + * Whether the detected format is a container/compression archive. + * @return isArchive + */ + @javax.annotation.Nonnull + public Boolean getIsArchive() { + return isArchive; + } + + public void setIsArchive(@javax.annotation.Nonnull Boolean isArchive) { + this.isArchive = isArchive; + } + + + public UploadOutputBody mime(@javax.annotation.Nonnull String mime) { + this.mime = mime; + return this; + } + + /** + * The MIME type detected from the file's contents, independent of upload_file_type. + * @return mime + */ + @javax.annotation.Nonnull + public String getMime() { + return mime; + } + + public void setMime(@javax.annotation.Nonnull String mime) { + this.mime = mime; + } + + + public UploadOutputBody sha256Hash(@javax.annotation.Nonnull String sha256Hash) { + this.sha256Hash = sha256Hash; + return this; + } + + /** + * SHA-256 hash of the uploaded file; the storage key for every subsequent reference to it. + * @return sha256Hash + */ + @javax.annotation.Nonnull + public String getSha256Hash() { + return sha256Hash; + } + + public void setSha256Hash(@javax.annotation.Nonnull String sha256Hash) { + this.sha256Hash = sha256Hash; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UploadOutputBody instance itself + */ + public UploadOutputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UploadOutputBody uploadOutputBody = (UploadOutputBody) o; + return Objects.equals(this.analysisRequirements, uploadOutputBody.analysisRequirements) && + Objects.equals(this.canExtract, uploadOutputBody.canExtract) && + Objects.equals(this.canSandbox, uploadOutputBody.canSandbox) && + Objects.equals(this.fileType, uploadOutputBody.fileType) && + Objects.equals(this.filename, uploadOutputBody.filename) && + Objects.equals(this.isArchive, uploadOutputBody.isArchive) && + Objects.equals(this.mime, uploadOutputBody.mime) && + Objects.equals(this.sha256Hash, uploadOutputBody.sha256Hash)&& + Objects.equals(this.additionalProperties, uploadOutputBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(analysisRequirements, canExtract, canSandbox, fileType, filename, isArchive, mime, sha256Hash, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UploadOutputBody {\n"); + sb.append(" analysisRequirements: ").append(toIndentedString(analysisRequirements)).append("\n"); + sb.append(" canExtract: ").append(toIndentedString(canExtract)).append("\n"); + sb.append(" canSandbox: ").append(toIndentedString(canSandbox)).append("\n"); + sb.append(" fileType: ").append(toIndentedString(fileType)).append("\n"); + sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); + sb.append(" isArchive: ").append(toIndentedString(isArchive)).append("\n"); + sb.append(" mime: ").append(toIndentedString(mime)).append("\n"); + sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_requirements", "can_extract", "can_sandbox", "file_type", "filename", "is_archive", "mime", "sha_256_hash")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_requirements", "can_extract", "can_sandbox", "file_type", "filename", "is_archive", "mime", "sha_256_hash")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UploadOutputBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UploadOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UploadOutputBody is not found in the empty JSON string", UploadOutputBody.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UploadOutputBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("analysis_requirements") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("analysis_requirements").isJsonArray() && !jsonObj.get("analysis_requirements").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_requirements` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_requirements").toString())); + } + if (!jsonObj.get("file_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_type").toString())); + } + // validate the required field `file_type` + FileTypeEnum.validateJsonElement(jsonObj.get("file_type")); + if (!jsonObj.get("filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + } + if (!jsonObj.get("mime").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime").toString())); + } + if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UploadOutputBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UploadOutputBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UploadOutputBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UploadOutputBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public UploadOutputBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UploadOutputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UploadOutputBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of UploadOutputBody + * @throws IOException if the JSON string is invalid with respect to UploadOutputBody + */ + public static UploadOutputBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UploadOutputBody.class); + } + + /** + * Convert an instance of UploadOutputBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/UploadResponse.java b/src/main/java/ai/reveng/model/UploadResponse.java index e2637bac..95bcd0ea 100644 --- a/src/main/java/ai/reveng/model/UploadResponse.java +++ b/src/main/java/ai/reveng/model/UploadResponse.java @@ -13,6 +13,7 @@ package ai.reveng.model; import java.util.Objects; +import ai.reveng.model.AnalysisRequirement; import ai.reveng.model.UploadFileType; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -20,7 +21,9 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -85,6 +88,11 @@ public class UploadResponse { @javax.annotation.Nonnull private Boolean canExtract; + public static final String SERIALIZED_NAME_ANALYSIS_REQUIREMENTS = "analysis_requirements"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_REQUIREMENTS) + @javax.annotation.Nullable + private List analysisRequirements = new ArrayList<>(); + public UploadResponse() { } @@ -220,6 +228,33 @@ public void setCanExtract(@javax.annotation.Nonnull Boolean canExtract) { this.canExtract = canExtract; } + + public UploadResponse analysisRequirements(@javax.annotation.Nullable List analysisRequirements) { + this.analysisRequirements = analysisRequirements; + return this; + } + + public UploadResponse addAnalysisRequirementsItem(AnalysisRequirement analysisRequirementsItem) { + if (this.analysisRequirements == null) { + this.analysisRequirements = new ArrayList<>(); + } + this.analysisRequirements.add(analysisRequirementsItem); + return this; + } + + /** + * Get analysisRequirements + * @return analysisRequirements + */ + @javax.annotation.Nullable + public List getAnalysisRequirements() { + return analysisRequirements; + } + + public void setAnalysisRequirements(@javax.annotation.Nullable List analysisRequirements) { + this.analysisRequirements = analysisRequirements; + } + /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -281,13 +316,14 @@ public boolean equals(Object o) { Objects.equals(this.mime, uploadResponse.mime) && Objects.equals(this.isArchive, uploadResponse.isArchive) && Objects.equals(this.canSandbox, uploadResponse.canSandbox) && - Objects.equals(this.canExtract, uploadResponse.canExtract)&& + Objects.equals(this.canExtract, uploadResponse.canExtract) && + Objects.equals(this.analysisRequirements, uploadResponse.analysisRequirements)&& Objects.equals(this.additionalProperties, uploadResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sha256Hash, fileType, filename, mime, isArchive, canSandbox, canExtract, additionalProperties); + return Objects.hash(sha256Hash, fileType, filename, mime, isArchive, canSandbox, canExtract, analysisRequirements, additionalProperties); } @Override @@ -301,6 +337,7 @@ public String toString() { sb.append(" isArchive: ").append(toIndentedString(isArchive)).append("\n"); sb.append(" canSandbox: ").append(toIndentedString(canSandbox)).append("\n"); sb.append(" canExtract: ").append(toIndentedString(canExtract)).append("\n"); + sb.append(" analysisRequirements: ").append(toIndentedString(analysisRequirements)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -320,7 +357,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("sha_256_hash", "file_type", "filename", "mime", "is_archive", "can_sandbox", "can_extract")); + openapiFields = new HashSet(Arrays.asList("sha_256_hash", "file_type", "filename", "mime", "is_archive", "can_sandbox", "can_extract", "analysis_requirements")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("sha_256_hash", "file_type", "filename", "mime", "is_archive", "can_sandbox", "can_extract")); @@ -357,6 +394,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("mime").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime").toString())); } + // ensure the optional json data is an array if present + if (jsonObj.get("analysis_requirements") != null && !jsonObj.get("analysis_requirements").isJsonNull() && !jsonObj.get("analysis_requirements").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_requirements` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_requirements").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/ai/reveng/model/UpsertOverridesData.java b/src/main/java/ai/reveng/model/UpsertOverridesData.java index 4b579ac4..712fc257 100644 --- a/src/main/java/ai/reveng/model/UpsertOverridesData.java +++ b/src/main/java/ai/reveng/model/UpsertOverridesData.java @@ -86,6 +86,50 @@ public void setPlaceholderToUserOverride(@javax.annotation.Nonnull Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpsertOverridesData instance itself + */ + public UpsertOverridesData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } UpsertOverridesData upsertOverridesData = (UpsertOverridesData) o; - return Objects.equals(this.placeholderToUserOverride, upsertOverridesData.placeholderToUserOverride); + return Objects.equals(this.placeholderToUserOverride, upsertOverridesData.placeholderToUserOverride)&& + Objects.equals(this.additionalProperties, upsertOverridesData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(placeholderToUserOverride); + return Objects.hash(placeholderToUserOverride, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpsertOverridesData {\n"); sb.append(" placeholderToUserOverride: ").append(toIndentedString(placeholderToUserOverride)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpsertOverridesData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpsertOverridesData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpsertOverridesData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -179,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpsertOverridesData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -186,7 +246,28 @@ public void write(JsonWriter out, UpsertOverridesData value) throws IOException public UpsertOverridesData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpsertOverridesData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java b/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java index c6459fd2..8659329a 100644 --- a/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java +++ b/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java @@ -86,6 +86,50 @@ public void setOverrides(@javax.annotation.Nonnull Map overrides) this.overrides = overrides; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpsertOverridesInputBody instance itself + */ + public UpsertOverridesInputBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } UpsertOverridesInputBody upsertOverridesInputBody = (UpsertOverridesInputBody) o; - return Objects.equals(this.overrides, upsertOverridesInputBody.overrides); + return Objects.equals(this.overrides, upsertOverridesInputBody.overrides)&& + Objects.equals(this.additionalProperties, upsertOverridesInputBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(overrides); + return Objects.hash(overrides, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpsertOverridesInputBody {\n"); sb.append(" overrides: ").append(toIndentedString(overrides)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpsertOverridesInputBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpsertOverridesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpsertOverridesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -179,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpsertOverridesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -186,7 +246,28 @@ public void write(JsonWriter out, UpsertOverridesInputBody value) throws IOExcep public UpsertOverridesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpsertOverridesInputBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/User.java b/src/main/java/ai/reveng/model/User.java index d3681cf5..48db7593 100644 --- a/src/main/java/ai/reveng/model/User.java +++ b/src/main/java/ai/reveng/model/User.java @@ -315,6 +315,50 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the User instance itself + */ + public User putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -331,12 +375,13 @@ public boolean equals(Object o) { Objects.equals(this.profile, user.profile) && Objects.equals(this.role, user.role) && Objects.equals(this.tier, user.tier) && - Objects.equals(this.userId, user.userId); + Objects.equals(this.userId, user.userId)&& + Objects.equals(this.additionalProperties, user.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdAt, email, profile, role, tier, userId); + return Objects.hash(createdAt, email, profile, role, tier, userId, additionalProperties); } @Override @@ -349,6 +394,7 @@ public String toString() { sb.append(" role: ").append(toIndentedString(role)).append("\n"); sb.append(" tier: ").append(toIndentedString(tier)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -386,14 +432,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!User.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `User` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : User.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -404,8 +442,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("email").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString())); } - // validate the required field `profile` - UserProfile.validateJsonElement(jsonObj.get("profile")); if (!jsonObj.get("role").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `role` to be a primitive type in the JSON string but got `%s`", jsonObj.get("role").toString())); } @@ -435,6 +471,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, User value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -442,7 +500,28 @@ public void write(JsonWriter out, User value) throws IOException { public User read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + User instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UserProfile.java b/src/main/java/ai/reveng/model/UserProfile.java index b254d783..bba0045e 100644 --- a/src/main/java/ai/reveng/model/UserProfile.java +++ b/src/main/java/ai/reveng/model/UserProfile.java @@ -195,6 +195,50 @@ public void setUsername(@javax.annotation.Nonnull String username) { this.username = username; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserProfile instance itself + */ + public UserProfile putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -211,12 +255,13 @@ public boolean equals(Object o) { Objects.equals(this.hideExampleBinaries, userProfile.hideExampleBinaries) && Objects.equals(this.lastName, userProfile.lastName) && Objects.equals(this.timeZone, userProfile.timeZone) && - Objects.equals(this.username, userProfile.username); + Objects.equals(this.username, userProfile.username)&& + Objects.equals(this.additionalProperties, userProfile.additionalProperties); } @Override public int hashCode() { - return Objects.hash(defaultTeamId, firstName, hideExampleBinaries, lastName, timeZone, username); + return Objects.hash(defaultTeamId, firstName, hideExampleBinaries, lastName, timeZone, username, additionalProperties); } @Override @@ -229,6 +274,7 @@ public String toString() { sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); sb.append(" timeZone: ").append(toIndentedString(timeZone)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -266,14 +312,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserProfile.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserProfile` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserProfile.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserProfile value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, UserProfile value) throws IOException { public UserProfile read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserProfile instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/WarningEvent.java b/src/main/java/ai/reveng/model/WarningEvent.java index 727dbc21..dc8582ed 100644 --- a/src/main/java/ai/reveng/model/WarningEvent.java +++ b/src/main/java/ai/reveng/model/WarningEvent.java @@ -206,6 +206,50 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the WarningEvent instance itself + */ + public WarningEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -222,7 +266,8 @@ public boolean equals(Object o) { Objects.equals(this.kind, warningEvent.kind) && Objects.equals(this.message, warningEvent.message) && Objects.equals(this.seq, warningEvent.seq) && - Objects.equals(this.type, warningEvent.type); + Objects.equals(this.type, warningEvent.type)&& + Objects.equals(this.additionalProperties, warningEvent.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -231,7 +276,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(attempt, identifiers, kind, message, seq, type); + return Objects.hash(attempt, identifiers, kind, message, seq, type, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -251,6 +296,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -288,14 +334,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WarningEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `WarningEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : WarningEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -333,6 +371,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, WarningEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -340,7 +400,28 @@ public void write(JsonWriter out, WarningEvent value) throws IOException { public WarningEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WarningEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/WorkflowProgress.java b/src/main/java/ai/reveng/model/WorkflowProgress.java index 17f804a6..d30ff38f 100644 --- a/src/main/java/ai/reveng/model/WorkflowProgress.java +++ b/src/main/java/ai/reveng/model/WorkflowProgress.java @@ -57,6 +57,11 @@ public class WorkflowProgress { @javax.annotation.Nullable private List messages; + public static final String SERIALIZED_NAME_PERCENT = "percent"; + @SerializedName(SERIALIZED_NAME_PERCENT) + @javax.annotation.Nonnull + private Long percent; + /** * Current workflow status */ @@ -132,11 +137,31 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nonnull private Long stepIndex; + public static final String SERIALIZED_NAME_STEP_SHARE = "step_share"; + @SerializedName(SERIALIZED_NAME_STEP_SHARE) + @javax.annotation.Nonnull + private Long stepShare; + public static final String SERIALIZED_NAME_STEPS_TOTAL = "steps_total"; @SerializedName(SERIALIZED_NAME_STEPS_TOTAL) @javax.annotation.Nonnull private Long stepsTotal; + public static final String SERIALIZED_NAME_SUB_STEP = "sub_step"; + @SerializedName(SERIALIZED_NAME_SUB_STEP) + @javax.annotation.Nullable + private String subStep; + + public static final String SERIALIZED_NAME_SUB_STEP_DONE = "sub_step_done"; + @SerializedName(SERIALIZED_NAME_SUB_STEP_DONE) + @javax.annotation.Nullable + private Long subStepDone; + + public static final String SERIALIZED_NAME_SUB_STEP_TOTAL = "sub_step_total"; + @SerializedName(SERIALIZED_NAME_SUB_STEP_TOTAL) + @javax.annotation.Nullable + private Long subStepTotal; + public WorkflowProgress() { } @@ -167,6 +192,25 @@ public void setMessages(@javax.annotation.Nullable List message } + public WorkflowProgress percent(@javax.annotation.Nonnull Long percent) { + this.percent = percent; + return this; + } + + /** + * Overall completion as a percentage, weighted by step duration + * @return percent + */ + @javax.annotation.Nonnull + public Long getPercent() { + return percent; + } + + public void setPercent(@javax.annotation.Nonnull Long percent) { + this.percent = percent; + } + + public WorkflowProgress status(@javax.annotation.Nonnull StatusEnum status) { this.status = status; return this; @@ -224,6 +268,25 @@ public void setStepIndex(@javax.annotation.Nonnull Long stepIndex) { } + public WorkflowProgress stepShare(@javax.annotation.Nonnull Long stepShare) { + this.stepShare = stepShare; + return this; + } + + /** + * Percentage points the current step contributes when it completes + * @return stepShare + */ + @javax.annotation.Nonnull + public Long getStepShare() { + return stepShare; + } + + public void setStepShare(@javax.annotation.Nonnull Long stepShare) { + this.stepShare = stepShare; + } + + public WorkflowProgress stepsTotal(@javax.annotation.Nonnull Long stepsTotal) { this.stepsTotal = stepsTotal; return this; @@ -243,6 +306,107 @@ public void setStepsTotal(@javax.annotation.Nonnull Long stepsTotal) { } + public WorkflowProgress subStep(@javax.annotation.Nullable String subStep) { + this.subStep = subStep; + return this; + } + + /** + * Phase within the current step, when the step reports one + * @return subStep + */ + @javax.annotation.Nullable + public String getSubStep() { + return subStep; + } + + public void setSubStep(@javax.annotation.Nullable String subStep) { + this.subStep = subStep; + } + + + public WorkflowProgress subStepDone(@javax.annotation.Nullable Long subStepDone) { + this.subStepDone = subStepDone; + return this; + } + + /** + * Items completed in the current phase + * @return subStepDone + */ + @javax.annotation.Nullable + public Long getSubStepDone() { + return subStepDone; + } + + public void setSubStepDone(@javax.annotation.Nullable Long subStepDone) { + this.subStepDone = subStepDone; + } + + + public WorkflowProgress subStepTotal(@javax.annotation.Nullable Long subStepTotal) { + this.subStepTotal = subStepTotal; + return this; + } + + /** + * Items the current phase will process, 0 when unknown + * @return subStepTotal + */ + @javax.annotation.Nullable + public Long getSubStepTotal() { + return subStepTotal; + } + + public void setSubStepTotal(@javax.annotation.Nullable Long subStepTotal) { + this.subStepTotal = subStepTotal; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the WorkflowProgress instance itself + */ + public WorkflowProgress putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + @Override public boolean equals(Object o) { @@ -254,15 +418,21 @@ public boolean equals(Object o) { } WorkflowProgress workflowProgress = (WorkflowProgress) o; return Objects.equals(this.messages, workflowProgress.messages) && + Objects.equals(this.percent, workflowProgress.percent) && Objects.equals(this.status, workflowProgress.status) && Objects.equals(this.step, workflowProgress.step) && Objects.equals(this.stepIndex, workflowProgress.stepIndex) && - Objects.equals(this.stepsTotal, workflowProgress.stepsTotal); + Objects.equals(this.stepShare, workflowProgress.stepShare) && + Objects.equals(this.stepsTotal, workflowProgress.stepsTotal) && + Objects.equals(this.subStep, workflowProgress.subStep) && + Objects.equals(this.subStepDone, workflowProgress.subStepDone) && + Objects.equals(this.subStepTotal, workflowProgress.subStepTotal)&& + Objects.equals(this.additionalProperties, workflowProgress.additionalProperties); } @Override public int hashCode() { - return Objects.hash(messages, status, step, stepIndex, stepsTotal); + return Objects.hash(messages, percent, status, step, stepIndex, stepShare, stepsTotal, subStep, subStepDone, subStepTotal, additionalProperties); } @Override @@ -270,10 +440,16 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class WorkflowProgress {\n"); sb.append(" messages: ").append(toIndentedString(messages)).append("\n"); + sb.append(" percent: ").append(toIndentedString(percent)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" step: ").append(toIndentedString(step)).append("\n"); sb.append(" stepIndex: ").append(toIndentedString(stepIndex)).append("\n"); + sb.append(" stepShare: ").append(toIndentedString(stepShare)).append("\n"); sb.append(" stepsTotal: ").append(toIndentedString(stepsTotal)).append("\n"); + sb.append(" subStep: ").append(toIndentedString(subStep)).append("\n"); + sb.append(" subStepDone: ").append(toIndentedString(subStepDone)).append("\n"); + sb.append(" subStepTotal: ").append(toIndentedString(subStepTotal)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -292,10 +468,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("messages", "status", "step", "step_index", "steps_total")); + openapiFields = new HashSet(Arrays.asList("messages", "percent", "status", "step", "step_index", "step_share", "steps_total", "sub_step", "sub_step_done", "sub_step_total")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("messages", "status", "step", "step_index", "steps_total")); + openapiRequiredFields = new HashSet(Arrays.asList("messages", "percent", "status", "step", "step_index", "step_share", "steps_total")); } /** @@ -311,14 +487,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkflowProgress.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `WorkflowProgress` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : WorkflowProgress.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -326,15 +494,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("messages") != null && !jsonObj.get("messages").isJsonNull()) { - if (!jsonObj.get("messages").isJsonArray()) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); - } - JsonArray jsonArraymessages = jsonObj.getAsJsonArray("messages"); - // validate the required field `messages` (array) - for (int i = 0; i < jsonArraymessages.size(); i++) { - ProgressMessage.validateJsonElement(jsonArraymessages.get(i)); - } + // ensure the required json array is present + if (jsonObj.get("messages") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("messages").isJsonArray() && !jsonObj.get("messages").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); @@ -344,6 +508,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("step").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); } + if ((jsonObj.get("sub_step") != null && !jsonObj.get("sub_step").isJsonNull()) && !jsonObj.get("sub_step").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sub_step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_step").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -361,6 +528,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, WorkflowProgress value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -368,7 +557,28 @@ public void write(JsonWriter out, WorkflowProgress value) throws IOException { public WorkflowProgress read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WorkflowProgress instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe();