@@ -533,3 +533,38 @@ def test_merge_rows(self):
533533 ]
534534
535535 assert severities == expected
536+
537+
538+ class RemoveCorrupteAdvisories (TestMigrations ):
539+ app_name = "vulnerabilities"
540+ migrate_from = "0037_advisory_weaknesses_weakness"
541+ migrate_to = "0038_remove_corrupted_advisories_with_incorrect_refs_and_severity"
542+
543+ def setUpBeforeMigration (self , apps ):
544+ # using get_model to avoid circular import
545+ Advisory = apps .get_model ("vulnerabilities" , "Advisory" )
546+
547+ corrupted_advisory = Advisory .objects .create (
548+ aliases = ["CVE-2020-1234" ],
549+ summary = "Corrupted advisory" ,
550+ references = [
551+ {
552+ "reference_id" : "cpe:2.3:a:f5:nginx:1.16.1:*:*:*:*:*:*:*" ,
553+ "url" : "" ,
554+ "severity" : [
555+ {
556+ "scoring_system" : "cvssv3_vector" ,
557+ "value" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H" ,
558+ }
559+ ],
560+ }
561+ ],
562+ date_collected = "2020-01-01" ,
563+ date_published = "2020-01-01" ,
564+ )
565+ corrupted_advisory .save ()
566+
567+ def test_removal_of_corrupted_advisory (self ):
568+ # using get_model to avoid circular import
569+ Advisory = self .apps .get_model ("vulnerabilities" , "Advisory" )
570+ Advisory .objects .all ().count () == 0
0 commit comments