File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from vulnerabilities .importer import AdvisoryData
2020from vulnerabilities .importer import AffectedPackage
2121from vulnerabilities .importer import Reference
22+ from vulnerabilities .utils import purl_to_dict
2223
2324
2425class TestMigrations (TestCase ):
@@ -922,3 +923,32 @@ def test_update_pysec_created_by_field(self):
922923 == 0
923924 )
924925 assert adv .filter (created_by = "alpine_linux_importer" ).count () == 1
926+
927+
928+ class TestFixAlpinePURLCreatedByField (TestMigrations ):
929+ app_name = "vulnerabilities"
930+ migrate_from = "0087_update_alpine_advisory_created_by"
931+ migrate_to = "0088_fix_alpine_purl_type"
932+
933+ def setUpBeforeMigration (self , apps ):
934+ Package = apps .get_model ("vulnerabilities" , "Package" )
935+ purl = str (
936+ PackageURL (
937+ type = "alpine" ,
938+ namespace = "" ,
939+ name = "curl" ,
940+ version = "7.83.0-r0" ,
941+ qualifiers = "arch=x86" ,
942+ )
943+ )
944+ package1 = Package .objects .create (
945+ ** purl_to_dict (purl = purl ), package_url = purl , plain_package_url = purl
946+ )
947+
948+ def test_fix_alpine_purl (self ):
949+ Package = apps .get_model ("vulnerabilities" , "Package" )
950+ package = Package .objects .all ()
951+ print (package )
952+
953+ assert package .filter (type = "alpine" ).count () == 0
954+ assert package .filter (type = "apk" ).count () == 1
You can’t perform that action at this time.
0 commit comments