]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
update: allow index "checksum" value to be a url
authorJason Ish <jason.ish@oisf.net>
Wed, 23 Nov 2022 18:04:10 +0000 (12:04 -0600)
committerJason Ish <jason.ish@oisf.net>
Thu, 24 Nov 2022 01:01:02 +0000 (19:01 -0600)
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

CHANGELOG.md
suricata/update/main.py

index b60d3d782574aa15f85d709c89eb21b3263bf779..095de5949574e7d3e1554301812d51b705f972b7 100644 (file)
@@ -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
index 10508358ff76d7f631bef701d689eabf620b9976..d562ef0789575d24ca6b1fa1a75cd5c09d87044a 100644 (file)
@@ -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)