reait 1.2.2__py3-none-any.whl → 1.2.4__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.
reait/api.py CHANGED
@@ -15,11 +15,12 @@ from pandas import DataFrame
15
15
  from requests import request, Response, HTTPError
16
16
  from sklearn.metrics.pairwise import cosine_similarity
17
17
 
18
- __version__ = "1.2.2"
18
+ __version__ = "1.2.4"
19
19
 
20
20
  re_conf = {
21
21
  "apikey": environ.get("REAI_API_KEY", ""),
22
22
  "host": environ.get("REAI_API_HOST", "https://api.reveng.ai"),
23
+ "user_agent": environ.get("REAI_USER_AGENT", "RevEng.AI Toolkit"),
23
24
  }
24
25
 
25
26
 
@@ -65,7 +66,8 @@ def reveng_req(
65
66
  :param files: Dictionary of files to send to the specified URL
66
67
  """
67
68
  url = f"{re_conf['host']}/{end_point if end_point[0] != '/' else end_point[1:]}"
68
- headers = {"Authorization": re_conf["apikey"]}
69
+ headers = {"Authorization": re_conf["apikey"],
70
+ "User-Agent": re_conf["user_agent"]}
69
71
 
70
72
  if ex_headers:
71
73
  headers.update(ex_headers)
@@ -246,7 +248,8 @@ def RE_analyse(
246
248
  skip_scraping: bool = False,
247
249
  skip_capabilities: bool = False,
248
250
  skip_sbom: bool = False,
249
- advanced_analysis: bool = False
251
+ advanced_analysis: bool = False,
252
+ skip_cves: bool = False,
250
253
  ) -> Response:
251
254
  """
252
255
  Start analysis job for binary file
@@ -308,7 +311,8 @@ def RE_analyse(
308
311
  "skip_scraping",
309
312
  "skip_capabilities",
310
313
  "skip_sbom",
311
- "advanced_analysis"
314
+ "advanced_analysis",
315
+ "skip_cves",
312
316
  ):
313
317
  p_value = locals()[p_name]
314
318
 
@@ -741,9 +745,7 @@ def RE_functions_list(
741
745
  params["max_v_address"] = max_v_address
742
746
 
743
747
  res: Response = reveng_req(
744
- requests.get,
745
- f"/v2/analyses/{analysis_id}/functions/list",
746
- params=params
748
+ requests.get, f"/v2/analyses/{analysis_id}/functions/list", params=params
747
749
  )
748
750
 
749
751
  res.raise_for_status()
@@ -850,12 +852,10 @@ def _binary_format(binary: Binary) -> str:
850
852
  return "Mach-O"
851
853
 
852
854
  logger.error(
853
- "Error, could not determine or unsupported"
854
- f" binary format: {binary.format}."
855
+ "Error, could not determine or unsupported" f" binary format: {binary.format}."
855
856
  )
856
857
  raise RuntimeError(
857
- "Error, could not determine or "
858
- f"unsupported binary format: {binary.format}"
858
+ "Error, could not determine or " f"unsupported binary format: {binary.format}"
859
859
  )
860
860
 
861
861
 
@@ -951,10 +951,7 @@ def RE_functions_data_types_poll(
951
951
  return res
952
952
 
953
953
 
954
- def RE_generate_data_types(
955
- analysis_id: int,
956
- function_ids: list[int]
957
- ) -> Response:
954
+ def RE_generate_data_types(analysis_id: int, function_ids: list[int]) -> Response:
958
955
  """
959
956
  Generate data types for the analysis
960
957
  :param aid: Analysis ID
@@ -1014,10 +1011,7 @@ def RE_begin_ai_decompilation(function_id: int) -> Response:
1014
1011
  return res
1015
1012
 
1016
1013
 
1017
- def RE_poll_ai_decompilation(
1018
- function_id: int,
1019
- summarise: bool = False
1020
- ) -> Response:
1014
+ def RE_poll_ai_decompilation(function_id: int, summarise: bool = False) -> Response:
1021
1015
  """
1022
1016
  Poll AI decompilation for the function
1023
1017
  :param function_id: Function ID
@@ -1050,9 +1044,9 @@ def RE_analysis_lookup(binary_id: int) -> Response:
1050
1044
 
1051
1045
 
1052
1046
  def RE_collections_search(
1053
- page: int = 1,
1054
- page_size: int = 10,
1055
- query: dict = {},
1047
+ page: int = 1,
1048
+ page_size: int = 10,
1049
+ query: dict = {},
1056
1050
  ) -> Response:
1057
1051
  """
1058
1052
  Search for collections in the database
@@ -1092,9 +1086,9 @@ def RE_collections_search(
1092
1086
 
1093
1087
 
1094
1088
  def RE_binaries_search(
1095
- page: int = 1,
1096
- page_size: int = 10,
1097
- query: dict = {},
1089
+ page: int = 1,
1090
+ page_size: int = 10,
1091
+ query: dict = {},
1098
1092
  ) -> Response:
1099
1093
  """
1100
1094
  Search for binaries in the database
@@ -1253,6 +1247,40 @@ def RE_recent_analysis(
1253
1247
  return res
1254
1248
 
1255
1249
 
1250
+ def RE_recent_analysis_v2(
1251
+ search: str = "",
1252
+ workspace: str = "personal",
1253
+ status: str = "All",
1254
+ users: list[str] = [],
1255
+ limit: int = 50
1256
+ ) -> Response:
1257
+ """
1258
+ Get recent analysis using the v2 API
1259
+ :param status: Status of the analysis (default: "All")
1260
+ :param scope: Scope of the analysis (default: "ALL")
1261
+ :param nb_analysis: Number of analysis to retrieve (default: 50)
1262
+ """
1263
+ res: Response = reveng_req(
1264
+ requests.get,
1265
+ "/v2/analyses/list",
1266
+ params={
1267
+ "search_term": search, "status": status, "workspace": workspace,
1268
+ "limit": limit, "usernames": users},
1269
+ )
1270
+
1271
+ res.raise_for_status()
1272
+ return res
1273
+
1274
+
1275
+ def RE_users_me() -> Response:
1276
+ """
1277
+ Get the current user's information
1278
+ """
1279
+ res: Response = reveng_req(requests.get, "/v2/users/me")
1280
+ res.raise_for_status()
1281
+ return res
1282
+
1283
+
1256
1284
  def RE_search(fpath: str) -> Response:
1257
1285
  bin_id = re_binary_id(fpath)
1258
1286
 
@@ -1311,3 +1339,48 @@ def RE_binary_ann(
1311
1339
  res: Response = reveng_req(requests.post, end_point, json_data=json_data)
1312
1340
  res.raise_for_status()
1313
1341
  return res
1342
+
1343
+
1344
+ def RE_name_score(functions: list, is_debug: bool = False) -> Response:
1345
+
1346
+ body = {"functions": functions, "is_debug": is_debug}
1347
+ res: Response = reveng_req(
1348
+ requests.post, "v2/confidence/functions/name_score", json_data=body
1349
+ )
1350
+
1351
+ res.raise_for_status()
1352
+ return res
1353
+
1354
+
1355
+ def RE_get_analysis_id_from_binary_id(binary_id: int) -> Response:
1356
+
1357
+ res: Response = reveng_req(requests.get, f"v2/analyses/lookup/{binary_id}")
1358
+
1359
+ res.raise_for_status()
1360
+ return res
1361
+
1362
+
1363
+ def RE_get_functions_from_analysis(analysis_id: int) -> Response:
1364
+
1365
+ res: Response = reveng_req(
1366
+ requests.get, f"v2/analyses/{analysis_id}/functions/list"
1367
+ )
1368
+
1369
+ res.raise_for_status()
1370
+ return res
1371
+
1372
+
1373
+ def RE_update_collection_description(
1374
+ collection_id: int,
1375
+ description: str = "",
1376
+ ):
1377
+ params = {
1378
+ "description": description,
1379
+ }
1380
+
1381
+ res: Response = reveng_req(
1382
+ requests.patch, f"v2/collections/{collection_id}", json_data=params
1383
+ )
1384
+
1385
+ res.raise_for_status()
1386
+ return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reait
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: RevEng.AI Toolkit and Python API
5
5
  Home-page: https://github.com/RevEng-AI/reait
6
6
  Author: James Patrick-Evans
@@ -0,0 +1,9 @@
1
+ reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
2
+ reait/api.py,sha256=Z0oiFjAsMKs2eJYiLs5QzvcaDOvhQefRF4M0OyiZSbU,38901
3
+ reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
4
+ reait-1.2.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
5
+ reait-1.2.4.dist-info/METADATA,sha256=VQf4xvWntdaXTsvwdZGqqszlvX_YutOzTOLvvqkA0ig,47663
6
+ reait-1.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ reait-1.2.4.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
8
+ reait-1.2.4.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
9
+ reait-1.2.4.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
2
- reait/api.py,sha256=10D3tITkhQN1mb04hHpgJgq26cii9gpzD2B3jcSxFQ0,36915
3
- reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
4
- reait-1.2.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
5
- reait-1.2.2.dist-info/METADATA,sha256=WOJrwIHV2HD6zY_g5AyL1i7JJ2knoOM42MNJ6TXAIww,47663
6
- reait-1.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- reait-1.2.2.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
8
- reait-1.2.2.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
9
- reait-1.2.2.dist-info/RECORD,,
File without changes