2020re_conf = {
2121 "apikey" : environ .get ("REAI_API_KEY" , "" ),
2222 "host" : environ .get ("REAI_API_HOST" , "https://api.reveng.ai" ),
23- "user_agent" : environ .get ("REAI_USER_AGENT" , "RevEng.AI Toolkit" )
23+ "user_agent" : environ .get ("REAI_USER_AGENT" , "RevEng.AI Toolkit" ),
2424}
2525
2626
@@ -33,8 +33,7 @@ def __init__(self, reason: str, end_point: str = None):
3333
3434 response .reason = reason
3535 response .status_code = 404
36- response ._content = b'{"success": false, "error": "' + \
37- reason .encode () + b'"}'
36+ response ._content = b'{"success": false, "error": "' + reason .encode () + b'"}'
3837 response .url = (
3938 f"{ re_conf ['host' ]} /{ end_point if end_point [0 ] != '/' else end_point [1 :]} "
4039 if end_point
@@ -247,7 +246,7 @@ def RE_analyse(
247246 skip_scraping : bool = False ,
248247 skip_capabilities : bool = False ,
249248 skip_sbom : bool = False ,
250- advanced_analysis : bool = False
249+ advanced_analysis : bool = False ,
251250) -> Response :
252251 """
253252 Start analysis job for binary file
@@ -309,7 +308,8 @@ def RE_analyse(
309308 "skip_scraping" ,
310309 "skip_capabilities" ,
311310 "skip_sbom" ,
312- "advanced_analysis"
311+ "advanced_analysis" ,
312+ "skip_cves" ,
313313 ):
314314 p_value = locals ()[p_name ]
315315
@@ -323,8 +323,7 @@ def RE_analyse(
323323 )
324324 elif res .status_code == 400 :
325325 if "error" in res .json ().keys ():
326- logger .warning ("Error analysing %s - %s" ,
327- fpath , res .json ()["error" ])
326+ logger .warning ("Error analysing %s - %s" , fpath , res .json ()["error" ])
328327
329328 res .raise_for_status ()
330329 return res
@@ -338,17 +337,15 @@ def RE_upload(fpath: str) -> Response:
338337 bin_id = re_binary_id (fpath )
339338
340339 with open (fpath , "rb" ) as fd :
341- res : Response = reveng_req (
342- requests .post , "v1/upload" , files = {"file" : fd })
340+ res : Response = reveng_req (requests .post , "v1/upload" , files = {"file" : fd })
343341
344342 if res .ok :
345343 logger .info (
346344 "Successfully uploaded binary to your account. %s - %s" , fpath , bin_id
347345 )
348346 elif res .status_code == 400 :
349347 if "error" in res .json ().keys ():
350- logger .warning ("Error uploading %s - %s" ,
351- fpath , res .json ()["error" ])
348+ logger .warning ("Error uploading %s - %s" , fpath , res .json ()["error" ])
352349 elif res .status_code == 413 :
353350 logger .warning ("File too large. Please upload files under 10MB." )
354351 elif res .status_code == 500 :
@@ -531,8 +528,7 @@ def RE_nearest_symbols_batch(
531528 if binaries :
532529 params ["binaries_search_list" ] = binaries
533530
534- res : Response = reveng_req (
535- requests .post , "v1/ann/symbol/batch" , json_data = params )
531+ res : Response = reveng_req (requests .post , "v1/ann/symbol/batch" , json_data = params )
536532
537533 res .raise_for_status ()
538534 return res
@@ -653,11 +649,9 @@ def RE_functions_rename(function_id: int, new_name: str) -> Response:
653649 )
654650
655651 if res .ok :
656- logger .info ("FunctionId %d has been renamed with '%s'." ,
657- function_id , new_name )
652+ logger .info ("FunctionId %d has been renamed with '%s'." , function_id , new_name )
658653 else :
659- logger .warning ("Error, cannot rename FunctionId %d. %s" ,
660- function_id , res .text )
654+ logger .warning ("Error, cannot rename FunctionId %d. %s" , function_id , res .text )
661655
662656 res .raise_for_status ()
663657 return res
@@ -742,9 +736,7 @@ def RE_functions_list(
742736 params ["max_v_address" ] = max_v_address
743737
744738 res : Response = reveng_req (
745- requests .get ,
746- f"/v2/analyses/{ analysis_id } /functions/list" ,
747- params = params
739+ requests .get , f"/v2/analyses/{ analysis_id } /functions/list" , params = params
748740 )
749741
750742 res .raise_for_status ()
@@ -757,8 +749,7 @@ def RE_function_callers_callees(function: int) -> Response:
757749 Get the callers and callees of a functions
758750 :param function: Function ID
759751 """
760- res : Response = reveng_req (
761- requests .get , f"v2/functions/{ function } /callees_callers" )
752+ res : Response = reveng_req (requests .get , f"v2/functions/{ function } /callees_callers" )
762753
763754 res .raise_for_status ()
764755 return res
@@ -769,8 +760,7 @@ def RE_analysis_info(analysis_id: int) -> Response:
769760 Get the analysis information
770761 :param analysis_id: Analysis ID
771762 """
772- res : Response = reveng_req (
773- requests .get , f"v2/analyses/{ analysis_id } /info/basic" )
763+ res : Response = reveng_req (requests .get , f"v2/analyses/{ analysis_id } /info/basic" )
774764
775765 res .raise_for_status ()
776766 return res
@@ -851,12 +841,10 @@ def _binary_format(binary: Binary) -> str:
851841 return "Mach-O"
852842
853843 logger .error (
854- "Error, could not determine or unsupported"
855- f" binary format: { binary .format } ."
844+ "Error, could not determine or unsupported" f" binary format: { binary .format } ."
856845 )
857846 raise RuntimeError (
858- "Error, could not determine or "
859- f"unsupported binary format: { binary .format } "
847+ "Error, could not determine or " f"unsupported binary format: { binary .format } "
860848 )
861849
862850
@@ -952,10 +940,7 @@ def RE_functions_data_types_poll(
952940 return res
953941
954942
955- def RE_generate_data_types (
956- analysis_id : int ,
957- function_ids : list [int ]
958- ) -> Response :
943+ def RE_generate_data_types (analysis_id : int , function_ids : list [int ]) -> Response :
959944 """
960945 Generate data types for the analysis
961946 :param aid: Analysis ID
@@ -1015,10 +1000,7 @@ def RE_begin_ai_decompilation(function_id: int) -> Response:
10151000 return res
10161001
10171002
1018- def RE_poll_ai_decompilation (
1019- function_id : int ,
1020- summarise : bool = False
1021- ) -> Response :
1003+ def RE_poll_ai_decompilation (function_id : int , summarise : bool = False ) -> Response :
10221004 """
10231005 Poll AI decompilation for the function
10241006 :param function_id: Function ID
@@ -1051,9 +1033,9 @@ def RE_analysis_lookup(binary_id: int) -> Response:
10511033
10521034
10531035def RE_collections_search (
1054- page : int = 1 ,
1055- page_size : int = 10 ,
1056- query : dict = {},
1036+ page : int = 1 ,
1037+ page_size : int = 10 ,
1038+ query : dict = {},
10571039) -> Response :
10581040 """
10591041 Search for collections in the database
@@ -1093,9 +1075,9 @@ def exist_and_populated(key: str) -> bool:
10931075
10941076
10951077def RE_binaries_search (
1096- page : int = 1 ,
1097- page_size : int = 10 ,
1098- query : dict = {},
1078+ page : int = 1 ,
1079+ page_size : int = 10 ,
1080+ query : dict = {},
10991081) -> Response :
11001082 """
11011083 Search for binaries in the database
@@ -1313,35 +1295,47 @@ def RE_binary_ann(
13131295 res .raise_for_status ()
13141296 return res
13151297
1316- def RE_name_score (
1317- functions : list ,
1318- is_debug : bool = False
1319- ) -> Response :
13201298
1321- body = {
1322- "functions" : functions ,
1323- "is_debug" : is_debug
1324- }
1325- res : Response = reveng_req (requests .post , "v2/confidence/functions/name_score" , json_data = body )
1299+ def RE_name_score (functions : list , is_debug : bool = False ) -> Response :
1300+
1301+ body = {"functions" : functions , "is_debug" : is_debug }
1302+ res : Response = reveng_req (
1303+ requests .post , "v2/confidence/functions/name_score" , json_data = body
1304+ )
13261305
13271306 res .raise_for_status ()
13281307 return res
13291308
13301309
1331- def RE_get_analysis_id_from_binary_id (
1332- binary_id : int
1333- ) -> Response :
1310+ def RE_get_analysis_id_from_binary_id (binary_id : int ) -> Response :
13341311
13351312 res : Response = reveng_req (requests .get , f"v2/analyses/lookup/{ binary_id } " )
13361313
13371314 res .raise_for_status ()
13381315 return res
13391316
1340- def RE_get_functions_from_analysis (
1341- analysis_id : int
1342- ) -> Response :
13431317
1344- res : Response = reveng_req (requests .get , f"v2/analyses/{ analysis_id } /functions/list" )
1318+ def RE_get_functions_from_analysis (analysis_id : int ) -> Response :
1319+
1320+ res : Response = reveng_req (
1321+ requests .get , f"v2/analyses/{ analysis_id } /functions/list"
1322+ )
1323+
1324+ res .raise_for_status ()
1325+ return res
1326+
1327+
1328+ def RE_update_collection_description (
1329+ collection_id : int ,
1330+ description : str = "" ,
1331+ ):
1332+ params = {
1333+ "description" : description ,
1334+ }
1335+
1336+ res : Response = reveng_req (
1337+ requests .patch , f"v2/collections/{ collection_id } " , json_data = params
1338+ )
13451339
13461340 res .raise_for_status ()
13471341 return res
0 commit comments