From 9591fea6e1673d4009f4559ae5a9e49d07b0ef0d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 16 Mar 2026 07:30:04 +0000 Subject: [PATCH] Update SDK to version v3.40.0 - Generated from OpenAPI spec version v3.40.0 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 8 +- build.gradle | 4 +- build.sbt | 2 +- docs/AnalysesXRefsApi.md | 82 +++ docs/BaseResponseXRef.md | 17 + docs/SegmentInfo.md | 19 + docs/XRef.md | 21 + pom.xml | 2 +- .../java/ai/reveng/api/AnalysesXRefsApi.java | 221 ++++++++ .../java/ai/reveng/invoker/ApiClient.java | 2 +- .../java/ai/reveng/invoker/Configuration.java | 2 +- src/main/java/ai/reveng/invoker/JSON.java | 3 + .../ai/reveng/model/BaseResponseXRef.java | 438 +++++++++++++++ .../java/ai/reveng/model/SegmentInfo.java | 429 ++++++++++++++ src/main/java/ai/reveng/model/XRef.java | 526 ++++++++++++++++++ 16 files changed, 1769 insertions(+), 9 deletions(-) create mode 100644 docs/AnalysesXRefsApi.md create mode 100644 docs/BaseResponseXRef.md create mode 100644 docs/SegmentInfo.md create mode 100644 docs/XRef.md create mode 100644 src/main/java/ai/reveng/api/AnalysesXRefsApi.java create mode 100644 src/main/java/ai/reveng/model/BaseResponseXRef.java create mode 100644 src/main/java/ai/reveng/model/SegmentInfo.java create mode 100644 src/main/java/ai/reveng/model/XRef.java diff --git a/.sdk-version b/.sdk-version index d6f9644..189a640 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v3.39.0 +v3.40.0 diff --git a/README.md b/README.md index a7be7a4..a48ca8d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add this dependency to your project's POM: ai.reveng sdk - 3.39.0 + 3.40.0 compile ``` @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation "ai.reveng:sdk:3.39.0" + implementation "ai.reveng:sdk:3.40.0" } ``` @@ -113,6 +113,7 @@ Class | Method | HTTP request | Description *AnalysesSecurityChecksApi* | [**createScurityChecksTask**](docs/AnalysesSecurityChecksApi.md#createScurityChecksTask) | **POST** /v2/analyses/{analysis_id}/security-checks | Queues a security check process *AnalysesSecurityChecksApi* | [**getSecurityChecks**](docs/AnalysesSecurityChecksApi.md#getSecurityChecks) | **GET** /v2/analyses/{analysis_id}/security-checks | Get Security Checks *AnalysesSecurityChecksApi* | [**getSecurityChecksTaskStatus**](docs/AnalysesSecurityChecksApi.md#getSecurityChecksTaskStatus) | **GET** /v2/analyses/{analysis_id}/security-checks/status | Check the status of a security check process +*AnalysesXRefsApi* | [**getXrefByVaddr**](docs/AnalysesXRefsApi.md#getXrefByVaddr) | **GET** /v2/analyses/{analysis_id}/xrefs/{vaddr} | [Beta] Look up an xref by virtual address *AuthenticationUsersApi* | [**getRequesterUserInfo**](docs/AuthenticationUsersApi.md#getRequesterUserInfo) | **GET** /v2/users/me | Get the requesters user information *AuthenticationUsersApi* | [**getUser**](docs/AuthenticationUsersApi.md#getUser) | **GET** /v2/users/{user_id} | Get a user's public information *AuthenticationUsersApi* | [**getUserActivity**](docs/AuthenticationUsersApi.md#getUserActivity) | **GET** /v2/users/activity | Get auth user activity @@ -298,6 +299,7 @@ Class | Method | HTTP request | Description - [BaseResponseTaskResponse](docs/BaseResponseTaskResponse.md) - [BaseResponseUploadResponse](docs/BaseResponseUploadResponse.md) - [BaseResponseVulnerabilities](docs/BaseResponseVulnerabilities.md) + - [BaseResponseXRef](docs/BaseResponseXRef.md) - [Basic](docs/Basic.md) - [BinariesRelatedStatusResponse](docs/BinariesRelatedStatusResponse.md) - [BinariesTaskStatus](docs/BinariesTaskStatus.md) @@ -454,6 +456,7 @@ Class | Method | HTTP request | Description - [SecurityChecksResponse](docs/SecurityChecksResponse.md) - [SecurityChecksResult](docs/SecurityChecksResult.md) - [SecurityModel](docs/SecurityModel.md) + - [SegmentInfo](docs/SegmentInfo.md) - [SeverityType](docs/SeverityType.md) - [SingleCodeCertificateModel](docs/SingleCodeCertificateModel.md) - [SingleCodeSignatureModel](docs/SingleCodeSignatureModel.md) @@ -489,6 +492,7 @@ Class | Method | HTTP request | Description - [Vulnerability](docs/Vulnerability.md) - [VulnerabilityType](docs/VulnerabilityType.md) - [Workspace](docs/Workspace.md) + - [XRef](docs/XRef.md) ## Recommendation diff --git a/build.gradle b/build.gradle index 49fd22c..e6fd263 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'ai.reveng' -version = '3.39.0' +version = '3.40.0' @@ -171,7 +171,7 @@ mavenPublishing { publishToMavenCentral(true) signAllPublications() - coordinates("ai.reveng", "sdk", "3.39.0") + coordinates("ai.reveng", "sdk", "3.40.0") pom { name = "sdk" diff --git a/build.sbt b/build.sbt index 8860a20..667b536 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ai.reveng", name := "sdk", - version := "3.39.0", + version := "3.40.0", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), diff --git a/docs/AnalysesXRefsApi.md b/docs/AnalysesXRefsApi.md new file mode 100644 index 0000000..2c5d10f --- /dev/null +++ b/docs/AnalysesXRefsApi.md @@ -0,0 +1,82 @@ +# AnalysesXRefsApi + +All URIs are relative to *https://api.reveng.ai* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**getXrefByVaddr**](AnalysesXRefsApi.md#getXrefByVaddr) | **GET** /v2/analyses/{analysis_id}/xrefs/{vaddr} | [Beta] Look up an xref by virtual address | + + + +# **getXrefByVaddr** +> BaseResponseXRef getXrefByVaddr(analysisId, vaddr) + +[Beta] Look up an xref by virtual address + +**This endpoint is in beta and may change without notice.** + +### 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.AnalysesXRefsApi; + +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"); + + AnalysesXRefsApi apiInstance = new AnalysesXRefsApi(defaultClient); + Integer analysisId = 56; // Integer | + Integer vaddr = 56; // Integer | Virtual address to match against xref_to + try { + BaseResponseXRef result = apiInstance.getXrefByVaddr(analysisId, vaddr); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AnalysesXRefsApi#getXrefByVaddr"); + 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**| | | +| **vaddr** | **Integer**| Virtual address to match against xref_to | | + +### Return type + +[**BaseResponseXRef**](BaseResponseXRef.md) + +### Authorization + +[APIKey](../README.md#APIKey) + +### 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 | - | +| **404** | Xref or analysis cache not found | - | + diff --git a/docs/BaseResponseXRef.md b/docs/BaseResponseXRef.md new file mode 100644 index 0000000..00cf7fa --- /dev/null +++ b/docs/BaseResponseXRef.md @@ -0,0 +1,17 @@ + + +# BaseResponseXRef + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**status** | **Boolean** | Response status on whether the request succeeded | [optional] | +|**data** | [**XRef**](XRef.md) | | [optional] | +|**message** | **String** | | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | + + + diff --git a/docs/SegmentInfo.md b/docs/SegmentInfo.md new file mode 100644 index 0000000..21a968b --- /dev/null +++ b/docs/SegmentInfo.md @@ -0,0 +1,19 @@ + + +# 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. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | [optional] | +|**r** | **Boolean** | | [optional] | +|**w** | **Boolean** | | [optional] | +|**x** | **Boolean** | | [optional] | +|**start** | **Integer** | | [optional] | +|**end** | **Integer** | | [optional] | + + + diff --git a/docs/XRef.md b/docs/XRef.md new file mode 100644 index 0000000..5aa1e42 --- /dev/null +++ b/docs/XRef.md @@ -0,0 +1,21 @@ + + +# XRef + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**value** | **String** | | | +|**xrefTo** | **String** | | | +|**isScalar** | **Boolean** | | [optional] | +|**isCall** | **Boolean** | | [optional] | +|**isData** | **Boolean** | | [optional] | +|**isString** | **Boolean** | | [optional] | +|**rawData** | **File** | | [optional] | +|**segment** | [**SegmentInfo**](SegmentInfo.md) | | [optional] | +|**origStrEncoding** | **String** | | [optional] | + + + diff --git a/pom.xml b/pom.xml index 4e390f2..8190086 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ sdk jar sdk - 3.39.0 + 3.40.0 https://github.com/RevEngAI/sdk-java Java SDK for the RevEng.AI API diff --git a/src/main/java/ai/reveng/api/AnalysesXRefsApi.java b/src/main/java/ai/reveng/api/AnalysesXRefsApi.java new file mode 100644 index 0000000..67ca7cf --- /dev/null +++ b/src/main/java/ai/reveng/api/AnalysesXRefsApi.java @@ -0,0 +1,221 @@ +/* + * 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 ai.reveng.model.BaseResponseXRef; +import ai.reveng.model.ErrorModel; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AnalysesXRefsApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public AnalysesXRefsApi() { + this(Configuration.getDefaultApiClient()); + } + + public AnalysesXRefsApi(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 getXrefByVaddr + * @param analysisId (required) + * @param vaddr Virtual address to match against xref_to (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 -
404 Xref or analysis cache not found -
+ */ + public okhttp3.Call getXrefByVaddrCall(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull Integer vaddr, 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}/xrefs/{vaddr}" + .replace("{" + "analysis_id" + "}", localVarApiClient.escapeString(analysisId.toString())) + .replace("{" + "vaddr" + "}", localVarApiClient.escapeString(vaddr.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" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getXrefByVaddrValidateBeforeCall(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull Integer vaddr, 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 getXrefByVaddr(Async)"); + } + + // verify the required parameter 'vaddr' is set + if (vaddr == null) { + throw new ApiException("Missing the required parameter 'vaddr' when calling getXrefByVaddr(Async)"); + } + + return getXrefByVaddrCall(analysisId, vaddr, _callback); + + } + + /** + * [Beta] Look up an xref by virtual address + * **This endpoint is in beta and may change without notice.** + * @param analysisId (required) + * @param vaddr Virtual address to match against xref_to (required) + * @return BaseResponseXRef + * @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 -
404 Xref or analysis cache not found -
+ */ + public BaseResponseXRef getXrefByVaddr(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull Integer vaddr) throws ApiException { + ApiResponse localVarResp = getXrefByVaddrWithHttpInfo(analysisId, vaddr); + return localVarResp.getData(); + } + + /** + * [Beta] Look up an xref by virtual address + * **This endpoint is in beta and may change without notice.** + * @param analysisId (required) + * @param vaddr Virtual address to match against xref_to (required) + * @return ApiResponse<BaseResponseXRef> + * @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 -
404 Xref or analysis cache not found -
+ */ + public ApiResponse getXrefByVaddrWithHttpInfo(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull Integer vaddr) throws ApiException { + okhttp3.Call localVarCall = getXrefByVaddrValidateBeforeCall(analysisId, vaddr, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * [Beta] Look up an xref by virtual address (asynchronously) + * **This endpoint is in beta and may change without notice.** + * @param analysisId (required) + * @param vaddr Virtual address to match against xref_to (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 -
404 Xref or analysis cache not found -
+ */ + public okhttp3.Call getXrefByVaddrAsync(@javax.annotation.Nonnull Integer analysisId, @javax.annotation.Nonnull Integer vaddr, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getXrefByVaddrValidateBeforeCall(analysisId, vaddr, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/ai/reveng/invoker/ApiClient.java b/src/main/java/ai/reveng/invoker/ApiClient.java index 52500d3..f2b7460 100644 --- a/src/main/java/ai/reveng/invoker/ApiClient.java +++ b/src/main/java/ai/reveng/invoker/ApiClient.java @@ -146,7 +146,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/3.39.0/java"); + setUserAgent("OpenAPI-Generator/3.40.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 3ca82d1..80c763e 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 = "3.39.0"; + public static final String VERSION = "3.40.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 4676e02..9478d14 100644 --- a/src/main/java/ai/reveng/invoker/JSON.java +++ b/src/main/java/ai/reveng/invoker/JSON.java @@ -202,6 +202,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseTaskResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseUploadResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseVulnerabilities.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BaseResponseXRef.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Basic.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BinariesRelatedStatusResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BinaryAdditionalDetailsDataResponse.CustomTypeAdapterFactory()); @@ -345,6 +346,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityChecksResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityChecksResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityModel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SegmentInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SingleCodeCertificateModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SingleCodeSignatureModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SinglePDBEntryModel.CustomTypeAdapterFactory()); @@ -374,6 +376,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.UserActivityResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Vulnerabilities.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Vulnerability.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.XRef.CustomTypeAdapterFactory()); gson = gsonBuilder.create(); } diff --git a/src/main/java/ai/reveng/model/BaseResponseXRef.java b/src/main/java/ai/reveng/model/BaseResponseXRef.java new file mode 100644 index 0000000..49adb06 --- /dev/null +++ b/src/main/java/ai/reveng/model/BaseResponseXRef.java @@ -0,0 +1,438 @@ +/* + * 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 java.util.Locale; +import ai.reveng.model.ErrorModel; +import ai.reveng.model.MetaModel; +import ai.reveng.model.XRef; +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 java.util.Locale; + +import ai.reveng.invoker.JSON; + +/** + * BaseResponseXRef + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BaseResponseXRef { + 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 XRef 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 BaseResponseXRef() { + } + + public BaseResponseXRef 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 BaseResponseXRef data(@javax.annotation.Nullable XRef data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nullable + public XRef getData() { + return data; + } + + public void setData(@javax.annotation.Nullable XRef data) { + this.data = data; + } + + + public BaseResponseXRef message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + public BaseResponseXRef errors(@javax.annotation.Nullable List errors) { + this.errors = errors; + return this; + } + + public BaseResponseXRef addErrorsItem(ErrorModel errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nullable List errors) { + this.errors = errors; + } + + + public BaseResponseXRef 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 BaseResponseXRef instance itself + */ + public BaseResponseXRef putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key 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; + } + BaseResponseXRef baseResponseXRef = (BaseResponseXRef) o; + return Objects.equals(this.status, baseResponseXRef.status) && + Objects.equals(this.data, baseResponseXRef.data) && + Objects.equals(this.message, baseResponseXRef.message) && + Objects.equals(this.errors, baseResponseXRef.errors) && + Objects.equals(this.meta, baseResponseXRef.meta)&& + Objects.equals(this.additionalProperties, baseResponseXRef.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 BaseResponseXRef {\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) { + if (o == null) { + return "null"; + } + return 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 BaseResponseXRef + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!BaseResponseXRef.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseXRef is not found in the empty JSON string", BaseResponseXRef.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + XRef.validateJsonElement(jsonObj.get("data")); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(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(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 (!BaseResponseXRef.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BaseResponseXRef' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BaseResponseXRef.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BaseResponseXRef value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = 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 BaseResponseXRef read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BaseResponseXRef instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(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 BaseResponseXRef given an JSON string + * + * @param jsonString JSON string + * @return An instance of BaseResponseXRef + * @throws IOException if the JSON string is invalid with respect to BaseResponseXRef + */ + public static BaseResponseXRef fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BaseResponseXRef.class); + } + + /** + * Convert an instance of BaseResponseXRef 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 new file mode 100644 index 0000000..ab45090 --- /dev/null +++ b/src/main/java/ai/reveng/model/SegmentInfo.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 java.util.Locale; +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 java.util.Locale; + +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. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SegmentInfo { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable + private String name = ""; + + public static final String SERIALIZED_NAME_R = "r"; + @SerializedName(SERIALIZED_NAME_R) + @javax.annotation.Nullable + private Boolean r; + + public static final String SERIALIZED_NAME_W = "w"; + @SerializedName(SERIALIZED_NAME_W) + @javax.annotation.Nullable + private Boolean w; + + public static final String SERIALIZED_NAME_X = "x"; + @SerializedName(SERIALIZED_NAME_X) + @javax.annotation.Nullable + private Boolean x; + + public static final String SERIALIZED_NAME_START = "start"; + @SerializedName(SERIALIZED_NAME_START) + @javax.annotation.Nullable + private Integer start = 0; + + public static final String SERIALIZED_NAME_END = "end"; + @SerializedName(SERIALIZED_NAME_END) + @javax.annotation.Nullable + private Integer end = 0; + + public SegmentInfo() { + } + + public SegmentInfo name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nullable + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + + public SegmentInfo r(@javax.annotation.Nullable Boolean r) { + this.r = r; + return this; + } + + /** + * Get r + * @return r + */ + @javax.annotation.Nullable + public Boolean getR() { + return r; + } + + public void setR(@javax.annotation.Nullable Boolean r) { + this.r = r; + } + + + public SegmentInfo w(@javax.annotation.Nullable Boolean w) { + this.w = w; + return this; + } + + /** + * Get w + * @return w + */ + @javax.annotation.Nullable + public Boolean getW() { + return w; + } + + public void setW(@javax.annotation.Nullable Boolean w) { + this.w = w; + } + + + public SegmentInfo x(@javax.annotation.Nullable Boolean x) { + this.x = x; + return this; + } + + /** + * Get x + * @return x + */ + @javax.annotation.Nullable + public Boolean getX() { + return x; + } + + public void setX(@javax.annotation.Nullable Boolean x) { + this.x = x; + } + + + public SegmentInfo start(@javax.annotation.Nullable Integer start) { + this.start = start; + return this; + } + + /** + * Get start + * @return start + */ + @javax.annotation.Nullable + public Integer getStart() { + return start; + } + + public void setStart(@javax.annotation.Nullable Integer start) { + this.start = start; + } + + + public SegmentInfo end(@javax.annotation.Nullable Integer end) { + this.end = end; + return this; + } + + /** + * Get end + * @return end + */ + @javax.annotation.Nullable + public Integer getEnd() { + return end; + } + + public void setEnd(@javax.annotation.Nullable Integer end) { + this.end = end; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SegmentInfo instance itself + */ + public SegmentInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key 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; + } + SegmentInfo segmentInfo = (SegmentInfo) o; + return Objects.equals(this.name, segmentInfo.name) && + Objects.equals(this.r, segmentInfo.r) && + Objects.equals(this.w, segmentInfo.w) && + Objects.equals(this.x, segmentInfo.x) && + Objects.equals(this.start, segmentInfo.start) && + Objects.equals(this.end, segmentInfo.end)&& + Objects.equals(this.additionalProperties, segmentInfo.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(name, r, w, x, start, end, 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 SegmentInfo {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" r: ").append(toIndentedString(r)).append("\n"); + sb.append(" w: ").append(toIndentedString(w)).append("\n"); + sb.append(" x: ").append(toIndentedString(x)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append(" end: ").append(toIndentedString(end)).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) { + if (o == null) { + return "null"; + } + return 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", "r", "w", "x", "start", "end")); + + // 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 SegmentInfo + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SegmentInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SegmentInfo is not found in the empty JSON string", SegmentInfo.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(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 (!SegmentInfo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SegmentInfo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SegmentInfo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SegmentInfo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = 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 SegmentInfo read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SegmentInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(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 SegmentInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of SegmentInfo + * @throws IOException if the JSON string is invalid with respect to SegmentInfo + */ + public static SegmentInfo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SegmentInfo.class); + } + + /** + * Convert an instance of SegmentInfo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/XRef.java b/src/main/java/ai/reveng/model/XRef.java new file mode 100644 index 0000000..0a00722 --- /dev/null +++ b/src/main/java/ai/reveng/model/XRef.java @@ -0,0 +1,526 @@ +/* + * 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 java.util.Locale; +import ai.reveng.model.SegmentInfo; +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.File; +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 java.util.Locale; + +import ai.reveng.invoker.JSON; + +/** + * XRef + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class XRef { + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + @javax.annotation.Nullable + private String value; + + public static final String SERIALIZED_NAME_XREF_TO = "xref_to"; + @SerializedName(SERIALIZED_NAME_XREF_TO) + @javax.annotation.Nullable + private String xrefTo; + + public static final String SERIALIZED_NAME_IS_SCALAR = "is_scalar"; + @SerializedName(SERIALIZED_NAME_IS_SCALAR) + @javax.annotation.Nullable + private Boolean isScalar; + + public static final String SERIALIZED_NAME_IS_CALL = "is_call"; + @SerializedName(SERIALIZED_NAME_IS_CALL) + @javax.annotation.Nullable + private Boolean isCall; + + public static final String SERIALIZED_NAME_IS_DATA = "is_data"; + @SerializedName(SERIALIZED_NAME_IS_DATA) + @javax.annotation.Nullable + private Boolean isData; + + public static final String SERIALIZED_NAME_IS_STRING = "is_string"; + @SerializedName(SERIALIZED_NAME_IS_STRING) + @javax.annotation.Nullable + private Boolean isString; + + public static final String SERIALIZED_NAME_RAW_DATA = "raw_data"; + @SerializedName(SERIALIZED_NAME_RAW_DATA) + @javax.annotation.Nullable + private File rawData; + + public static final String SERIALIZED_NAME_SEGMENT = "segment"; + @SerializedName(SERIALIZED_NAME_SEGMENT) + @javax.annotation.Nullable + private SegmentInfo segment; + + public static final String SERIALIZED_NAME_ORIG_STR_ENCODING = "orig_str_encoding"; + @SerializedName(SERIALIZED_NAME_ORIG_STR_ENCODING) + @javax.annotation.Nullable + private String origStrEncoding; + + public XRef() { + } + + public XRef value(@javax.annotation.Nullable String value) { + this.value = value; + return this; + } + + /** + * Get value + * @return value + */ + @javax.annotation.Nullable + public String getValue() { + return value; + } + + public void setValue(@javax.annotation.Nullable String value) { + this.value = value; + } + + + public XRef xrefTo(@javax.annotation.Nullable String xrefTo) { + this.xrefTo = xrefTo; + return this; + } + + /** + * Get xrefTo + * @return xrefTo + */ + @javax.annotation.Nullable + public String getXrefTo() { + return xrefTo; + } + + public void setXrefTo(@javax.annotation.Nullable String xrefTo) { + this.xrefTo = xrefTo; + } + + + public XRef isScalar(@javax.annotation.Nullable Boolean isScalar) { + this.isScalar = isScalar; + return this; + } + + /** + * Get isScalar + * @return isScalar + */ + @javax.annotation.Nullable + public Boolean getIsScalar() { + return isScalar; + } + + public void setIsScalar(@javax.annotation.Nullable Boolean isScalar) { + this.isScalar = isScalar; + } + + + public XRef isCall(@javax.annotation.Nullable Boolean isCall) { + this.isCall = isCall; + return this; + } + + /** + * Get isCall + * @return isCall + */ + @javax.annotation.Nullable + public Boolean getIsCall() { + return isCall; + } + + public void setIsCall(@javax.annotation.Nullable Boolean isCall) { + this.isCall = isCall; + } + + + public XRef isData(@javax.annotation.Nullable Boolean isData) { + this.isData = isData; + return this; + } + + /** + * Get isData + * @return isData + */ + @javax.annotation.Nullable + public Boolean getIsData() { + return isData; + } + + public void setIsData(@javax.annotation.Nullable Boolean isData) { + this.isData = isData; + } + + + public XRef isString(@javax.annotation.Nullable Boolean isString) { + this.isString = isString; + return this; + } + + /** + * Get isString + * @return isString + */ + @javax.annotation.Nullable + public Boolean getIsString() { + return isString; + } + + public void setIsString(@javax.annotation.Nullable Boolean isString) { + this.isString = isString; + } + + + public XRef rawData(@javax.annotation.Nullable File rawData) { + this.rawData = rawData; + return this; + } + + /** + * Get rawData + * @return rawData + */ + @javax.annotation.Nullable + public File getRawData() { + return rawData; + } + + public void setRawData(@javax.annotation.Nullable File rawData) { + this.rawData = rawData; + } + + + public XRef segment(@javax.annotation.Nullable SegmentInfo segment) { + this.segment = segment; + return this; + } + + /** + * Get segment + * @return segment + */ + @javax.annotation.Nullable + public SegmentInfo getSegment() { + return segment; + } + + public void setSegment(@javax.annotation.Nullable SegmentInfo segment) { + this.segment = segment; + } + + + public XRef origStrEncoding(@javax.annotation.Nullable String origStrEncoding) { + this.origStrEncoding = origStrEncoding; + return this; + } + + /** + * Get origStrEncoding + * @return origStrEncoding + */ + @javax.annotation.Nullable + public String getOrigStrEncoding() { + return origStrEncoding; + } + + public void setOrigStrEncoding(@javax.annotation.Nullable String origStrEncoding) { + this.origStrEncoding = origStrEncoding; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the XRef instance itself + */ + public XRef putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key 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; + } + XRef xref = (XRef) o; + return Objects.equals(this.value, xref.value) && + Objects.equals(this.xrefTo, xref.xrefTo) && + Objects.equals(this.isScalar, xref.isScalar) && + Objects.equals(this.isCall, xref.isCall) && + Objects.equals(this.isData, xref.isData) && + Objects.equals(this.isString, xref.isString) && + Objects.equals(this.rawData, xref.rawData) && + Objects.equals(this.segment, xref.segment) && + Objects.equals(this.origStrEncoding, xref.origStrEncoding)&& + Objects.equals(this.additionalProperties, xref.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, xrefTo, isScalar, isCall, isData, isString, rawData, segment, origStrEncoding, 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 XRef {\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" xrefTo: ").append(toIndentedString(xrefTo)).append("\n"); + sb.append(" isScalar: ").append(toIndentedString(isScalar)).append("\n"); + sb.append(" isCall: ").append(toIndentedString(isCall)).append("\n"); + sb.append(" isData: ").append(toIndentedString(isData)).append("\n"); + sb.append(" isString: ").append(toIndentedString(isString)).append("\n"); + sb.append(" rawData: ").append(toIndentedString(rawData)).append("\n"); + sb.append(" segment: ").append(toIndentedString(segment)).append("\n"); + sb.append(" origStrEncoding: ").append(toIndentedString(origStrEncoding)).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) { + if (o == null) { + return "null"; + } + return 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", "xref_to", "is_scalar", "is_call", "is_data", "is_string", "raw_data", "segment", "orig_str_encoding")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("value", "xref_to")); + } + + /** + * 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 XRef + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!XRef.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in XRef is not found in the empty JSON string", XRef.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : XRef.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(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") != null && !jsonObj.get("value").isJsonNull()) && !jsonObj.get("value").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(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("xref_to") != null && !jsonObj.get("xref_to").isJsonNull()) && !jsonObj.get("xref_to").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `xref_to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("xref_to").toString())); + } + // validate the optional field `segment` + if (jsonObj.get("segment") != null && !jsonObj.get("segment").isJsonNull()) { + SegmentInfo.validateJsonElement(jsonObj.get("segment")); + } + if ((jsonObj.get("orig_str_encoding") != null && !jsonObj.get("orig_str_encoding").isJsonNull()) && !jsonObj.get("orig_str_encoding").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `orig_str_encoding` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orig_str_encoding").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!XRef.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'XRef' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(XRef.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, XRef value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = 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 XRef read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + XRef instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(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 XRef given an JSON string + * + * @param jsonString JSON string + * @return An instance of XRef + * @throws IOException if the JSON string is invalid with respect to XRef + */ + public static XRef fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, XRef.class); + } + + /** + * Convert an instance of XRef to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +