reait 1.2.1__py3-none-any.whl → 1.2.3__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 +141 -59
- {reait-1.2.1.dist-info → reait-1.2.3.dist-info}/METADATA +1 -1
- reait-1.2.3.dist-info/RECORD +9 -0
- {reait-1.2.1.dist-info → reait-1.2.3.dist-info}/WHEEL +1 -1
- reait-1.2.1.dist-info/RECORD +0 -9
- {reait-1.2.1.dist-info → reait-1.2.3.dist-info}/entry_points.txt +0 -0
- {reait-1.2.1.dist-info → reait-1.2.3.dist-info}/licenses/LICENSE +0 -0
- {reait-1.2.1.dist-info → reait-1.2.3.dist-info}/top_level.txt +0 -0
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.
|
18
|
+
__version__ = "1.2.3"
|
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,7 @@ 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,
|
250
252
|
) -> Response:
|
251
253
|
"""
|
252
254
|
Start analysis job for binary file
|
@@ -308,7 +310,8 @@ def RE_analyse(
|
|
308
310
|
"skip_scraping",
|
309
311
|
"skip_capabilities",
|
310
312
|
"skip_sbom",
|
311
|
-
"advanced_analysis"
|
313
|
+
"advanced_analysis",
|
314
|
+
"skip_cves",
|
312
315
|
):
|
313
316
|
p_value = locals()[p_name]
|
314
317
|
|
@@ -335,43 +338,25 @@ def RE_upload(fpath: str) -> Response:
|
|
335
338
|
:param fpath: File path for binary to analyse
|
336
339
|
"""
|
337
340
|
bin_id = re_binary_id(fpath)
|
338
|
-
result = re_hash_check(bin_id)
|
339
341
|
|
340
|
-
|
342
|
+
with open(fpath, "rb") as fd:
|
343
|
+
res: Response = reveng_req(
|
344
|
+
requests.post, "v1/upload", files={"file": fd})
|
345
|
+
|
346
|
+
if res.ok:
|
341
347
|
logger.info(
|
342
|
-
"
|
343
|
-
|
344
|
-
|
345
|
-
res.
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
.format("{", bin_id, "}")
|
354
|
-
.encode()
|
348
|
+
"Successfully uploaded binary to your account. %s - %s", fpath, bin_id
|
349
|
+
)
|
350
|
+
elif res.status_code == 400:
|
351
|
+
if "error" in res.json().keys():
|
352
|
+
logger.warning("Error uploading %s - %s",
|
353
|
+
fpath, res.json()["error"])
|
354
|
+
elif res.status_code == 413:
|
355
|
+
logger.warning("File too large. Please upload files under 10MB.")
|
356
|
+
elif res.status_code == 500:
|
357
|
+
logger.error(
|
358
|
+
"Internal Server Error. Please contact support. Skipping upload..."
|
355
359
|
)
|
356
|
-
else:
|
357
|
-
with open(fpath, "rb") as fd:
|
358
|
-
res: Response = reveng_req(
|
359
|
-
requests.post, "v1/upload", files={"file": fd})
|
360
|
-
|
361
|
-
if res.ok:
|
362
|
-
logger.info(
|
363
|
-
"Successfully uploaded binary to your account. %s - %s", fpath, bin_id
|
364
|
-
)
|
365
|
-
elif res.status_code == 400:
|
366
|
-
if "error" in res.json().keys():
|
367
|
-
logger.warning("Error uploading %s - %s",
|
368
|
-
fpath, res.json()["error"])
|
369
|
-
elif res.status_code == 413:
|
370
|
-
logger.warning("File too large. Please upload files under 10MB.")
|
371
|
-
elif res.status_code == 500:
|
372
|
-
logger.error(
|
373
|
-
"Internal Server Error. Please contact support. Skipping upload..."
|
374
|
-
)
|
375
360
|
|
376
361
|
res.raise_for_status()
|
377
362
|
return res
|
@@ -759,9 +744,7 @@ def RE_functions_list(
|
|
759
744
|
params["max_v_address"] = max_v_address
|
760
745
|
|
761
746
|
res: Response = reveng_req(
|
762
|
-
requests.get,
|
763
|
-
f"/v2/analyses/{analysis_id}/functions/list",
|
764
|
-
params=params
|
747
|
+
requests.get, f"/v2/analyses/{analysis_id}/functions/list", params=params
|
765
748
|
)
|
766
749
|
|
767
750
|
res.raise_for_status()
|
@@ -868,12 +851,10 @@ def _binary_format(binary: Binary) -> str:
|
|
868
851
|
return "Mach-O"
|
869
852
|
|
870
853
|
logger.error(
|
871
|
-
"Error, could not determine or unsupported"
|
872
|
-
f" binary format: {binary.format}."
|
854
|
+
"Error, could not determine or unsupported" f" binary format: {binary.format}."
|
873
855
|
)
|
874
856
|
raise RuntimeError(
|
875
|
-
"Error, could not determine or "
|
876
|
-
f"unsupported binary format: {binary.format}"
|
857
|
+
"Error, could not determine or " f"unsupported binary format: {binary.format}"
|
877
858
|
)
|
878
859
|
|
879
860
|
|
@@ -969,10 +950,7 @@ def RE_functions_data_types_poll(
|
|
969
950
|
return res
|
970
951
|
|
971
952
|
|
972
|
-
def RE_generate_data_types(
|
973
|
-
analysis_id: int,
|
974
|
-
function_ids: list[int]
|
975
|
-
) -> Response:
|
953
|
+
def RE_generate_data_types(analysis_id: int, function_ids: list[int]) -> Response:
|
976
954
|
"""
|
977
955
|
Generate data types for the analysis
|
978
956
|
:param aid: Analysis ID
|
@@ -1032,10 +1010,7 @@ def RE_begin_ai_decompilation(function_id: int) -> Response:
|
|
1032
1010
|
return res
|
1033
1011
|
|
1034
1012
|
|
1035
|
-
def RE_poll_ai_decompilation(
|
1036
|
-
function_id: int,
|
1037
|
-
summarise: bool = False
|
1038
|
-
) -> Response:
|
1013
|
+
def RE_poll_ai_decompilation(function_id: int, summarise: bool = False) -> Response:
|
1039
1014
|
"""
|
1040
1015
|
Poll AI decompilation for the function
|
1041
1016
|
:param function_id: Function ID
|
@@ -1068,9 +1043,9 @@ def RE_analysis_lookup(binary_id: int) -> Response:
|
|
1068
1043
|
|
1069
1044
|
|
1070
1045
|
def RE_collections_search(
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1046
|
+
page: int = 1,
|
1047
|
+
page_size: int = 10,
|
1048
|
+
query: dict = {},
|
1074
1049
|
) -> Response:
|
1075
1050
|
"""
|
1076
1051
|
Search for collections in the database
|
@@ -1110,9 +1085,9 @@ def RE_collections_search(
|
|
1110
1085
|
|
1111
1086
|
|
1112
1087
|
def RE_binaries_search(
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1088
|
+
page: int = 1,
|
1089
|
+
page_size: int = 10,
|
1090
|
+
query: dict = {},
|
1116
1091
|
) -> Response:
|
1117
1092
|
"""
|
1118
1093
|
Search for binaries in the database
|
@@ -1271,6 +1246,40 @@ def RE_recent_analysis(
|
|
1271
1246
|
return res
|
1272
1247
|
|
1273
1248
|
|
1249
|
+
def RE_recent_analysis_v2(
|
1250
|
+
search: str = "",
|
1251
|
+
workspace: str = "personal",
|
1252
|
+
status: str = "All",
|
1253
|
+
users: list[str] = [],
|
1254
|
+
limit: int = 50
|
1255
|
+
) -> Response:
|
1256
|
+
"""
|
1257
|
+
Get recent analysis using the v2 API
|
1258
|
+
:param status: Status of the analysis (default: "All")
|
1259
|
+
:param scope: Scope of the analysis (default: "ALL")
|
1260
|
+
:param nb_analysis: Number of analysis to retrieve (default: 50)
|
1261
|
+
"""
|
1262
|
+
res: Response = reveng_req(
|
1263
|
+
requests.get,
|
1264
|
+
"/v2/analyses/list",
|
1265
|
+
params={
|
1266
|
+
"search_term": search, "status": status, "workspace": workspace,
|
1267
|
+
"limit": limit, "usernames": users},
|
1268
|
+
)
|
1269
|
+
|
1270
|
+
res.raise_for_status()
|
1271
|
+
return res
|
1272
|
+
|
1273
|
+
|
1274
|
+
def RE_users_me() -> Response:
|
1275
|
+
"""
|
1276
|
+
Get the current user's information
|
1277
|
+
"""
|
1278
|
+
res: Response = reveng_req(requests.get, "/v2/users/me")
|
1279
|
+
res.raise_for_status()
|
1280
|
+
return res
|
1281
|
+
|
1282
|
+
|
1274
1283
|
def RE_search(fpath: str) -> Response:
|
1275
1284
|
bin_id = re_binary_id(fpath)
|
1276
1285
|
|
@@ -1301,3 +1310,76 @@ def RE_similar_functions(
|
|
1301
1310
|
|
1302
1311
|
res.raise_for_status()
|
1303
1312
|
return res
|
1313
|
+
|
1314
|
+
|
1315
|
+
def RE_binary_ann(
|
1316
|
+
analysis_id: int,
|
1317
|
+
confidence: float = 0.0,
|
1318
|
+
nns: int = 1,
|
1319
|
+
collection_ids: list[int] = None,
|
1320
|
+
binary_ids: list[int] = None,
|
1321
|
+
) -> Response:
|
1322
|
+
"""
|
1323
|
+
Perform binary ANN (Approximate Nearest Neighbor) search.
|
1324
|
+
:param analysis_id: Analysis ID
|
1325
|
+
:param confidence: Confidence threshold for the search
|
1326
|
+
:param nns: Number of nearest neighbors to retrieve
|
1327
|
+
:param collection_ids: List of collection IDs to search within
|
1328
|
+
:param binary_ids: List of binary IDs to search within
|
1329
|
+
"""
|
1330
|
+
end_point = f"v2/binary_ann/{analysis_id}"
|
1331
|
+
json_data = {
|
1332
|
+
"confidence": confidence,
|
1333
|
+
"nns": nns,
|
1334
|
+
"collection_ids": collection_ids or [],
|
1335
|
+
"binary_ids": binary_ids or [],
|
1336
|
+
}
|
1337
|
+
|
1338
|
+
res: Response = reveng_req(requests.post, end_point, json_data=json_data)
|
1339
|
+
res.raise_for_status()
|
1340
|
+
return res
|
1341
|
+
|
1342
|
+
|
1343
|
+
def RE_name_score(functions: list, is_debug: bool = False) -> Response:
|
1344
|
+
|
1345
|
+
body = {"functions": functions, "is_debug": is_debug}
|
1346
|
+
res: Response = reveng_req(
|
1347
|
+
requests.post, "v2/confidence/functions/name_score", json_data=body
|
1348
|
+
)
|
1349
|
+
|
1350
|
+
res.raise_for_status()
|
1351
|
+
return res
|
1352
|
+
|
1353
|
+
|
1354
|
+
def RE_get_analysis_id_from_binary_id(binary_id: int) -> Response:
|
1355
|
+
|
1356
|
+
res: Response = reveng_req(requests.get, f"v2/analyses/lookup/{binary_id}")
|
1357
|
+
|
1358
|
+
res.raise_for_status()
|
1359
|
+
return res
|
1360
|
+
|
1361
|
+
|
1362
|
+
def RE_get_functions_from_analysis(analysis_id: int) -> Response:
|
1363
|
+
|
1364
|
+
res: Response = reveng_req(
|
1365
|
+
requests.get, f"v2/analyses/{analysis_id}/functions/list"
|
1366
|
+
)
|
1367
|
+
|
1368
|
+
res.raise_for_status()
|
1369
|
+
return res
|
1370
|
+
|
1371
|
+
|
1372
|
+
def RE_update_collection_description(
|
1373
|
+
collection_id: int,
|
1374
|
+
description: str = "",
|
1375
|
+
):
|
1376
|
+
params = {
|
1377
|
+
"description": description,
|
1378
|
+
}
|
1379
|
+
|
1380
|
+
res: Response = reveng_req(
|
1381
|
+
requests.patch, f"v2/collections/{collection_id}", json_data=params
|
1382
|
+
)
|
1383
|
+
|
1384
|
+
res.raise_for_status()
|
1385
|
+
return res
|
@@ -0,0 +1,9 @@
|
|
1
|
+
reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
|
2
|
+
reait/api.py,sha256=Y7SZVr8d8gTE0y1Y7FVpEJGGzWhFtD00aHTtV7VXM8Q,38872
|
3
|
+
reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
|
4
|
+
reait-1.2.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
5
|
+
reait-1.2.3.dist-info/METADATA,sha256=Ue_-BK0dEm_0kI1O4WlBZeiYsvJJKeUyWA8lrYfmcy4,47663
|
6
|
+
reait-1.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
reait-1.2.3.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
|
8
|
+
reait-1.2.3.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
|
9
|
+
reait-1.2.3.dist-info/RECORD,,
|
reait-1.2.1.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
|
2
|
-
reait/api.py,sha256=ztgJEvd76L_ddN7vLxtCtLY4n3pxddMvu4VP7YA2a1w,36642
|
3
|
-
reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
|
4
|
-
reait-1.2.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
5
|
-
reait-1.2.1.dist-info/METADATA,sha256=Twgqyouwxy3lRCDP1YDAlct5_ltT2sPio0eHg5rX0eA,47663
|
6
|
-
reait-1.2.1.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
7
|
-
reait-1.2.1.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
|
8
|
-
reait-1.2.1.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
|
9
|
-
reait-1.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|