From af800c73aa3e203c637fe26c37625d5b0d028499 Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Tue, 12 Dec 2023 14:32:19 +0100 Subject: [PATCH] fix DatabaseList init --- pyquarantine/conditions.py | 16 ++++++++-------- pyquarantine/storage.py | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pyquarantine/conditions.py b/pyquarantine/conditions.py index 038c5df..26b1258 100644 --- a/pyquarantine/conditions.py +++ b/pyquarantine/conditions.py @@ -33,7 +33,7 @@ class Conditions: self.logger.setLevel(cfg.get_loglevel(debug)) for arg in ("local", "hosts", "envfrom", "envto", "headers", "metavar", - "var"): + "var", "list"): if arg not in cfg: setattr(self, arg, None) continue @@ -59,16 +59,16 @@ class Conditions: header, re.IGNORECASE + re.DOTALL + re.MULTILINE)) except re.error as e: raise RuntimeError(e) + elif arg == "list": + if cfg["list"]["type"] == "db": + cfg["list"]["name"] = cfg["name"] + cfg["list"]["loglevel"] = cfg["loglevel"] + self.list = DatabaseList(cfg["list"], debug) + else: + raise RuntimeError("invalid list type") else: setattr(self, arg, cfg[arg]) - self.list = cfg["list"] if "list" in cfg else None - if self.list is not None: - if self.list["type"] == "db": - self.list = DatabaseList(self.list, debug) - else: - raise RuntimeError("invalid list type") - def __str__(self): cfg = [] for arg in ("local", "hosts", "envfrom", "envto", "headers", diff --git a/pyquarantine/storage.py b/pyquarantine/storage.py index 2e6270c..cdc8f4f 100644 --- a/pyquarantine/storage.py +++ b/pyquarantine/storage.py @@ -432,6 +432,8 @@ class Quarantine: if "allowlist" in cfg["options"]: allowlist = cfg["options"]["allowlist"] if allowlist["type"] == "db": + allowlist["name"] = f"{cfg['name']}: allowlist" + allowlist["loglevel"] = cfg["loglevel"] self._allowlist = DatabaseList(allowlist, debug) else: raise RuntimeError("invalid allowlist type")