Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(purl): skip local Go packages #5190

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/purl/purl.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ func parseQualifier(pkg ftypes.Package) packageurl.Qualifiers {

func parsePkgName(name string) (string, string) {
var namespace string
if len(name) > 0 && name[len(name)-1] == '/' {
javierfreire marked this conversation as resolved.
Show resolved Hide resolved
name = name[:len(name)-1]
}
index := strings.LastIndex(name, "/")
if index != -1 {
namespace = name[:index]
Expand Down
16 changes: 16 additions & 0 deletions pkg/purl/purl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ func TestNewPackageURL(t *testing.T) {
},
},
},
{
name: "golang package with a local path",
typ: ftypes.GoModule,
pkg: ftypes.Package{
Name: "./private_repos/cnrm.googlesource.com/cnrm/",
knqyf263 marked this conversation as resolved.
Show resolved Hide resolved
Version: "(devel)",
},
want: purl.PackageURL{
PackageURL: packageurl.PackageURL{
Type: packageurl.TypeGolang,
Namespace: "./private_repos/cnrm.googlesource.com",
Name: "cnrm",
Version: "(devel)",
},
},
},
{
name: "hex package",
typ: ftypes.Hex,
Expand Down
Loading