Skip to content

Commit

Permalink
feat: add azurelinux3 URLs
Browse files Browse the repository at this point in the history
Includes re-generating models.

Signed-off-by: Will Murphy <[email protected]>
  • Loading branch information
willmurphyscode committed May 7, 2024
1 parent a33a36a commit 7c15051
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/vunnel/providers/mariner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Config:
),
)
request_timeout: int = 125
allow_versions: list[str] = field(default_factory=lambda: ["1.0", "2.0"])
allow_versions: list[str] = field(default_factory=lambda: ["1.0", "2.0", "3.0"])


class Provider(provider.Provider):
Expand Down
14 changes: 8 additions & 6 deletions src/vunnel/providers/mariner/generate_models.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import os
import tempfile
from parser import VERSION_TO_FILENAME, VERSION_TO_URL
from subprocess import PIPE, Popen

import requests

MARINER_URL_BASE = "https://raw.githubusercontent.com/microsoft/CBL-MarinerVulnerabilityData/main/{}"
MARINER_URL_FILENAME = "cbl-mariner-{}-oval.xml"


def download_version(version: str, dest_dir: str) -> None:
filename = MARINER_URL_FILENAME.format(version)
url = MARINER_URL_BASE.format(filename)
filename = VERSION_TO_FILENAME[version]
if not filename:
raise Exception(f"mariner/azurelinux provider misconfigured: no filename for version {version}")
url = VERSION_TO_URL[version]
if not url:
raise Exception(f"mariner/azurelinux provider misconfigured: no URL for version {version}")
r = requests.get(url, timeout=125)
destination = os.path.join(dest_dir, filename)
with open(destination, "wb") as w:
w.write(r.content)


def main() -> None:
versions = ["2.0"]
versions = ["2.0", "3.0"]
dest_path = tempfile.TemporaryDirectory()
for v in versions:
download_version(v, dest_path.name)
Expand Down
Loading

0 comments on commit 7c15051

Please sign in to comment.