mirror of
https://github.com/anchore/syft
synced 2024-11-10 06:14:16 +00:00
Map the downloadLocation field for PHP Composer packages (#3011)
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
This commit is contained in:
parent
de3313cfb6
commit
b101f44aba
2 changed files with 48 additions and 0 deletions
|
@ -22,6 +22,10 @@ func DownloadLocation(p pkg.Package) string {
|
|||
return NoneIfEmpty(metadata.URL)
|
||||
case pkg.NpmPackageLockEntry:
|
||||
return NoneIfEmpty(metadata.Resolved)
|
||||
case pkg.PhpComposerLockEntry:
|
||||
return NoneIfEmpty(metadata.Dist.URL)
|
||||
case pkg.PhpComposerInstalledEntry:
|
||||
return NoneIfEmpty(metadata.Dist.URL)
|
||||
}
|
||||
}
|
||||
return NOASSERTION
|
||||
|
|
|
@ -64,6 +64,50 @@ func Test_DownloadLocation(t *testing.T) {
|
|||
},
|
||||
expected: NONE,
|
||||
},
|
||||
{
|
||||
name: "from php installed.json",
|
||||
input: pkg.Package{
|
||||
Metadata: pkg.PhpComposerInstalledEntry{
|
||||
Dist: pkg.PhpComposerExternalReference{
|
||||
URL: "http://package-lock.test",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "http://package-lock.test",
|
||||
},
|
||||
{
|
||||
name: "empty",
|
||||
input: pkg.Package{
|
||||
Metadata: pkg.PhpComposerInstalledEntry{
|
||||
Dist: pkg.PhpComposerExternalReference{
|
||||
URL: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "NONE",
|
||||
},
|
||||
{
|
||||
name: "from php composer.lock",
|
||||
input: pkg.Package{
|
||||
Metadata: pkg.PhpComposerLockEntry{
|
||||
Dist: pkg.PhpComposerExternalReference{
|
||||
URL: "http://package-lock.test",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "http://package-lock.test",
|
||||
},
|
||||
{
|
||||
name: "empty",
|
||||
input: pkg.Package{
|
||||
Metadata: pkg.PhpComposerLockEntry{
|
||||
Dist: pkg.PhpComposerExternalReference{
|
||||
URL: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "NONE",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue