]> git.ipfire.org Git - suricata-reporter.git/commitdiff
generator: Implement better line wrapping in the table
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 31 Aug 2025 11:43:06 +0000 (11:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 31 Aug 2025 11:45:21 +0000 (11:45 +0000)
Sometimes the signature names are very long and we need to be able to
wrap the next which is only possible by using Paragraph() inside the
individual table cells.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/suricata-report-generator.in

index 40559b441b71730d801242e6ab65f1320ab1dbec..63d55843adb37bfb52c3d5d68d2268ed7cd76e24 100644 (file)
@@ -74,6 +74,15 @@ class ReportGenerator(object):
                )
                self.styles.add(centered)
 
+               # Add a smaller style for the table content
+               small = reportlab.lib.styles.ParagraphStyle(
+                       name      = "Small",
+                       parent    = self.styles["Normal"],
+                       fontSize  = 8,
+                       leading   = 10,
+               )
+               self.styles.add(small)
+
        def generate(self, output, year, month, week, day):
                """
                        Generates a PDF report.
@@ -272,16 +281,26 @@ class ReportGenerator(object):
 
                        # Append the row
                        rows.append((
+                               # Time
                                t.strftime("%H:%M:%S"),
-                               "%s %s\n[%s:%s:%s] - %s" % (
-                                       "*" * row.alert_severity,
-                                       row.alert_signature,
-                                       row.alert_gid,
-                                       row.alert_signature_id,
-                                       row.alert_rev,
-                                       row.alert_category,
+
+                               # Signature
+                               reportlab.platypus.Paragraph(
+                                       "%s %s<br />[%s:%s:%s] - %s" % (
+                                               "*" * row.alert_severity,
+                                               row.alert_signature,
+                                               row.alert_gid,
+                                               row.alert_signature_id,
+                                               row.alert_rev,
+                                               row.alert_category,
+                                       ),
+                                       self.styles["Small"],
                                ),
+
+                               # Protocol
                                row.protocol,
+
+                               # Source/Destination
                                "%s:%s\n%s:%s" % (
                                        row.source_address, (row.source_port or row.icmp_code),
                                        row.destination_address, (row.destination_port or row.icmp_type),