Repository navigation
Conversation
Implement PKG:001 (package-exists) and PKG:002 (package-versions-exist) for the opam ecosystem. Packages and versions removed from opam-repository are moved to opam-repository-archive, so both repositories are consulted: - Package existence is checked against opam.ocaml.org, falling back to opam-repository-archive via the GitHub contents API. - Version existence is checked by looking up the packages/<pkg>/<pkg>.<version>/opam file in opam-repository and then opam-repository-archive. osv-scalibr has no opam version parser, so versions are matched exactly. Signed-off-by: Boning <me@boni.ng>
- Check versions against opam.ocaml.org/packages/<pkg>/<pkg>.<version>/ like the package check, only falling back to opam-repository-archive for archived versions. - Report missing versions with MissingVersionsError. Since opam has no API listing all versions of a package, Known is left nil and omitted from the message. - Inline the opam-repository-archive URLs and drop opam.go and the path escaping, which no other ecosystem does. Signed-off-by: Boning <me@boni.ng>
The linter only uses the message of the error, so report missing opam versions with a plain error, like goVersionsExist does, rather than changing MissingVersionsError for all ecosystems. Signed-off-by: Boning <me@boni.ng>
bn-d
marked this pull request as ready for review
November 3, 2026 20:04
Author
|
@hannesm could you take a look at this PR? Thanks |
bn-d
added a commit
to bn-d/security-advisories
that referenced
this pull request
Nov 3, 2026
Build osv-linter from bn-d/osv-schema#linter-opam (ossf/osv-schema#652) and lint all advisories with the ALL collection, which includes the PKG:001/PKG:002 package checks. Signed-off-by: Boning <me@boni.ng>
bn-d
added a commit
to bn-d/security-advisories
that referenced
this pull request
Nov 4, 2026
Build osv-linter from bn-d/osv-schema#linter-opam (ossf/osv-schema#652) and lint all advisories with the ALL collection, which includes the PKG:001/PKG:002 package checks. Signed-off-by: Boning <me@boni.ng>
bn-d
added a commit
to bn-d/security-advisories
that referenced
this pull request
Nov 4, 2026
Build osv-linter from bn-d/osv-schema#linter-opam (ossf/osv-schema#652) and lint all advisories with the ALL collection, which includes the PKG:001/PKG:002 package checks. Signed-off-by: Boning <me@boni.ng>
bn-d
added a commit
to bn-d/security-advisories
that referenced
this pull request
Nov 4, 2026
Build osv-linter from bn-d/osv-schema#linter-opam (ossf/osv-schema#652) and lint all advisories with the ALL collection, which includes the PKG:001/PKG:002 package checks. Signed-off-by: Boning <me@boni.ng>
Contributor
|
I'm not very familiar with go, but this looks good. I remember in osv.dev initially I developed the python module for the opam ecosystem which used the GitHub API (google/osv.dev#4582), but due to rate limits this was discarded (google/osv.dev#4756). I guess for the linter it is fine to use the GitHub API. |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements PKG:001 (
package-exists) and PKG:002 (package-versions-exist) for theopamecosystem. Currently both checks pass every opam record without a lookup, sinceopamis a known ecosystem with no registry checker.Approach
Packages and versions removed from opam-repository are moved to opam-repository-archive, so both repositories need to be consulted. This matches osv.dev's own
opamecosystem, which enumerates versions from both repositories.HEAD https://opam.ocaml.org/packages/<pkg>/, falling back to the GitHub contents API foropam-repository-archive/packages/<pkg>. The API fallback is only hit for archived or non-existent packages, which keeps usage of the unauthenticated API rate limit low.HEADofpackages/<pkg>/<pkg>.<version>/opamon raw.githubusercontent.com inopam-repository, thenopam-repository-archive. This avoids the API rate limit entirely.osv-scalibrhas no opam version parser, so versions are matched exactly, which is also how versions are named in the repository.Testing
Test_existsInOpamandTest_versionsExistInOpam, covering current, archived, and non-existent packages and versions.go test ./...,gofmt -s,go vet ./...andgo mod tidy -diffpass.osv record lint(ALLcollection) over all 35 published OCaml advisories (OSEC-*) covering 619 package versions. 380 of those versions only exist in opam-repository-archive. The run took about 15s with--parallel 8and flagged 5 genuinely non-existent versions, e.g.ocaml5and4.04(rather than5.0.0/4.04.0), with no false positives.