Skip to content

Commit 9bfc787

Browse files
Maffoochclaude
andcommitted
fix(vuln-id): cap autodetected vulnerability_id_type at column width (20)
resolve_vulnerability_id_type returned the raw uppercased prefix with no length bound, but vulnerability_id_type is CharField(max_length=20) while vulnerability_id is unbounded text. A >20-char prefix (e.g. a dash-less token/hash used as an id) raised DataError on save()/bulk_create (import 500) and was silently truncated by the 0277 backfill's bulk_update CAST. Treat an over-length prefix as untyped (None) so save, bulk_create, and the backfill all agree and never error or truncate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c395a2c commit 9bfc787

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dojo/finding/vulnerability_id.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ def resolve_vulnerability_id_type(vulnerability_id: str | None) -> str | None:
88
Structural, no registry: ``CVE-2024-1 -> "CVE"``, ``GHSA-... -> "GHSA"``,
99
``RUSTSEC-2021-0001 -> "RUSTSEC"``, ``ALINUX2-SA-... -> "ALINUX2"``. Returns the uppercased
1010
prefix, or ``None`` when there is no non-numeric prefix (bare numbers / UUIDs / no dash).
11+
12+
The prefix is capped at the ``vulnerability_id_type`` column width (20). A longer prefix is
13+
not a real scheme (e.g. a dash-less hash used as an id), so it is treated as untyped rather
14+
than truncated/erroring on save, bulk_create, and the 0277 backfill.
1115
"""
1216
if not vulnerability_id:
1317
return None
1418
prefix = str(vulnerability_id).strip().split("-", 1)[0].strip()
15-
if not prefix or prefix.isdigit():
19+
if not prefix or prefix.isdigit() or len(prefix) > 20:
1620
return None
1721
return prefix.upper()

0 commit comments

Comments
 (0)