Commit 0f2a5af
feat(finding): copy finding fix + autodetected vulnerability id type + uniqueness constraint (#15145)
* feat(finding): autodetected vulnerability_id type + uniqueness constraint
Adds Vulnerability_Id.vulnerability_id_type, autodetected from the id's
leading prefix (CVE-2024-1234 -> CVE, GHSA-... -> GHSA), stored and indexed
so identifiers can be filtered/grouped by type. Populated on import (bulk)
and on save(); existing rows backfilled by migration.
Also de-duplicates (finding, vulnerability_id) rows and adds a unique
constraint on the pair. CWE is a weakness class and is intentionally NOT
part of this change; vulnerability_id_type does not participate in
hash_code, so existing hash codes and deduplication are unaffected.
Migrations: 0276 (type column + lookup index), 0277 (dedupe + backfill,
data), 0278 (unique constraint).
* 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>
* chore(migrations): rebase onto dev, renumber vuln-id chain 0280-0282
Resolves the migration-graph leaf collision: dev has advanced to
0279_jira_project_transition_fields, so the vulnerability-id migrations are
renumbered 0276/0277/0278 -> 0280/0281/0282 and the first is re-parented onto
the current dev leaf.
Also merges a duplicate `class Meta` on Vulnerability_Id introduced by the
rebase: dev's global-search FTS work added its own Meta (GIN indexes) adjacent
to this branch's Meta (unique constraint + dojo_vuln_id_lookup_idx). Python
keeps only the last class body, which silently dropped the constraint/index
from the model state (makemigrations wanted to remove them). Both are now in a
single Meta. `makemigrations --check dojo` reports no changes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* perf(migrations): build vuln-id index + unique constraint concurrently (F9)
0280's lookup index and 0282's (finding, vulnerability_id) unique constraint
were built with plain AddIndex / AddConstraint, taking a SHARE lock (blocks
writes) and an ACCESS EXCLUSIVE lock (blocks reads+writes) for the full build
over the whole dojo_vulnerability_id table -- a material downtime window on
large instances.
Build both CONCURRENTLY instead (atomic=False), keeping the work in-migration:
- 0280: AddIndexConcurrently for dojo_vuln_id_lookup_idx.
- 0282: CREATE UNIQUE INDEX CONCURRENTLY, then ADD CONSTRAINT ... USING INDEX
(brief lock to adopt the pre-built index); SeparateDatabaseAndState keeps the
UniqueConstraint in Django's model state.
Verified on a 100k-finding / 174k-id dataset with duplicate rows: 0281 dedupe
-> 0, constraint built valid as a real UNIQUE constraint, makemigrations
--check clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent ad76b1b commit 0f2a5af
10 files changed
Lines changed: 257 additions & 3 deletions
File tree
- docs/content/releases/os_upgrading
- dojo
- db_migrations
- finding
- importers
- unittests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
1068 | 1069 | | |
1069 | 1070 | | |
1070 | 1071 | | |
1071 | | - | |
| 1072 | + | |
1072 | 1073 | | |
1073 | 1074 | | |
1074 | 1075 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
700 | 701 | | |
701 | 702 | | |
702 | 703 | | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
703 | 707 | | |
704 | 708 | | |
705 | 709 | | |
| |||
1377 | 1381 | | |
1378 | 1382 | | |
1379 | 1383 | | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1380 | 1387 | | |
1381 | 1388 | | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
1382 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
1383 | 1396 | | |
1384 | 1397 | | |
1385 | 1398 | | |
| |||
1391 | 1404 | | |
1392 | 1405 | | |
1393 | 1406 | | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
1394 | 1412 | | |
1395 | 1413 | | |
1396 | 1414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
893 | 894 | | |
894 | 895 | | |
895 | 896 | | |
896 | | - | |
| 897 | + | |
897 | 898 | | |
898 | 899 | | |
899 | 900 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
1000 | 1001 | | |
1001 | 1002 | | |
1002 | 1003 | | |
1003 | | - | |
| 1004 | + | |
1004 | 1005 | | |
1005 | 1006 | | |
1006 | 1007 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
0 commit comments