@@ -761,3 +761,44 @@ def test_removal_of_duped_purls(self):
761761 adv .filter (created_by = "vulnerabilities.importers.gitlab.GitLabAPIImporter" ).count () == 0
762762 )
763763 assert adv .filter (created_by = "gitlab_importer" ).count () == 1
764+
765+
766+ class TestUpdateGitHubAdvisoryCreatedByField (TestMigrations ):
767+ app_name = "vulnerabilities"
768+ migrate_from = "0066_update_gitlab_advisory_created_by"
769+ migrate_to = "0067_update_github_advisory_created_by"
770+
771+ advisory_data1 = AdvisoryData (
772+ aliases = ["CVE-2020-13371337" ],
773+ summary = "vulnerability description here" ,
774+ affected_packages = [
775+ AffectedPackage (
776+ package = PackageURL (type = "pypi" , name = "foobar" ),
777+ affected_version_range = VersionRange .from_string ("vers:pypi/>=1.0.0|<=2.0.0" ),
778+ )
779+ ],
780+ references = [Reference (url = "https://example.com/with/more/info/CVE-2020-13371337" )],
781+ date_published = timezone .now (),
782+ url = "https://test.com" ,
783+ )
784+
785+ def setUpBeforeMigration (self , apps ):
786+ Advisory = apps .get_model ("vulnerabilities" , "Advisory" )
787+ adv1 = Advisory .objects .create (
788+ aliases = self .advisory_data1 .aliases ,
789+ summary = self .advisory_data1 .summary ,
790+ affected_packages = [pkg .to_dict () for pkg in self .advisory_data1 .affected_packages ],
791+ references = [ref .to_dict () for ref in self .advisory_data1 .references ],
792+ url = self .advisory_data1 .url ,
793+ created_by = "vulnerabilities.importers.github.GitHubAPIImporter" ,
794+ date_collected = timezone .now (),
795+ )
796+
797+ def test_removal_of_duped_purls (self ):
798+ Advisory = apps .get_model ("vulnerabilities" , "Advisory" )
799+ adv = Advisory .objects .all ()
800+
801+ assert (
802+ adv .filter (created_by = "vulnerabilities.importers.github.GitHubAPIImporter" ).count () == 0
803+ )
804+ assert adv .filter (created_by = "github_importer" ).count () == 1
0 commit comments