reait 1.1.0__py3-none-any.whl → 1.1.1__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 +54 -22
- {reait-1.1.0.dist-info → reait-1.1.1.dist-info}/METADATA +1 -1
- reait-1.1.1.dist-info/RECORD +9 -0
- reait-1.1.0.dist-info/RECORD +0 -9
- {reait-1.1.0.dist-info → reait-1.1.1.dist-info}/WHEEL +0 -0
- {reait-1.1.0.dist-info → reait-1.1.1.dist-info}/entry_points.txt +0 -0
- {reait-1.1.0.dist-info → reait-1.1.1.dist-info}/licenses/LICENSE +0 -0
- {reait-1.1.0.dist-info → reait-1.1.1.dist-info}/top_level.txt +0 -0
    
        reait/api.py
    CHANGED
    
    | @@ -15,7 +15,7 @@ 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.1. | 
| 18 | 
            +
            __version__ = "1.1.1"
         | 
| 19 19 |  | 
| 20 20 | 
             
            re_conf = {
         | 
| 21 21 | 
             
                "apikey": environ.get("REAI_API_KEY", ""),
         | 
| @@ -32,7 +32,8 @@ class ReaitError(HTTPError): | |
| 32 32 |  | 
| 33 33 | 
             
                    response.reason = reason
         | 
| 34 34 | 
             
                    response.status_code = 404
         | 
| 35 | 
            -
                    response._content = b'{"success": false, "error": "' +  | 
| 35 | 
            +
                    response._content = b'{"success": false, "error": "' + \
         | 
| 36 | 
            +
                        reason.encode() + b'"}'
         | 
| 36 37 | 
             
                    response.url = (
         | 
| 37 38 | 
             
                        f"{re_conf['host']}/{end_point if end_point[0] != '/' else end_point[1:]}"
         | 
| 38 39 | 
             
                        if end_point
         | 
| @@ -243,6 +244,9 @@ def RE_analyse( | |
| 243 244 | 
             
                symbols: dict = None,
         | 
| 244 245 | 
             
                debug_fpath: str = None,
         | 
| 245 246 | 
             
                skip_scraping: bool = False,
         | 
| 247 | 
            +
                skip_capabilities: bool = False,
         | 
| 248 | 
            +
                skip_sbom: bool = False,
         | 
| 249 | 
            +
                advanced_analysis: bool = False
         | 
| 246 250 | 
             
            ) -> Response:
         | 
| 247 251 | 
             
                """
         | 
| 248 252 | 
             
                Start analysis job for binary file
         | 
| @@ -302,6 +306,9 @@ def RE_analyse( | |
| 302 306 | 
             
                    "priority",
         | 
| 303 307 | 
             
                    "symbols",
         | 
| 304 308 | 
             
                    "skip_scraping",
         | 
| 309 | 
            +
                    "skip_capabilities",
         | 
| 310 | 
            +
                    "skip_sbom",
         | 
| 311 | 
            +
                    "advanced_analysis"
         | 
| 305 312 | 
             
                ):
         | 
| 306 313 | 
             
                    p_value = locals()[p_name]
         | 
| 307 314 |  | 
| @@ -315,7 +322,8 @@ def RE_analyse( | |
| 315 322 | 
             
                    )
         | 
| 316 323 | 
             
                elif res.status_code == 400:
         | 
| 317 324 | 
             
                    if "error" in res.json().keys():
         | 
| 318 | 
            -
                        logger.warning("Error analysing %s - %s", | 
| 325 | 
            +
                        logger.warning("Error analysing %s - %s",
         | 
| 326 | 
            +
                                       fpath, res.json()["error"])
         | 
| 319 327 |  | 
| 320 328 | 
             
                res.raise_for_status()
         | 
| 321 329 | 
             
                return res
         | 
| @@ -330,7 +338,8 @@ def RE_upload(fpath: str) -> Response: | |
| 330 338 | 
             
                result = re_hash_check(bin_id)
         | 
| 331 339 |  | 
| 332 340 | 
             
                if result:
         | 
| 333 | 
            -
                    logger.info( | 
| 341 | 
            +
                    logger.info(
         | 
| 342 | 
            +
                        "File %s - %s already uploaded. Skipping upload...", fpath, bin_id)
         | 
| 334 343 |  | 
| 335 344 | 
             
                    res = Response()
         | 
| 336 345 | 
             
                    res.status_code = 200
         | 
| @@ -346,7 +355,8 @@ def RE_upload(fpath: str) -> Response: | |
| 346 355 | 
             
                    )
         | 
| 347 356 | 
             
                else:
         | 
| 348 357 | 
             
                    with open(fpath, "rb") as fd:
         | 
| 349 | 
            -
                        res: Response = reveng_req( | 
| 358 | 
            +
                        res: Response = reveng_req(
         | 
| 359 | 
            +
                            requests.post, "v1/upload", files={"file": fd})
         | 
| 350 360 |  | 
| 351 361 | 
             
                    if res.ok:
         | 
| 352 362 | 
             
                        logger.info(
         | 
| @@ -354,7 +364,8 @@ def RE_upload(fpath: str) -> Response: | |
| 354 364 | 
             
                        )
         | 
| 355 365 | 
             
                    elif res.status_code == 400:
         | 
| 356 366 | 
             
                        if "error" in res.json().keys():
         | 
| 357 | 
            -
                            logger.warning("Error uploading %s - %s", | 
| 367 | 
            +
                            logger.warning("Error uploading %s - %s",
         | 
| 368 | 
            +
                                           fpath, res.json()["error"])
         | 
| 358 369 | 
             
                    elif res.status_code == 413:
         | 
| 359 370 | 
             
                        logger.warning("File too large. Please upload files under 10MB.")
         | 
| 360 371 | 
             
                    elif res.status_code == 500:
         | 
| @@ -511,7 +522,8 @@ def RE_compute_distance(embedding: list, embeddings: list, nns: int = 5) -> list | |
| 511 522 | 
             
            def RE_nearest_symbols_batch(
         | 
| 512 523 | 
             
                function_ids: list[int],
         | 
| 513 524 | 
             
                nns: int = 5,
         | 
| 514 | 
            -
                collections: list[ | 
| 525 | 
            +
                collections: list[int] = None,
         | 
| 526 | 
            +
                binaries: list[int] = None,
         | 
| 515 527 | 
             
                distance: float = 0.1,
         | 
| 516 528 | 
             
                debug_enabled: bool = False,
         | 
| 517 529 | 
             
            ) -> Response:
         | 
| @@ -531,10 +543,13 @@ def RE_nearest_symbols_batch( | |
| 531 543 | 
             
                }
         | 
| 532 544 |  | 
| 533 545 | 
             
                if collections:
         | 
| 534 | 
            -
                     | 
| 535 | 
            -
             | 
| 546 | 
            +
                    params["collection_search_list"] = collections
         | 
| 547 | 
            +
             | 
| 548 | 
            +
                if binaries:
         | 
| 549 | 
            +
                    params["binaries_search_list"] = binaries
         | 
| 536 550 |  | 
| 537 | 
            -
                res: Response = reveng_req( | 
| 551 | 
            +
                res: Response = reveng_req(
         | 
| 552 | 
            +
                    requests.post, "v1/ann/symbol/batch", json_data=params)
         | 
| 538 553 |  | 
| 539 554 | 
             
                res.raise_for_status()
         | 
| 540 555 | 
             
                return res
         | 
| @@ -655,9 +670,11 @@ def RE_functions_rename(function_id: int, new_name: str) -> Response: | |
| 655 670 | 
             
                )
         | 
| 656 671 |  | 
| 657 672 | 
             
                if res.ok:
         | 
| 658 | 
            -
                    logger.info("FunctionId %d has been renamed with '%s'.", | 
| 673 | 
            +
                    logger.info("FunctionId %d has been renamed with '%s'.",
         | 
| 674 | 
            +
                                function_id, new_name)
         | 
| 659 675 | 
             
                else:
         | 
| 660 | 
            -
                    logger.warning("Error, cannot rename FunctionId %d. %s", | 
| 676 | 
            +
                    logger.warning("Error, cannot rename FunctionId %d. %s",
         | 
| 677 | 
            +
                                   function_id, res.text)
         | 
| 661 678 |  | 
| 662 679 | 
             
                res.raise_for_status()
         | 
| 663 680 | 
             
                return res
         | 
| @@ -755,7 +772,8 @@ def RE_function_callers_callees(function: int) -> Response: | |
| 755 772 | 
             
                Get the callers and callees of a functions
         | 
| 756 773 | 
             
                :param function: Function ID
         | 
| 757 774 | 
             
                """
         | 
| 758 | 
            -
                res: Response = reveng_req( | 
| 775 | 
            +
                res: Response = reveng_req(
         | 
| 776 | 
            +
                    requests.get, f"v2/functions/{function}/callees_callers")
         | 
| 759 777 |  | 
| 760 778 | 
             
                res.raise_for_status()
         | 
| 761 779 | 
             
                return res
         | 
| @@ -766,7 +784,8 @@ def RE_analysis_info(analysis_id: int) -> Response: | |
| 766 784 | 
             
                Get the analysis information
         | 
| 767 785 | 
             
                :param analysis_id: Analysis ID
         | 
| 768 786 | 
             
                """
         | 
| 769 | 
            -
                res: Response = reveng_req( | 
| 787 | 
            +
                res: Response = reveng_req(
         | 
| 788 | 
            +
                    requests.get, f"v2/analyses/{analysis_id}/info/basic")
         | 
| 770 789 |  | 
| 771 790 | 
             
                res.raise_for_status()
         | 
| 772 791 | 
             
                return res
         | 
| @@ -919,7 +938,7 @@ def RE_generate_data_types(analysis_id: int, function_ids: list[int]) -> Respons | |
| 919 938 | 
             
                Generate data types for the analysis
         | 
| 920 939 | 
             
                :param aid: Analysis ID
         | 
| 921 940 | 
             
                """
         | 
| 922 | 
            -
                end_point = f"/v2/analyses/{analysis_id}/ | 
| 941 | 
            +
                end_point = f"/v2/analyses/{analysis_id}/functions/data_types"
         | 
| 923 942 |  | 
| 924 943 | 
             
                res: Response = reveng_req(
         | 
| 925 944 | 
             
                    requests.post, end_point, json_data={"function_ids": function_ids}
         | 
| @@ -934,7 +953,7 @@ def RE_list_data_types(analysis_id: int, function_ids: list[int]) -> Response: | |
| 934 953 | 
             
                :param aid: Analysis ID
         | 
| 935 954 | 
             
                :param function_ids: List of function IDs
         | 
| 936 955 | 
             
                """
         | 
| 937 | 
            -
                end_point = f"/v2/analyses/{analysis_id}/ | 
| 956 | 
            +
                end_point = f"/v2/analyses/{analysis_id}/functions/data_types"
         | 
| 938 957 |  | 
| 939 958 | 
             
                res: Response = reveng_req(
         | 
| 940 959 | 
             
                    requests.get, end_point, json_data={"function_ids": function_ids}
         | 
| @@ -988,11 +1007,7 @@ def RE_analysis_lookup(binary_id: int) -> Response: | |
| 988 1007 | 
             
            def RE_collections_search(
         | 
| 989 1008 | 
             
                    page: int = 1,
         | 
| 990 1009 | 
             
                    page_size: int = 10,
         | 
| 991 | 
            -
                     | 
| 992 | 
            -
                    partial_binary_name: str = "",
         | 
| 993 | 
            -
                    partial_binary_sha256: str = "",
         | 
| 994 | 
            -
                    tags: list[str] | str = "",
         | 
| 995 | 
            -
                    model_name: str = "",
         | 
| 1010 | 
            +
                    search: str = "",
         | 
| 996 1011 | 
             
            ) -> Response:
         | 
| 997 1012 | 
             
                """
         | 
| 998 1013 | 
             
                """
         | 
| @@ -1000,7 +1015,24 @@ def RE_collections_search( | |
| 1000 1015 | 
             
                res: Response = reveng_req(requests.get, end_point, params={
         | 
| 1001 1016 | 
             
                    "page": page,
         | 
| 1002 1017 | 
             
                    "page_size": page_size,
         | 
| 1003 | 
            -
                    "partial_collection_name":  | 
| 1018 | 
            +
                    "partial_collection_name": search,
         | 
| 1019 | 
            +
                })
         | 
| 1020 | 
            +
                res.raise_for_status()
         | 
| 1021 | 
            +
                return res
         | 
| 1022 | 
            +
             | 
| 1023 | 
            +
             | 
| 1024 | 
            +
            def RE_binaries_search(
         | 
| 1025 | 
            +
                    page: int = 1,
         | 
| 1026 | 
            +
                    page_size: int = 10,
         | 
| 1027 | 
            +
                    search: str = "",
         | 
| 1028 | 
            +
            ) -> Response:
         | 
| 1029 | 
            +
                """
         | 
| 1030 | 
            +
                """
         | 
| 1031 | 
            +
                end_point = "/v2/search/binaries"
         | 
| 1032 | 
            +
                res: Response = reveng_req(requests.get, end_point, params={
         | 
| 1033 | 
            +
                    "page": page,
         | 
| 1034 | 
            +
                    "page_size": page_size,
         | 
| 1035 | 
            +
                    "partial_name": search,
         | 
| 1004 1036 | 
             
                })
         | 
| 1005 1037 | 
             
                res.raise_for_status()
         | 
| 1006 1038 | 
             
                return res
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
         | 
| 2 | 
            +
            reait/api.py,sha256=53rj5CxPSAvggPalFS3nF8OH5F15eVpDoKW-EkrnSqU,33724
         | 
| 3 | 
            +
            reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
         | 
| 4 | 
            +
            reait-1.1.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
         | 
| 5 | 
            +
            reait-1.1.1.dist-info/METADATA,sha256=hPJLcJOT1HKNAUyvJWnIC2ZgtWUD61IlO8-M25r3Nxg,47663
         | 
| 6 | 
            +
            reait-1.1.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
         | 
| 7 | 
            +
            reait-1.1.1.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
         | 
| 8 | 
            +
            reait-1.1.1.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
         | 
| 9 | 
            +
            reait-1.1.1.dist-info/RECORD,,
         | 
    
        reait-1.1.0.dist-info/RECORD
    DELETED
    
    | @@ -1,9 +0,0 @@ | |
| 1 | 
            -
            reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
         | 
| 2 | 
            -
            reait/api.py,sha256=gYF4K9fns47bkIUu9_ZV1glRBqEP-J1OaIn99prRugE,33128
         | 
| 3 | 
            -
            reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
         | 
| 4 | 
            -
            reait-1.1.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
         | 
| 5 | 
            -
            reait-1.1.0.dist-info/METADATA,sha256=ULUT4H4-BSwIOVl9_cn51PwU7D_2U7qnlgT6nWAEjG0,47663
         | 
| 6 | 
            -
            reait-1.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
         | 
| 7 | 
            -
            reait-1.1.0.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
         | 
| 8 | 
            -
            reait-1.1.0.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
         | 
| 9 | 
            -
            reait-1.1.0.dist-info/RECORD,,
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |