Skip to content

Use opam package versions that exist in affected ranges - #50

Closed
bn-d wants to merge 1 commit into
ocaml:mainfrom
bn-d:fix-opam-versions
Closed

bn-d wants to merge 1 commit into
ocaml:mainfrom
bn-d:fix-opam-versions

Conversation

@bn-d

@bn-d bn-d commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

osv-linter's PKG:002 check requires every version in an ECOSYSTEM range to exist in opam-repository (or opam-repository-archive). Replace lower bounds that are not released versions with the earliest real one:

  • OSEC-2017-01: ocaml "4.04" -> "4.04.0"
  • OSEC-2022-01: solo5 "0.6.6" -> "0.7.0"; 0.6.x was released as solo5-bindings-xen, which is now mentioned in the advisory text
  • OSEC-2023-01: opam-repository "2" -> "2.0.0beta", the first release containing the download cache (cfa4e77); "2" also included 2.0alpha5
  • OSEC-2026-01, -05, -25, -26: ocaml "5" -> "5.0.0"
  • OSEC-2026-09: albatross "1.0.0" -> "1.0.1", the first opam release

osv-linter's PKG:002 check requires every version in an ECOSYSTEM range
to exist in opam-repository (or opam-repository-archive). Replace lower
bounds that are not released versions with the earliest real one:

- OSEC-2017-01: ocaml "4.04" -> "4.04.0"
- OSEC-2022-01: solo5 "0.6.6" -> "0.7.0"; 0.6.x was released as
  solo5-bindings-xen, which is now mentioned in the advisory text
- OSEC-2023-01: opam-repository "2" -> "2.0.0~beta", the first release
  containing the download cache (cfa4e77); "2" also included 2.0~alpha5
- OSEC-2026-01, -05, -25, -26: ocaml "5" -> "5.0.0"
- OSEC-2026-09: albatross "1.0.0" -> "1.0.1", the first opam release

Signed-off-by: Boning <me@boni.ng>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bn-d
bn-d force-pushed the fix-opam-versions branch from 7dbf0fe to d452958 Compare November 4, 2026 02:38
@bn-d
bn-d marked this pull request as ready for review November 4, 2026 02:46
@bn-d
bn-d requested review from edwintorok and hannesm November 4, 2026 02:46
@hannesm

hannesm commented Nov 4, 2026

Copy link
Copy Markdown
Member

I understand what is done here, but at the same time I wonder why this is needed. The expression in the affected aims to be similar to what you write in opam files, and there the versions don't need to exist in the opam-repository. It looks to me that you want to reuse these affected expressions elsewhere and require them to be actual versions -- but why?

@bn-d

bn-d commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

and there the versions don't need to exist in the opam-repository

Then should we list those version in the OPAM purl and ecosystem type? Should they just list them under SEMVER type?

Edit: this is mainly done for the osv-lint. I see 3 options:

  • Accept this PR, because the change is also valid and correct OPAM syntax.
  • Change the advisory tool to generate exact version in the osv json, and keep the md unchanged.
  • Loosen the osv-lint PR logic to accept version like 4.0

@hannesm

hannesm commented Nov 4, 2026

Copy link
Copy Markdown
Member

The advisories tool indeed already uses the opam-repository (and opam-repository-archive) to write out the exact versions affected. Please take a look at https://github.com/ocaml/security-advisories/blob/generated-osv/2017/OSEC-2017-01.json#L49-L52 or https://github.com/ocaml/security-advisories/blob/generated-osv/2026/OSEC-2026-01.json#L98-L179

@bn-d

bn-d commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

We are talking about different section

"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "4.04"
},
{
"fixed": "4.04.2"
}
]
},

@edwintorok

Copy link
Copy Markdown
Collaborator

Using package versions that exist (or have existed) in the repository can prevent typos, OTOH I agree with #50 (comment) that ">= 5" should be just as valid as ">= 5.0.0".

Since the tool already knows how to expand the semver range into exact versions, then it should be possible to make it emit exact introduced values too, so I'd have a slight preference towards improving the tool so instead of generating #50 (comment) it'd generate "introduced" : "4.04.0".
I don't have a strong opinion though, if it is easier to merge this PR to make the linter pass, and then work on the tool to improve it, that'd be fine too.

@bn-d bn-d closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants