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 0b26672..964d177 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Class | Method | HTTP request | Description *AnalysesSecurityChecksApi* | [**create_scurity_checks_task**](docs/AnalysesSecurityChecksApi.md#create_scurity_checks_task) | **POST** /v2/analyses/{analysis_id}/security-checks | Queues a security check process *AnalysesSecurityChecksApi* | [**get_security_checks**](docs/AnalysesSecurityChecksApi.md#get_security_checks) | **GET** /v2/analyses/{analysis_id}/security-checks | Get Security Checks *AnalysesSecurityChecksApi* | [**get_security_checks_task_status**](docs/AnalysesSecurityChecksApi.md#get_security_checks_task_status) | **GET** /v2/analyses/{analysis_id}/security-checks/status | Check the status of a security check process +*AnalysesXRefsApi* | [**get_xref_by_vaddr**](docs/AnalysesXRefsApi.md#get_xref_by_vaddr) | **GET** /v2/analyses/{analysis_id}/xrefs/{vaddr} | [Beta] Look up an xref by virtual address *AuthenticationUsersApi* | [**get_requester_user_info**](docs/AuthenticationUsersApi.md#get_requester_user_info) | **GET** /v2/users/me | Get the requesters user information *AuthenticationUsersApi* | [**get_user**](docs/AuthenticationUsersApi.md#get_user) | **GET** /v2/users/{user_id} | Get a user's public information *AuthenticationUsersApi* | [**get_user_activity**](docs/AuthenticationUsersApi.md#get_user_activity) | **GET** /v2/users/activity | Get auth user activity @@ -263,6 +264,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) @@ -419,6 +421,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) @@ -454,3 +457,4 @@ Class | Method | HTTP request | Description - [Vulnerability](docs/Vulnerability.md) - [VulnerabilityType](docs/VulnerabilityType.md) - [Workspace](docs/Workspace.md) + - [XRef](docs/XRef.md) diff --git a/docs/AnalysesXRefsApi.md b/docs/AnalysesXRefsApi.md new file mode 100644 index 0000000..9aee5e3 --- /dev/null +++ b/docs/AnalysesXRefsApi.md @@ -0,0 +1,92 @@ +# revengai.AnalysesXRefsApi + +All URIs are relative to *https://api.reveng.ai* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_xref_by_vaddr**](AnalysesXRefsApi.md#get_xref_by_vaddr) | **GET** /v2/analyses/{analysis_id}/xrefs/{vaddr} | [Beta] Look up an xref by virtual address + + +# **get_xref_by_vaddr** +> BaseResponseXRef get_xref_by_vaddr(analysis_id, vaddr) + +[Beta] Look up an xref by virtual address + +**This endpoint is in beta and may change without notice.** + +### Example + +* Api Key Authentication (APIKey): + +```python +import revengai +from revengai.models.base_response_x_ref import BaseResponseXRef +from revengai.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.reveng.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = revengai.Configuration( + host = "https://api.reveng.ai" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: APIKey +configuration.api_key['APIKey'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['APIKey'] = 'Bearer' + +# Enter a context with an instance of the API client +with revengai.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = revengai.AnalysesXRefsApi(api_client) + analysis_id = 56 # int | + vaddr = 56 # int | Virtual address to match against xref_to + + try: + # [Beta] Look up an xref by virtual address + api_response = api_instance.get_xref_by_vaddr(analysis_id, vaddr) + print("The response of AnalysesXRefsApi->get_xref_by_vaddr:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling AnalysesXRefsApi->get_xref_by_vaddr: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **analysis_id** | **int**| | + **vaddr** | **int**| 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 | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/BaseResponseXRef.md b/docs/BaseResponseXRef.md new file mode 100644 index 0000000..4d05a09 --- /dev/null +++ b/docs/BaseResponseXRef.md @@ -0,0 +1,33 @@ +# BaseResponseXRef + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**status** | **bool** | Response status on whether the request succeeded | [optional] [default to True] +**data** | [**XRef**](XRef.md) | | [optional] +**message** | **str** | | [optional] +**errors** | [**List[ErrorModel]**](ErrorModel.md) | | [optional] +**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] + +## Example + +```python +from revengai.models.base_response_x_ref import BaseResponseXRef + +# TODO update the JSON string below +json = "{}" +# create an instance of BaseResponseXRef from a JSON string +base_response_x_ref_instance = BaseResponseXRef.from_json(json) +# print the JSON string representation of the object +print(BaseResponseXRef.to_json()) + +# convert the object into a dict +base_response_x_ref_dict = base_response_x_ref_instance.to_dict() +# create an instance of BaseResponseXRef from a dict +base_response_x_ref_from_dict = BaseResponseXRef.from_dict(base_response_x_ref_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SegmentInfo.md b/docs/SegmentInfo.md new file mode 100644 index 0000000..d4068bd --- /dev/null +++ b/docs/SegmentInfo.md @@ -0,0 +1,35 @@ +# 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** | **str** | | [optional] [default to ''] +**r** | **bool** | | [optional] +**w** | **bool** | | [optional] +**x** | **bool** | | [optional] +**start** | **int** | | [optional] [default to 0] +**end** | **int** | | [optional] [default to 0] + +## Example + +```python +from revengai.models.segment_info import SegmentInfo + +# TODO update the JSON string below +json = "{}" +# create an instance of SegmentInfo from a JSON string +segment_info_instance = SegmentInfo.from_json(json) +# print the JSON string representation of the object +print(SegmentInfo.to_json()) + +# convert the object into a dict +segment_info_dict = segment_info_instance.to_dict() +# create an instance of SegmentInfo from a dict +segment_info_from_dict = SegmentInfo.from_dict(segment_info_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/XRef.md b/docs/XRef.md new file mode 100644 index 0000000..70c30fb --- /dev/null +++ b/docs/XRef.md @@ -0,0 +1,37 @@ +# XRef + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **str** | | +**xref_to** | **str** | | +**is_scalar** | **bool** | | [optional] +**is_call** | **bool** | | [optional] +**is_data** | **bool** | | [optional] +**is_string** | **bool** | | [optional] +**raw_data** | **bytearray** | | [optional] +**segment** | [**SegmentInfo**](SegmentInfo.md) | | [optional] +**orig_str_encoding** | **str** | | [optional] + +## Example + +```python +from revengai.models.x_ref import XRef + +# TODO update the JSON string below +json = "{}" +# create an instance of XRef from a JSON string +x_ref_instance = XRef.from_json(json) +# print the JSON string representation of the object +print(XRef.to_json()) + +# convert the object into a dict +x_ref_dict = x_ref_instance.to_dict() +# create an instance of XRef from a dict +x_ref_from_dict = XRef.from_dict(x_ref_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/revengai/__init__.py b/revengai/__init__.py index 269b6f6..2a7998c 100644 --- a/revengai/__init__.py +++ b/revengai/__init__.py @@ -13,7 +13,7 @@ """ # noqa: E501 -__version__ = "v3.39.0" +__version__ = "v3.40.0" # Define package exports __all__ = [ @@ -22,6 +22,7 @@ "AnalysesDynamicExecutionApi", "AnalysesResultsMetadataApi", "AnalysesSecurityChecksApi", + "AnalysesXRefsApi", "AuthenticationUsersApi", "BinariesApi", "CollectionsApi", @@ -155,6 +156,7 @@ "BaseResponseTaskResponse", "BaseResponseUploadResponse", "BaseResponseVulnerabilities", + "BaseResponseXRef", "Basic", "BinariesRelatedStatusResponse", "BinariesTaskStatus", @@ -311,6 +313,7 @@ "SecurityChecksResponse", "SecurityChecksResult", "SecurityModel", + "SegmentInfo", "SeverityType", "SingleCodeCertificateModel", "SingleCodeSignatureModel", @@ -346,6 +349,7 @@ "Vulnerability", "VulnerabilityType", "Workspace", + "XRef", ] # import apis into sdk package @@ -354,6 +358,7 @@ from revengai.api.analyses_dynamic_execution_api import AnalysesDynamicExecutionApi as AnalysesDynamicExecutionApi from revengai.api.analyses_results_metadata_api import AnalysesResultsMetadataApi as AnalysesResultsMetadataApi from revengai.api.analyses_security_checks_api import AnalysesSecurityChecksApi as AnalysesSecurityChecksApi +from revengai.api.analyses_x_refs_api import AnalysesXRefsApi as AnalysesXRefsApi from revengai.api.authentication_users_api import AuthenticationUsersApi as AuthenticationUsersApi from revengai.api.binaries_api import BinariesApi as BinariesApi from revengai.api.collections_api import CollectionsApi as CollectionsApi @@ -491,6 +496,7 @@ from revengai.models.base_response_task_response import BaseResponseTaskResponse as BaseResponseTaskResponse from revengai.models.base_response_upload_response import BaseResponseUploadResponse as BaseResponseUploadResponse from revengai.models.base_response_vulnerabilities import BaseResponseVulnerabilities as BaseResponseVulnerabilities +from revengai.models.base_response_x_ref import BaseResponseXRef as BaseResponseXRef from revengai.models.basic import Basic as Basic from revengai.models.binaries_related_status_response import BinariesRelatedStatusResponse as BinariesRelatedStatusResponse from revengai.models.binaries_task_status import BinariesTaskStatus as BinariesTaskStatus @@ -647,6 +653,7 @@ from revengai.models.security_checks_response import SecurityChecksResponse as SecurityChecksResponse from revengai.models.security_checks_result import SecurityChecksResult as SecurityChecksResult from revengai.models.security_model import SecurityModel as SecurityModel +from revengai.models.segment_info import SegmentInfo as SegmentInfo from revengai.models.severity_type import SeverityType as SeverityType from revengai.models.single_code_certificate_model import SingleCodeCertificateModel as SingleCodeCertificateModel from revengai.models.single_code_signature_model import SingleCodeSignatureModel as SingleCodeSignatureModel @@ -682,4 +689,5 @@ from revengai.models.vulnerability import Vulnerability as Vulnerability from revengai.models.vulnerability_type import VulnerabilityType as VulnerabilityType from revengai.models.workspace import Workspace as Workspace +from revengai.models.x_ref import XRef as XRef diff --git a/revengai/api/__init__.py b/revengai/api/__init__.py index 0ea7a62..459bf9a 100644 --- a/revengai/api/__init__.py +++ b/revengai/api/__init__.py @@ -6,6 +6,7 @@ from revengai.api.analyses_dynamic_execution_api import AnalysesDynamicExecutionApi from revengai.api.analyses_results_metadata_api import AnalysesResultsMetadataApi from revengai.api.analyses_security_checks_api import AnalysesSecurityChecksApi +from revengai.api.analyses_x_refs_api import AnalysesXRefsApi from revengai.api.authentication_users_api import AuthenticationUsersApi from revengai.api.binaries_api import BinariesApi from revengai.api.collections_api import CollectionsApi diff --git a/revengai/api/analyses_x_refs_api.py b/revengai/api/analyses_x_refs_api.py new file mode 100644 index 0000000..0e2968f --- /dev/null +++ b/revengai/api/analyses_x_refs_api.py @@ -0,0 +1,319 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictInt +from typing_extensions import Annotated +from revengai.models.base_response_x_ref import BaseResponseXRef + +from revengai.api_client import ApiClient, RequestSerialized +from revengai.api_response import ApiResponse +from revengai.rest import RESTResponseType + + +class AnalysesXRefsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def get_xref_by_vaddr( + self, + analysis_id: StrictInt, + vaddr: Annotated[StrictInt, Field(description="Virtual address to match against xref_to")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> BaseResponseXRef: + """[Beta] Look up an xref by virtual address + + **This endpoint is in beta and may change without notice.** + + :param analysis_id: (required) + :type analysis_id: int + :param vaddr: Virtual address to match against xref_to (required) + :type vaddr: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_xref_by_vaddr_serialize( + analysis_id=analysis_id, + vaddr=vaddr, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "BaseResponseXRef", + '422': "BaseResponse", + '404': "ErrorModel", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_xref_by_vaddr_with_http_info( + self, + analysis_id: StrictInt, + vaddr: Annotated[StrictInt, Field(description="Virtual address to match against xref_to")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[BaseResponseXRef]: + """[Beta] Look up an xref by virtual address + + **This endpoint is in beta and may change without notice.** + + :param analysis_id: (required) + :type analysis_id: int + :param vaddr: Virtual address to match against xref_to (required) + :type vaddr: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_xref_by_vaddr_serialize( + analysis_id=analysis_id, + vaddr=vaddr, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "BaseResponseXRef", + '422': "BaseResponse", + '404': "ErrorModel", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_xref_by_vaddr_without_preload_content( + self, + analysis_id: StrictInt, + vaddr: Annotated[StrictInt, Field(description="Virtual address to match against xref_to")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """[Beta] Look up an xref by virtual address + + **This endpoint is in beta and may change without notice.** + + :param analysis_id: (required) + :type analysis_id: int + :param vaddr: Virtual address to match against xref_to (required) + :type vaddr: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_xref_by_vaddr_serialize( + analysis_id=analysis_id, + vaddr=vaddr, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "BaseResponseXRef", + '422': "BaseResponse", + '404': "ErrorModel", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_xref_by_vaddr_serialize( + self, + analysis_id, + vaddr, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if analysis_id is not None: + _path_params['analysis_id'] = analysis_id + if vaddr is not None: + _path_params['vaddr'] = vaddr + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'APIKey' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v2/analyses/{analysis_id}/xrefs/{vaddr}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/revengai/api_client.py b/revengai/api_client.py index 201c62d..159a31a 100644 --- a/revengai/api_client.py +++ b/revengai/api_client.py @@ -90,7 +90,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/v3.39.0/python' + self.user_agent = 'OpenAPI-Generator/v3.40.0/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/revengai/configuration.py b/revengai/configuration.py index 1bf7b70..3f79e7d 100644 --- a/revengai/configuration.py +++ b/revengai/configuration.py @@ -533,8 +533,8 @@ def to_debug_report(self) -> str: return "Python SDK Debug Report:\n"\ "OS: {env}\n"\ "Python Version: {pyversion}\n"\ - "Version of the API: v3.39.0\n"\ - "SDK Package Version: v3.39.0".\ + "Version of the API: v3.40.0\n"\ + "SDK Package Version: v3.40.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self) -> List[HostSetting]: diff --git a/revengai/models/__init__.py b/revengai/models/__init__.py index ccf817e..fdd2437 100644 --- a/revengai/models/__init__.py +++ b/revengai/models/__init__.py @@ -122,6 +122,7 @@ from revengai.models.base_response_task_response import BaseResponseTaskResponse from revengai.models.base_response_upload_response import BaseResponseUploadResponse from revengai.models.base_response_vulnerabilities import BaseResponseVulnerabilities +from revengai.models.base_response_x_ref import BaseResponseXRef from revengai.models.basic import Basic from revengai.models.binaries_related_status_response import BinariesRelatedStatusResponse from revengai.models.binaries_task_status import BinariesTaskStatus @@ -278,6 +279,7 @@ from revengai.models.security_checks_response import SecurityChecksResponse from revengai.models.security_checks_result import SecurityChecksResult from revengai.models.security_model import SecurityModel +from revengai.models.segment_info import SegmentInfo from revengai.models.severity_type import SeverityType from revengai.models.single_code_certificate_model import SingleCodeCertificateModel from revengai.models.single_code_signature_model import SingleCodeSignatureModel @@ -313,4 +315,5 @@ from revengai.models.vulnerability import Vulnerability from revengai.models.vulnerability_type import VulnerabilityType from revengai.models.workspace import Workspace +from revengai.models.x_ref import XRef diff --git a/revengai/models/base_response_x_ref.py b/revengai/models/base_response_x_ref.py new file mode 100644 index 0000000..6a00bfb --- /dev/null +++ b/revengai/models/base_response_x_ref.py @@ -0,0 +1,125 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from revengai.models.error_model import ErrorModel +from revengai.models.meta_model import MetaModel +from revengai.models.x_ref import XRef +from typing import Optional, Set +from typing_extensions import Self + +class BaseResponseXRef(BaseModel): + """ + BaseResponseXRef + """ # noqa: E501 + status: Optional[StrictBool] = Field(default=True, description="Response status on whether the request succeeded") + data: Optional[XRef] = None + message: Optional[StrictStr] = None + errors: Optional[List[ErrorModel]] = None + meta: Optional[MetaModel] = Field(default=None, description="Metadata") + __properties: ClassVar[List[str]] = ["status", "data", "message", "errors", "meta"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of BaseResponseXRef from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict['data'] = self.data.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in errors (list) + _items = [] + if self.errors: + for _item_errors in self.errors: + if _item_errors: + _items.append(_item_errors.to_dict()) + _dict['errors'] = _items + # override the default output from pydantic by calling `to_dict()` of meta + if self.meta: + _dict['meta'] = self.meta.to_dict() + # set to None if data (nullable) is None + # and model_fields_set contains the field + if self.data is None and "data" in self.model_fields_set: + _dict['data'] = None + + # set to None if message (nullable) is None + # and model_fields_set contains the field + if self.message is None and "message" in self.model_fields_set: + _dict['message'] = None + + # set to None if errors (nullable) is None + # and model_fields_set contains the field + if self.errors is None and "errors" in self.model_fields_set: + _dict['errors'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of BaseResponseXRef from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "status": obj.get("status") if obj.get("status") is not None else True, + "data": XRef.from_dict(obj["data"]) if obj.get("data") is not None else None, + "message": obj.get("message"), + "errors": [ErrorModel.from_dict(_item) for _item in obj["errors"]] if obj.get("errors") is not None else None, + "meta": MetaModel.from_dict(obj["meta"]) if obj.get("meta") is not None else None + }) + return _obj + + diff --git a/revengai/models/segment_info.py b/revengai/models/segment_info.py new file mode 100644 index 0000000..89aaeef --- /dev/null +++ b/revengai/models/segment_info.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class SegmentInfo(BaseModel): + """ + 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. + """ # noqa: E501 + name: Optional[StrictStr] = '' + r: Optional[StrictBool] = None + w: Optional[StrictBool] = None + x: Optional[StrictBool] = None + start: Optional[StrictInt] = 0 + end: Optional[StrictInt] = 0 + __properties: ClassVar[List[str]] = ["name", "r", "w", "x", "start", "end"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SegmentInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if r (nullable) is None + # and model_fields_set contains the field + if self.r is None and "r" in self.model_fields_set: + _dict['r'] = None + + # set to None if w (nullable) is None + # and model_fields_set contains the field + if self.w is None and "w" in self.model_fields_set: + _dict['w'] = None + + # set to None if x (nullable) is None + # and model_fields_set contains the field + if self.x is None and "x" in self.model_fields_set: + _dict['x'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SegmentInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name") if obj.get("name") is not None else '', + "r": obj.get("r"), + "w": obj.get("w"), + "x": obj.get("x"), + "start": obj.get("start") if obj.get("start") is not None else 0, + "end": obj.get("end") if obj.get("end") is not None else 0 + }) + return _obj + + diff --git a/revengai/models/x_ref.py b/revengai/models/x_ref.py new file mode 100644 index 0000000..5ebf12f --- /dev/null +++ b/revengai/models/x_ref.py @@ -0,0 +1,151 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictBytes, StrictStr +from typing import Any, ClassVar, Dict, List, Optional, Tuple, Union +from revengai.models.segment_info import SegmentInfo +from typing import Optional, Set +from typing_extensions import Self + +class XRef(BaseModel): + """ + XRef + """ # noqa: E501 + value: Optional[StrictStr] + xref_to: Optional[StrictStr] + is_scalar: Optional[StrictBool] = None + is_call: Optional[StrictBool] = None + is_data: Optional[StrictBool] = None + is_string: Optional[StrictBool] = None + raw_data: Optional[Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]]] = None + segment: Optional[SegmentInfo] = None + orig_str_encoding: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["value", "xref_to", "is_scalar", "is_call", "is_data", "is_string", "raw_data", "segment", "orig_str_encoding"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of XRef from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of segment + if self.segment: + _dict['segment'] = self.segment.to_dict() + # set to None if value (nullable) is None + # and model_fields_set contains the field + if self.value is None and "value" in self.model_fields_set: + _dict['value'] = None + + # set to None if xref_to (nullable) is None + # and model_fields_set contains the field + if self.xref_to is None and "xref_to" in self.model_fields_set: + _dict['xref_to'] = None + + # set to None if is_scalar (nullable) is None + # and model_fields_set contains the field + if self.is_scalar is None and "is_scalar" in self.model_fields_set: + _dict['is_scalar'] = None + + # set to None if is_call (nullable) is None + # and model_fields_set contains the field + if self.is_call is None and "is_call" in self.model_fields_set: + _dict['is_call'] = None + + # set to None if is_data (nullable) is None + # and model_fields_set contains the field + if self.is_data is None and "is_data" in self.model_fields_set: + _dict['is_data'] = None + + # set to None if is_string (nullable) is None + # and model_fields_set contains the field + if self.is_string is None and "is_string" in self.model_fields_set: + _dict['is_string'] = None + + # set to None if raw_data (nullable) is None + # and model_fields_set contains the field + if self.raw_data is None and "raw_data" in self.model_fields_set: + _dict['raw_data'] = None + + # set to None if segment (nullable) is None + # and model_fields_set contains the field + if self.segment is None and "segment" in self.model_fields_set: + _dict['segment'] = None + + # set to None if orig_str_encoding (nullable) is None + # and model_fields_set contains the field + if self.orig_str_encoding is None and "orig_str_encoding" in self.model_fields_set: + _dict['orig_str_encoding'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of XRef from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "value": obj.get("value"), + "xref_to": obj.get("xref_to"), + "is_scalar": obj.get("is_scalar"), + "is_call": obj.get("is_call"), + "is_data": obj.get("is_data"), + "is_string": obj.get("is_string"), + "raw_data": obj.get("raw_data"), + "segment": SegmentInfo.from_dict(obj["segment"]) if obj.get("segment") is not None else None, + "orig_str_encoding": obj.get("orig_str_encoding") + }) + return _obj + + diff --git a/test/test_analyses_x_refs_api.py b/test/test_analyses_x_refs_api.py new file mode 100644 index 0000000..d36640b --- /dev/null +++ b/test/test_analyses_x_refs_api.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.api.analyses_x_refs_api import AnalysesXRefsApi + + +class TestAnalysesXRefsApi(unittest.TestCase): + """AnalysesXRefsApi unit test stubs""" + + def setUp(self) -> None: + self.api = AnalysesXRefsApi() + + def tearDown(self) -> None: + pass + + def test_get_xref_by_vaddr(self) -> None: + """Test case for get_xref_by_vaddr + + [Beta] Look up an xref by virtual address + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_base_response_x_ref.py b/test/test_base_response_x_ref.py new file mode 100644 index 0000000..5155b65 --- /dev/null +++ b/test/test_base_response_x_ref.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.base_response_x_ref import BaseResponseXRef + +class TestBaseResponseXRef(unittest.TestCase): + """BaseResponseXRef unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> BaseResponseXRef: + """Test BaseResponseXRef + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `BaseResponseXRef` + """ + model = BaseResponseXRef() + if include_optional: + return BaseResponseXRef( + status = True, + data = revengai.models.x_ref.XRef( + value = '', + xref_to = '', + is_scalar = True, + is_call = True, + is_data = True, + is_string = True, + raw_data = bytes(b'blah'), + segment = revengai.models.segment_info.SegmentInfo( + name = '', + r = True, + w = True, + x = True, + start = 56, + end = 56, ), + orig_str_encoding = '', ), + message = '', + errors = [ + revengai.models.error_model.ErrorModel( + code = '', + message = '', ) + ], + meta = revengai.models.meta_model.MetaModel( + pagination = revengai.models.pagination_model.PaginationModel( + page_size = 56, + page_number = 56, + has_next_page = True, ), ) + ) + else: + return BaseResponseXRef( + ) + """ + + def testBaseResponseXRef(self): + """Test BaseResponseXRef""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_segment_info.py b/test/test_segment_info.py new file mode 100644 index 0000000..1b3919a --- /dev/null +++ b/test/test_segment_info.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.segment_info import SegmentInfo + +class TestSegmentInfo(unittest.TestCase): + """SegmentInfo unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> SegmentInfo: + """Test SegmentInfo + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `SegmentInfo` + """ + model = SegmentInfo() + if include_optional: + return SegmentInfo( + name = '', + r = True, + w = True, + x = True, + start = 56, + end = 56 + ) + else: + return SegmentInfo( + ) + """ + + def testSegmentInfo(self): + """Test SegmentInfo""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_x_ref.py b/test/test_x_ref.py new file mode 100644 index 0000000..ad0d40c --- /dev/null +++ b/test/test_x_ref.py @@ -0,0 +1,66 @@ +# coding: utf-8 + +""" + 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. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.x_ref import XRef + +class TestXRef(unittest.TestCase): + """XRef unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> XRef: + """Test XRef + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `XRef` + """ + model = XRef() + if include_optional: + return XRef( + value = '', + xref_to = '', + is_scalar = True, + is_call = True, + is_data = True, + is_string = True, + raw_data = bytes(b'blah'), + segment = revengai.models.segment_info.SegmentInfo( + name = '', + r = True, + w = True, + x = True, + start = 56, + end = 56, ), + orig_str_encoding = '' + ) + else: + return XRef( + value = '', + xref_to = '', + ) + """ + + def testXRef(self): + """Test XRef""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()