Skip to content

Commit 7171d02

Browse files
committed
address review comments
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 6f6f0c9 commit 7171d02

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

vulnerabilities/importers/alpine_linux.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,19 @@ def fetch_response(url):
7979
response = requests.get(url)
8080
if response.status_code == 200:
8181
return response
82-
raise Exception(f"Failed to fetch data from {url!r}")
82+
raise Exception(f"Failed to fetch data from {url!r} with status code: {response.status_code!r}")
8383

8484

8585
def fetch_advisory_directory_links(page_response_content: str) -> List[str]:
8686
"""
8787
Return a list of advisory directory links present in `page_response_content` html string
8888
"""
8989
index_page = BeautifulSoup(page_response_content, features="lxml")
90-
alpine_versions = [link.text for link in index_page.find_all("a") if link.text.startswith("v")]
90+
alpine_versions = [
91+
link.text
92+
for link in index_page.find_all("a")
93+
if link.text.startswith("v") or link.text.startswith("edge")
94+
]
9195

9296
if not alpine_versions:
9397
LOGGER.error(f"No versions found in {BASE_URL!r}")

vulnerabilities/improver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class Inference:
2727
"""
2828

2929
vulnerability_id: str = None
30-
aliases: Optional[List[str]] = None
30+
aliases: Optional[List[str]] = dataclasses.field(default_factory=list)
3131
confidence: int = MAX_CONFIDENCE
3232
summary: Optional[str] = None
33-
affected_purls: Optional[List[PackageURL]] = None
33+
affected_purls: Optional[List[PackageURL]] = dataclasses.field(default_factory=list)
3434
fixed_purl: PackageURL = None
3535
references: List[Reference] = dataclasses.field(default_factory=list)
3636

@@ -50,9 +50,9 @@ def __post_init__(self):
5050
versionless_purls = []
5151
purls = []
5252
if self.fixed_purl:
53-
purls = [self.fixed_purl]
53+
purls.append(self.fixed_purl)
5454
if self.affected_purls:
55-
purls = purls + self.affected_purls
55+
purls.extend(self.affected_purls)
5656
for purl in purls:
5757
if purl and not purl.version:
5858
versionless_purls.append(purl)

vulnerabilities/tests/test_alpine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ def test_process_record(caplog):
465465

466466
def test_fetch_advisory_directory_links():
467467
expected = [
468+
"https://secdb.alpinelinux.org/edge/",
468469
"https://secdb.alpinelinux.org/v3.10/",
469470
"https://secdb.alpinelinux.org/v3.11/",
470471
"https://secdb.alpinelinux.org/v3.12/",

0 commit comments

Comments
 (0)