Skip to content
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
5 changes: 5 additions & 0 deletions src/anchore_security_cli/identifiers/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def parse_identifier_from_url(url: str) -> str | None:
class Aliases:
cve: list[str] = field(default_factory=list)
gcve: list[str] = field(default_factory=list)
enisa: list[str] = field(default_factory=list)
cnvd: list[str] = field(default_factory=list)
github: list[str] = field(default_factory=list)
chainguard: list[str] = field(default_factory=list)
Expand Down Expand Up @@ -114,6 +115,7 @@ def normalize(cls, alias: str) -> str:
def from_list(cls, aliases: list[str], provider: str | None = None): # noqa: C901, PLR0912, PLR0915
cve = set()
gcve = set()
enisa = set()
cnvd = set()
github = set()
chainguard = set()
Expand Down Expand Up @@ -165,6 +167,8 @@ def from_list(cls, aliases: list[str], provider: str | None = None): # noqa: C9
cve_id = gcve_to_cve(a)
if cve_id:
cve.add(cve_id)
elif a.startswith("EUVD-"):
enisa.add(a)
elif a.startswith("CNVD-"):
cnvd.add(a)
elif a.startswith("GHSA-"):
Expand Down Expand Up @@ -238,6 +242,7 @@ def from_list(cls, aliases: list[str], provider: str | None = None): # noqa: C9
return Aliases(
cve=list(cve),
gcve=list(gcve),
enisa=list(enisa),
cnvd=list(cnvd),
github=list(github),
chainguard=list(chainguard),
Expand Down
4 changes: 4 additions & 0 deletions src/anchore_security_cli/identifiers/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from anchore_security_cli.identifiers.providers.cve5 import CVE5
from anchore_security_cli.identifiers.providers.debian import Debian
from anchore_security_cli.identifiers.providers.echo import Echo
from anchore_security_cli.identifiers.providers.enisa import ENISA
from anchore_security_cli.identifiers.providers.gcve import GCVE
from anchore_security_cli.identifiers.providers.github import GitHub
from anchore_security_cli.identifiers.providers.go import Go
Expand Down Expand Up @@ -38,6 +39,7 @@ class Providers:
cve5: CVE5
github: GitHub
gcve: GCVE
enisa: ENISA
cnvd: CNVD
chainguard: Chainguard
bitnami: Bitnami
Expand Down Expand Up @@ -112,6 +114,7 @@ def fetch_all() -> Providers:
github = executor.submit(GitHub)
gcve = executor.submit(GCVE)
cnvd = executor.submit(CNVD)
enisa = executor.submit(ENISA)
openssf_malicious_packages = executor.submit(OpenSSFMaliciousPackages)
ubuntu = executor.submit(Ubuntu)
chainguard = executor.submit(Chainguard)
Expand Down Expand Up @@ -143,6 +146,7 @@ def fetch_all() -> Providers:
cve5=cve5.result(),
github=github.result(),
gcve=gcve.result(),
enisa=enisa.result(),
cnvd=cnvd.result(),
chainguard=chainguard.result(),
bitnami=bitnami.result(),
Expand Down
56 changes: 56 additions & 0 deletions src/anchore_security_cli/identifiers/providers/enisa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import logging

import requests

from anchore_security_cli.identifiers.aliases import Aliases
from anchore_security_cli.identifiers.providers.provider import Provider, ProviderRecord


class ENISA(Provider):
def __init__(self):
super().__init__(
name="ENISA",
)

def _normalise_identifier(self, identifier: str) -> str:
components = identifier.split("-", 1)
if len(components) < 2:
return identifier

prefix = components[0].upper()
return f"{prefix}-{components[1]}"

def _fetch(self) -> list[ProviderRecord]:
records = []
r = requests.get(
url="https://euvdservices.enisa.europa.eu/api/dump/cve-euvd-mapping",
timeout=30,
stream=True,
)
r.raise_for_status()

for record in r.iter_lines():
record = record.decode("utf-8")

if not record.startswith("EUVD-"):
continue

components = record.split(",", 1)

if len(components) != 2:
logging.warning(f"{self.name}: Skipping unexpected row {record}")

euvd_id = self._normalise_identifier(components[0])
cve_id = self._normalise_identifier(components[1])

logging.trace(f"{self.name}: processing record for {euvd_id}")

records.append(
ProviderRecord(
id=euvd_id,
published=self._parse_date(None),
aliases=Aliases.from_list([euvd_id, cve_id], provider=self.name),
),
)

return records