From: Michael Tremer Date: Tue, 3 Mar 2026 15:53:43 +0000 (+0000) Subject: reports: Validate the name when creating reports X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7012562423090c5a4e8b5ba3c83fabcf7b5d92d1;p=dbl.git reports: Validate the name when creating reports Signed-off-by: Michael Tremer --- diff --git a/src/dbl/reports.py b/src/dbl/reports.py index 67801b8..6071286 100644 --- a/src/dbl/reports.py +++ b/src/dbl/reports.py @@ -118,16 +118,20 @@ class Reports(object): return self.backend.db.fetch(stmt) - async def create(self, reported_by, comment=None, **kwargs): + async def create(self, name, reported_by, comment=None, **kwargs): """ Creates a new report """ + # Check if the name is valid + if not util.is_fqdn(name): + raise ValueError("'%s' is not a valid FQDN" % name) + # The database can only handle users by their UID if isinstance(reported_by, users.User): reported_by = reported_by.uid report = await self.backend.db.insert( - Report, reported_by=reported_by, **kwargs, + Report, name=name, reported_by=reported_by, **kwargs, ) # Manifest the object in the database immediately to assign the ID