-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2b94e3
commit decae61
Showing
6 changed files
with
32 additions
and
25 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
extractor/filesystem/language/python/internal/pypipurl/pythonpurl.go
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Package pypipurl converts an inventory to a PyPI type PackageURL. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
another-rex
Author
Collaborator
|
||
package pypipurl | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/google/osv-scalibr/extractor" | ||
"github.com/google/osv-scalibr/purl" | ||
) | ||
|
||
// MakePackageURL returns a package URL following the purl PyPI spec: | ||
// - Name is lowercased | ||
// - Replaces _ with - | ||
// | ||
// See: https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#pypi | ||
func MakePackageURL(i *extractor.Inventory) *purl.PackageURL { | ||
return &purl.PackageURL{ | ||
Type: purl.TypePyPi, | ||
Name: strings.ReplaceAll(strings.ToLower(i.Name), "_", "-"), | ||
Version: i.Version, | ||
} | ||
} |
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
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
Can you add a TODO to move this into the regular osv-scalibr/purl library? e.g. make a New() function that creates the PURL and applies this transformation for Python purls, and use that everywhere in SCALIBR instead of using &purl.PackageURL{...}
If you use an internal bug to track this you can use the syntax // TODO(b/...): ... With a link to the internal bug