Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_ib():
"""Setup ImageBuilder based on `request`
This function downloads and verifies the ImageBuilder archive. Existing
setups are automatically updated if newer version are available
upstream.
"""
log.debug("Setting up ImageBuilder")
if (cache / subtarget).is_dir():
rmtree(cache / subtarget)
download_file("sha256sums.sig", sig_file)
download_file("sha256sums", sums_file)
assert verify_usign(
sig_file, sums_file, request["version_data"]["pubkey"]
), "Bad signature for cheksums"
# openwrt-imagebuilder-ath79-generic.Linux-x86_64.tar.xz
ib_search = re.search(
r"^(.{64}) \*(openwrt-imagebuilder-.+?\.Linux-x86_64\.tar\.xz)$",
sums_file.read_text(),
re.MULTILINE,
)
assert ib_search, "No ImageBuilder in checksums found"
ib_hash, ib_archive = ib_search.groups()
download_file(ib_archive)