Skip to content

Commit 867191c

Browse files
committed
refactor: remove redundant package download
Signed-off-by: Amine <[email protected]>
1 parent 036282b commit 867191c

File tree

2 files changed

+0
-16
lines changed

2 files changed

+0
-16
lines changed

src/macaron/malware_analyzer/pypi_heuristics/metadata/fake_email.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes
7676
HeuristicAnalyzerValueError
7777
if the analysis fails.
7878
"""
79-
response = pypi_package_json.download("")
80-
if not response:
81-
error_message = "Failed to download package JSON "
82-
return HeuristicResult.FAIL, {"message": error_message}
83-
8479
data = pypi_package_json.package_json
8580
author_email = data.get("info", {}).get("author_email", None)
8681
maintainer_email = data.get("info", {}).get("maintainer_email", None)

tests/malware_analyzer/pypi/test_fake_email.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,6 @@ def mock_dns_resolve_fixture() -> Generator[MagicMock]:
4646

4747

4848
# Tests for the analyze method
49-
def test_analyze_download_failure(analyzer: FakeEmailAnalyzer, pypi_package_json_asset_mock: MagicMock) -> None:
50-
"""Test the analyzer fails if downloading package JSON fails."""
51-
pypi_package_json_asset_mock.download.return_value = False
52-
result, info = analyzer.analyze(pypi_package_json_asset_mock)
53-
assert result == HeuristicResult.FAIL
54-
assert "message" in info
55-
assert isinstance(info["message"], str)
56-
assert "Failed to download package JSON" in info["message"]
57-
pypi_package_json_asset_mock.download.assert_called_once_with("")
58-
59-
6049
def test_analyze_skip_no_emails_present(analyzer: FakeEmailAnalyzer, pypi_package_json_asset_mock: MagicMock) -> None:
6150
"""Test the analyzer skips if no author_email or maintainer_email is present."""
6251
pypi_package_json_asset_mock.package_json = {"info": {"author_email": None, "maintainer_email": None}}

0 commit comments

Comments
 (0)