@@ -720,3 +720,44 @@ def test_removal_of_duped_purls(self):
720720
721721 assert adv .filter (created_by = "vulnerabilities.importers.nginx.NginxImporter" ).count () == 0
722722 assert adv .filter (created_by = "nginx_importer" ).count () == 1
723+
724+
725+ class TestUpdateGitLabAdvisoryCreatedByField (TestMigrations ):
726+ app_name = "vulnerabilities"
727+ migrate_from = "0065_update_nginx_advisory_created_by"
728+ migrate_to = "0066_update_gitlab_advisory_created_by"
729+
730+ advisory_data1 = AdvisoryData (
731+ aliases = ["CVE-2020-13371337" ],
732+ summary = "vulnerability description here" ,
733+ affected_packages = [
734+ AffectedPackage (
735+ package = PackageURL (type = "pypi" , name = "foobar" ),
736+ affected_version_range = VersionRange .from_string ("vers:pypi/>=1.0.0|<=2.0.0" ),
737+ )
738+ ],
739+ references = [Reference (url = "https://example.com/with/more/info/CVE-2020-13371337" )],
740+ date_published = timezone .now (),
741+ url = "https://test.com" ,
742+ )
743+
744+ def setUpBeforeMigration (self , apps ):
745+ Advisory = apps .get_model ("vulnerabilities" , "Advisory" )
746+ adv1 = Advisory .objects .create (
747+ aliases = self .advisory_data1 .aliases ,
748+ summary = self .advisory_data1 .summary ,
749+ affected_packages = [pkg .to_dict () for pkg in self .advisory_data1 .affected_packages ],
750+ references = [ref .to_dict () for ref in self .advisory_data1 .references ],
751+ url = self .advisory_data1 .url ,
752+ created_by = "vulnerabilities.importers.gitlab.GitLabAPIImporter" ,
753+ date_collected = timezone .now (),
754+ )
755+
756+ def test_removal_of_duped_purls (self ):
757+ Advisory = apps .get_model ("vulnerabilities" , "Advisory" )
758+ adv = Advisory .objects .all ()
759+
760+ assert (
761+ adv .filter (created_by = "vulnerabilities.importers.gitlab.GitLabAPIImporter" ).count () == 0
762+ )
763+ assert adv .filter (created_by = "gitlab_importer" ).count () == 1
0 commit comments