]> git.ipfire.org Git - dbl.git/commitdiff
reports: Validate the name when creating reports
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Mar 2026 15:53:43 +0000 (15:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Mar 2026 15:53:43 +0000 (15:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dbl/reports.py

index 67801b823a784eb5d0b6f5ce709bbd19ebca091a..6071286de6be0aede2f106ddf6b9349c1204f21e 100644 (file)
@@ -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