-- PostgreSQL database dump
--
-\restrict 0x0tldyHgIUyWxgnGUGi115yWYckW02ZTvAqVYxdprpqc4kMhzpMBPkpIKiHQLO
+\restrict 1diYTcUdWXmrci8nOPBU0L49Gy6AtiuIiTy0rir4PbAGglPIHU607lYZcp7rwvf
-- Dumped from database version 17.6 (Debian 17.6-0+deb13u1)
-- Dumped by pg_dump version 17.6 (Debian 17.6-0+deb13u1)
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
description text,
total_domains integer DEFAULT 0 NOT NULL,
- pending_reports integer DEFAULT 0 NOT NULL
+ pending_reports integer DEFAULT 0 NOT NULL,
+ priority integer DEFAULT 0 NOT NULL
);
-- PostgreSQL database dump complete
--
-\unrestrict 0x0tldyHgIUyWxgnGUGi115yWYckW02ZTvAqVYxdprpqc4kMhzpMBPkpIKiHQLO
+\unrestrict 1diYTcUdWXmrci8nOPBU0L49Gy6AtiuIiTy0rir4PbAGglPIHU607lYZcp7rwvf
# Write the header
self.write_header(f)
- # XXX Maybe we should look into having different priority for different lists.
- # For example, blocking some advertising has a lower priority than accessing
- # a malware/phishing domain.
-
# Shift the ID of the list to the higher 16 bits and append the offset
sid = self.list.id << 16
+ # Map the priority
+ # High Priority
+ if self.list.priority == 3:
+ priority = 1
+ # Medium Priority
+ elif self.list.priority == 2:
+ priority = 2
+ # Low Priority
+ elif self.list.priority == 1:
+ priority = 3
+ # Informational
+ else:
+ priority = 4
+
rules = {
# DNS
"dns" : {
"load datasets/%s.txt" % self.list.slug,
),
"classtype" : "policy-violation",
- "priority" : "3",
+ "priority" : priority,
"sid" : sid | 1,
"rev" : "1",
"reference" : (
"load datasets/%s.txt" % self.list.slug,
),
"classtype" : "policy-violation",
- "priority" : "3",
+ "priority" : priority,
"sid" : sid | 2,
"rev" : "1",
"reference" : (
"load datasets/%s.txt" % self.list.slug,
),
"classtype" : "policy-violation",
- "priority" : "3",
+ "priority" : priority,
"sid" : sid | 3,
"rev" : "1",
"reference" : (
"load datasets/%s.txt" % self.list.slug,
),
"classtype" : "policy-violation",
- "priority" : "3",
+ "priority" : priority,
"sid" : sid | 4,
"rev" : "1",
"reference" : (
# Setup logging
log = logging.getLogger(__name__)
+PRIORITIES = {
+ "INFORMATIONAL" : 0,
+ "LOW" : 1,
+ "MEDIUM" : 2,
+ "HIGH" : 3,
+}
+
class Lists(object):
def __init__(self, backend):
self.backend = backend
return slug
- def create(self, name, created_by, license, description=None):
+ def create(self, name, created_by, license, description=None, priority=None):
"""
Creates a new list
"""
slug = self._make_slug(name)
+ # Map priority
+ try:
+ priority = PRIORITIES[priority]
+ except KeyError as e:
+ raise ValueError("Invalid priority: %s" % priority) from e
+
# Create a new list
return self.backend.db.insert(
List,
created_by = created_by,
license = license,
description = description,
+ priority = priority,
)
# Description
description : str
+ # Priority
+ priority: int = 0
+
# Sources
sources : typing.List["Source"] = sqlmodel.Relationship(
back_populates="list",
help=_("The license of the list"))
create.add_argument("--description",
help=_("The description of the list"))
+ create.add_argument("--priority", choices=dnsbl.lists.PRIORITIES,
+ help=_("The priority of this list"), default="INFORMATIONAL")
create.set_defaults(func=self.__create)
# delete
created_by = args.created_by,
license = args.license,
description = args.description,
+ priority = args.priority,
)
def __delete(self, backend, args):