From: Jason Ish Date: Wed, 23 Nov 2022 18:04:10 +0000 (-0600) Subject: update: allow index "checksum" value to be a url X-Git-Tag: 1.3.0rc1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93047464a5a141d95133ac2959d8daea307343bc;p=thirdparty%2Fsuricata-update.git update: allow index "checksum" value to be a url If the checksum field in the index is a string, use it as the checksum URL. This allows a source to specify a custom checksum URL instead of the derived ".md5" URL. Ticket: #5684 --- diff --git a/CHANGELOG.md b/CHANGELOG.md index b60d3d7..095de59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ https://redmine.openinfosecfoundation.org/issues/4362 - Better error message on invalid source specification: https://redmine.openinfosecfoundation.org/issues/5141 +- Allow checksum URL to be specified by the index: + https://redmine.openinfosecfoundation.org/issues/5684 ## 1.2.5 - 2022-09-22 - Update entrypoint search path when not installed with distutils. This is diff --git a/suricata/update/main.py b/suricata/update/main.py index 1050835..d562ef0 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -109,9 +109,10 @@ class Fetch: def __init__(self): self.istty = os.isatty(sys.stdout.fileno()) - def check_checksum(self, tmp_filename, url): + def check_checksum(self, tmp_filename, url, checksum_url=None): try: - checksum_url = url[0] + ".md5" + if not isinstance(checksum_url, str): + checksum_url = url[0] + ".md5" net_arg=(checksum_url,url[1]) local_checksum = hashlib.md5( open(tmp_filename, "rb").read()).hexdigest().strip() @@ -180,7 +181,7 @@ class Fetch: url) return self.extract_files(tmp_filename) if checksum: - if self.check_checksum(tmp_filename, net_arg): + if self.check_checksum(tmp_filename, net_arg, checksum): logger.info("Remote checksum has not changed. " "Not fetching.") return self.extract_files(tmp_filename)