From: Michael Tremer Date: Mon, 5 Jan 2026 18:31:37 +0000 (+0000) Subject: exporters: Use the tarball exporter to write Suricata rules X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13ff7fbb8f0bdb9b320e7f8d73c295b0a4917015;p=dbl.git exporters: Use the tarball exporter to write Suricata rules That way, we will always compress them as they are rather large to be downloaded as plaintext. Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/exporters.py b/src/dnsbl/exporters.py index 21b99bf..5de5722 100644 --- a/src/dnsbl/exporters.py +++ b/src/dnsbl/exporters.py @@ -415,7 +415,7 @@ class SquidGuardExporter(TarballExporter): } -class SuricataExporter(TextExporter): +class SuricataRulesExporter(TextExporter): """ Export domains as a set of rules for Suricata """ @@ -486,7 +486,7 @@ class SuricataExporter(TextExporter): return h -class SuricataDNSExporter(SuricataExporter): +class SuricataDNSExporter(SuricataRulesExporter): """ Exports the lists as a Suricata ruleset that filters DNS queries. """ @@ -505,7 +505,7 @@ class SuricataDNSExporter(SuricataExporter): ) -class SuricataHTTPExporter(SuricataExporter): +class SuricataHTTPExporter(SuricataRulesExporter): """ Exports the lists as a Suricata ruleset that filters HTTP requests. """ @@ -524,7 +524,7 @@ class SuricataHTTPExporter(SuricataExporter): ) -class SuricataTLSExporter(SuricataExporter): +class SuricataTLSExporter(SuricataRulesExporter): """ Exports the lists as a Suricata ruleset that filters TLS connections. """ @@ -543,7 +543,7 @@ class SuricataTLSExporter(SuricataExporter): ) -class SuricataQUICExporter(SuricataExporter): +class SuricataQUICExporter(SuricataRulesExporter): """ Exports the lists as a Suricata ruleset that filters QUIC connections. """ @@ -562,6 +562,18 @@ class SuricataQUICExporter(SuricataExporter): ) +class SuricataExporter(TarballExporter): + """ + Export a list in the format that squidguard can process it + """ + files = { + "%(list)s-dns.rules" : SuricataDNSExporter, + "%(list)s-http.rules" : SuricataHTTPExporter, + "%(list)s-tls.rules" : SuricataTLSExporter, + "%(list)s-quic.rules" : SuricataQUICExporter, + } + + class MultiExporter(abc.ABC): """ This is a base class that can export multiple lists at the same time @@ -614,9 +626,8 @@ class CombinedSuricataExporter(MultiExporter): # Create a tar file with tarfile.open(fileobj=f, mode="w|gz") as tarball: for list in self.lists: - for file, exporter in self.files.items(): - e = exporter(self.backend, list) - e.export_to_tarball(tarball, file) + exporter = SuricataExporter(self.backend, list) + exporter(tarball) class DirectoryExporter(MultiExporter):