revengai 1.86.0__py3-none-any.whl → 1.88.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of revengai might be problematic. Click here for more details.

revengai/api_client.py CHANGED
@@ -90,7 +90,7 @@ class ApiClient:
90
90
  self.default_headers[header_name] = header_value
91
91
  self.cookie = cookie
92
92
  # Set default User-Agent.
93
- self.user_agent = 'OpenAPI-Generator/v1.86.0/python'
93
+ self.user_agent = 'OpenAPI-Generator/v1.88.0/python'
94
94
  self.client_side_validation = configuration.client_side_validation
95
95
 
96
96
  def __enter__(self):
revengai/configuration.py CHANGED
@@ -529,8 +529,8 @@ conf = revengai.Configuration(
529
529
  return "Python SDK Debug Report:\n"\
530
530
  "OS: {env}\n"\
531
531
  "Python Version: {pyversion}\n"\
532
- "Version of the API: v1.86.0\n"\
533
- "SDK Package Version: v1.86.0".\
532
+ "Version of the API: v1.88.0\n"\
533
+ "SDK Package Version: v1.88.0".\
534
534
  format(env=sys.platform, pyversion=sys.version)
535
535
 
536
536
  def get_host_settings(self) -> List[HostSetting]:
@@ -21,6 +21,7 @@ from revengai.models.analysis_create_request import AnalysisCreateRequest
21
21
  from revengai.models.analysis_create_response import AnalysisCreateResponse
22
22
  from revengai.models.analysis_detail_response import AnalysisDetailResponse
23
23
  from revengai.models.analysis_function_mapping import AnalysisFunctionMapping
24
+ from revengai.models.analysis_function_matching_request import AnalysisFunctionMatchingRequest
24
25
  from revengai.models.analysis_functions import AnalysisFunctions
25
26
  from revengai.models.analysis_record import AnalysisRecord
26
27
  from revengai.models.analysis_scope import AnalysisScope
@@ -207,6 +208,10 @@ from revengai.models.function_info_output import FunctionInfoOutput
207
208
  from revengai.models.function_local_variable_response import FunctionLocalVariableResponse
208
209
  from revengai.models.function_mapping import FunctionMapping
209
210
  from revengai.models.function_mapping_full import FunctionMappingFull
211
+ from revengai.models.function_matching_batch_request import FunctionMatchingBatchRequest
212
+ from revengai.models.function_matching_batch_response import FunctionMatchingBatchResponse
213
+ from revengai.models.function_matching_result_with_best_match import FunctionMatchingResultWithBestMatch
214
+ from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest
210
215
  from revengai.models.function_name_confidence_body import FunctionNameConfidenceBody
211
216
  from revengai.models.function_name_history import FunctionNameHistory
212
217
  from revengai.models.function_name_input import FunctionNameInput
@@ -241,6 +246,7 @@ from revengai.models.list_collection_results import ListCollectionResults
241
246
  from revengai.models.login_request import LoginRequest
242
247
  from revengai.models.login_response import LoginResponse
243
248
  from revengai.models.logs import Logs
249
+ from revengai.models.matched_function import MatchedFunction
244
250
  from revengai.models.matched_function_suggestion import MatchedFunctionSuggestion
245
251
  from revengai.models.meta_model import MetaModel
246
252
  from revengai.models.model_name import ModelName
@@ -0,0 +1,87 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ RevEng.AI API
5
+
6
+ RevEng.AI is Similarity Search Engine for executable binaries
7
+
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field
20
+ from typing import Any, ClassVar, Dict, List, Optional, Union
21
+ from typing_extensions import Annotated
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class AnalysisFunctionMatchingRequest(BaseModel):
26
+ """
27
+ AnalysisFunctionMatchingRequest
28
+ """ # noqa: E501
29
+ 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")
30
+ __properties: ClassVar[List[str]] = ["min_similarity"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+
39
+ def to_str(self) -> str:
40
+ """Returns the string representation of the model using alias"""
41
+ return pprint.pformat(self.model_dump(by_alias=True))
42
+
43
+ def to_json(self) -> str:
44
+ """Returns the JSON representation of the model using alias"""
45
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46
+ return json.dumps(self.to_dict())
47
+
48
+ @classmethod
49
+ def from_json(cls, json_str: str) -> Optional[Self]:
50
+ """Create an instance of AnalysisFunctionMatchingRequest from a JSON string"""
51
+ return cls.from_dict(json.loads(json_str))
52
+
53
+ def to_dict(self) -> Dict[str, Any]:
54
+ """Return the dictionary representation of the model using alias.
55
+
56
+ This has the following differences from calling pydantic's
57
+ `self.model_dump(by_alias=True)`:
58
+
59
+ * `None` is only added to the output dict for nullable fields that
60
+ were set at model initialization. Other fields with value `None`
61
+ are ignored.
62
+ """
63
+ excluded_fields: Set[str] = set([
64
+ ])
65
+
66
+ _dict = self.model_dump(
67
+ by_alias=True,
68
+ exclude=excluded_fields,
69
+ exclude_none=True,
70
+ )
71
+ return _dict
72
+
73
+ @classmethod
74
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
75
+ """Create an instance of AnalysisFunctionMatchingRequest from a dict"""
76
+ if obj is None:
77
+ return None
78
+
79
+ if not isinstance(obj, dict):
80
+ return cls.model_validate(obj)
81
+
82
+ _obj = cls.model_validate({
83
+ "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 0.9
84
+ })
85
+ return _obj
86
+
87
+
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ RevEng.AI API
5
+
6
+ RevEng.AI is Similarity Search Engine for executable binaries
7
+
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from revengai.models.function_matching_scope_request import FunctionMatchingScopeRequest
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class FunctionMatchingBatchRequest(BaseModel):
26
+ """
27
+ FunctionMatchingBatchRequest
28
+ """ # noqa: E501
29
+ model_id: Optional[StrictInt] = None
30
+ scope: FunctionMatchingScopeRequest = Field(description="Scope of the function matching request, used to limit the search to specific binaries, collections, and functions")
31
+ __properties: ClassVar[List[str]] = ["model_id", "scope"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of FunctionMatchingBatchRequest from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ # override the default output from pydantic by calling `to_dict()` of scope
73
+ if self.scope:
74
+ _dict['scope'] = self.scope.to_dict()
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of FunctionMatchingBatchRequest from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ _obj = cls.model_validate({
87
+ "model_id": obj.get("model_id"),
88
+ "scope": FunctionMatchingScopeRequest.from_dict(obj["scope"]) if obj.get("scope") is not None else None
89
+ })
90
+ return _obj
91
+
92
+
@@ -0,0 +1,117 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ RevEng.AI API
5
+
6
+ RevEng.AI is Similarity Search Engine for executable binaries
7
+
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from revengai.models.function_matching_result_with_best_match import FunctionMatchingResultWithBestMatch
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class FunctionMatchingBatchResponse(BaseModel):
26
+ """
27
+ FunctionMatchingBatchResponse
28
+ """ # noqa: E501
29
+ progress: Optional[StrictInt] = Field(default=0, description="Progress of the matching operation, represented as a percentage")
30
+ status: Optional[StrictStr] = None
31
+ total_time: Optional[StrictInt] = None
32
+ error_message: Optional[StrictStr] = None
33
+ matches: List[FunctionMatchingResultWithBestMatch]
34
+ __properties: ClassVar[List[str]] = ["progress", "status", "total_time", "error_message", "matches"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of FunctionMatchingBatchResponse from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # override the default output from pydantic by calling `to_dict()` of each item in matches (list)
76
+ _items = []
77
+ if self.matches:
78
+ for _item_matches in self.matches:
79
+ if _item_matches:
80
+ _items.append(_item_matches.to_dict())
81
+ _dict['matches'] = _items
82
+ # set to None if status (nullable) is None
83
+ # and model_fields_set contains the field
84
+ if self.status is None and "status" in self.model_fields_set:
85
+ _dict['status'] = None
86
+
87
+ # set to None if total_time (nullable) is None
88
+ # and model_fields_set contains the field
89
+ if self.total_time is None and "total_time" in self.model_fields_set:
90
+ _dict['total_time'] = None
91
+
92
+ # set to None if error_message (nullable) is None
93
+ # and model_fields_set contains the field
94
+ if self.error_message is None and "error_message" in self.model_fields_set:
95
+ _dict['error_message'] = None
96
+
97
+ return _dict
98
+
99
+ @classmethod
100
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
101
+ """Create an instance of FunctionMatchingBatchResponse from a dict"""
102
+ if obj is None:
103
+ return None
104
+
105
+ if not isinstance(obj, dict):
106
+ return cls.model_validate(obj)
107
+
108
+ _obj = cls.model_validate({
109
+ "progress": obj.get("progress") if obj.get("progress") is not None else 0,
110
+ "status": obj.get("status"),
111
+ "total_time": obj.get("total_time"),
112
+ "error_message": obj.get("error_message"),
113
+ "matches": [FunctionMatchingResultWithBestMatch.from_dict(_item) for _item in obj["matches"]] if obj.get("matches") is not None else None
114
+ })
115
+ return _obj
116
+
117
+
@@ -0,0 +1,101 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ RevEng.AI API
5
+
6
+ RevEng.AI is Similarity Search Engine for executable binaries
7
+
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional, Union
21
+ from revengai.models.matched_function import MatchedFunction
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class FunctionMatchingResultWithBestMatch(BaseModel):
26
+ """
27
+ FunctionMatchingResultWithBestMatch
28
+ """ # noqa: E501
29
+ function_id: StrictInt
30
+ similarity: Union[StrictFloat, StrictInt]
31
+ matched_function: MatchedFunction
32
+ suggested_name: Optional[StrictStr] = None
33
+ __properties: ClassVar[List[str]] = ["function_id", "similarity", "matched_function", "suggested_name"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of FunctionMatchingResultWithBestMatch from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # override the default output from pydantic by calling `to_dict()` of matched_function
75
+ if self.matched_function:
76
+ _dict['matched_function'] = self.matched_function.to_dict()
77
+ # set to None if suggested_name (nullable) is None
78
+ # and model_fields_set contains the field
79
+ if self.suggested_name is None and "suggested_name" in self.model_fields_set:
80
+ _dict['suggested_name'] = None
81
+
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of FunctionMatchingResultWithBestMatch from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "function_id": obj.get("function_id"),
95
+ "similarity": obj.get("similarity"),
96
+ "matched_function": MatchedFunction.from_dict(obj["matched_function"]) if obj.get("matched_function") is not None else None,
97
+ "suggested_name": obj.get("suggested_name")
98
+ })
99
+ return _obj
100
+
101
+
@@ -0,0 +1,106 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ RevEng.AI API
5
+
6
+ RevEng.AI is Similarity Search Engine for executable binaries
7
+
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
20
+ from typing import Any, ClassVar, Dict, List, Optional, Union
21
+ from typing_extensions import Annotated
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class FunctionMatchingScopeRequest(BaseModel):
26
+ """
27
+ FunctionMatchingScopeRequest
28
+ """ # noqa: E501
29
+ binary_ids: Optional[List[StrictInt]] = Field(default=None, description="ID's of binaries to limit the search to, if empty, search all scoped binaries")
30
+ collection_ids: Optional[List[StrictInt]] = Field(default=None, description="ID's of collections to limit the search to, if empty, search all scoped collections")
31
+ function_ids: Optional[List[StrictInt]] = Field(default=None, description="ID's of functions to limit the search to, if empty, search all scoped functions")
32
+ 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")
33
+ 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")
34
+ __properties: ClassVar[List[str]] = ["binary_ids", "collection_ids", "function_ids", "min_similarity", "debug_types"]
35
+
36
+ @field_validator('debug_types')
37
+ def debug_types_validate_enum(cls, value):
38
+ """Validates the enum"""
39
+ if value is None:
40
+ return value
41
+
42
+ for i in value:
43
+ if i not in set(['USER', 'SYSTEM', 'EXTERNAL']):
44
+ raise ValueError("each list item must be one of ('USER', 'SYSTEM', 'EXTERNAL')")
45
+ return value
46
+
47
+ model_config = ConfigDict(
48
+ populate_by_name=True,
49
+ validate_assignment=True,
50
+ protected_namespaces=(),
51
+ )
52
+
53
+
54
+ def to_str(self) -> str:
55
+ """Returns the string representation of the model using alias"""
56
+ return pprint.pformat(self.model_dump(by_alias=True))
57
+
58
+ def to_json(self) -> str:
59
+ """Returns the JSON representation of the model using alias"""
60
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61
+ return json.dumps(self.to_dict())
62
+
63
+ @classmethod
64
+ def from_json(cls, json_str: str) -> Optional[Self]:
65
+ """Create an instance of FunctionMatchingScopeRequest from a JSON string"""
66
+ return cls.from_dict(json.loads(json_str))
67
+
68
+ def to_dict(self) -> Dict[str, Any]:
69
+ """Return the dictionary representation of the model using alias.
70
+
71
+ This has the following differences from calling pydantic's
72
+ `self.model_dump(by_alias=True)`:
73
+
74
+ * `None` is only added to the output dict for nullable fields that
75
+ were set at model initialization. Other fields with value `None`
76
+ are ignored.
77
+ """
78
+ excluded_fields: Set[str] = set([
79
+ ])
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ return _dict
87
+
88
+ @classmethod
89
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
90
+ """Create an instance of FunctionMatchingScopeRequest from a dict"""
91
+ if obj is None:
92
+ return None
93
+
94
+ if not isinstance(obj, dict):
95
+ return cls.model_validate(obj)
96
+
97
+ _obj = cls.model_validate({
98
+ "binary_ids": obj.get("binary_ids"),
99
+ "collection_ids": obj.get("collection_ids"),
100
+ "function_ids": obj.get("function_ids"),
101
+ "min_similarity": obj.get("min_similarity") if obj.get("min_similarity") is not None else 0.9,
102
+ "debug_types": obj.get("debug_types")
103
+ })
104
+ return _obj
105
+
106
+
@@ -0,0 +1,114 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ RevEng.AI API
5
+
6
+ RevEng.AI is Similarity Search Engine for executable binaries
7
+
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional, Union
21
+ from typing import Optional, Set
22
+ from typing_extensions import Self
23
+
24
+ class MatchedFunction(BaseModel):
25
+ """
26
+ MatchedFunction
27
+ """ # noqa: E501
28
+ function_id: StrictInt
29
+ binary_id: StrictInt
30
+ function_name: StrictStr
31
+ function_vaddr: StrictInt
32
+ mangled_name: Optional[StrictStr]
33
+ debug: StrictBool
34
+ binary_name: StrictStr
35
+ sha_256_hash: StrictStr
36
+ analysis_id: StrictInt
37
+ similarity: Optional[Union[StrictFloat, StrictInt]] = None
38
+ __properties: ClassVar[List[str]] = ["function_id", "binary_id", "function_name", "function_vaddr", "mangled_name", "debug", "binary_name", "sha_256_hash", "analysis_id", "similarity"]
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+
47
+ def to_str(self) -> str:
48
+ """Returns the string representation of the model using alias"""
49
+ return pprint.pformat(self.model_dump(by_alias=True))
50
+
51
+ def to_json(self) -> str:
52
+ """Returns the JSON representation of the model using alias"""
53
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
+ return json.dumps(self.to_dict())
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of MatchedFunction from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ # set to None if mangled_name (nullable) is None
80
+ # and model_fields_set contains the field
81
+ if self.mangled_name is None and "mangled_name" in self.model_fields_set:
82
+ _dict['mangled_name'] = None
83
+
84
+ # set to None if similarity (nullable) is None
85
+ # and model_fields_set contains the field
86
+ if self.similarity is None and "similarity" in self.model_fields_set:
87
+ _dict['similarity'] = None
88
+
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of MatchedFunction from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj)
99
+
100
+ _obj = cls.model_validate({
101
+ "function_id": obj.get("function_id"),
102
+ "binary_id": obj.get("binary_id"),
103
+ "function_name": obj.get("function_name"),
104
+ "function_vaddr": obj.get("function_vaddr"),
105
+ "mangled_name": obj.get("mangled_name"),
106
+ "debug": obj.get("debug"),
107
+ "binary_name": obj.get("binary_name"),
108
+ "sha_256_hash": obj.get("sha_256_hash"),
109
+ "analysis_id": obj.get("analysis_id"),
110
+ "similarity": obj.get("similarity")
111
+ })
112
+ return _obj
113
+
114
+