github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/elixir/parse_mix_lock_test.go (about) 1 package elixir 2 3 import ( 4 "testing" 5 6 "github.com/anchore/syft/syft/artifact" 7 "github.com/anchore/syft/syft/file" 8 "github.com/anchore/syft/syft/pkg" 9 "github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest" 10 ) 11 12 func TestParseMixLock(t *testing.T) { 13 locations := file.NewLocationSet(file.NewLocation("test-fixtures/mix.lock")) 14 expected := []pkg.Package{ 15 { 16 Name: "castore", 17 Version: "0.1.17", 18 Language: pkg.Elixir, 19 Type: pkg.HexPkg, 20 Locations: locations, 21 PURL: "pkg:hex/castore@0.1.17", 22 MetadataType: pkg.MixLockMetadataType, 23 Metadata: pkg.MixLockMetadata{ 24 Name: "castore", 25 Version: "0.1.17", 26 PkgHash: "ba672681de4e51ed8ec1f74ed624d104c0db72742ea1a5e74edbc770c815182f", 27 PkgHashExt: "d9844227ed52d26e7519224525cb6868650c272d4a3d327ce3ca5570c12163f9", 28 }, 29 }, 30 { 31 Name: "connection", 32 Version: "1.1.0", 33 Language: pkg.Elixir, 34 Type: pkg.HexPkg, 35 Locations: locations, 36 PURL: "pkg:hex/connection@1.1.0", 37 MetadataType: pkg.MixLockMetadataType, 38 Metadata: pkg.MixLockMetadata{ 39 Name: "connection", 40 Version: "1.1.0", 41 PkgHash: "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", 42 PkgHashExt: "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c", 43 }, 44 }, 45 { 46 Name: "cowboy", 47 Version: "2.9.0", 48 Language: pkg.Elixir, 49 Type: pkg.HexPkg, 50 Locations: locations, 51 PURL: "pkg:hex/cowboy@2.9.0", 52 MetadataType: pkg.MixLockMetadataType, 53 Metadata: pkg.MixLockMetadata{ 54 Name: "cowboy", 55 Version: "2.9.0", 56 PkgHash: "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", 57 PkgHashExt: "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde", 58 }, 59 }, 60 { 61 Name: "cowboy_telemetry", 62 Version: "0.4.0", 63 Language: pkg.Elixir, 64 Type: pkg.HexPkg, 65 Locations: locations, 66 PURL: "pkg:hex/cowboy_telemetry@0.4.0", 67 MetadataType: pkg.MixLockMetadataType, 68 Metadata: pkg.MixLockMetadata{ 69 Name: "cowboy_telemetry", 70 Version: "0.4.0", 71 PkgHash: "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", 72 PkgHashExt: "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de", 73 }, 74 }, 75 { 76 Name: "cowlib", 77 Version: "2.11.0", 78 Language: pkg.Elixir, 79 Type: pkg.HexPkg, 80 Locations: locations, 81 PURL: "pkg:hex/cowlib@2.11.0", 82 MetadataType: pkg.MixLockMetadataType, 83 Metadata: pkg.MixLockMetadata{ 84 Name: "cowlib", 85 Version: "2.11.0", 86 PkgHash: "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", 87 PkgHashExt: "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9", 88 }, 89 }, 90 { 91 Name: "db_connection", 92 Version: "2.4.2", 93 Language: pkg.Elixir, 94 Type: pkg.HexPkg, 95 Locations: locations, 96 PURL: "pkg:hex/db_connection@2.4.2", 97 MetadataType: pkg.MixLockMetadataType, 98 Metadata: pkg.MixLockMetadata{ 99 Name: "db_connection", 100 Version: "2.4.2", 101 PkgHash: "f92e79aff2375299a16bcb069a14ee8615c3414863a6fef93156aee8e86c2ff3", 102 PkgHashExt: "4fe53ca91b99f55ea249693a0229356a08f4d1a7931d8ffa79289b145fe83668", 103 }, 104 }, 105 { 106 Name: "decimal", 107 Version: "2.0.0", 108 Language: pkg.Elixir, 109 Type: pkg.HexPkg, 110 Locations: locations, 111 PURL: "pkg:hex/decimal@2.0.0", 112 MetadataType: pkg.MixLockMetadataType, 113 Metadata: pkg.MixLockMetadata{ 114 Name: "decimal", 115 Version: "2.0.0", 116 PkgHash: "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", 117 PkgHashExt: "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577", 118 }, 119 }, 120 { 121 Name: "earmark_parser", 122 Version: "1.4.25", 123 Language: pkg.Elixir, 124 Type: pkg.HexPkg, 125 Locations: locations, 126 PURL: "pkg:hex/earmark_parser@1.4.25", 127 MetadataType: pkg.MixLockMetadataType, 128 Metadata: pkg.MixLockMetadata{ 129 Name: "earmark_parser", 130 Version: "1.4.25", 131 PkgHash: "2024618731c55ebfcc5439d756852ec4e85978a39d0d58593763924d9a15916f", 132 PkgHashExt: "56749c5e1c59447f7b7a23ddb235e4b3defe276afc220a6227237f3efe83f51e", 133 }, 134 }, 135 { 136 Name: "ecto", 137 Version: "3.8.1", 138 Language: pkg.Elixir, 139 Type: pkg.HexPkg, 140 Locations: locations, 141 PURL: "pkg:hex/ecto@3.8.1", 142 MetadataType: pkg.MixLockMetadataType, 143 Metadata: pkg.MixLockMetadata{ 144 Name: "ecto", 145 Version: "3.8.1", 146 PkgHash: "35e0bd8c8eb772e14a5191a538cd079706ecb45164ea08a7523b4fc69ab70f56", 147 PkgHashExt: "f1b68f8d5fe3ab89e24f57c03db5b5d0aed3602077972098b3a6006a1be4b69b", 148 }, 149 }, 150 { 151 Name: "ecto_sql", 152 Version: "3.8.1", 153 Language: pkg.Elixir, 154 Type: pkg.HexPkg, 155 Locations: locations, 156 PURL: "pkg:hex/ecto_sql@3.8.1", 157 MetadataType: pkg.MixLockMetadataType, 158 Metadata: pkg.MixLockMetadata{ 159 Name: "ecto_sql", 160 Version: "3.8.1", 161 PkgHash: "1acaaba32ca0551fd19e492fc7c80414e72fc1a7140fc9395aaa53c2e8629798", 162 PkgHashExt: "ba7fc75882edce6f2ceca047315d5db27ead773cafea47f1724e35f1e7964525", 163 }, 164 }, 165 { 166 Name: "esbuild", 167 Version: "0.5.0", 168 Language: pkg.Elixir, 169 Type: pkg.HexPkg, 170 Locations: locations, 171 PURL: "pkg:hex/esbuild@0.5.0", 172 MetadataType: pkg.MixLockMetadataType, 173 Metadata: pkg.MixLockMetadata{ 174 Name: "esbuild", 175 Version: "0.5.0", 176 PkgHash: "d5bb08ff049d7880ee3609ed5c4b864bd2f46445ea40b16b4acead724fb4c4a3", 177 PkgHashExt: "f183a0b332d963c4cfaf585477695ea59eef9a6f2204fdd0efa00e099694ffe5", 178 }, 179 }, 180 { 181 Name: "ex_doc", 182 Version: "0.28.4", 183 Language: pkg.Elixir, 184 Type: pkg.HexPkg, 185 Locations: locations, 186 PURL: "pkg:hex/ex_doc@0.28.4", 187 MetadataType: pkg.MixLockMetadataType, 188 Metadata: pkg.MixLockMetadata{ 189 Name: "ex_doc", 190 Version: "0.28.4", 191 PkgHash: "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", 192 PkgHashExt: "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed", 193 }, 194 }, 195 { 196 Name: "gettext", 197 Version: "0.19.1", 198 Language: pkg.Elixir, 199 Type: pkg.HexPkg, 200 Locations: locations, 201 PURL: "pkg:hex/gettext@0.19.1", 202 MetadataType: pkg.MixLockMetadataType, 203 Metadata: pkg.MixLockMetadata{ 204 Name: "gettext", 205 Version: "0.19.1", 206 PkgHash: "564953fd21f29358e68b91634799d9d26989f8d039d7512622efb3c3b1c97892", 207 PkgHashExt: "10c656c0912b8299adba9b061c06947511e3f109ab0d18b44a866a4498e77222", 208 }, 209 }, 210 { 211 Name: "hpax", 212 Version: "0.1.1", 213 Language: pkg.Elixir, 214 Type: pkg.HexPkg, 215 Locations: locations, 216 PURL: "pkg:hex/hpax@0.1.1", 217 MetadataType: pkg.MixLockMetadataType, 218 Metadata: pkg.MixLockMetadata{ 219 Name: "hpax", 220 Version: "0.1.1", 221 PkgHash: "2396c313683ada39e98c20a75a82911592b47e5c24391363343bde74f82396ca", 222 PkgHashExt: "0ae7d5a0b04a8a60caf7a39fcf3ec476f35cc2cc16c05abea730d3ce6ac6c826", 223 }, 224 }, 225 { 226 Name: "jason", 227 Version: "1.3.0", 228 Language: pkg.Elixir, 229 Type: pkg.HexPkg, 230 Locations: locations, 231 PURL: "pkg:hex/jason@1.3.0", 232 MetadataType: pkg.MixLockMetadataType, 233 Metadata: pkg.MixLockMetadata{ 234 Name: "jason", 235 Version: "1.3.0", 236 PkgHash: "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", 237 PkgHashExt: "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac", 238 }, 239 }, 240 } 241 242 fixture := "test-fixtures/mix.lock" 243 244 // TODO: relationships are not under test 245 var expectedRelationships []artifact.Relationship 246 247 pkgtest.TestFileParser(t, fixture, parseMixLock, expected, expectedRelationships) 248 }