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

Modify from_string for golang purls #115

Merged
merged 4 commits into from Dec 8, 2023

Conversation

TG1999
Copy link
Collaborator

@TG1999 TG1999 commented Mar 27, 2023

Golang packages does not have a definitive way to store namespace and name of a package. sometimes name can have two or more than two '/' separated components and same is also the case for namespace so for that reason we should totally drop namespaces for golang purls and store the whole purl name in name.

@TG1999 TG1999 requested review from pombredanne and tdruez and removed request for pombredanne March 27, 2023 15:15
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks: some nits for you consideration!

@@ -518,7 +518,7 @@ def from_string(cls, purl: str) -> "PackageURL":
# and the namespace in an npm purl is
# different from others because it starts with `@`
# so we need to handle this case separately
if type == "npm" and path.startswith("@"):
if type.lower() == "npm" and path.startswith("@"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -530,7 +530,10 @@ def from_string(cls, purl: str) -> "PackageURL":
ns_name_parts = ns_name.split("/")
ns_name_parts = [seg for seg in ns_name_parts if seg and seg.strip()]
name = ""
if not namespace and len(ns_name_parts) > 1:
if type.lower() == "golang":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really do not like these warts for each type: npm, now golang .... sigh ... eventually we will need to bubble these issue up in the spec. They have little impact since they do not change the purl, only how a purl is interpreted.... But for golang there is the issue of legacy that uses a subpath.

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
@TG1999
Copy link
Collaborator Author

TG1999 commented Mar 28, 2023

Add migrations, documentation and warnings in CHANGELOG for the above changes. Create a branch for migrations in VCIO, scancode.io and PurlDB for the above changes in golang.

@tdruez tdruez merged commit baf0c61 into package-url:main Dec 8, 2023
16 checks passed
TG1999 added a commit to TG1999/packageurl-python that referenced this pull request Dec 8, 2023
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
tdruez pushed a commit that referenced this pull request Dec 11, 2023
* Revert changes from #115

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>

* Add CHANGELOG

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>

* Bump version to 0.13.0

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>

---------

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Dec 11, 2023
0.12.0 (2023-12-08)
-------------------

- Modified `PackageURL.from_string` to properly handle golang purls.
  package-url/packageurl-python#115

- Improve support for PyPI URLs in `url2purl`.
  package-url/packageurl-python#128

- Return the "gem" type instead of "rubygems" for "https://rubygems.org/" URLs in
  `url2purl`. The `pkg:rubygems/` purls are backward-compatible in `purl2url`.
  package-url/packageurl-python#114

0.11.3 (2023-12-08)
--------------------

- Add support for GitLab "/archive/" URLs in `url2purl`.
  package-url/packageurl-python#133
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Dec 11, 2023
0.13.0 (2023-12-08)

- Revert changes from
  package-url/packageurl-python#115
@TG1999 TG1999 deleted the golang_purl_from_string branch December 12, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants