Commit 86ca913
fix(cwe): guard save_cwes on partial update; bound CWE number to column width
Two data-safety fixes for the multi-CWE relation:
- FindingSerializer.update() called save_cwes() unconditionally, so any
PATCH/PUT that omitted `cwes` deleted a finding's extra Finding_CWE rows
(leaving only the primary). Guard the call on `parsed_cwes is not None`,
mirroring the vulnerability-id path.
- cwe_number() had no upper bound, but Finding_CWE.cwe stores "CWE-<n>" in a
varchar(11). A number > 9,999,999 passed validation then raised DataError
at insert (API/form 500, and would abort the 0280 backfill's bulk_create,
since ignore_conflicts does not swallow DataError). Reject it as invalid
input (None) so it becomes a clean 400/skip.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 9ec9a1c commit 86ca913
2 files changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
486 | 489 | | |
487 | 490 | | |
488 | | - | |
| 491 | + | |
489 | 492 | | |
490 | 493 | | |
491 | 494 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
0 commit comments