feat(pipeline): Support GitHub Actions commit enumeration - #6012
Conversation
|
/gemini review |
|
Please read our contributing guide before opening pull requests |
michaelkedar
left a comment
There was a problem hiding this comment.
Thanks for working on this!
| if owner == "." || owner == ".." || repo == "." || repo == ".." || | ||
| strings.Contains(owner, "..") || strings.Contains(repo, "..") { |
There was a problem hiding this comment.
nit: strings.Contains(owner, "..") does cover owner == "..", so we could make this if statement a bit shorter
| Fixed: e.GetFixed(), | ||
| LastAffected: e.GetLastAffected(), | ||
| Limit: e.GetLimit(), | ||
| } |
There was a problem hiding this comment.
We actually need to convert these from version strings to git commit SHAs ("introduced": "0", "fixed": "123abcdef....").
We have a GetTags method on the Gitter client which should return the list of tags and commits - you should be able to create and add the Gitter client to the EnrichParams to use it.
I think you'll still need to do some form of normalisation of the git tags to match the version - a quick look at some of the Github Actions repos is that the tags often have a leading v that would need to be stripped. I'm not too sure if any other normalization is necessary, but there is some more thorough logic somewhere in vulnfeeds that might be useful reference if needed.
| ) | ||
|
|
||
| // EcosystemGitHubActions is the canonical OSV ecosystem name for GitHub Actions. | ||
| const EcosystemGitHubActions = "GitHub Actions" |
There was a problem hiding this comment.
nit: we could use this constant from osv-schema/bindings/go/osvconstants
Overview
Adds automated Git commit enumeration support for the
GitHub Actionsecosystem within the OSV worker pipeline (go/internal/worker/pipeline/githubactions/).Fixes #6013
Details
Currently, GitHub Actions advisories imported into OSV only specify
SEMVERorECOSYSTEMversion ranges. When workflows pin actions to immutable Git commit SHAs (as recommended by OpenSSF Scorecard), vulnerability scanners querying OSV by commit SHA cannot match these advisories.This pull request implements:
ExtractGitHubRepoURL): Parses GitHub Action package identifiers into their canonical repository URLs (https://github.com/<owner>/<repo>), gracefully handling nested sub-action directories (e.g.,docker/build-push-action/v2), leading slashes,.gitsuffixes, and directory traversal (..) attempts.githubactions.Enricher): Inspects vulnerability records affecting theGitHub Actionsecosystem. For each affected package, it extracts the repository URL and injects companionRange_GITranges duplicating the version events (introduced / fixed / last_affected).Range_GITranges and queries the Gitter service, injecting companionRange_GITranges automatically enumerates intermediate commits and tags intoaffected.versionswith zero changes required to Gitter or the core engine.Enrichdo not duplicate existingRange_GITentries, and events are deep-copied to prevent shared pointer mutation.&githubactions.Enricher{}ininternal/worker/pipeline/registry/registry.go.Testing
go/internal/worker/pipeline/githubactions/githubactions_test.gocovering URL canonicalization, sub-action normalization, malicious path handling, SEMVER/ECOSYSTEM range companion generation, non-GitHub Actions filtering, and idempotency.go test -race -v ./internal/worker/pipeline/githubactions/...(100% PASS).gofmt -s -d(0 diffs).go vet ./internal/worker/pipeline/githubactions/...(0 warnings).stringscutprefix,nlreturn, andprotogetterprotobuf accessor compliance).