more strict limit

This commit is contained in:
David Duran Rosich committed 2026-10-24 00:16:53 +02:00
1 parent 65b9c1fc84
commit cdd8004a6f
2 files changed
+80 -22

No files matched your search

+17 -3
View File
@@ -413,6 +413,20 @@ class ReportTests(unittest.TestCase):
body = scan.build_aggregated_body(aggregated, 200)
self.assertLessEqual(len(body), scan.MAX_NOTIFICATION_CHARS)
def test_aggregated_body_compact_for_discord(self) -> None:
aggregated = scan.AggregatedReport()
for i in range(50):
vuln = {
"Severity": "CRITICAL",
"VulnerabilityID": f"CVE-2026-{i:05d}",
"PkgName": "libc",
"InstalledVersion": "1.0",
"FixedVersion": "1.1",
}
aggregated.add_vulnerability(vuln, f"img{i}:latest", [f"c{i}"])
body = scan.build_aggregated_body(aggregated, 50, compact=True)
self.assertLessEqual(len(body), scan.DISCORD_MAX_NOTIFICATION_CHARS)
def test_build_aggregated_body_groups_by_cve(self) -> None:
aggregated = scan.AggregatedReport()
vuln1 = {
@@ -433,9 +447,9 @@ class ReportTests(unittest.TestCase):
aggregated.add_vulnerability(vuln2, "redis:7", ["cache"])
body = scan.build_aggregated_body(aggregated, 15)
self.assertIn("CVE-1", body)
self.assertIn("containers: web", body)
self.assertIn("web", body)
self.assertIn("nginx:1.27", body)
self.assertIn("containers: cache", body)
self.assertIn("cache", body)
self.assertIn("redis:7", body)
@@ -568,7 +582,7 @@ printf '%s\\n' "$*" >> "$APPRISE_LOG"
self.assertEqual(code, 1)
notification = Path(self.apprise_log).read_text()
self.assertIn("CVE-2026-0001", notification)
self.assertIn("containers: testphp", notification)
self.assertIn("testphp", notification)
def test_scan_failure_notification_includes_container(self) -> None:
containers = [container("a" * 64, "testphp-php", name="testphp")]