fix DatabaseList init

This commit is contained in:
2023-12-12 14:32:19 +01:00
parent 479c1513a3
commit af800c73aa
2 changed files with 10 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ class Conditions:
self.logger.setLevel(cfg.get_loglevel(debug)) self.logger.setLevel(cfg.get_loglevel(debug))
for arg in ("local", "hosts", "envfrom", "envto", "headers", "metavar", for arg in ("local", "hosts", "envfrom", "envto", "headers", "metavar",
"var"): "var", "list"):
if arg not in cfg: if arg not in cfg:
setattr(self, arg, None) setattr(self, arg, None)
continue continue
@@ -59,15 +59,15 @@ class Conditions:
header, re.IGNORECASE + re.DOTALL + re.MULTILINE)) header, re.IGNORECASE + re.DOTALL + re.MULTILINE))
except re.error as e: except re.error as e:
raise RuntimeError(e) raise RuntimeError(e)
else: elif arg == "list":
setattr(self, arg, cfg[arg]) if cfg["list"]["type"] == "db":
cfg["list"]["name"] = cfg["name"]
self.list = cfg["list"] if "list" in cfg else None cfg["list"]["loglevel"] = cfg["loglevel"]
if self.list is not None: self.list = DatabaseList(cfg["list"], debug)
if self.list["type"] == "db":
self.list = DatabaseList(self.list, debug)
else: else:
raise RuntimeError("invalid list type") raise RuntimeError("invalid list type")
else:
setattr(self, arg, cfg[arg])
def __str__(self): def __str__(self):
cfg = [] cfg = []

View File

@@ -432,6 +432,8 @@ class Quarantine:
if "allowlist" in cfg["options"]: if "allowlist" in cfg["options"]:
allowlist = cfg["options"]["allowlist"] allowlist = cfg["options"]["allowlist"]
if allowlist["type"] == "db": if allowlist["type"] == "db":
allowlist["name"] = f"{cfg['name']}: allowlist"
allowlist["loglevel"] = cfg["loglevel"]
self._allowlist = DatabaseList(allowlist, debug) self._allowlist = DatabaseList(allowlist, debug)
else: else:
raise RuntimeError("invalid allowlist type") raise RuntimeError("invalid allowlist type")