-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): support conan purl query (#2961)
fixes #2960 Although OSV.dev currently doesn't have any `ConanCenter` records, it's listed in the OSV schema. So adding support for ConanCenter PURL query. The other ecosystems listed in the comments cannot be converted into PURL strings because they are not defined in the PURL spec. Queries for these ecosystems will return a 400 error with an "unknown PURL ecosystem" message
- Loading branch information
Showing
4 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,15 @@ def tests_package_to_purl(self): | |
self.assertEqual('pkg:cran/commonmark', | ||
purl_helpers.package_to_purl('CRAN', 'commonmark')) | ||
|
||
self.assertEqual('pkg:conan/openssl', | ||
purl_helpers.package_to_purl('ConanCenter', 'openssl')) | ||
|
||
self.assertEqual('pkg:pypi/django', | ||
purl_helpers.package_to_purl('PyPI', 'django')) | ||
|
||
self.assertEqual('pkg:rpm/mageia/python-aiohttp', | ||
purl_helpers.package_to_purl('Mageia', 'python-aiohttp')) | ||
|
||
self.assertEqual( | ||
'pkg:maven/org.apache.struts/struts2-core', | ||
purl_helpers.package_to_purl('Maven', 'org.apache.struts:struts2-core')) | ||
|
@@ -146,6 +152,9 @@ def test_parse_purl(self): | |
self.assertEqual(('CRAN', 'commonmark', None), | ||
purl_helpers.parse_purl('pkg:cran/commonmark')) | ||
|
||
self.assertEqual(('ConanCenter', 'openssl', '3.0.3'), | ||
purl_helpers.parse_purl('pkg:conan/[email protected]')) | ||
|
||
self.assertEqual(('Debian', 'mpg123', '1.26.4-1+deb11u1'), | ||
purl_helpers.parse_purl( | ||
'pkg:deb/debian/[email protected]+deb11u1?arch=source')) | ||
|
@@ -163,6 +172,10 @@ def test_parse_purl(self): | |
self.assertEqual(('Hex', 'acme/foo', '2.3.'), | ||
purl_helpers.parse_purl('pkg:hex/acme/[email protected].')) | ||
|
||
self.assertEqual(('Mageia', 'python-aiohttp', None), | ||
purl_helpers.parse_purl( | ||
'pkg:rpm/mageia/python-aiohttp?distro=mageia-9')) | ||
|
||
self.assertEqual(('Maven', 'org.apache.struts:struts2-core', '1.0.0'), | ||
purl_helpers.parse_purl( | ||
'pkg:maven/org.apache.struts/[email protected]')) | ||
|
@@ -221,8 +234,7 @@ def test_parse_purl(self): | |
('Wolfi', 'test-package', '1.2.3'), | ||
purl_helpers.parse_purl('pkg:apk/wolfi/[email protected]')) | ||
|
||
with self.assertRaises(ValueError): | ||
purl_helpers.parse_purl('pkg:bad/ubuntu/pygments') | ||
self.assertIsNone(purl_helpers.parse_purl('pkg:bad/ubuntu/pygments')) | ||
|
||
with self.assertRaises(ValueError): | ||
purl_helpers.parse_purl('purl:apk/wolfi/[email protected]') | ||
|