-
Notifications
You must be signed in to change notification settings - Fork 53
feat: fix parsing of names and namespaces with colons #178
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,3 +330,47 @@ def test_to_dict_custom_empty_value(self): | |
| def test_purl_is_hashable(): | ||
| s = {PackageURL(name="hashable", type="pypi")} | ||
| assert len(s) == 1 | ||
|
|
||
|
|
||
| def test_colons_in_name_are_handled_correctly() -> None: | ||
| p = PackageURL.from_string( | ||
| "pkg:nuget/libiconv:%20character%20set%20conversion%20library@1.9?package-id=e11a609df352e292" | ||
| ) | ||
|
|
||
| assert p.type == "nuget" | ||
| assert p.namespace is None | ||
| assert p.name == "libiconv: character set conversion library" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a real name, seen in the wild? I do not think this would be a valid NuGet name.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is the name that started me down this nightmare of journey. :) It's a name picked up by syft in a binary component.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you have a URL to this? Because afaik this is not a legal NuGet name. It could be a bug in syft, which is known to create incorrect PURLs. |
||
| assert p.version == "1.9" | ||
| assert p.qualifiers == {"package-id": "e11a609df352e292"} | ||
| assert p.subpath is None | ||
|
|
||
| assert PackageURL.from_string(p.to_string()).to_string() == p.to_string() | ||
|
|
||
|
|
||
| def test_colons_in_namespace_are_handled_correctly() -> None: | ||
| p = PackageURL.from_string( | ||
| "pkg:nuget/an:odd:space/libiconv:%20character%20set%20conversion%20library@1.9?package-id=e11a609df352e292" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use actual real life data rather than made up ones? In all cases the colon should be encoded there IMHO.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't seen a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so you saw a colon in a namespace in a PURL? I would really like to see that exact PURL and which tool did create that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not have a namespace with a colon, but I did see a name with a colon.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sjn you have :: colons in CPAN, do you? |
||
| ) | ||
|
|
||
| assert p.type == "nuget" | ||
| assert p.namespace == "an:odd:space" | ||
| assert p.name == "libiconv: character set conversion library" | ||
| assert p.version == "1.9" | ||
| assert p.qualifiers == {"package-id": "e11a609df352e292"} | ||
| assert p.subpath is None | ||
|
|
||
| assert PackageURL.from_string(p.to_string()).to_string() == p.to_string() | ||
|
|
||
|
|
||
| def test_encoding_stuff_with_colons_correctly() -> None: | ||
| p = PackageURL( | ||
| type="nuget", | ||
| namespace="an:odd:space", | ||
| name="libiconv: character set conversion library", | ||
| version="1.9", | ||
| qualifiers={"package-id": "e11a609df352e292"}, | ||
| ) | ||
| assert ( | ||
| p.to_string() | ||
| == "pkg:nuget/an:odd:space/libiconv:%20character%20set%20conversion%20library@1.9?package-id=e11a609df352e292" | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.