Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Tushar Goel <[email protected]>
  • Loading branch information
TG1999 committed Mar 3, 2022
1 parent 6f6f0c9 commit 7171d02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions vulnerabilities/importers/alpine_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@ def fetch_response(url):
response = requests.get(url)
if response.status_code == 200:
return response
raise Exception(f"Failed to fetch data from {url!r}")
raise Exception(f"Failed to fetch data from {url!r} with status code: {response.status_code!r}")


def fetch_advisory_directory_links(page_response_content: str) -> List[str]:
"""
Return a list of advisory directory links present in `page_response_content` html string
"""
index_page = BeautifulSoup(page_response_content, features="lxml")
alpine_versions = [link.text for link in index_page.find_all("a") if link.text.startswith("v")]
alpine_versions = [
link.text
for link in index_page.find_all("a")
if link.text.startswith("v") or link.text.startswith("edge")
]

if not alpine_versions:
LOGGER.error(f"No versions found in {BASE_URL!r}")
Expand Down
8 changes: 4 additions & 4 deletions vulnerabilities/improver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class Inference:
"""

vulnerability_id: str = None
aliases: Optional[List[str]] = None
aliases: Optional[List[str]] = dataclasses.field(default_factory=list)
confidence: int = MAX_CONFIDENCE
summary: Optional[str] = None
affected_purls: Optional[List[PackageURL]] = None
affected_purls: Optional[List[PackageURL]] = dataclasses.field(default_factory=list)
fixed_purl: PackageURL = None
references: List[Reference] = dataclasses.field(default_factory=list)

Expand All @@ -50,9 +50,9 @@ def __post_init__(self):
versionless_purls = []
purls = []
if self.fixed_purl:
purls = [self.fixed_purl]
purls.append(self.fixed_purl)
if self.affected_purls:
purls = purls + self.affected_purls
purls.extend(self.affected_purls)
for purl in purls:
if purl and not purl.version:
versionless_purls.append(purl)
Expand Down
1 change: 1 addition & 0 deletions vulnerabilities/tests/test_alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ def test_process_record(caplog):

def test_fetch_advisory_directory_links():
expected = [
"https://secdb.alpinelinux.org/edge/",
"https://secdb.alpinelinux.org/v3.10/",
"https://secdb.alpinelinux.org/v3.11/",
"https://secdb.alpinelinux.org/v3.12/",
Expand Down

0 comments on commit 7171d02

Please sign in to comment.