From: Jason Ish Date: Fri, 3 Nov 2017 13:34:51 +0000 (-0600) Subject: issue 2261: don't fail on empty "local" X-Git-Tag: 1.0.0a1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa4ccefb0cbf71962b104c695c4092f3b4ce3ece;p=thirdparty%2Fsuricata-update.git issue 2261: don't fail on empty "local" 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. --- diff --git a/suricata/update/main.py b/suricata/update/main.py index 67cc818..6ee7ea0 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -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