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

Integrate support for custom types #155

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 7 additions & 2 deletions glad/glad.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (

var (
// https://gitlab.com/gitlab-org/advisories-community
supportedTypes = []string{"gem", "go", "maven", "npm", "nuget", "packagist", "pypi", "nuget", "conan"}
supportedTypes = []string{"gem", "go", "maven", "npm", "nuget", "packagist", "pypi", "nuget", "conan", "alpine"}
)

type Updater struct {
Expand All @@ -34,7 +34,12 @@ type Updater struct {
appFs afero.Fs
}

func NewUpdater(alternativeRepoURL string, alternativeRepoBranch string) Updater {
func NewUpdater(alternativeRepoURL string, alternativeRepoBranch string, customTypes string) Updater {
if len(customTypes) > 0 {
customTypes := strings.Split(customTypes, ",")
supportedTypes = append(supportedTypes, customTypes...)

Choose a reason for hiding this comment

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

@julianthome Rather than introduce a new flag, I don't see why we shouldn't add the new types to the supportedTypes list? I presume that eventually this data will also be included in advisories-community.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks a lot @Brcrwilliams. Yes adding the alpine package type makes total sense as a default 👍🏼. I just modified the PR accordingly.

However, having the flag/option to pass custom types may come in handy in the future if we want to integrate advisories about package types that are not officially supported yet. Having a flag would give us some flexibility by enabling us to freely experiment with new package types without having to go through upstream PRs.

}

return Updater{
alternativeRepoBranch: alternativeRepoBranch,
alternativeRepoURL: alternativeRepoURL,
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
years = flag.String("years", "", "update years (only redhat)")
targetUri = flag.String("target-uri", "", "alternative repository URI (only glad)")
targetBranch = flag.String("target-branch", "", "alternative repository branch (only glad)")
customTypes = flag.String("custom-types", "", "additional (comma-separated list) of custom package types (only glad)")
)

func main() {
Expand Down Expand Up @@ -176,7 +177,7 @@ func run() error {
}
commitMsg = "GitHub Security Advisory"
case "glad":
gu := glad.NewUpdater(*targetUri, *targetBranch)
gu := glad.NewUpdater(*targetUri, *targetBranch, *customTypes)
if err := gu.Update(); err != nil {
return xerrors.Errorf("GitLab Advisory Database update error: %w", err)
}
Expand Down