Documentation
¶
Overview ¶
Package versionorder orders the versions of one package by the rules of the ecosystem it comes from.
Every ecosystem orders differently. Debian's `3.0.17-1~deb12u3` is newer than `3.0.17-1~deb12u2` and `1.0~rc1` is older than `1.0`; PEP 440 puts `1.0rc1` before `1.0` and `1.0.post1` after it; Maven's `2.13.4.2` follows `2.13.4`. A comparison that reads dotted numbers alone gets each of these wrong, and a wrong order recommends an upgrade that leaves findings behind or a downgrade of a working dependency.
The rules are osv-scalibr's, which are the ones OSV's own matching uses. Where the ecosystem is not one it orders, or a version does not parse in it, Compare says so rather than guessing, and the caller keeps every version it was given.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare returns -1, 0 or +1 as a is older than, the same as or newer than b under ecosystem's rules. ok is false when the ecosystem is not one this orders, or either version does not parse in it, and then the order is unknown rather than equal.
func Ecosystem ¶
Ecosystem names the rules that order a package's versions, from its package URL or, without one, from the ecosystem a scanner reported. Empty when neither names rules this package knows.
func MavenCoordinate ¶ added in v0.171.0
MavenCoordinate is the groupId:artifactId a Maven package URL names, and false for any other package URL.
Types ¶
type Version ¶ added in v0.165.3
type Version struct {
// contains filtered or unexported fields
}
Version is one version parsed under one ecosystem's rules, for a caller comparing it many times. Comparing two Versions gives the answer Compare gives for the strings they were parsed from.
func Parse ¶ added in v0.165.3
Parse reads s as a version under ecosystem's rules. ok is false where Compare would have no order for s against any version: the ecosystem is not one this orders, or s does not parse in it.