Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://github.com/nexB/vulnerablecode/issues/725 #726

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion vulnerabilities/package_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,12 @@ def fetch(self, pkg: str) -> Iterable[PackageVersion]:
url = f"https://proxy.golang.org/{escaped_pkg}/@v/list"
response = get_response(url=url, content_type="text")
if not response:
escaped_pkg = self.trim_go_url_path(escaped_pkg)
trimmed_escaped_pkg = self.trim_go_url_path(escaped_pkg)
trimmed_pkg = self.trim_go_url_path(trimmed_pkg) or ""
if trimmed_escaped_pkg == escaped_pkg:
break

escaped_pkg = trimmed_escaped_pkg
continue

break
Expand Down
9 changes: 9 additions & 0 deletions vulnerabilities/tests/test_package_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ def test_fetch(self, mock_fetcher):
]
assert results == expected

@mock.patch("vulnerabilities.package_managers.get_response")
def test_fetch_with_responses_are_none(self, mock_fetcher):
# we have many calls made to get_response
responses = [None, None, None, None, None]
mock_fetcher.side_effect = responses

results = list(GoproxyVersionAPI().fetch("github.com/FerretDB/FerretDB"))
assert results == []


class TestNugetVersionAPI:
expected_versions = [
Expand Down