]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
issue 2261: don't fail on empty "local"
authorJason Ish <ish@unx.ca>
Fri, 3 Nov 2017 13:34:51 +0000 (07:34 -0600)
committerJason Ish <ish@unx.ca>
Fri, 3 Nov 2017 14:06:41 +0000 (08:06 -0600)
If local existed, but was empty, YAML would make it a None
value instead of the default empty list.

For local and sources, make sure they are an empty list after
loading instead of None.

suricata/update/main.py

index 67cc8186268fca6232fdb8465404aa26186f173d..6ee7ea09a76dc30556c43843d63224e234fe6e36 100644 (file)
@@ -809,13 +809,21 @@ class Config:
                 config = yaml.load(fileobj)
                 if config:
                     self.config.update(config)
-            return
-        for path in self.DEFAULT_LOCATIONS:
-            if os.path.exists(path):
-                with open(path) as fileobj:
-                    config = yaml.load(fileobj)
-                    if config:
-                        self.config.update(config)
+        else:
+            for path in self.DEFAULT_LOCATIONS:
+                if os.path.exists(path):
+                    with open(path) as fileobj:
+                        config = yaml.load(fileobj)
+                        if config:
+                            self.config.update(config)
+
+        # Make sure sources is a list if empty/none.
+        if not self.config["sources"]:
+            self.config["sources"] = []
+
+        # Make sure local is a list if empty/none.
+        if not self.config["local"]:
+            self.config["local"] = []
 
     def get_arg(self, key):
         """Return the value for a command line argument. To be compatible