From 7517948cd88ec8e16130f9c28a99dcbec3d29e1c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 22 Sep 2025 06:11:51 +0000 Subject: [PATCH] Update SDK to version v1.88.0 - Generated from OpenAPI spec version v1.88.0 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 8 + docs/AnalysisFunctionMatchingRequest.md | 29 + docs/FunctionMatchingBatchRequest.md | 30 + docs/FunctionMatchingBatchResponse.md | 33 + docs/FunctionMatchingResultWithBestMatch.md | 32 + docs/FunctionMatchingScopeRequest.md | 33 + docs/FunctionsCoreApi.md | 170 +++++ docs/MatchedFunction.md | 38 + revengai/__init__.py | 14 +- revengai/api/functions_core_api.py | 652 +++++++++++++++++- revengai/api_client.py | 2 +- revengai/configuration.py | 4 +- revengai/models/__init__.py | 6 + .../analysis_function_matching_request.py | 87 +++ .../models/function_matching_batch_request.py | 92 +++ .../function_matching_batch_response.py | 117 ++++ ...unction_matching_result_with_best_match.py | 101 +++ .../models/function_matching_scope_request.py | 106 +++ revengai/models/matched_function.py | 114 +++ ...test_analysis_function_matching_request.py | 50 ++ test/test_function_matching_batch_request.py | 78 +++ test/test_function_matching_batch_response.py | 87 +++ ...unction_matching_result_with_best_match.py | 76 ++ test/test_function_matching_scope_request.py | 62 ++ test/test_functions_core_api.py | 14 + test/test_matched_function.py | 68 ++ 27 files changed, 2075 insertions(+), 30 deletions(-) create mode 100644 docs/AnalysisFunctionMatchingRequest.md create mode 100644 docs/FunctionMatchingBatchRequest.md create mode 100644 docs/FunctionMatchingBatchResponse.md create mode 100644 docs/FunctionMatchingResultWithBestMatch.md create mode 100644 docs/FunctionMatchingScopeRequest.md create mode 100644 docs/MatchedFunction.md create mode 100644 revengai/models/analysis_function_matching_request.py create mode 100644 revengai/models/function_matching_batch_request.py create mode 100644 revengai/models/function_matching_batch_response.py create mode 100644 revengai/models/function_matching_result_with_best_match.py create mode 100644 revengai/models/function_matching_scope_request.py create mode 100644 revengai/models/matched_function.py create mode 100644 test/test_analysis_function_matching_request.py create mode 100644 test/test_function_matching_batch_request.py create mode 100644 test/test_function_matching_batch_response.py create mode 100644 test/test_function_matching_result_with_best_match.py create mode 100644 test/test_function_matching_scope_request.py create mode 100644 test/test_matched_function.py diff --git a/.sdk-version b/.sdk-version index 739706f..95cc5bb 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v1.86.0 +v1.88.0 diff --git a/README.md b/README.md index 16832cf..cdc3b1d 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,9 @@ Class | Method | HTTP request | Description *FunctionsBlockCommentsApi* | [**generate_block_comments_for_function**](docs/FunctionsBlockCommentsApi.md#generate_block_comments_for_function) | **POST** /v2/functions/{function_id}/block-comments | Generate block comments for a function *FunctionsBlockCommentsApi* | [**generate_overview_comment_for_function**](docs/FunctionsBlockCommentsApi.md#generate_overview_comment_for_function) | **POST** /v2/functions/{function_id}/block-comments/overview | Generate overview comment for a function *FunctionsCoreApi* | [**ai_unstrip**](docs/FunctionsCoreApi.md#ai_unstrip) | **POST** /v2/analyses/{analysis_id}/functions/ai-unstrip | Performs matching and auto-unstrip for an analysis and its functions +*FunctionsCoreApi* | [**analysis_function_matching**](docs/FunctionsCoreApi.md#analysis_function_matching) | **POST** /v2/analyses/{analysis_id}/functions/matches | Perform matching for the functions of an analysis *FunctionsCoreApi* | [**auto_unstrip**](docs/FunctionsCoreApi.md#auto_unstrip) | **POST** /v2/analyses/{analysis_id}/functions/auto-unstrip | Performs matching and auto-unstrip for an analysis and its functions +*FunctionsCoreApi* | [**batch_function_matching**](docs/FunctionsCoreApi.md#batch_function_matching) | **POST** /v2/functions/matches | Perform function matching for an arbitrary batch of functions, binaries or collections *FunctionsCoreApi* | [**cancel_ai_unstrip**](docs/FunctionsCoreApi.md#cancel_ai_unstrip) | **DELETE** /v2/analyses/{analysis_id}/functions/ai-unstrip/cancel | Cancels a running ai-unstrip *FunctionsCoreApi* | [**cancel_auto_unstrip**](docs/FunctionsCoreApi.md#cancel_auto_unstrip) | **DELETE** /v2/analyses/{analysis_id}/functions/unstrip/cancel | Cancels a running auto-unstrip *FunctionsCoreApi* | [**get_analysis_strings**](docs/FunctionsCoreApi.md#get_analysis_strings) | **GET** /v2/analyses/{analysis_id}/functions/strings | Get string information found in the Analysis @@ -169,6 +171,7 @@ Class | Method | HTTP request | Description - [AnalysisCreateResponse](docs/AnalysisCreateResponse.md) - [AnalysisDetailResponse](docs/AnalysisDetailResponse.md) - [AnalysisFunctionMapping](docs/AnalysisFunctionMapping.md) + - [AnalysisFunctionMatchingRequest](docs/AnalysisFunctionMatchingRequest.md) - [AnalysisFunctions](docs/AnalysisFunctions.md) - [AnalysisRecord](docs/AnalysisRecord.md) - [AnalysisScope](docs/AnalysisScope.md) @@ -355,6 +358,10 @@ Class | Method | HTTP request | Description - [FunctionLocalVariableResponse](docs/FunctionLocalVariableResponse.md) - [FunctionMapping](docs/FunctionMapping.md) - [FunctionMappingFull](docs/FunctionMappingFull.md) + - [FunctionMatchingBatchRequest](docs/FunctionMatchingBatchRequest.md) + - [FunctionMatchingBatchResponse](docs/FunctionMatchingBatchResponse.md) + - [FunctionMatchingResultWithBestMatch](docs/FunctionMatchingResultWithBestMatch.md) + - [FunctionMatchingScopeRequest](docs/FunctionMatchingScopeRequest.md) - [FunctionNameConfidenceBody](docs/FunctionNameConfidenceBody.md) - [FunctionNameHistory](docs/FunctionNameHistory.md) - [FunctionNameInput](docs/FunctionNameInput.md) @@ -389,6 +396,7 @@ Class | Method | HTTP request | Description - [LoginRequest](docs/LoginRequest.md) - [LoginResponse](docs/LoginResponse.md) - [Logs](docs/Logs.md) + - [MatchedFunction](docs/MatchedFunction.md) - [MatchedFunctionSuggestion](docs/MatchedFunctionSuggestion.md) - [MetaModel](docs/MetaModel.md) - [ModelName](docs/ModelName.md) diff --git a/docs/AnalysisFunctionMatchingRequest.md b/docs/AnalysisFunctionMatchingRequest.md new file mode 100644 index 0000000..d949ea9 --- /dev/null +++ b/docs/AnalysisFunctionMatchingRequest.md @@ -0,0 +1,29 @@ +# AnalysisFunctionMatchingRequest + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**min_similarity** | **float** | Minimum similarity expected for a match, default is 0.9 | [optional] [default to 0.9] + +## Example + +```python +from revengai.models.analysis_function_matching_request import AnalysisFunctionMatchingRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of AnalysisFunctionMatchingRequest from a JSON string +analysis_function_matching_request_instance = AnalysisFunctionMatchingRequest.from_json(json) +# print the JSON string representation of the object +print(AnalysisFunctionMatchingRequest.to_json()) + +# convert the object into a dict +analysis_function_matching_request_dict = analysis_function_matching_request_instance.to_dict() +# create an instance of AnalysisFunctionMatchingRequest from a dict +analysis_function_matching_request_from_dict = AnalysisFunctionMatchingRequest.from_dict(analysis_function_matching_request_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/FunctionMatchingBatchRequest.md b/docs/FunctionMatchingBatchRequest.md new file mode 100644 index 0000000..f2a1d39 --- /dev/null +++ b/docs/FunctionMatchingBatchRequest.md @@ -0,0 +1,30 @@ +# FunctionMatchingBatchRequest + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**model_id** | **int** | | [optional] +**scope** | [**FunctionMatchingScopeRequest**](FunctionMatchingScopeRequest.md) | Scope of the function matching request, used to limit the search to specific binaries, collections, and functions | + +## Example + +```python +from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of FunctionMatchingBatchRequest from a JSON string +function_matching_batch_request_instance = FunctionMatchingBatchRequest.from_json(json) +# print the JSON string representation of the object +print(FunctionMatchingBatchRequest.to_json()) + +# convert the object into a dict +function_matching_batch_request_dict = function_matching_batch_request_instance.to_dict() +# create an instance of FunctionMatchingBatchRequest from a dict +function_matching_batch_request_from_dict = FunctionMatchingBatchRequest.from_dict(function_matching_batch_request_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/FunctionMatchingBatchResponse.md b/docs/FunctionMatchingBatchResponse.md new file mode 100644 index 0000000..dd09ece --- /dev/null +++ b/docs/FunctionMatchingBatchResponse.md @@ -0,0 +1,33 @@ +# FunctionMatchingBatchResponse + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**progress** | **int** | Progress of the matching operation, represented as a percentage | [optional] [default to 0] +**status** | **str** | | [optional] +**total_time** | **int** | | [optional] +**error_message** | **str** | | [optional] +**matches** | [**List[FunctionMatchingResultWithBestMatch]**](FunctionMatchingResultWithBestMatch.md) | | + +## Example + +```python +from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of FunctionMatchingBatchResponse from a JSON string +function_matching_batch_response_instance = FunctionMatchingBatchResponse.from_json(json) +# print the JSON string representation of the object +print(FunctionMatchingBatchResponse.to_json()) + +# convert the object into a dict +function_matching_batch_response_dict = function_matching_batch_response_instance.to_dict() +# create an instance of FunctionMatchingBatchResponse from a dict +function_matching_batch_response_from_dict = FunctionMatchingBatchResponse.from_dict(function_matching_batch_response_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/FunctionMatchingResultWithBestMatch.md b/docs/FunctionMatchingResultWithBestMatch.md new file mode 100644 index 0000000..3633bf9 --- /dev/null +++ b/docs/FunctionMatchingResultWithBestMatch.md @@ -0,0 +1,32 @@ +# FunctionMatchingResultWithBestMatch + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**function_id** | **int** | | +**similarity** | **float** | | +**matched_function** | [**MatchedFunction**](MatchedFunction.md) | | +**suggested_name** | **str** | | [optional] + +## Example + +```python +from revengai.models.function_matching_result_with_best_match import FunctionMatchingResultWithBestMatch + +# TODO update the JSON string below +json = "{}" +# create an instance of FunctionMatchingResultWithBestMatch from a JSON string +function_matching_result_with_best_match_instance = FunctionMatchingResultWithBestMatch.from_json(json) +# print the JSON string representation of the object +print(FunctionMatchingResultWithBestMatch.to_json()) + +# convert the object into a dict +function_matching_result_with_best_match_dict = function_matching_result_with_best_match_instance.to_dict() +# create an instance of FunctionMatchingResultWithBestMatch from a dict +function_matching_result_with_best_match_from_dict = FunctionMatchingResultWithBestMatch.from_dict(function_matching_result_with_best_match_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/FunctionMatchingScopeRequest.md b/docs/FunctionMatchingScopeRequest.md new file mode 100644 index 0000000..6a9d797 --- /dev/null +++ b/docs/FunctionMatchingScopeRequest.md @@ -0,0 +1,33 @@ +# FunctionMatchingScopeRequest + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**binary_ids** | **List[int]** | ID's of binaries to limit the search to, if empty, search all scoped binaries | [optional] [default to []] +**collection_ids** | **List[int]** | ID's of collections to limit the search to, if empty, search all scoped collections | [optional] [default to []] +**function_ids** | **List[int]** | ID's of functions to limit the search to, if empty, search all scoped functions | [optional] [default to []] +**min_similarity** | **float** | Minimum similarity expected for a match, default is 0.9 | [optional] [default to 0.9] +**debug_types** | **List[str]** | Limit the search to specific debug types, if empty, search all scoped debug & non-debug functions | [optional] [default to []] + +## Example + +```python +from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of FunctionMatchingScopeRequest from a JSON string +function_matching_scope_request_instance = FunctionMatchingScopeRequest.from_json(json) +# print the JSON string representation of the object +print(FunctionMatchingScopeRequest.to_json()) + +# convert the object into a dict +function_matching_scope_request_dict = function_matching_scope_request_instance.to_dict() +# create an instance of FunctionMatchingScopeRequest from a dict +function_matching_scope_request_from_dict = FunctionMatchingScopeRequest.from_dict(function_matching_scope_request_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/FunctionsCoreApi.md b/docs/FunctionsCoreApi.md index da269a9..8c38ec1 100644 --- a/docs/FunctionsCoreApi.md +++ b/docs/FunctionsCoreApi.md @@ -5,7 +5,9 @@ All URIs are relative to *https://api.reveng.ai* Method | HTTP request | Description ------------- | ------------- | ------------- [**ai_unstrip**](FunctionsCoreApi.md#ai_unstrip) | **POST** /v2/analyses/{analysis_id}/functions/ai-unstrip | Performs matching and auto-unstrip for an analysis and its functions +[**analysis_function_matching**](FunctionsCoreApi.md#analysis_function_matching) | **POST** /v2/analyses/{analysis_id}/functions/matches | Perform matching for the functions of an analysis [**auto_unstrip**](FunctionsCoreApi.md#auto_unstrip) | **POST** /v2/analyses/{analysis_id}/functions/auto-unstrip | Performs matching and auto-unstrip for an analysis and its functions +[**batch_function_matching**](FunctionsCoreApi.md#batch_function_matching) | **POST** /v2/functions/matches | Perform function matching for an arbitrary batch of functions, binaries or collections [**cancel_ai_unstrip**](FunctionsCoreApi.md#cancel_ai_unstrip) | **DELETE** /v2/analyses/{analysis_id}/functions/ai-unstrip/cancel | Cancels a running ai-unstrip [**cancel_auto_unstrip**](FunctionsCoreApi.md#cancel_auto_unstrip) | **DELETE** /v2/analyses/{analysis_id}/functions/unstrip/cancel | Cancels a running auto-unstrip [**get_analysis_strings**](FunctionsCoreApi.md#get_analysis_strings) | **GET** /v2/analyses/{analysis_id}/functions/strings | Get string information found in the Analysis @@ -102,6 +104,91 @@ Name | Type | Description | Notes [[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) +# **analysis_function_matching** +> FunctionMatchingBatchResponse analysis_function_matching(analysis_id, analysis_function_matching_request, authorization=authorization) + +Perform matching for the functions of an analysis + +Takes in an analysis id and settings and finds the nearest functions for each function that's within the system + +### Example + +* Api Key Authentication (APIKey): + +```python +import revengai +from revengai.models.analysis_function_matching_request import AnalysisFunctionMatchingRequest +from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse +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.FunctionsCoreApi(api_client) + analysis_id = 56 # int | + analysis_function_matching_request = revengai.AnalysisFunctionMatchingRequest() # AnalysisFunctionMatchingRequest | + authorization = 'authorization_example' # str | API Key bearer token (optional) + + try: + # Perform matching for the functions of an analysis + api_response = api_instance.analysis_function_matching(analysis_id, analysis_function_matching_request, authorization=authorization) + print("The response of FunctionsCoreApi->analysis_function_matching:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FunctionsCoreApi->analysis_function_matching: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **analysis_id** | **int**| | + **analysis_function_matching_request** | [**AnalysisFunctionMatchingRequest**](AnalysisFunctionMatchingRequest.md)| | + **authorization** | **str**| API Key bearer token | [optional] + +### Return type + +[**FunctionMatchingBatchResponse**](FunctionMatchingBatchResponse.md) + +### Authorization + +[APIKey](../README.md#APIKey) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Invalid request parameters | - | + +[[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) + # **auto_unstrip** > AutoUnstripResponse auto_unstrip(analysis_id, auto_unstrip_request, authorization=authorization) @@ -187,6 +274,89 @@ Name | Type | Description | Notes [[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) +# **batch_function_matching** +> FunctionMatchingBatchResponse batch_function_matching(function_matching_batch_request, authorization=authorization) + +Perform function matching for an arbitrary batch of functions, binaries or collections + +Takes in an input of functions ID's and settings and finds the nearest functions for each function that's within the system + +### Example + +* Api Key Authentication (APIKey): + +```python +import revengai +from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest +from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse +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.FunctionsCoreApi(api_client) + function_matching_batch_request = revengai.FunctionMatchingBatchRequest() # FunctionMatchingBatchRequest | + authorization = 'authorization_example' # str | API Key bearer token (optional) + + try: + # Perform function matching for an arbitrary batch of functions, binaries or collections + api_response = api_instance.batch_function_matching(function_matching_batch_request, authorization=authorization) + print("The response of FunctionsCoreApi->batch_function_matching:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FunctionsCoreApi->batch_function_matching: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **function_matching_batch_request** | [**FunctionMatchingBatchRequest**](FunctionMatchingBatchRequest.md)| | + **authorization** | **str**| API Key bearer token | [optional] + +### Return type + +[**FunctionMatchingBatchResponse**](FunctionMatchingBatchResponse.md) + +### Authorization + +[APIKey](../README.md#APIKey) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Invalid request parameters | - | + +[[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) + # **cancel_ai_unstrip** > AutoUnstripResponse cancel_ai_unstrip(analysis_id, authorization=authorization) diff --git a/docs/MatchedFunction.md b/docs/MatchedFunction.md new file mode 100644 index 0000000..1438582 --- /dev/null +++ b/docs/MatchedFunction.md @@ -0,0 +1,38 @@ +# MatchedFunction + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**function_id** | **int** | | +**binary_id** | **int** | | +**function_name** | **str** | | +**function_vaddr** | **int** | | +**mangled_name** | **str** | | +**debug** | **bool** | | +**binary_name** | **str** | | +**sha_256_hash** | **str** | | +**analysis_id** | **int** | | +**similarity** | **float** | | [optional] + +## Example + +```python +from revengai.models.matched_function import MatchedFunction + +# TODO update the JSON string below +json = "{}" +# create an instance of MatchedFunction from a JSON string +matched_function_instance = MatchedFunction.from_json(json) +# print the JSON string representation of the object +print(MatchedFunction.to_json()) + +# convert the object into a dict +matched_function_dict = matched_function_instance.to_dict() +# create an instance of MatchedFunction from a dict +matched_function_from_dict = MatchedFunction.from_dict(matched_function_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 61fc58c..348e79b 100644 --- a/revengai/__init__.py +++ b/revengai/__init__.py @@ -13,7 +13,7 @@ """ # noqa: E501 -__version__ = "v1.86.0" +__version__ = "v1.88.0" # Define package exports __all__ = [ @@ -55,6 +55,7 @@ "AnalysisCreateResponse", "AnalysisDetailResponse", "AnalysisFunctionMapping", + "AnalysisFunctionMatchingRequest", "AnalysisFunctions", "AnalysisRecord", "AnalysisScope", @@ -241,6 +242,10 @@ "FunctionLocalVariableResponse", "FunctionMapping", "FunctionMappingFull", + "FunctionMatchingBatchRequest", + "FunctionMatchingBatchResponse", + "FunctionMatchingResultWithBestMatch", + "FunctionMatchingScopeRequest", "FunctionNameConfidenceBody", "FunctionNameHistory", "FunctionNameInput", @@ -275,6 +280,7 @@ "LoginRequest", "LoginResponse", "Logs", + "MatchedFunction", "MatchedFunctionSuggestion", "MetaModel", "ModelName", @@ -397,6 +403,7 @@ from revengai.models.analysis_create_response import AnalysisCreateResponse as AnalysisCreateResponse from revengai.models.analysis_detail_response import AnalysisDetailResponse as AnalysisDetailResponse from revengai.models.analysis_function_mapping import AnalysisFunctionMapping as AnalysisFunctionMapping +from revengai.models.analysis_function_matching_request import AnalysisFunctionMatchingRequest as AnalysisFunctionMatchingRequest from revengai.models.analysis_functions import AnalysisFunctions as AnalysisFunctions from revengai.models.analysis_record import AnalysisRecord as AnalysisRecord from revengai.models.analysis_scope import AnalysisScope as AnalysisScope @@ -583,6 +590,10 @@ from revengai.models.function_local_variable_response import FunctionLocalVariableResponse as FunctionLocalVariableResponse from revengai.models.function_mapping import FunctionMapping as FunctionMapping from revengai.models.function_mapping_full import FunctionMappingFull as FunctionMappingFull +from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest as FunctionMatchingBatchRequest +from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse as FunctionMatchingBatchResponse +from revengai.models.function_matching_result_with_best_match import FunctionMatchingResultWithBestMatch as FunctionMatchingResultWithBestMatch +from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest as FunctionMatchingScopeRequest from revengai.models.function_name_confidence_body import FunctionNameConfidenceBody as FunctionNameConfidenceBody from revengai.models.function_name_history import FunctionNameHistory as FunctionNameHistory from revengai.models.function_name_input import FunctionNameInput as FunctionNameInput @@ -617,6 +628,7 @@ from revengai.models.login_request import LoginRequest as LoginRequest from revengai.models.login_response import LoginResponse as LoginResponse from revengai.models.logs import Logs as Logs +from revengai.models.matched_function import MatchedFunction as MatchedFunction from revengai.models.matched_function_suggestion import MatchedFunctionSuggestion as MatchedFunctionSuggestion from revengai.models.meta_model import MetaModel as MetaModel from revengai.models.model_name import ModelName as ModelName diff --git a/revengai/api/functions_core_api.py b/revengai/api/functions_core_api.py index 170b9b3..273b6f0 100644 --- a/revengai/api/functions_core_api.py +++ b/revengai/api/functions_core_api.py @@ -19,6 +19,7 @@ from typing import List, Optional, Union from typing_extensions import Annotated from revengai.models.ai_unstrip_request import AiUnstripRequest +from revengai.models.analysis_function_matching_request import AnalysisFunctionMatchingRequest from revengai.models.auto_unstrip_request import AutoUnstripRequest from revengai.models.auto_unstrip_response import AutoUnstripResponse from revengai.models.base_response_analysis_strings_response import BaseResponseAnalysisStringsResponse @@ -28,6 +29,8 @@ from revengai.models.base_response_function_strings_response import BaseResponseFunctionStringsResponse from revengai.models.base_response_functions_detail_response import BaseResponseFunctionsDetailResponse from revengai.models.base_response_list_similar_functions_response import BaseResponseListSimilarFunctionsResponse +from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest +from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse from revengai.api_client import ApiClient, RequestSerialized from revengai.api_response import ApiResponse @@ -354,6 +357,313 @@ def _ai_unstrip_serialize( + @validate_call + def analysis_function_matching( + self, + analysis_id: StrictInt, + analysis_function_matching_request: AnalysisFunctionMatchingRequest, + authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, + _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, + ) -> FunctionMatchingBatchResponse: + """Perform matching for the functions of an analysis + + Takes in an analysis id and settings and finds the nearest functions for each function that's within the system + + :param analysis_id: (required) + :type analysis_id: int + :param analysis_function_matching_request: (required) + :type analysis_function_matching_request: AnalysisFunctionMatchingRequest + :param authorization: API Key bearer token + :type authorization: str + :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._analysis_function_matching_serialize( + analysis_id=analysis_id, + analysis_function_matching_request=analysis_function_matching_request, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FunctionMatchingBatchResponse", + '422': "BaseResponse", + } + 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 analysis_function_matching_with_http_info( + self, + analysis_id: StrictInt, + analysis_function_matching_request: AnalysisFunctionMatchingRequest, + authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, + _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[FunctionMatchingBatchResponse]: + """Perform matching for the functions of an analysis + + Takes in an analysis id and settings and finds the nearest functions for each function that's within the system + + :param analysis_id: (required) + :type analysis_id: int + :param analysis_function_matching_request: (required) + :type analysis_function_matching_request: AnalysisFunctionMatchingRequest + :param authorization: API Key bearer token + :type authorization: str + :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._analysis_function_matching_serialize( + analysis_id=analysis_id, + analysis_function_matching_request=analysis_function_matching_request, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FunctionMatchingBatchResponse", + '422': "BaseResponse", + } + 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 analysis_function_matching_without_preload_content( + self, + analysis_id: StrictInt, + analysis_function_matching_request: AnalysisFunctionMatchingRequest, + authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, + _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: + """Perform matching for the functions of an analysis + + Takes in an analysis id and settings and finds the nearest functions for each function that's within the system + + :param analysis_id: (required) + :type analysis_id: int + :param analysis_function_matching_request: (required) + :type analysis_function_matching_request: AnalysisFunctionMatchingRequest + :param authorization: API Key bearer token + :type authorization: str + :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._analysis_function_matching_serialize( + analysis_id=analysis_id, + analysis_function_matching_request=analysis_function_matching_request, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FunctionMatchingBatchResponse", + '422': "BaseResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _analysis_function_matching_serialize( + self, + analysis_id, + analysis_function_matching_request, + authorization, + _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 + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + if analysis_function_matching_request is not None: + _body_params = analysis_function_matching_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'APIKey' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v2/analyses/{analysis_id}/functions/matches', + 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 + ) + + + + @validate_call def auto_unstrip( self, @@ -372,7 +682,83 @@ def auto_unstrip( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> AutoUnstripResponse: + ) -> AutoUnstripResponse: + """Performs matching and auto-unstrip for an analysis and its functions + + Takes in the analysis ID, uses the functions ID's from it and settings to find the nearest function for each function that's within the system + + :param analysis_id: (required) + :type analysis_id: int + :param auto_unstrip_request: (required) + :type auto_unstrip_request: AutoUnstripRequest + :param authorization: API Key bearer token + :type authorization: str + :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._auto_unstrip_serialize( + analysis_id=analysis_id, + auto_unstrip_request=auto_unstrip_request, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AutoUnstripResponse", + '422': "BaseResponse", + } + 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 auto_unstrip_with_http_info( + self, + analysis_id: StrictInt, + auto_unstrip_request: AutoUnstripRequest, + authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, + _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[AutoUnstripResponse]: """Performs matching and auto-unstrip for an analysis and its functions Takes in the analysis ID, uses the functions ID's from it and settings to find the nearest function for each function that's within the system @@ -427,11 +813,11 @@ def auto_unstrip( return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, - ).data + ) @validate_call - def auto_unstrip_with_http_info( + def auto_unstrip_without_preload_content( self, analysis_id: StrictInt, auto_unstrip_request: AutoUnstripRequest, @@ -448,7 +834,7 @@ def auto_unstrip_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[AutoUnstripResponse]: + ) -> RESTResponseType: """Performs matching and auto-unstrip for an analysis and its functions Takes in the analysis ID, uses the functions ID's from it and settings to find the nearest function for each function that's within the system @@ -499,6 +885,229 @@ def auto_unstrip_with_http_info( *_param, _request_timeout=_request_timeout ) + return response_data.response + + + def _auto_unstrip_serialize( + self, + analysis_id, + auto_unstrip_request, + authorization, + _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 + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + if auto_unstrip_request is not None: + _body_params = auto_unstrip_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'APIKey' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v2/analyses/{analysis_id}/functions/auto-unstrip', + 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 + ) + + + + + @validate_call + def batch_function_matching( + self, + function_matching_batch_request: FunctionMatchingBatchRequest, + authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, + _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, + ) -> FunctionMatchingBatchResponse: + """Perform function matching for an arbitrary batch of functions, binaries or collections + + Takes in an input of functions ID's and settings and finds the nearest functions for each function that's within the system + + :param function_matching_batch_request: (required) + :type function_matching_batch_request: FunctionMatchingBatchRequest + :param authorization: API Key bearer token + :type authorization: str + :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._batch_function_matching_serialize( + function_matching_batch_request=function_matching_batch_request, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FunctionMatchingBatchResponse", + '422': "BaseResponse", + } + 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 batch_function_matching_with_http_info( + self, + function_matching_batch_request: FunctionMatchingBatchRequest, + authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, + _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[FunctionMatchingBatchResponse]: + """Perform function matching for an arbitrary batch of functions, binaries or collections + + Takes in an input of functions ID's and settings and finds the nearest functions for each function that's within the system + + :param function_matching_batch_request: (required) + :type function_matching_batch_request: FunctionMatchingBatchRequest + :param authorization: API Key bearer token + :type authorization: str + :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._batch_function_matching_serialize( + function_matching_batch_request=function_matching_batch_request, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FunctionMatchingBatchResponse", + '422': "BaseResponse", + } + 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, @@ -507,10 +1116,9 @@ def auto_unstrip_with_http_info( @validate_call - def auto_unstrip_without_preload_content( + def batch_function_matching_without_preload_content( self, - analysis_id: StrictInt, - auto_unstrip_request: AutoUnstripRequest, + function_matching_batch_request: FunctionMatchingBatchRequest, authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, _request_timeout: Union[ None, @@ -525,14 +1133,12 @@ def auto_unstrip_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Performs matching and auto-unstrip for an analysis and its functions + """Perform function matching for an arbitrary batch of functions, binaries or collections - Takes in the analysis ID, uses the functions ID's from it and settings to find the nearest function for each function that's within the system + Takes in an input of functions ID's and settings and finds the nearest functions for each function that's within the system - :param analysis_id: (required) - :type analysis_id: int - :param auto_unstrip_request: (required) - :type auto_unstrip_request: AutoUnstripRequest + :param function_matching_batch_request: (required) + :type function_matching_batch_request: FunctionMatchingBatchRequest :param authorization: API Key bearer token :type authorization: str :param _request_timeout: timeout setting for this request. If one @@ -557,9 +1163,8 @@ def auto_unstrip_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._auto_unstrip_serialize( - analysis_id=analysis_id, - auto_unstrip_request=auto_unstrip_request, + _param = self._batch_function_matching_serialize( + function_matching_batch_request=function_matching_batch_request, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, @@ -568,7 +1173,7 @@ def auto_unstrip_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "AutoUnstripResponse", + '200': "FunctionMatchingBatchResponse", '422': "BaseResponse", } response_data = self.api_client.call_api( @@ -578,10 +1183,9 @@ def auto_unstrip_without_preload_content( return response_data.response - def _auto_unstrip_serialize( + def _batch_function_matching_serialize( self, - analysis_id, - auto_unstrip_request, + function_matching_batch_request, authorization, _request_auth, _content_type, @@ -604,16 +1208,14 @@ def _auto_unstrip_serialize( _body_params: Optional[bytes] = None # process the path parameters - if analysis_id is not None: - _path_params['analysis_id'] = analysis_id # process the query parameters # process the header parameters if authorization is not None: _header_params['authorization'] = authorization # process the form parameters # process the body parameter - if auto_unstrip_request is not None: - _body_params = auto_unstrip_request + if function_matching_batch_request is not None: + _body_params = function_matching_batch_request # set the HTTP header `Accept` @@ -645,7 +1247,7 @@ def _auto_unstrip_serialize( return self.api_client.param_serialize( method='POST', - resource_path='/v2/analyses/{analysis_id}/functions/auto-unstrip', + resource_path='/v2/functions/matches', path_params=_path_params, query_params=_query_params, header_params=_header_params, diff --git a/revengai/api_client.py b/revengai/api_client.py index fe3e346..32b50df 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/v1.86.0/python' + self.user_agent = 'OpenAPI-Generator/v1.88.0/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/revengai/configuration.py b/revengai/configuration.py index dc7d318..9c82148 100644 --- a/revengai/configuration.py +++ b/revengai/configuration.py @@ -529,8 +529,8 @@ def to_debug_report(self) -> str: return "Python SDK Debug Report:\n"\ "OS: {env}\n"\ "Python Version: {pyversion}\n"\ - "Version of the API: v1.86.0\n"\ - "SDK Package Version: v1.86.0".\ + "Version of the API: v1.88.0\n"\ + "SDK Package Version: v1.88.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 b69ee13..ffef232 100644 --- a/revengai/models/__init__.py +++ b/revengai/models/__init__.py @@ -21,6 +21,7 @@ from revengai.models.analysis_create_response import AnalysisCreateResponse from revengai.models.analysis_detail_response import AnalysisDetailResponse from revengai.models.analysis_function_mapping import AnalysisFunctionMapping +from revengai.models.analysis_function_matching_request import AnalysisFunctionMatchingRequest from revengai.models.analysis_functions import AnalysisFunctions from revengai.models.analysis_record import AnalysisRecord from revengai.models.analysis_scope import AnalysisScope @@ -207,6 +208,10 @@ from revengai.models.function_local_variable_response import FunctionLocalVariableResponse from revengai.models.function_mapping import FunctionMapping from revengai.models.function_mapping_full import FunctionMappingFull +from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest +from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse +from revengai.models.function_matching_result_with_best_match import FunctionMatchingResultWithBestMatch +from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest from revengai.models.function_name_confidence_body import FunctionNameConfidenceBody from revengai.models.function_name_history import FunctionNameHistory from revengai.models.function_name_input import FunctionNameInput @@ -241,6 +246,7 @@ from revengai.models.login_request import LoginRequest from revengai.models.login_response import LoginResponse from revengai.models.logs import Logs +from revengai.models.matched_function import MatchedFunction from revengai.models.matched_function_suggestion import MatchedFunctionSuggestion from revengai.models.meta_model import MetaModel from revengai.models.model_name import ModelName diff --git a/revengai/models/analysis_function_matching_request.py b/revengai/models/analysis_function_matching_request.py new file mode 100644 index 0000000..1eac1ed --- /dev/null +++ b/revengai/models/analysis_function_matching_request.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + 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 +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class AnalysisFunctionMatchingRequest(BaseModel): + """ + AnalysisFunctionMatchingRequest + """ # noqa: E501 + min_similarity: Optional[Union[Annotated[float, Field(le=1.0, strict=True, ge=0.0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=0.9, description="Minimum similarity expected for a match, default is 0.9") + __properties: ClassVar[List[str]] = ["min_similarity"] + + 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 AnalysisFunctionMatchingRequest 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, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnalysisFunctionMatchingRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 0.9 + }) + return _obj + + diff --git a/revengai/models/function_matching_batch_request.py b/revengai/models/function_matching_batch_request.py new file mode 100644 index 0000000..4e6fddf --- /dev/null +++ b/revengai/models/function_matching_batch_request.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + 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, StrictInt +from typing import Any, ClassVar, Dict, List, Optional +from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest +from typing import Optional, Set +from typing_extensions import Self + +class FunctionMatchingBatchRequest(BaseModel): + """ + FunctionMatchingBatchRequest + """ # noqa: E501 + model_id: Optional[StrictInt] = None + scope: FunctionMatchingScopeRequest = Field(description="Scope of the function matching request, used to limit the search to specific binaries, collections, and functions") + __properties: ClassVar[List[str]] = ["model_id", "scope"] + + 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 FunctionMatchingBatchRequest 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 scope + if self.scope: + _dict['scope'] = self.scope.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FunctionMatchingBatchRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "model_id": obj.get("model_id"), + "scope": FunctionMatchingScopeRequest.from_dict(obj["scope"]) if obj.get("scope") is not None else None + }) + return _obj + + diff --git a/revengai/models/function_matching_batch_response.py b/revengai/models/function_matching_batch_response.py new file mode 100644 index 0000000..d26f42b --- /dev/null +++ b/revengai/models/function_matching_batch_response.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + 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, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from revengai.models.function_matching_result_with_best_match import FunctionMatchingResultWithBestMatch +from typing import Optional, Set +from typing_extensions import Self + +class FunctionMatchingBatchResponse(BaseModel): + """ + FunctionMatchingBatchResponse + """ # noqa: E501 + progress: Optional[StrictInt] = Field(default=0, description="Progress of the matching operation, represented as a percentage") + status: Optional[StrictStr] = None + total_time: Optional[StrictInt] = None + error_message: Optional[StrictStr] = None + matches: List[FunctionMatchingResultWithBestMatch] + __properties: ClassVar[List[str]] = ["progress", "status", "total_time", "error_message", "matches"] + + 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 FunctionMatchingBatchResponse 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 each item in matches (list) + _items = [] + if self.matches: + for _item_matches in self.matches: + if _item_matches: + _items.append(_item_matches.to_dict()) + _dict['matches'] = _items + # set to None if status (nullable) is None + # and model_fields_set contains the field + if self.status is None and "status" in self.model_fields_set: + _dict['status'] = None + + # set to None if total_time (nullable) is None + # and model_fields_set contains the field + if self.total_time is None and "total_time" in self.model_fields_set: + _dict['total_time'] = None + + # set to None if error_message (nullable) is None + # and model_fields_set contains the field + if self.error_message is None and "error_message" in self.model_fields_set: + _dict['error_message'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FunctionMatchingBatchResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "progress": obj.get("progress") if obj.get("progress") is not None else 0, + "status": obj.get("status"), + "total_time": obj.get("total_time"), + "error_message": obj.get("error_message"), + "matches": [FunctionMatchingResultWithBestMatch.from_dict(_item) for _item in obj["matches"]] if obj.get("matches") is not None else None + }) + return _obj + + diff --git a/revengai/models/function_matching_result_with_best_match.py b/revengai/models/function_matching_result_with_best_match.py new file mode 100644 index 0000000..f9e17a6 --- /dev/null +++ b/revengai/models/function_matching_result_with_best_match.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + 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, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional, Union +from revengai.models.matched_function import MatchedFunction +from typing import Optional, Set +from typing_extensions import Self + +class FunctionMatchingResultWithBestMatch(BaseModel): + """ + FunctionMatchingResultWithBestMatch + """ # noqa: E501 + function_id: StrictInt + similarity: Union[StrictFloat, StrictInt] + matched_function: MatchedFunction + suggested_name: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["function_id", "similarity", "matched_function", "suggested_name"] + + 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 FunctionMatchingResultWithBestMatch 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 matched_function + if self.matched_function: + _dict['matched_function'] = self.matched_function.to_dict() + # set to None if suggested_name (nullable) is None + # and model_fields_set contains the field + if self.suggested_name is None and "suggested_name" in self.model_fields_set: + _dict['suggested_name'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FunctionMatchingResultWithBestMatch from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "function_id": obj.get("function_id"), + "similarity": obj.get("similarity"), + "matched_function": MatchedFunction.from_dict(obj["matched_function"]) if obj.get("matched_function") is not None else None, + "suggested_name": obj.get("suggested_name") + }) + return _obj + + diff --git a/revengai/models/function_matching_scope_request.py b/revengai/models/function_matching_scope_request.py new file mode 100644 index 0000000..3693f9b --- /dev/null +++ b/revengai/models/function_matching_scope_request.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + 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, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class FunctionMatchingScopeRequest(BaseModel): + """ + FunctionMatchingScopeRequest + """ # noqa: E501 + binary_ids: Optional[List[StrictInt]] = Field(default=None, description="ID's of binaries to limit the search to, if empty, search all scoped binaries") + collection_ids: Optional[List[StrictInt]] = Field(default=None, description="ID's of collections to limit the search to, if empty, search all scoped collections") + function_ids: Optional[List[StrictInt]] = Field(default=None, description="ID's of functions to limit the search to, if empty, search all scoped functions") + min_similarity: Optional[Union[Annotated[float, Field(le=1.0, strict=True, ge=0.0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=0.9, description="Minimum similarity expected for a match, default is 0.9") + debug_types: Optional[List[StrictStr]] = Field(default=None, description="Limit the search to specific debug types, if empty, search all scoped debug & non-debug functions") + __properties: ClassVar[List[str]] = ["binary_ids", "collection_ids", "function_ids", "min_similarity", "debug_types"] + + @field_validator('debug_types') + def debug_types_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + for i in value: + if i not in set(['USER', 'SYSTEM', 'EXTERNAL']): + raise ValueError("each list item must be one of ('USER', 'SYSTEM', 'EXTERNAL')") + return value + + 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 FunctionMatchingScopeRequest 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, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FunctionMatchingScopeRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "binary_ids": obj.get("binary_ids"), + "collection_ids": obj.get("collection_ids"), + "function_ids": obj.get("function_ids"), + "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 0.9, + "debug_types": obj.get("debug_types") + }) + return _obj + + diff --git a/revengai/models/matched_function.py b/revengai/models/matched_function.py new file mode 100644 index 0000000..d1c66f8 --- /dev/null +++ b/revengai/models/matched_function.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + 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, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class MatchedFunction(BaseModel): + """ + MatchedFunction + """ # noqa: E501 + function_id: StrictInt + binary_id: StrictInt + function_name: StrictStr + function_vaddr: StrictInt + mangled_name: Optional[StrictStr] + debug: StrictBool + binary_name: StrictStr + sha_256_hash: StrictStr + analysis_id: StrictInt + similarity: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["function_id", "binary_id", "function_name", "function_vaddr", "mangled_name", "debug", "binary_name", "sha_256_hash", "analysis_id", "similarity"] + + 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 MatchedFunction 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 mangled_name (nullable) is None + # and model_fields_set contains the field + if self.mangled_name is None and "mangled_name" in self.model_fields_set: + _dict['mangled_name'] = None + + # set to None if similarity (nullable) is None + # and model_fields_set contains the field + if self.similarity is None and "similarity" in self.model_fields_set: + _dict['similarity'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MatchedFunction from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "function_id": obj.get("function_id"), + "binary_id": obj.get("binary_id"), + "function_name": obj.get("function_name"), + "function_vaddr": obj.get("function_vaddr"), + "mangled_name": obj.get("mangled_name"), + "debug": obj.get("debug"), + "binary_name": obj.get("binary_name"), + "sha_256_hash": obj.get("sha_256_hash"), + "analysis_id": obj.get("analysis_id"), + "similarity": obj.get("similarity") + }) + return _obj + + diff --git a/test/test_analysis_function_matching_request.py b/test/test_analysis_function_matching_request.py new file mode 100644 index 0000000..8ac5a05 --- /dev/null +++ b/test/test_analysis_function_matching_request.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.analysis_function_matching_request import AnalysisFunctionMatchingRequest + +class TestAnalysisFunctionMatchingRequest(unittest.TestCase): + """AnalysisFunctionMatchingRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> AnalysisFunctionMatchingRequest: + """Test AnalysisFunctionMatchingRequest + 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 `AnalysisFunctionMatchingRequest` + """ + model = AnalysisFunctionMatchingRequest() + if include_optional: + return AnalysisFunctionMatchingRequest( + min_similarity = 0.0 + ) + else: + return AnalysisFunctionMatchingRequest( + ) + """ + + def testAnalysisFunctionMatchingRequest(self): + """Test AnalysisFunctionMatchingRequest""" + # 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_function_matching_batch_request.py b/test/test_function_matching_batch_request.py new file mode 100644 index 0000000..84651c3 --- /dev/null +++ b/test/test_function_matching_batch_request.py @@ -0,0 +1,78 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest + +class TestFunctionMatchingBatchRequest(unittest.TestCase): + """FunctionMatchingBatchRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> FunctionMatchingBatchRequest: + """Test FunctionMatchingBatchRequest + 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 `FunctionMatchingBatchRequest` + """ + model = FunctionMatchingBatchRequest() + if include_optional: + return FunctionMatchingBatchRequest( + model_id = 56, + scope = revengai.models.function_matching_scope_request.FunctionMatchingScopeRequest( + binary_ids = [ + 56 + ], + collection_ids = [ + 56 + ], + function_ids = [ + 56 + ], + min_similarity = 0.0, + debug_types = [ + 'USER' + ], ) + ) + else: + return FunctionMatchingBatchRequest( + scope = revengai.models.function_matching_scope_request.FunctionMatchingScopeRequest( + binary_ids = [ + 56 + ], + collection_ids = [ + 56 + ], + function_ids = [ + 56 + ], + min_similarity = 0.0, + debug_types = [ + 'USER' + ], ), + ) + """ + + def testFunctionMatchingBatchRequest(self): + """Test FunctionMatchingBatchRequest""" + # 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_function_matching_batch_response.py b/test/test_function_matching_batch_response.py new file mode 100644 index 0000000..8cebab4 --- /dev/null +++ b/test/test_function_matching_batch_response.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse + +class TestFunctionMatchingBatchResponse(unittest.TestCase): + """FunctionMatchingBatchResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> FunctionMatchingBatchResponse: + """Test FunctionMatchingBatchResponse + 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 `FunctionMatchingBatchResponse` + """ + model = FunctionMatchingBatchResponse() + if include_optional: + return FunctionMatchingBatchResponse( + progress = 56, + status = '', + total_time = 56, + error_message = '', + matches = [ + revengai.models.function_matching_result_with_best_match.FunctionMatchingResultWithBestMatch( + function_id = 56, + similarity = 1.337, + matched_function = revengai.models.matched_function.MatchedFunction( + function_id = 56, + binary_id = 56, + function_name = '', + function_vaddr = 56, + mangled_name = '', + debug = True, + binary_name = '', + sha_256_hash = '', + analysis_id = 56, + similarity = 1.337, ), + suggested_name = '', ) + ] + ) + else: + return FunctionMatchingBatchResponse( + matches = [ + revengai.models.function_matching_result_with_best_match.FunctionMatchingResultWithBestMatch( + function_id = 56, + similarity = 1.337, + matched_function = revengai.models.matched_function.MatchedFunction( + function_id = 56, + binary_id = 56, + function_name = '', + function_vaddr = 56, + mangled_name = '', + debug = True, + binary_name = '', + sha_256_hash = '', + analysis_id = 56, + similarity = 1.337, ), + suggested_name = '', ) + ], + ) + """ + + def testFunctionMatchingBatchResponse(self): + """Test FunctionMatchingBatchResponse""" + # 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_function_matching_result_with_best_match.py b/test/test_function_matching_result_with_best_match.py new file mode 100644 index 0000000..dff04c7 --- /dev/null +++ b/test/test_function_matching_result_with_best_match.py @@ -0,0 +1,76 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.function_matching_result_with_best_match import FunctionMatchingResultWithBestMatch + +class TestFunctionMatchingResultWithBestMatch(unittest.TestCase): + """FunctionMatchingResultWithBestMatch unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> FunctionMatchingResultWithBestMatch: + """Test FunctionMatchingResultWithBestMatch + 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 `FunctionMatchingResultWithBestMatch` + """ + model = FunctionMatchingResultWithBestMatch() + if include_optional: + return FunctionMatchingResultWithBestMatch( + function_id = 56, + similarity = 1.337, + matched_function = revengai.models.matched_function.MatchedFunction( + function_id = 56, + binary_id = 56, + function_name = '', + function_vaddr = 56, + mangled_name = '', + debug = True, + binary_name = '', + sha_256_hash = '', + analysis_id = 56, + similarity = 1.337, ), + suggested_name = '' + ) + else: + return FunctionMatchingResultWithBestMatch( + function_id = 56, + similarity = 1.337, + matched_function = revengai.models.matched_function.MatchedFunction( + function_id = 56, + binary_id = 56, + function_name = '', + function_vaddr = 56, + mangled_name = '', + debug = True, + binary_name = '', + sha_256_hash = '', + analysis_id = 56, + similarity = 1.337, ), + ) + """ + + def testFunctionMatchingResultWithBestMatch(self): + """Test FunctionMatchingResultWithBestMatch""" + # 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_function_matching_scope_request.py b/test/test_function_matching_scope_request.py new file mode 100644 index 0000000..03e76a3 --- /dev/null +++ b/test/test_function_matching_scope_request.py @@ -0,0 +1,62 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest + +class TestFunctionMatchingScopeRequest(unittest.TestCase): + """FunctionMatchingScopeRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> FunctionMatchingScopeRequest: + """Test FunctionMatchingScopeRequest + 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 `FunctionMatchingScopeRequest` + """ + model = FunctionMatchingScopeRequest() + if include_optional: + return FunctionMatchingScopeRequest( + binary_ids = [ + 56 + ], + collection_ids = [ + 56 + ], + function_ids = [ + 56 + ], + min_similarity = 0.0, + debug_types = [ + 'USER' + ] + ) + else: + return FunctionMatchingScopeRequest( + ) + """ + + def testFunctionMatchingScopeRequest(self): + """Test FunctionMatchingScopeRequest""" + # 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_functions_core_api.py b/test/test_functions_core_api.py index 9ea01bc..cf0ad96 100644 --- a/test/test_functions_core_api.py +++ b/test/test_functions_core_api.py @@ -32,6 +32,13 @@ def test_ai_unstrip(self) -> None: """ pass + def test_analysis_function_matching(self) -> None: + """Test case for analysis_function_matching + + Perform matching for the functions of an analysis + """ + pass + def test_auto_unstrip(self) -> None: """Test case for auto_unstrip @@ -39,6 +46,13 @@ def test_auto_unstrip(self) -> None: """ pass + def test_batch_function_matching(self) -> None: + """Test case for batch_function_matching + + Perform function matching for an arbitrary batch of functions, binaries or collections + """ + pass + def test_cancel_ai_unstrip(self) -> None: """Test case for cancel_ai_unstrip diff --git a/test/test_matched_function.py b/test/test_matched_function.py new file mode 100644 index 0000000..aa7a561 --- /dev/null +++ b/test/test_matched_function.py @@ -0,0 +1,68 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is Similarity Search Engine for executable binaries + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from revengai.models.matched_function import MatchedFunction + +class TestMatchedFunction(unittest.TestCase): + """MatchedFunction unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> MatchedFunction: + """Test MatchedFunction + 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 `MatchedFunction` + """ + model = MatchedFunction() + if include_optional: + return MatchedFunction( + function_id = 56, + binary_id = 56, + function_name = '', + function_vaddr = 56, + mangled_name = '', + debug = True, + binary_name = '', + sha_256_hash = '', + analysis_id = 56, + similarity = 1.337 + ) + else: + return MatchedFunction( + function_id = 56, + binary_id = 56, + function_name = '', + function_vaddr = 56, + mangled_name = '', + debug = True, + binary_name = '', + sha_256_hash = '', + analysis_id = 56, + ) + """ + + def testMatchedFunction(self): + """Test MatchedFunction""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()