mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 00:46:38 +01:00
feat(golang): add license parsing from vendor dirs (#3522)
Signed-off-by: Dominik Schmidt <dev@dominik-schmidt.de> Signed-off-by: Keith Zantow <kzantow@gmail.com> Co-authored-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
co-authored by
Keith Zantow
parent
8198a706d6
commit
19a75fe504
@@ -68,6 +68,8 @@ func Test_LicenseSearch(t *testing.T) {
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
|
||||
localVendorDir := filepath.Join(wd, "test-fixtures", "licenses-vendor")
|
||||
|
||||
licenseScanner := licenses.TestingOnlyScanner()
|
||||
|
||||
tests := []struct {
|
||||
@@ -168,6 +170,51 @@ func Test_LicenseSearch(t *testing.T) {
|
||||
Locations: file.NewLocationSet(),
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "github.com/someorg/somename",
|
||||
version: "v0.3.2",
|
||||
config: CatalogerConfig{
|
||||
SearchLocalVendorLicenses: true,
|
||||
LocalVendorDir: localVendorDir,
|
||||
},
|
||||
expected: []pkg.License{{
|
||||
Value: "Apache-2.0",
|
||||
SPDXExpression: "Apache-2.0",
|
||||
Type: license.Concluded,
|
||||
URLs: []string{"file://$GO_VENDOR/github.com/someorg/somename/LICENSE"},
|
||||
Locations: file.NewLocationSet(),
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "github.com/CapORG/CapProject",
|
||||
version: "v4.111.5",
|
||||
config: CatalogerConfig{
|
||||
SearchLocalVendorLicenses: true,
|
||||
LocalVendorDir: localVendorDir,
|
||||
},
|
||||
expected: []pkg.License{{
|
||||
Value: "MIT",
|
||||
SPDXExpression: "MIT",
|
||||
Type: license.Concluded,
|
||||
URLs: []string{"file://$GO_VENDOR/github.com/!cap!o!r!g/!cap!project/LICENSE.txt"},
|
||||
Locations: file.NewLocationSet(),
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "github.com/someorg/strangelicense",
|
||||
version: "v1.2.3",
|
||||
config: CatalogerConfig{
|
||||
SearchLocalVendorLicenses: true,
|
||||
LocalVendorDir: localVendorDir,
|
||||
},
|
||||
expected: []pkg.License{{
|
||||
Value: "Apache-2.0",
|
||||
SPDXExpression: "Apache-2.0",
|
||||
Type: license.Concluded,
|
||||
URLs: []string{"file://$GO_VENDOR/github.com/someorg/strangelicense/LiCeNsE.tXt"},
|
||||
Locations: file.NewLocationSet(),
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user