github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/pkg/cataloger/swift/parse_podfile_lock_test.go (about) 1 package swift 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 TestParsePodfileLock(t *testing.T) { 13 fixture := "test-fixtures/Podfile.lock" 14 locations := file.NewLocationSet(file.NewLocation(fixture)) 15 expectedPkgs := []pkg.Package{ 16 { 17 Name: "GlossButtonNode", 18 Version: "3.1.2", 19 PURL: "pkg:cocoapods/GlossButtonNode@3.1.2", 20 Locations: locations, 21 Language: pkg.Swift, 22 Type: pkg.CocoapodsPkg, 23 Metadata: pkg.CocoaPodfileLockEntry{ 24 Checksum: "4ea1197a744f2fb5fb875fe31caf17ded4762e8f", 25 }, 26 }, 27 { 28 Name: "PINCache", 29 Version: "3.0.3", 30 PURL: "pkg:cocoapods/PINCache@3.0.3", 31 Locations: locations, 32 Language: pkg.Swift, 33 Type: pkg.CocoapodsPkg, 34 Metadata: pkg.CocoaPodfileLockEntry{ 35 Checksum: "7a8fc1a691173d21dbddbf86cd515de6efa55086", 36 }, 37 }, 38 { 39 Name: "PINCache/Arc-exception-safe", 40 Version: "3.0.3", 41 PURL: "pkg:cocoapods/PINCache/Arc-exception-safe@3.0.3", 42 Locations: locations, 43 Language: pkg.Swift, 44 Type: pkg.CocoapodsPkg, 45 Metadata: pkg.CocoaPodfileLockEntry{ 46 Checksum: "7a8fc1a691173d21dbddbf86cd515de6efa55086", 47 }, 48 }, 49 { 50 Name: "PINCache/Core", 51 Version: "3.0.3", 52 PURL: "pkg:cocoapods/PINCache/Core@3.0.3", 53 Locations: locations, 54 Language: pkg.Swift, 55 Type: pkg.CocoapodsPkg, 56 Metadata: pkg.CocoaPodfileLockEntry{ 57 Checksum: "7a8fc1a691173d21dbddbf86cd515de6efa55086", 58 }, 59 }, 60 { 61 Name: "PINOperation", 62 Version: "1.2.1", 63 PURL: "pkg:cocoapods/PINOperation@1.2.1", 64 Locations: locations, 65 Language: pkg.Swift, 66 Type: pkg.CocoapodsPkg, 67 Metadata: pkg.CocoaPodfileLockEntry{ 68 Checksum: "00c935935f1e8cf0d1e2d6b542e75b88fc3e5e20", 69 }, 70 }, 71 { 72 Name: "PINRemoteImage/Core", 73 Version: "3.0.3", 74 PURL: "pkg:cocoapods/PINRemoteImage/Core@3.0.3", 75 Locations: locations, 76 Language: pkg.Swift, 77 Type: pkg.CocoapodsPkg, 78 Metadata: pkg.CocoaPodfileLockEntry{ 79 Checksum: "f1295b29f8c5e640e25335a1b2bd9d805171bd01", 80 }, 81 }, 82 { 83 Name: "PINRemoteImage/iOS", 84 Version: "3.0.3", 85 PURL: "pkg:cocoapods/PINRemoteImage/iOS@3.0.3", 86 Locations: locations, 87 Language: pkg.Swift, 88 Type: pkg.CocoapodsPkg, 89 Metadata: pkg.CocoaPodfileLockEntry{ 90 Checksum: "f1295b29f8c5e640e25335a1b2bd9d805171bd01", 91 }, 92 }, 93 { 94 Name: "PINRemoteImage/PINCache", 95 Version: "3.0.3", 96 PURL: "pkg:cocoapods/PINRemoteImage/PINCache@3.0.3", 97 Locations: locations, 98 Language: pkg.Swift, 99 Type: pkg.CocoapodsPkg, 100 Metadata: pkg.CocoaPodfileLockEntry{ 101 Checksum: "f1295b29f8c5e640e25335a1b2bd9d805171bd01", 102 }, 103 }, 104 { 105 Name: "Reveal-SDK", 106 Version: "33", 107 PURL: "pkg:cocoapods/Reveal-SDK@33", 108 Locations: locations, 109 Language: pkg.Swift, 110 Type: pkg.CocoapodsPkg, 111 Metadata: pkg.CocoaPodfileLockEntry{ 112 Checksum: "effba1c940b8337195563c425a6b5862ec875caa", 113 }, 114 }, 115 { 116 Name: "SwiftGen", 117 Version: "6.5.1", 118 PURL: "pkg:cocoapods/SwiftGen@6.5.1", 119 Locations: locations, 120 Language: pkg.Swift, 121 Type: pkg.CocoapodsPkg, 122 Metadata: pkg.CocoaPodfileLockEntry{ 123 Checksum: "a6d22010845f08fe18fbdf3a07a8e380fd22e0ea", 124 }, 125 }, 126 { 127 Name: "Texture", 128 Version: "3.1.0", 129 PURL: "pkg:cocoapods/Texture@3.1.0", 130 Locations: locations, 131 Language: pkg.Swift, 132 Type: pkg.CocoapodsPkg, 133 Metadata: pkg.CocoaPodfileLockEntry{ 134 Checksum: "2e8ab2519452515f7f5a520f5a8f7e0a413abfa3", 135 }, 136 }, 137 { 138 Name: "Texture/AssetsLibrary", 139 Version: "3.1.0", 140 PURL: "pkg:cocoapods/Texture/AssetsLibrary@3.1.0", 141 Locations: locations, 142 Language: pkg.Swift, 143 Type: pkg.CocoapodsPkg, 144 Metadata: pkg.CocoaPodfileLockEntry{ 145 Checksum: "2e8ab2519452515f7f5a520f5a8f7e0a413abfa3", 146 }, 147 }, 148 { 149 Name: "Texture/Core", 150 Version: "3.1.0", 151 PURL: "pkg:cocoapods/Texture/Core@3.1.0", 152 Locations: locations, 153 Language: pkg.Swift, 154 Type: pkg.CocoapodsPkg, 155 Metadata: pkg.CocoaPodfileLockEntry{ 156 Checksum: "2e8ab2519452515f7f5a520f5a8f7e0a413abfa3", 157 }, 158 }, 159 { 160 Name: "Texture/MapKit", 161 Version: "3.1.0", 162 PURL: "pkg:cocoapods/Texture/MapKit@3.1.0", 163 Locations: locations, 164 Language: pkg.Swift, 165 Type: pkg.CocoapodsPkg, 166 Metadata: pkg.CocoaPodfileLockEntry{ 167 Checksum: "2e8ab2519452515f7f5a520f5a8f7e0a413abfa3", 168 }, 169 }, 170 { 171 Name: "Texture/Photos", 172 Version: "3.1.0", 173 PURL: "pkg:cocoapods/Texture/Photos@3.1.0", 174 Locations: locations, 175 Language: pkg.Swift, 176 Type: pkg.CocoapodsPkg, 177 Metadata: pkg.CocoaPodfileLockEntry{ 178 Checksum: "2e8ab2519452515f7f5a520f5a8f7e0a413abfa3", 179 }, 180 }, 181 { 182 Name: "Texture/PINRemoteImage", 183 Version: "3.1.0", 184 PURL: "pkg:cocoapods/Texture/PINRemoteImage@3.1.0", 185 Locations: locations, 186 Language: pkg.Swift, 187 Type: pkg.CocoapodsPkg, 188 Metadata: pkg.CocoaPodfileLockEntry{ 189 Checksum: "2e8ab2519452515f7f5a520f5a8f7e0a413abfa3", 190 }, 191 }, 192 { 193 Name: "Texture/Video", 194 Version: "3.1.0", 195 PURL: "pkg:cocoapods/Texture/Video@3.1.0", 196 Locations: locations, 197 Language: pkg.Swift, 198 Type: pkg.CocoapodsPkg, 199 Metadata: pkg.CocoaPodfileLockEntry{ 200 Checksum: "2e8ab2519452515f7f5a520f5a8f7e0a413abfa3", 201 }, 202 }, 203 { 204 Name: "TextureSwiftSupport", 205 Version: "3.13.0", 206 PURL: "pkg:cocoapods/TextureSwiftSupport@3.13.0", 207 Locations: locations, 208 Language: pkg.Swift, 209 Type: pkg.CocoapodsPkg, 210 Metadata: pkg.CocoaPodfileLockEntry{ 211 Checksum: "c515c7927fab92d0d9485f49b885b8c5de34fbfb", 212 }, 213 }, 214 { 215 Name: "TextureSwiftSupport/Components", 216 Version: "3.13.0", 217 PURL: "pkg:cocoapods/TextureSwiftSupport/Components@3.13.0", 218 Locations: locations, 219 Language: pkg.Swift, 220 Type: pkg.CocoapodsPkg, 221 Metadata: pkg.CocoaPodfileLockEntry{ 222 Checksum: "c515c7927fab92d0d9485f49b885b8c5de34fbfb", 223 }, 224 }, 225 { 226 Name: "TextureSwiftSupport/Experiments", 227 Version: "3.13.0", 228 PURL: "pkg:cocoapods/TextureSwiftSupport/Experiments@3.13.0", 229 Locations: locations, 230 Language: pkg.Swift, 231 Type: pkg.CocoapodsPkg, 232 Metadata: pkg.CocoaPodfileLockEntry{ 233 Checksum: "c515c7927fab92d0d9485f49b885b8c5de34fbfb", 234 }, 235 }, 236 { 237 Name: "TextureSwiftSupport/Extensions", 238 Version: "3.13.0", 239 PURL: "pkg:cocoapods/TextureSwiftSupport/Extensions@3.13.0", 240 Locations: locations, 241 Language: pkg.Swift, 242 Type: pkg.CocoapodsPkg, 243 Metadata: pkg.CocoaPodfileLockEntry{ 244 Checksum: "c515c7927fab92d0d9485f49b885b8c5de34fbfb", 245 }, 246 }, 247 { 248 Name: "TextureSwiftSupport/LayoutSpecBuilders", 249 Version: "3.13.0", 250 PURL: "pkg:cocoapods/TextureSwiftSupport/LayoutSpecBuilders@3.13.0", 251 Locations: locations, 252 Language: pkg.Swift, 253 Type: pkg.CocoapodsPkg, 254 Metadata: pkg.CocoaPodfileLockEntry{ 255 Checksum: "c515c7927fab92d0d9485f49b885b8c5de34fbfb", 256 }, 257 }, 258 { 259 Name: "TinyConstraints", 260 Version: "4.0.2", 261 PURL: "pkg:cocoapods/TinyConstraints@4.0.2", 262 Locations: locations, 263 Language: pkg.Swift, 264 Type: pkg.CocoapodsPkg, 265 Metadata: pkg.CocoaPodfileLockEntry{ 266 Checksum: "7b7ccc0c485bb3bb47082138ff28bc33cd49897f", 267 }, 268 }, 269 } 270 271 // TODO: no relationships are under test yet 272 var expectedRelationships []artifact.Relationship 273 274 pkgtest.TestFileParser(t, fixture, parsePodfileLock, expectedPkgs, expectedRelationships) 275 }