diff --git a/vulnerabilities/importers/alpine_linux.py b/vulnerabilities/importers/alpine_linux.py index 15d1d1716..350e906f0 100644 --- a/vulnerabilities/importers/alpine_linux.py +++ b/vulnerabilities/importers/alpine_linux.py @@ -79,7 +79,7 @@ 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]: @@ -87,7 +87,11 @@ 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}") diff --git a/vulnerabilities/improver.py b/vulnerabilities/improver.py index 60f293efd..27e6a26cd 100644 --- a/vulnerabilities/improver.py +++ b/vulnerabilities/improver.py @@ -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) @@ -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) diff --git a/vulnerabilities/tests/test_alpine.py b/vulnerabilities/tests/test_alpine.py index 5a2876557..3f1f5f950 100644 --- a/vulnerabilities/tests/test_alpine.py +++ b/vulnerabilities/tests/test_alpine.py @@ -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/",