From 85c5d9744e495279f824355c37e9e8e3c501afcd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 24 Sep 2025 06:11:20 +0000 Subject: [PATCH] Update SDK to version v1.89.4 - Generated from OpenAPI spec version v1.89.4 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 1 + docs/AnalysisFunctionMatchingRequest.md | 5 +- docs/AutoUnstripRequest.md | 4 +- docs/FunctionMatchingBatchResponse.md | 2 + docs/FunctionMatchingRequest.md | 5 +- docs/FunctionMatchingResultWithBestMatch.md | 5 +- docs/MatchedFunction.md | 1 + docs/NameConfidence.md | 30 +++++++ revengai/__init__.py | 4 +- revengai/api_client.py | 2 +- revengai/configuration.py | 4 +- revengai/models/__init__.py | 1 + .../analysis_function_matching_request.py | 14 ++- revengai/models/auto_unstrip_request.py | 8 +- .../function_matching_batch_response.py | 16 +++- revengai/models/function_matching_request.py | 14 ++- ...unction_matching_result_with_best_match.py | 45 +++++----- revengai/models/matched_function.py | 11 ++- revengai/models/name_confidence.py | 89 +++++++++++++++++++ ...test_analysis_function_matching_request.py | 5 +- test/test_function_matching_batch_response.py | 66 ++++++++------ test/test_function_matching_request.py | 5 +- ...unction_matching_result_with_best_match.py | 57 +++++++----- test/test_matched_function.py | 3 +- test/test_name_confidence.py | 53 +++++++++++ 26 files changed, 352 insertions(+), 100 deletions(-) create mode 100644 docs/NameConfidence.md create mode 100644 revengai/models/name_confidence.py create mode 100644 test/test_name_confidence.py diff --git a/.sdk-version b/.sdk-version index ebc636d..3d7e843 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v1.89.2 +v1.89.4 diff --git a/README.md b/README.md index 29fd48a..59c6f0a 100644 --- a/README.md +++ b/README.md @@ -401,6 +401,7 @@ Class | Method | HTTP request | Description - [MetaModel](docs/MetaModel.md) - [ModelName](docs/ModelName.md) - [ModelsResponse](docs/ModelsResponse.md) + - [NameConfidence](docs/NameConfidence.md) - [NearestNeighbor](docs/NearestNeighbor.md) - [NetworkOverviewDns](docs/NetworkOverviewDns.md) - [NetworkOverviewDnsAnswer](docs/NetworkOverviewDnsAnswer.md) diff --git a/docs/AnalysisFunctionMatchingRequest.md b/docs/AnalysisFunctionMatchingRequest.md index 8a82b43..d4935f0 100644 --- a/docs/AnalysisFunctionMatchingRequest.md +++ b/docs/AnalysisFunctionMatchingRequest.md @@ -5,8 +5,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**min_similarity** | **float** | Minimum similarity expected for a match, default is 0.9 | [optional] [default to 0.9] +**min_similarity** | **float** | Minimum similarity expected for a match as a percentage, default is 90 | [optional] [default to 90.0] **filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | | [optional] +**results_per_function** | **int** | Maximum number of matches to return per function, default is 1, max is 10 | [optional] [default to 1] +**page** | **int** | Page number for paginated results, default is 1 (first page) | [optional] [default to 1] +**page_size** | **int** | Number of functions to return per page, default is 0 (all functions), max is 1000 | [optional] [default to 0] ## Example diff --git a/docs/AutoUnstripRequest.md b/docs/AutoUnstripRequest.md index 8c9ef89..4cd5f43 100644 --- a/docs/AutoUnstripRequest.md +++ b/docs/AutoUnstripRequest.md @@ -5,9 +5,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**min_similarity** | **float** | Minimum similarity expected for a match, default is 0.9 | [optional] [default to 0.9] +**min_similarity** | **float** | Minimum similarity expected for a match as a percentage, default is 90 | [optional] [default to 90.0] **apply** | **bool** | Whether to apply the matched function names to the target binary, default is False | [optional] [default to False] -**confidence_threshold** | **float** | Confidence threshold for applying function names, default is 0.9 | [optional] [default to 0.9] +**confidence_threshold** | **float** | Confidence threshold for applying function names as a percentage, default is 90 | [optional] [default to 90.0] **min_group_size** | **int** | Minimum number of matching functions required to consider for a match, default is 10 | [optional] [default to 10] ## Example diff --git a/docs/FunctionMatchingBatchResponse.md b/docs/FunctionMatchingBatchResponse.md index dd09ece..18d133a 100644 --- a/docs/FunctionMatchingBatchResponse.md +++ b/docs/FunctionMatchingBatchResponse.md @@ -9,6 +9,8 @@ Name | Type | Description | Notes **status** | **str** | | [optional] **total_time** | **int** | | [optional] **error_message** | **str** | | [optional] +**current_page** | **int** | | [optional] +**total_pages** | **int** | | [optional] **matches** | [**List[FunctionMatchingResultWithBestMatch]**](FunctionMatchingResultWithBestMatch.md) | | ## Example diff --git a/docs/FunctionMatchingRequest.md b/docs/FunctionMatchingRequest.md index 85a833b..792f177 100644 --- a/docs/FunctionMatchingRequest.md +++ b/docs/FunctionMatchingRequest.md @@ -7,8 +7,11 @@ 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] +**min_similarity** | **float** | Minimum similarity expected for a match as a percentage, default is 90 | [optional] [default to 90.0] **filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | | [optional] +**results_per_function** | **int** | Maximum number of matches to return per function, default is 1, max is 10 | [optional] [default to 1] +**page** | **int** | Page number for paginated results, default is 1 (first page) | [optional] [default to 1] +**page_size** | **int** | Number of functions to return per page, default is 0 (all functions), max is 1000 | [optional] [default to 0] ## Example diff --git a/docs/FunctionMatchingResultWithBestMatch.md b/docs/FunctionMatchingResultWithBestMatch.md index e70991c..5437700 100644 --- a/docs/FunctionMatchingResultWithBestMatch.md +++ b/docs/FunctionMatchingResultWithBestMatch.md @@ -6,9 +6,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **function_id** | **int** | | -**matched_function** | [**MatchedFunction**](MatchedFunction.md) | | -**suggested_name** | **str** | | [optional] -**suggested_name_confidence** | **float** | | [optional] +**matched_functions** | [**List[MatchedFunction]**](MatchedFunction.md) | | +**confidences** | [**List[NameConfidence]**](NameConfidence.md) | | [optional] ## Example diff --git a/docs/MatchedFunction.md b/docs/MatchedFunction.md index 1438582..e168f5c 100644 --- a/docs/MatchedFunction.md +++ b/docs/MatchedFunction.md @@ -15,6 +15,7 @@ Name | Type | Description | Notes **sha_256_hash** | **str** | | **analysis_id** | **int** | | **similarity** | **float** | | [optional] +**confidence** | **float** | | [optional] ## Example diff --git a/docs/NameConfidence.md b/docs/NameConfidence.md new file mode 100644 index 0000000..5b8342c --- /dev/null +++ b/docs/NameConfidence.md @@ -0,0 +1,30 @@ +# NameConfidence + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | The suggested function name | +**confidence** | **float** | Confidence score as a percentage | + +## Example + +```python +from revengai.models.name_confidence import NameConfidence + +# TODO update the JSON string below +json = "{}" +# create an instance of NameConfidence from a JSON string +name_confidence_instance = NameConfidence.from_json(json) +# print the JSON string representation of the object +print(NameConfidence.to_json()) + +# convert the object into a dict +name_confidence_dict = name_confidence_instance.to_dict() +# create an instance of NameConfidence from a dict +name_confidence_from_dict = NameConfidence.from_dict(name_confidence_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 039777f..1b04094 100644 --- a/revengai/__init__.py +++ b/revengai/__init__.py @@ -13,7 +13,7 @@ """ # noqa: E501 -__version__ = "v1.89.2" +__version__ = "v1.89.4" # Define package exports __all__ = [ @@ -285,6 +285,7 @@ "MetaModel", "ModelName", "ModelsResponse", + "NameConfidence", "NearestNeighbor", "NetworkOverviewDns", "NetworkOverviewDnsAnswer", @@ -633,6 +634,7 @@ from revengai.models.meta_model import MetaModel as MetaModel from revengai.models.model_name import ModelName as ModelName from revengai.models.models_response import ModelsResponse as ModelsResponse +from revengai.models.name_confidence import NameConfidence as NameConfidence from revengai.models.nearest_neighbor import NearestNeighbor as NearestNeighbor from revengai.models.network_overview_dns import NetworkOverviewDns as NetworkOverviewDns from revengai.models.network_overview_dns_answer import NetworkOverviewDnsAnswer as NetworkOverviewDnsAnswer diff --git a/revengai/api_client.py b/revengai/api_client.py index b042568..979eb67 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.89.2/python' + self.user_agent = 'OpenAPI-Generator/v1.89.4/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/revengai/configuration.py b/revengai/configuration.py index 767e3c8..2c98fb9 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.89.2\n"\ - "SDK Package Version: v1.89.2".\ + "Version of the API: v1.89.4\n"\ + "SDK Package Version: v1.89.4".\ 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 a1ba1ab..71d13bc 100644 --- a/revengai/models/__init__.py +++ b/revengai/models/__init__.py @@ -251,6 +251,7 @@ from revengai.models.meta_model import MetaModel from revengai.models.model_name import ModelName from revengai.models.models_response import ModelsResponse +from revengai.models.name_confidence import NameConfidence from revengai.models.nearest_neighbor import NearestNeighbor from revengai.models.network_overview_dns import NetworkOverviewDns from revengai.models.network_overview_dns_answer import NetworkOverviewDnsAnswer diff --git a/revengai/models/analysis_function_matching_request.py b/revengai/models/analysis_function_matching_request.py index 61cbb72..8154393 100644 --- a/revengai/models/analysis_function_matching_request.py +++ b/revengai/models/analysis_function_matching_request.py @@ -27,9 +27,12 @@ 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") + min_similarity: Optional[Union[Annotated[float, Field(le=100.0, strict=True, ge=0.0)], Annotated[int, Field(le=100, strict=True, ge=0)]]] = Field(default=90.0, description="Minimum similarity expected for a match as a percentage, default is 90") filters: Optional[FunctionMatchingFilters] = None - __properties: ClassVar[List[str]] = ["min_similarity", "filters"] + results_per_function: Optional[Annotated[int, Field(le=10, strict=True, ge=1)]] = Field(default=1, description="Maximum number of matches to return per function, default is 1, max is 10") + page: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=1, description="Page number for paginated results, default is 1 (first page)") + page_size: Optional[Annotated[int, Field(le=1000, strict=True, ge=0)]] = Field(default=0, description="Number of functions to return per page, default is 0 (all functions), max is 1000") + __properties: ClassVar[List[str]] = ["min_similarity", "filters", "results_per_function", "page", "page_size"] model_config = ConfigDict( populate_by_name=True, @@ -90,8 +93,11 @@ 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, - "filters": FunctionMatchingFilters.from_dict(obj["filters"]) if obj.get("filters") is not None else None + "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 90.0, + "filters": FunctionMatchingFilters.from_dict(obj["filters"]) if obj.get("filters") is not None else None, + "results_per_function": obj.get("results_per_function") if obj.get("results_per_function") is not None else 1, + "page": obj.get("page") if obj.get("page") is not None else 1, + "page_size": obj.get("page_size") if obj.get("page_size") is not None else 0 }) return _obj diff --git a/revengai/models/auto_unstrip_request.py b/revengai/models/auto_unstrip_request.py index 2edf670..473f3c4 100644 --- a/revengai/models/auto_unstrip_request.py +++ b/revengai/models/auto_unstrip_request.py @@ -26,9 +26,9 @@ class AutoUnstripRequest(BaseModel): """ AutoUnstripRequest """ # 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") + min_similarity: Optional[Union[Annotated[float, Field(le=100.0, strict=True, ge=0.0)], Annotated[int, Field(le=100, strict=True, ge=0)]]] = Field(default=90.0, description="Minimum similarity expected for a match as a percentage, default is 90") apply: Optional[StrictBool] = Field(default=False, description="Whether to apply the matched function names to the target binary, default is False") - confidence_threshold: 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="Confidence threshold for applying function names, default is 0.9") + confidence_threshold: Optional[Union[Annotated[float, Field(le=100.0, strict=True, ge=0.0)], Annotated[int, Field(le=100, strict=True, ge=0)]]] = Field(default=90.0, description="Confidence threshold for applying function names as a percentage, default is 90") min_group_size: Optional[Annotated[int, Field(le=20, strict=True, ge=1)]] = Field(default=10, description="Minimum number of matching functions required to consider for a match, default is 10") __properties: ClassVar[List[str]] = ["min_similarity", "apply", "confidence_threshold", "min_group_size"] @@ -83,9 +83,9 @@ 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 90.0, "apply": obj.get("apply") if obj.get("apply") is not None else False, - "confidence_threshold": obj.get("confidence_threshold") if obj.get("confidence_threshold") is not None else 0.9, + "confidence_threshold": obj.get("confidence_threshold") if obj.get("confidence_threshold") is not None else 90.0, "min_group_size": obj.get("min_group_size") if obj.get("min_group_size") is not None else 10 }) return _obj diff --git a/revengai/models/function_matching_batch_response.py b/revengai/models/function_matching_batch_response.py index d26f42b..95ee9b2 100644 --- a/revengai/models/function_matching_batch_response.py +++ b/revengai/models/function_matching_batch_response.py @@ -30,8 +30,10 @@ class FunctionMatchingBatchResponse(BaseModel): status: Optional[StrictStr] = None total_time: Optional[StrictInt] = None error_message: Optional[StrictStr] = None + current_page: Optional[StrictInt] = None + total_pages: Optional[StrictInt] = None matches: List[FunctionMatchingResultWithBestMatch] - __properties: ClassVar[List[str]] = ["progress", "status", "total_time", "error_message", "matches"] + __properties: ClassVar[List[str]] = ["progress", "status", "total_time", "error_message", "current_page", "total_pages", "matches"] model_config = ConfigDict( populate_by_name=True, @@ -94,6 +96,16 @@ def to_dict(self) -> Dict[str, Any]: if self.error_message is None and "error_message" in self.model_fields_set: _dict['error_message'] = None + # set to None if current_page (nullable) is None + # and model_fields_set contains the field + if self.current_page is None and "current_page" in self.model_fields_set: + _dict['current_page'] = None + + # set to None if total_pages (nullable) is None + # and model_fields_set contains the field + if self.total_pages is None and "total_pages" in self.model_fields_set: + _dict['total_pages'] = None + return _dict @classmethod @@ -110,6 +122,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "status": obj.get("status"), "total_time": obj.get("total_time"), "error_message": obj.get("error_message"), + "current_page": obj.get("current_page"), + "total_pages": obj.get("total_pages"), "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_request.py b/revengai/models/function_matching_request.py index e3a4c68..f572f3c 100644 --- a/revengai/models/function_matching_request.py +++ b/revengai/models/function_matching_request.py @@ -29,9 +29,12 @@ class FunctionMatchingRequest(BaseModel): """ # noqa: E501 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") + min_similarity: Optional[Union[Annotated[float, Field(le=100.0, strict=True, ge=0.0)], Annotated[int, Field(le=100, strict=True, ge=0)]]] = Field(default=90.0, description="Minimum similarity expected for a match as a percentage, default is 90") filters: Optional[FunctionMatchingFilters] = None - __properties: ClassVar[List[str]] = ["model_id", "function_ids", "min_similarity", "filters"] + results_per_function: Optional[Annotated[int, Field(le=10, strict=True, ge=1)]] = Field(default=1, description="Maximum number of matches to return per function, default is 1, max is 10") + page: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=1, description="Page number for paginated results, default is 1 (first page)") + page_size: Optional[Annotated[int, Field(le=1000, strict=True, ge=0)]] = Field(default=0, description="Number of functions to return per page, default is 0 (all functions), max is 1000") + __properties: ClassVar[List[str]] = ["model_id", "function_ids", "min_similarity", "filters", "results_per_function", "page", "page_size"] model_config = ConfigDict( populate_by_name=True, @@ -94,8 +97,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "model_id": obj.get("model_id"), "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 + "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 90.0, + "filters": FunctionMatchingFilters.from_dict(obj["filters"]) if obj.get("filters") is not None else None, + "results_per_function": obj.get("results_per_function") if obj.get("results_per_function") is not None else 1, + "page": obj.get("page") if obj.get("page") is not None else 1, + "page_size": obj.get("page_size") if obj.get("page_size") is not None else 0 }) 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 dd01257..29e8267 100644 --- a/revengai/models/function_matching_result_with_best_match.py +++ b/revengai/models/function_matching_result_with_best_match.py @@ -16,9 +16,10 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List, Optional from revengai.models.matched_function import MatchedFunction +from revengai.models.name_confidence import NameConfidence from typing import Optional, Set from typing_extensions import Self @@ -27,10 +28,9 @@ class FunctionMatchingResultWithBestMatch(BaseModel): FunctionMatchingResultWithBestMatch """ # noqa: E501 function_id: StrictInt - matched_function: MatchedFunction - suggested_name: Optional[StrictStr] = None - suggested_name_confidence: Optional[Union[StrictFloat, StrictInt]] = None - __properties: ClassVar[List[str]] = ["function_id", "matched_function", "suggested_name", "suggested_name_confidence"] + matched_functions: List[MatchedFunction] + confidences: Optional[List[NameConfidence]] = None + __properties: ClassVar[List[str]] = ["function_id", "matched_functions", "confidences"] model_config = ConfigDict( populate_by_name=True, @@ -71,18 +71,24 @@ def to_dict(self) -> Dict[str, Any]: 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 + # override the default output from pydantic by calling `to_dict()` of each item in matched_functions (list) + _items = [] + if self.matched_functions: + for _item_matched_functions in self.matched_functions: + if _item_matched_functions: + _items.append(_item_matched_functions.to_dict()) + _dict['matched_functions'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in confidences (list) + _items = [] + if self.confidences: + for _item_confidences in self.confidences: + if _item_confidences: + _items.append(_item_confidences.to_dict()) + _dict['confidences'] = _items + # set to None if confidences (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 - - # 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 + if self.confidences is None and "confidences" in self.model_fields_set: + _dict['confidences'] = None return _dict @@ -97,9 +103,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "function_id": obj.get("function_id"), - "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_confidence": obj.get("suggested_name_confidence") + "matched_functions": [MatchedFunction.from_dict(_item) for _item in obj["matched_functions"]] if obj.get("matched_functions") is not None else None, + "confidences": [NameConfidence.from_dict(_item) for _item in obj["confidences"]] if obj.get("confidences") is not None else None }) return _obj diff --git a/revengai/models/matched_function.py b/revengai/models/matched_function.py index d1c66f8..38feca9 100644 --- a/revengai/models/matched_function.py +++ b/revengai/models/matched_function.py @@ -35,7 +35,8 @@ class MatchedFunction(BaseModel): 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"] + confidence: 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", "confidence"] model_config = ConfigDict( populate_by_name=True, @@ -86,6 +87,11 @@ def to_dict(self) -> Dict[str, Any]: if self.similarity is None and "similarity" in self.model_fields_set: _dict['similarity'] = None + # set to None if confidence (nullable) is None + # and model_fields_set contains the field + if self.confidence is None and "confidence" in self.model_fields_set: + _dict['confidence'] = None + return _dict @classmethod @@ -107,7 +113,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "binary_name": obj.get("binary_name"), "sha_256_hash": obj.get("sha_256_hash"), "analysis_id": obj.get("analysis_id"), - "similarity": obj.get("similarity") + "similarity": obj.get("similarity"), + "confidence": obj.get("confidence") }) return _obj diff --git a/revengai/models/name_confidence.py b/revengai/models/name_confidence.py new file mode 100644 index 0000000..27bdc2a --- /dev/null +++ b/revengai/models/name_confidence.py @@ -0,0 +1,89 @@ +# 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, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class NameConfidence(BaseModel): + """ + NameConfidence + """ # noqa: E501 + name: StrictStr = Field(description="The suggested function name") + confidence: Union[Annotated[float, Field(le=100.0, strict=True, ge=0.0)], Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(description="Confidence score as a percentage") + __properties: ClassVar[List[str]] = ["name", "confidence"] + + 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 NameConfidence 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 NameConfidence from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name"), + "confidence": obj.get("confidence") + }) + return _obj + + diff --git a/test/test_analysis_function_matching_request.py b/test/test_analysis_function_matching_request.py index a325df6..ccc6169 100644 --- a/test/test_analysis_function_matching_request.py +++ b/test/test_analysis_function_matching_request.py @@ -47,7 +47,10 @@ def make_instance(self, include_optional) -> AnalysisFunctionMatchingRequest: ], debug_types = [ 'USER' - ], ) + ], ), + results_per_function = 1.0, + page = 1.0, + page_size = 0.0 ) else: return AnalysisFunctionMatchingRequest( diff --git a/test/test_function_matching_batch_response.py b/test/test_function_matching_batch_response.py index 911b687..d738658 100644 --- a/test/test_function_matching_batch_response.py +++ b/test/test_function_matching_batch_response.py @@ -38,22 +38,30 @@ def make_instance(self, include_optional) -> FunctionMatchingBatchResponse: status = '', total_time = 56, error_message = '', + current_page = 56, + total_pages = 56, matches = [ revengai.models.function_matching_result_with_best_match.FunctionMatchingResultWithBestMatch( function_id = 56, - 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 = '', - suggested_name_confidence = 1.337, ) + matched_functions = [ + 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, + confidence = 1.337, ) + ], + confidences = [ + revengai.models.name_confidence.NameConfidence( + name = '', + confidence = 0.0, ) + ], ) ] ) else: @@ -61,19 +69,25 @@ def make_instance(self, include_optional) -> FunctionMatchingBatchResponse: matches = [ revengai.models.function_matching_result_with_best_match.FunctionMatchingResultWithBestMatch( function_id = 56, - 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 = '', - suggested_name_confidence = 1.337, ) + matched_functions = [ + 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, + confidence = 1.337, ) + ], + confidences = [ + revengai.models.name_confidence.NameConfidence( + name = '', + confidence = 0.0, ) + ], ) ], ) """ diff --git a/test/test_function_matching_request.py b/test/test_function_matching_request.py index 70a2cf0..0513e8a 100644 --- a/test/test_function_matching_request.py +++ b/test/test_function_matching_request.py @@ -51,7 +51,10 @@ def make_instance(self, include_optional) -> FunctionMatchingRequest: ], debug_types = [ 'USER' - ], ) + ], ), + results_per_function = 1.0, + page = 1.0, + page_size = 0.0 ) else: return FunctionMatchingRequest( diff --git a/test/test_function_matching_result_with_best_match.py b/test/test_function_matching_result_with_best_match.py index dd6eb6a..02c4939 100644 --- a/test/test_function_matching_result_with_best_match.py +++ b/test/test_function_matching_result_with_best_match.py @@ -35,34 +35,43 @@ def make_instance(self, include_optional) -> FunctionMatchingResultWithBestMatch if include_optional: return FunctionMatchingResultWithBestMatch( function_id = 56, - 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 = '', - suggested_name_confidence = 1.337 + matched_functions = [ + 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, + confidence = 1.337, ) + ], + confidences = [ + revengai.models.name_confidence.NameConfidence( + name = '', + confidence = 0.0, ) + ] ) else: return FunctionMatchingResultWithBestMatch( function_id = 56, - 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, ), + matched_functions = [ + 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, + confidence = 1.337, ) + ], ) """ diff --git a/test/test_matched_function.py b/test/test_matched_function.py index aa7a561..9a86eb5 100644 --- a/test/test_matched_function.py +++ b/test/test_matched_function.py @@ -43,7 +43,8 @@ def make_instance(self, include_optional) -> MatchedFunction: binary_name = '', sha_256_hash = '', analysis_id = 56, - similarity = 1.337 + similarity = 1.337, + confidence = 1.337 ) else: return MatchedFunction( diff --git a/test/test_name_confidence.py b/test/test_name_confidence.py new file mode 100644 index 0000000..9c492c8 --- /dev/null +++ b/test/test_name_confidence.py @@ -0,0 +1,53 @@ +# 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.name_confidence import NameConfidence + +class TestNameConfidence(unittest.TestCase): + """NameConfidence unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> NameConfidence: + """Test NameConfidence + 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 `NameConfidence` + """ + model = NameConfidence() + if include_optional: + return NameConfidence( + name = '', + confidence = 0.0 + ) + else: + return NameConfidence( + name = '', + confidence = 0.0, + ) + """ + + def testNameConfidence(self): + """Test NameConfidence""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()