From a2fca7745440ac66974a0026ded6b2cfdb555c22 Mon Sep 17 00:00:00 2001 From: Carl Flottmann Date: Thu, 5 Dec 2024 17:32:48 +1000 Subject: [PATCH] fix: return only inspector links from wheel absence heuristic --- .../pypi_heuristics/metadata/wheel_absence.py | 4 ---- tests/malware_analyzer/pypi/test_wheel_absence.py | 6 ------ 2 files changed, 10 deletions(-) diff --git a/src/macaron/malware_analyzer/pypi_heuristics/metadata/wheel_absence.py b/src/macaron/malware_analyzer/pypi_heuristics/metadata/wheel_absence.py index 827fad945..450093465 100644 --- a/src/macaron/malware_analyzer/pypi_heuristics/metadata/wheel_absence.py +++ b/src/macaron/malware_analyzer/pypi_heuristics/metadata/wheel_absence.py @@ -67,7 +67,6 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes logger.debug(error_msg) raise HeuristicAnalyzerValueError(error_msg) - file_server_links: list[JsonType] = [] inspector_links: list[JsonType] = [] wheel_present: bool = False @@ -91,7 +90,6 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes if send_head_http_raw(inspector_link) is None: inspector_link = None - file_server_links.append(release_metadata["url"]) inspector_links.append(inspector_link) except KeyError as error: @@ -100,8 +98,6 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes raise HeuristicAnalyzerValueError(error_msg) from error detail_info: dict[str, JsonType] = { - "version": version, - "file_server_links": file_server_links, "inspector_links": inspector_links, } diff --git a/tests/malware_analyzer/pypi/test_wheel_absence.py b/tests/malware_analyzer/pypi/test_wheel_absence.py index 79efcf191..76138c336 100644 --- a/tests/malware_analyzer/pypi/test_wheel_absence.py +++ b/tests/malware_analyzer/pypi/test_wheel_absence.py @@ -72,8 +72,6 @@ def test_analyze_tar_present(mock_send_head_http_raw: MagicMock, pypi_package_js mock_send_head_http_raw.return_value = MagicMock() # assume valid URL for testing purposes expected_detail_info = { - "version": version, - "file_server_links": [url], "inspector_links": [inspector_link_expected], } @@ -131,8 +129,6 @@ def test_analyze_whl_present(mock_send_head_http_raw: MagicMock, pypi_package_js mock_send_head_http_raw.return_value = MagicMock() # assume valid URL for testing purposes expected_detail_info = { - "version": version, - "file_server_links": [url], "inspector_links": [inspector_link_expected], } @@ -219,8 +215,6 @@ def test_analyze_both_present(mock_send_head_http_raw: MagicMock, pypi_package_j mock_send_head_http_raw.return_value = MagicMock() # assume valid URL for testing purposes expected_detail_info = { - "version": version, - "file_server_links": [wheel_url, tar_url], "inspector_links": [wheel_link_expected, tar_link_expected], }