From 7987e9e8276bf44764b91837b4290cb5680242d1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 23 Sep 2025 06:11:39 +0000 Subject: [PATCH] Update SDK to version v1.89.2 - Generated from OpenAPI spec version v1.89.2 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 4 +- docs/AnalysisFunctionMatchingRequest.md | 1 + docs/FunctionMatchingBatchRequest.md | 30 ------------ ...eRequest.md => FunctionMatchingFilters.md} | 17 ++++--- docs/FunctionMatchingRequest.md | 32 +++++++++++++ docs/FunctionMatchingResultWithBestMatch.md | 2 +- docs/FunctionsCoreApi.md | 12 ++--- revengai/__init__.py | 10 ++-- revengai/api/functions_core_api.py | 38 +++++++-------- revengai/api_client.py | 2 +- revengai/configuration.py | 4 +- revengai/models/__init__.py | 4 +- .../analysis_function_matching_request.py | 15 +++++- ...equest.py => function_matching_filters.py} | 15 +++--- ...equest.py => function_matching_request.py} | 36 +++++++++----- ...unction_matching_result_with_best_match.py | 13 +++-- ...test_analysis_function_matching_request.py | 15 +++++- test/test_function_matching_batch_response.py | 8 ++-- ...t.py => test_function_matching_filters.py} | 23 +++++---- ...t.py => test_function_matching_request.py} | 47 ++++++++----------- ...unction_matching_result_with_best_match.py | 5 +- 22 files changed, 182 insertions(+), 153 deletions(-) delete mode 100644 docs/FunctionMatchingBatchRequest.md rename docs/{FunctionMatchingScopeRequest.md => FunctionMatchingFilters.md} (59%) create mode 100644 docs/FunctionMatchingRequest.md rename revengai/models/{function_matching_scope_request.py => function_matching_filters.py} (82%) rename revengai/models/{function_matching_batch_request.py => function_matching_request.py} (57%) rename test/{test_function_matching_scope_request.py => test_function_matching_filters.py} (68%) rename test/{test_function_matching_batch_request.py => test_function_matching_request.py} (52%) diff --git a/.sdk-version b/.sdk-version index 95cc5bb..ebc636d 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v1.88.0 +v1.89.2 diff --git a/README.md b/README.md index cdc3b1d..29fd48a 100644 --- a/README.md +++ b/README.md @@ -358,10 +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) + - [FunctionMatchingFilters](docs/FunctionMatchingFilters.md) + - [FunctionMatchingRequest](docs/FunctionMatchingRequest.md) - [FunctionMatchingResultWithBestMatch](docs/FunctionMatchingResultWithBestMatch.md) - - [FunctionMatchingScopeRequest](docs/FunctionMatchingScopeRequest.md) - [FunctionNameConfidenceBody](docs/FunctionNameConfidenceBody.md) - [FunctionNameHistory](docs/FunctionNameHistory.md) - [FunctionNameInput](docs/FunctionNameInput.md) diff --git a/docs/AnalysisFunctionMatchingRequest.md b/docs/AnalysisFunctionMatchingRequest.md index d949ea9..8a82b43 100644 --- a/docs/AnalysisFunctionMatchingRequest.md +++ b/docs/AnalysisFunctionMatchingRequest.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **min_similarity** | **float** | Minimum similarity expected for a match, default is 0.9 | [optional] [default to 0.9] +**filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | | [optional] ## Example diff --git a/docs/FunctionMatchingBatchRequest.md b/docs/FunctionMatchingBatchRequest.md deleted file mode 100644 index f2a1d39..0000000 --- a/docs/FunctionMatchingBatchRequest.md +++ /dev/null @@ -1,30 +0,0 @@ -# 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/FunctionMatchingScopeRequest.md b/docs/FunctionMatchingFilters.md similarity index 59% rename from docs/FunctionMatchingScopeRequest.md rename to docs/FunctionMatchingFilters.md index 6a9d797..6df2261 100644 --- a/docs/FunctionMatchingScopeRequest.md +++ b/docs/FunctionMatchingFilters.md @@ -1,4 +1,4 @@ -# FunctionMatchingScopeRequest +# FunctionMatchingFilters ## Properties @@ -8,25 +8,24 @@ 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 +from revengai.models.function_matching_filters import FunctionMatchingFilters # 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) +# create an instance of FunctionMatchingFilters from a JSON string +function_matching_filters_instance = FunctionMatchingFilters.from_json(json) # print the JSON string representation of the object -print(FunctionMatchingScopeRequest.to_json()) +print(FunctionMatchingFilters.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) +function_matching_filters_dict = function_matching_filters_instance.to_dict() +# create an instance of FunctionMatchingFilters from a dict +function_matching_filters_from_dict = FunctionMatchingFilters.from_dict(function_matching_filters_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/FunctionMatchingRequest.md b/docs/FunctionMatchingRequest.md new file mode 100644 index 0000000..85a833b --- /dev/null +++ b/docs/FunctionMatchingRequest.md @@ -0,0 +1,32 @@ +# FunctionMatchingRequest + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**model_id** | **int** | ID of the model used for function matching, used to determine the embedding model | +**function_ids** | **List[int]** | ID's of functions to find matches for, must be at least one function ID | +**min_similarity** | **float** | Minimum similarity expected for a match, default is 0.9 | [optional] [default to 0.9] +**filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | | [optional] + +## Example + +```python +from revengai.models.function_matching_request import FunctionMatchingRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of FunctionMatchingRequest from a JSON string +function_matching_request_instance = FunctionMatchingRequest.from_json(json) +# print the JSON string representation of the object +print(FunctionMatchingRequest.to_json()) + +# convert the object into a dict +function_matching_request_dict = function_matching_request_instance.to_dict() +# create an instance of FunctionMatchingRequest from a dict +function_matching_request_from_dict = FunctionMatchingRequest.from_dict(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/FunctionMatchingResultWithBestMatch.md b/docs/FunctionMatchingResultWithBestMatch.md index 3633bf9..e70991c 100644 --- a/docs/FunctionMatchingResultWithBestMatch.md +++ b/docs/FunctionMatchingResultWithBestMatch.md @@ -6,9 +6,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **function_id** | **int** | | -**similarity** | **float** | | **matched_function** | [**MatchedFunction**](MatchedFunction.md) | | **suggested_name** | **str** | | [optional] +**suggested_name_confidence** | **float** | | [optional] ## Example diff --git a/docs/FunctionsCoreApi.md b/docs/FunctionsCoreApi.md index 8c38ec1..2cf4f23 100644 --- a/docs/FunctionsCoreApi.md +++ b/docs/FunctionsCoreApi.md @@ -109,7 +109,7 @@ Name | Type | Description | Notes 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 +Takes in an analysis id and settings and matches the nearest functions to the ones associated with it. Results can optionally be filtered by collection, binary, debug type or (other) function ids ### Example @@ -275,7 +275,7 @@ 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) +> FunctionMatchingBatchResponse batch_function_matching(function_matching_request, authorization=authorization) Perform function matching for an arbitrary batch of functions, binaries or collections @@ -287,8 +287,8 @@ Takes in an input of functions ID's and settings and finds the nearest functions ```python import revengai -from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse +from revengai.models.function_matching_request import FunctionMatchingRequest from revengai.rest import ApiException from pprint import pprint @@ -313,12 +313,12 @@ configuration.api_key['APIKey'] = os.environ["API_KEY"] 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 | + function_matching_request = revengai.FunctionMatchingRequest() # FunctionMatchingRequest | 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) + api_response = api_instance.batch_function_matching(function_matching_request, authorization=authorization) print("The response of FunctionsCoreApi->batch_function_matching:\n") pprint(api_response) except Exception as e: @@ -332,7 +332,7 @@ with revengai.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **function_matching_batch_request** | [**FunctionMatchingBatchRequest**](FunctionMatchingBatchRequest.md)| | + **function_matching_request** | [**FunctionMatchingRequest**](FunctionMatchingRequest.md)| | **authorization** | **str**| API Key bearer token | [optional] ### Return type diff --git a/revengai/__init__.py b/revengai/__init__.py index 348e79b..039777f 100644 --- a/revengai/__init__.py +++ b/revengai/__init__.py @@ -13,7 +13,7 @@ """ # noqa: E501 -__version__ = "v1.88.0" +__version__ = "v1.89.2" # Define package exports __all__ = [ @@ -242,10 +242,10 @@ "FunctionLocalVariableResponse", "FunctionMapping", "FunctionMappingFull", - "FunctionMatchingBatchRequest", "FunctionMatchingBatchResponse", + "FunctionMatchingFilters", + "FunctionMatchingRequest", "FunctionMatchingResultWithBestMatch", - "FunctionMatchingScopeRequest", "FunctionNameConfidenceBody", "FunctionNameHistory", "FunctionNameInput", @@ -590,10 +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_filters import FunctionMatchingFilters as FunctionMatchingFilters +from revengai.models.function_matching_request import FunctionMatchingRequest as FunctionMatchingRequest 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 diff --git a/revengai/api/functions_core_api.py b/revengai/api/functions_core_api.py index 273b6f0..a305791 100644 --- a/revengai/api/functions_core_api.py +++ b/revengai/api/functions_core_api.py @@ -29,8 +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.models.function_matching_request import FunctionMatchingRequest from revengai.api_client import ApiClient, RequestSerialized from revengai.api_response import ApiResponse @@ -378,7 +378,7 @@ def analysis_function_matching( ) -> 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 + Takes in an analysis id and settings and matches the nearest functions to the ones associated with it. Results can optionally be filtered by collection, binary, debug type or (other) function ids :param analysis_id: (required) :type analysis_id: int @@ -454,7 +454,7 @@ def analysis_function_matching_with_http_info( ) -> 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 + Takes in an analysis id and settings and matches the nearest functions to the ones associated with it. Results can optionally be filtered by collection, binary, debug type or (other) function ids :param analysis_id: (required) :type analysis_id: int @@ -530,7 +530,7 @@ def analysis_function_matching_without_preload_content( ) -> 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 + Takes in an analysis id and settings and matches the nearest functions to the ones associated with it. Results can optionally be filtered by collection, binary, debug type or (other) function ids :param analysis_id: (required) :type analysis_id: int @@ -974,7 +974,7 @@ def _auto_unstrip_serialize( @validate_call def batch_function_matching( self, - function_matching_batch_request: FunctionMatchingBatchRequest, + function_matching_request: FunctionMatchingRequest, authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, _request_timeout: Union[ None, @@ -993,8 +993,8 @@ def batch_function_matching( 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 function_matching_request: (required) + :type function_matching_request: FunctionMatchingRequest :param authorization: API Key bearer token :type authorization: str :param _request_timeout: timeout setting for this request. If one @@ -1020,7 +1020,7 @@ def batch_function_matching( """ # noqa: E501 _param = self._batch_function_matching_serialize( - function_matching_batch_request=function_matching_batch_request, + function_matching_request=function_matching_request, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, @@ -1046,7 +1046,7 @@ def batch_function_matching( @validate_call def batch_function_matching_with_http_info( self, - function_matching_batch_request: FunctionMatchingBatchRequest, + function_matching_request: FunctionMatchingRequest, authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, _request_timeout: Union[ None, @@ -1065,8 +1065,8 @@ def batch_function_matching_with_http_info( 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 function_matching_request: (required) + :type function_matching_request: FunctionMatchingRequest :param authorization: API Key bearer token :type authorization: str :param _request_timeout: timeout setting for this request. If one @@ -1092,7 +1092,7 @@ def batch_function_matching_with_http_info( """ # noqa: E501 _param = self._batch_function_matching_serialize( - function_matching_batch_request=function_matching_batch_request, + function_matching_request=function_matching_request, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, @@ -1118,7 +1118,7 @@ def batch_function_matching_with_http_info( @validate_call def batch_function_matching_without_preload_content( self, - function_matching_batch_request: FunctionMatchingBatchRequest, + function_matching_request: FunctionMatchingRequest, authorization: Annotated[Optional[StrictStr], Field(description="API Key bearer token")] = None, _request_timeout: Union[ None, @@ -1137,8 +1137,8 @@ def batch_function_matching_without_preload_content( 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 function_matching_request: (required) + :type function_matching_request: FunctionMatchingRequest :param authorization: API Key bearer token :type authorization: str :param _request_timeout: timeout setting for this request. If one @@ -1164,7 +1164,7 @@ def batch_function_matching_without_preload_content( """ # noqa: E501 _param = self._batch_function_matching_serialize( - function_matching_batch_request=function_matching_batch_request, + function_matching_request=function_matching_request, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, @@ -1185,7 +1185,7 @@ def batch_function_matching_without_preload_content( def _batch_function_matching_serialize( self, - function_matching_batch_request, + function_matching_request, authorization, _request_auth, _content_type, @@ -1214,8 +1214,8 @@ def _batch_function_matching_serialize( _header_params['authorization'] = authorization # process the form parameters # process the body parameter - if function_matching_batch_request is not None: - _body_params = function_matching_batch_request + if function_matching_request is not None: + _body_params = function_matching_request # set the HTTP header `Accept` diff --git a/revengai/api_client.py b/revengai/api_client.py index 32b50df..b042568 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.88.0/python' + self.user_agent = 'OpenAPI-Generator/v1.89.2/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/revengai/configuration.py b/revengai/configuration.py index 9c82148..767e3c8 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.88.0\n"\ - "SDK Package Version: v1.88.0".\ + "Version of the API: v1.89.2\n"\ + "SDK Package Version: v1.89.2".\ 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 ffef232..a1ba1ab 100644 --- a/revengai/models/__init__.py +++ b/revengai/models/__init__.py @@ -208,10 +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_filters import FunctionMatchingFilters +from revengai.models.function_matching_request import FunctionMatchingRequest 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 diff --git a/revengai/models/analysis_function_matching_request.py b/revengai/models/analysis_function_matching_request.py index 1eac1ed..61cbb72 100644 --- a/revengai/models/analysis_function_matching_request.py +++ b/revengai/models/analysis_function_matching_request.py @@ -19,6 +19,7 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated +from revengai.models.function_matching_filters import FunctionMatchingFilters from typing import Optional, Set from typing_extensions import Self @@ -27,7 +28,8 @@ 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"] + filters: Optional[FunctionMatchingFilters] = None + __properties: ClassVar[List[str]] = ["min_similarity", "filters"] model_config = ConfigDict( populate_by_name=True, @@ -68,6 +70,14 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of filters + if self.filters: + _dict['filters'] = self.filters.to_dict() + # set to None if filters (nullable) is None + # and model_fields_set contains the field + if self.filters is None and "filters" in self.model_fields_set: + _dict['filters'] = None + return _dict @classmethod @@ -80,7 +90,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 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 + "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 0.9, + "filters": FunctionMatchingFilters.from_dict(obj["filters"]) if obj.get("filters") is not None else None }) return _obj diff --git a/revengai/models/function_matching_scope_request.py b/revengai/models/function_matching_filters.py similarity index 82% rename from revengai/models/function_matching_scope_request.py rename to revengai/models/function_matching_filters.py index 3693f9b..f0e4b49 100644 --- a/revengai/models/function_matching_scope_request.py +++ b/revengai/models/function_matching_filters.py @@ -17,21 +17,19 @@ 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 Any, ClassVar, Dict, List, Optional from typing import Optional, Set from typing_extensions import Self -class FunctionMatchingScopeRequest(BaseModel): +class FunctionMatchingFilters(BaseModel): """ - FunctionMatchingScopeRequest + FunctionMatchingFilters """ # 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"] + __properties: ClassVar[List[str]] = ["binary_ids", "collection_ids", "function_ids", "debug_types"] @field_validator('debug_types') def debug_types_validate_enum(cls, value): @@ -62,7 +60,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FunctionMatchingScopeRequest from a JSON string""" + """Create an instance of FunctionMatchingFilters from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -87,7 +85,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FunctionMatchingScopeRequest from a dict""" + """Create an instance of FunctionMatchingFilters from a dict""" if obj is None: return None @@ -98,7 +96,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "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/function_matching_batch_request.py b/revengai/models/function_matching_request.py similarity index 57% rename from revengai/models/function_matching_batch_request.py rename to revengai/models/function_matching_request.py index 4e6fddf..e3a4c68 100644 --- a/revengai/models/function_matching_batch_request.py +++ b/revengai/models/function_matching_request.py @@ -17,18 +17,21 @@ 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 Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from revengai.models.function_matching_filters import FunctionMatchingFilters from typing import Optional, Set from typing_extensions import Self -class FunctionMatchingBatchRequest(BaseModel): +class FunctionMatchingRequest(BaseModel): """ - FunctionMatchingBatchRequest + FunctionMatchingRequest """ # 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_id: StrictInt = Field(description="ID of the model used for function matching, used to determine the embedding model") + function_ids: List[StrictInt] = Field(description="ID's of functions to find matches for, must be at least one function ID") + 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") + filters: Optional[FunctionMatchingFilters] = None + __properties: ClassVar[List[str]] = ["model_id", "function_ids", "min_similarity", "filters"] model_config = ConfigDict( populate_by_name=True, @@ -48,7 +51,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FunctionMatchingBatchRequest from a JSON string""" + """Create an instance of FunctionMatchingRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -69,14 +72,19 @@ def to_dict(self) -> Dict[str, Any]: 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() + # override the default output from pydantic by calling `to_dict()` of filters + if self.filters: + _dict['filters'] = self.filters.to_dict() + # set to None if filters (nullable) is None + # and model_fields_set contains the field + if self.filters is None and "filters" in self.model_fields_set: + _dict['filters'] = None + return _dict @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FunctionMatchingBatchRequest from a dict""" + """Create an instance of FunctionMatchingRequest from a dict""" if obj is None: return None @@ -85,7 +93,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _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 + "function_ids": obj.get("function_ids"), + "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 0.9, + "filters": FunctionMatchingFilters.from_dict(obj["filters"]) if obj.get("filters") 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 index f9e17a6..dd01257 100644 --- a/revengai/models/function_matching_result_with_best_match.py +++ b/revengai/models/function_matching_result_with_best_match.py @@ -27,10 +27,10 @@ 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"] + suggested_name_confidence: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["function_id", "matched_function", "suggested_name", "suggested_name_confidence"] model_config = ConfigDict( populate_by_name=True, @@ -79,6 +79,11 @@ def to_dict(self) -> Dict[str, Any]: if self.suggested_name is None and "suggested_name" in self.model_fields_set: _dict['suggested_name'] = None + # set to None if suggested_name_confidence (nullable) is None + # and model_fields_set contains the field + if self.suggested_name_confidence is None and "suggested_name_confidence" in self.model_fields_set: + _dict['suggested_name_confidence'] = None + return _dict @classmethod @@ -92,9 +97,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _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") + "suggested_name": obj.get("suggested_name"), + "suggested_name_confidence": obj.get("suggested_name_confidence") }) return _obj diff --git a/test/test_analysis_function_matching_request.py b/test/test_analysis_function_matching_request.py index 8ac5a05..a325df6 100644 --- a/test/test_analysis_function_matching_request.py +++ b/test/test_analysis_function_matching_request.py @@ -34,7 +34,20 @@ def make_instance(self, include_optional) -> AnalysisFunctionMatchingRequest: model = AnalysisFunctionMatchingRequest() if include_optional: return AnalysisFunctionMatchingRequest( - min_similarity = 0.0 + min_similarity = 0.0, + filters = revengai.models.function_matching_filters.FunctionMatchingFilters( + binary_ids = [ + 56 + ], + collection_ids = [ + 56 + ], + function_ids = [ + 56 + ], + debug_types = [ + 'USER' + ], ) ) else: return AnalysisFunctionMatchingRequest( diff --git a/test/test_function_matching_batch_response.py b/test/test_function_matching_batch_response.py index 8cebab4..911b687 100644 --- a/test/test_function_matching_batch_response.py +++ b/test/test_function_matching_batch_response.py @@ -41,7 +41,6 @@ def make_instance(self, include_optional) -> 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, @@ -53,7 +52,8 @@ def make_instance(self, include_optional) -> FunctionMatchingBatchResponse: sha_256_hash = '', analysis_id = 56, similarity = 1.337, ), - suggested_name = '', ) + suggested_name = '', + suggested_name_confidence = 1.337, ) ] ) else: @@ -61,7 +61,6 @@ def make_instance(self, include_optional) -> 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, @@ -73,7 +72,8 @@ def make_instance(self, include_optional) -> FunctionMatchingBatchResponse: sha_256_hash = '', analysis_id = 56, similarity = 1.337, ), - suggested_name = '', ) + suggested_name = '', + suggested_name_confidence = 1.337, ) ], ) """ diff --git a/test/test_function_matching_scope_request.py b/test/test_function_matching_filters.py similarity index 68% rename from test/test_function_matching_scope_request.py rename to test/test_function_matching_filters.py index 03e76a3..49acb93 100644 --- a/test/test_function_matching_scope_request.py +++ b/test/test_function_matching_filters.py @@ -13,10 +13,10 @@ import unittest -from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest +from revengai.models.function_matching_filters import FunctionMatchingFilters -class TestFunctionMatchingScopeRequest(unittest.TestCase): - """FunctionMatchingScopeRequest unit test stubs""" +class TestFunctionMatchingFilters(unittest.TestCase): + """FunctionMatchingFilters unit test stubs""" def setUp(self): pass @@ -24,16 +24,16 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> FunctionMatchingScopeRequest: - """Test FunctionMatchingScopeRequest + def make_instance(self, include_optional) -> FunctionMatchingFilters: + """Test FunctionMatchingFilters 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` + # uncomment below to create an instance of `FunctionMatchingFilters` """ - model = FunctionMatchingScopeRequest() + model = FunctionMatchingFilters() if include_optional: - return FunctionMatchingScopeRequest( + return FunctionMatchingFilters( binary_ids = [ 56 ], @@ -43,18 +43,17 @@ def make_instance(self, include_optional) -> FunctionMatchingScopeRequest: function_ids = [ 56 ], - min_similarity = 0.0, debug_types = [ 'USER' ] ) else: - return FunctionMatchingScopeRequest( + return FunctionMatchingFilters( ) """ - def testFunctionMatchingScopeRequest(self): - """Test FunctionMatchingScopeRequest""" + def testFunctionMatchingFilters(self): + """Test FunctionMatchingFilters""" # inst_req_only = self.make_instance(include_optional=False) # inst_req_and_optional = self.make_instance(include_optional=True) diff --git a/test/test_function_matching_batch_request.py b/test/test_function_matching_request.py similarity index 52% rename from test/test_function_matching_batch_request.py rename to test/test_function_matching_request.py index 84651c3..70a2cf0 100644 --- a/test/test_function_matching_batch_request.py +++ b/test/test_function_matching_request.py @@ -13,10 +13,10 @@ import unittest -from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest +from revengai.models.function_matching_request import FunctionMatchingRequest -class TestFunctionMatchingBatchRequest(unittest.TestCase): - """FunctionMatchingBatchRequest unit test stubs""" +class TestFunctionMatchingRequest(unittest.TestCase): + """FunctionMatchingRequest unit test stubs""" def setUp(self): pass @@ -24,18 +24,22 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> FunctionMatchingBatchRequest: - """Test FunctionMatchingBatchRequest + def make_instance(self, include_optional) -> FunctionMatchingRequest: + """Test FunctionMatchingRequest 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` + # uncomment below to create an instance of `FunctionMatchingRequest` """ - model = FunctionMatchingBatchRequest() + model = FunctionMatchingRequest() if include_optional: - return FunctionMatchingBatchRequest( + return FunctionMatchingRequest( model_id = 56, - scope = revengai.models.function_matching_scope_request.FunctionMatchingScopeRequest( + function_ids = [ + 56 + ], + min_similarity = 0.0, + filters = revengai.models.function_matching_filters.FunctionMatchingFilters( binary_ids = [ 56 ], @@ -45,32 +49,21 @@ def make_instance(self, include_optional) -> FunctionMatchingBatchRequest: 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' - ], ), + return FunctionMatchingRequest( + model_id = 56, + function_ids = [ + 56 + ], ) """ - def testFunctionMatchingBatchRequest(self): - """Test FunctionMatchingBatchRequest""" + def testFunctionMatchingRequest(self): + """Test FunctionMatchingRequest""" # inst_req_only = self.make_instance(include_optional=False) # inst_req_and_optional = self.make_instance(include_optional=True) diff --git a/test/test_function_matching_result_with_best_match.py b/test/test_function_matching_result_with_best_match.py index dff04c7..dd6eb6a 100644 --- a/test/test_function_matching_result_with_best_match.py +++ b/test/test_function_matching_result_with_best_match.py @@ -35,7 +35,6 @@ def make_instance(self, include_optional) -> 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, @@ -47,12 +46,12 @@ def make_instance(self, include_optional) -> FunctionMatchingResultWithBestMatch sha_256_hash = '', analysis_id = 56, similarity = 1.337, ), - suggested_name = '' + suggested_name = '', + suggested_name_confidence = 1.337 ) else: return FunctionMatchingResultWithBestMatch( function_id = 56, - similarity = 1.337, matched_function = revengai.models.matched_function.MatchedFunction( function_id = 56, binary_id = 56,