From: Michael Tremer Date: Wed, 10 Dec 2025 11:49:51 +0000 (+0000) Subject: dnsbl: Add description to lists X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb739b1f3f31fe63ca50be3637b6bd4fd3d9c6db;p=dbl.git dnsbl: Add description to lists Signed-off-by: Michael Tremer --- diff --git a/src/database.sql b/src/database.sql index 9c39018..f75331c 100644 --- a/src/database.sql +++ b/src/database.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- -\restrict uoDsydSaI5FPlrxacSe4GcAWBxa12RWCgmwmzOXlefNHtJ99eaarw0pTVxjYoSs +\restrict iyF1xJX6Rr5HXWxSVy3hc4tk2qFzInuecwfyZcCbdOKUcUhTZab2fHQNbRay16f -- Dumped from database version 17.6 (Debian 17.6-0+deb13u1) -- Dumped by pg_dump version 17.6 (Debian 17.6-0+deb13u1) @@ -36,7 +36,8 @@ CREATE TABLE public.lists ( deleted_at timestamp with time zone, deleted_by text, license text NOT NULL, - updated_at timestamp with time zone + updated_at timestamp with time zone, + description text ); @@ -273,5 +274,5 @@ ALTER TABLE ONLY public.sources -- PostgreSQL database dump complete -- -\unrestrict uoDsydSaI5FPlrxacSe4GcAWBxa12RWCgmwmzOXlefNHtJ99eaarw0pTVxjYoSs +\unrestrict iyF1xJX6Rr5HXWxSVy3hc4tk2qFzInuecwfyZcCbdOKUcUhTZab2fHQNbRay16f diff --git a/src/dnsbl/exporters.py b/src/dnsbl/exporters.py index 5cebc6a..76f17c2 100644 --- a/src/dnsbl/exporters.py +++ b/src/dnsbl/exporters.py @@ -79,6 +79,17 @@ class TextExporter(Exporter): " that support blocklisting of known malicious or unwanted domains.", "", " List : %s" % self.list.name, + ] + + # Add the description + if self.list.description: + lines += [ + "", + " %s" % self.list.description, + "", + ] + + lines += [ " License : %s" % self.list.license, " Updated : %s" % self.list.updated_at.isoformat(), "", diff --git a/src/dnsbl/lists.py b/src/dnsbl/lists.py index 7d34c0b..efcd96e 100644 --- a/src/dnsbl/lists.py +++ b/src/dnsbl/lists.py @@ -85,7 +85,7 @@ class Lists(object): return slug - def create(self, name, created_by, license): + def create(self, name, created_by, license, description=None): """ Creates a new list """ @@ -94,10 +94,11 @@ class Lists(object): # Create a new list return self.backend.db.insert( List, - name = name, - slug = slug, - created_by = created_by, - license = license, + name = name, + slug = slug, + created_by = created_by, + license = license, + description = description, ) @@ -140,6 +141,9 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): # License license : str + # Description + description : str + # Sources sources : typing.List["Source"] = sqlmodel.Relationship( back_populates="list", diff --git a/src/scripts/dnsbl.in b/src/scripts/dnsbl.in index 522ff72..ec0196b 100644 --- a/src/scripts/dnsbl.in +++ b/src/scripts/dnsbl.in @@ -72,6 +72,8 @@ class CLI(object): default=os.environ.get("USER"), help=_("The creator of the list")) create.add_argument("--license", required=True, help=_("The license of the list")) + create.add_argument("--description", + help=_("The description of the list")) create.set_defaults(func=self.__create) # delete @@ -204,9 +206,10 @@ class CLI(object): Creates a new list """ backend.lists.create( - name = args.name, - created_by = args.created_by, - license = args.license, + name = args.name, + created_by = args.created_by, + license = args.license, + description = args.description, ) def __delete(self, backend, args):