@@ -802,3 +802,42 @@ def test_removal_of_duped_purls(self):
802802 adv .filter (created_by = "vulnerabilities.importers.github.GitHubAPIImporter" ).count () == 0
803803 )
804804 assert adv .filter (created_by = "github_importer" ).count () == 1
805+
806+
807+ class TestUpdateNVDAdvisoryCreatedByField (TestMigrations ):
808+ app_name = "vulnerabilities"
809+ migrate_from = "0067_update_github_advisory_created_by"
810+ migrate_to = "0068_update_nvd_advisory_created_by"
811+
812+ advisory_data1 = AdvisoryData (
813+ aliases = ["CVE-2020-13371337" ],
814+ summary = "vulnerability description here" ,
815+ affected_packages = [
816+ AffectedPackage (
817+ package = PackageURL (type = "pypi" , name = "foobar" ),
818+ affected_version_range = VersionRange .from_string ("vers:pypi/>=1.0.0|<=2.0.0" ),
819+ )
820+ ],
821+ references = [Reference (url = "https://example.com/with/more/info/CVE-2020-13371337" )],
822+ date_published = timezone .now (),
823+ url = "https://test.com" ,
824+ )
825+
826+ def setUpBeforeMigration (self , apps ):
827+ Advisory = apps .get_model ("vulnerabilities" , "Advisory" )
828+ adv1 = Advisory .objects .create (
829+ aliases = self .advisory_data1 .aliases ,
830+ summary = self .advisory_data1 .summary ,
831+ affected_packages = [pkg .to_dict () for pkg in self .advisory_data1 .affected_packages ],
832+ references = [ref .to_dict () for ref in self .advisory_data1 .references ],
833+ url = self .advisory_data1 .url ,
834+ created_by = "vulnerabilities.importers.nvd.NVDImporter" ,
835+ date_collected = timezone .now (),
836+ )
837+
838+ def test_removal_of_duped_purls (self ):
839+ Advisory = apps .get_model ("vulnerabilities" , "Advisory" )
840+ adv = Advisory .objects .all ()
841+
842+ assert adv .filter (created_by = "vulnerabilities.importers.nvd.NVDImporter" ).count () == 0
843+ assert adv .filter (created_by = "nvd_importer" ).count () == 1
0 commit comments