Skip to content

Create utility for package version handling: parsing, normalization, comparison #119

Description

@pombredanne

There are many different versions styles and ways to express version ranges we need to deal with:

  • semver, deb, rpm, pypi, ... e.g. in general system and application package managers may use different version conventions
  • versions ranges and specs are used when referencing dependencies in package manifests but also may be used in advisory and vulnerabilities (cvss, npm advisories, etc.)

We need to craft a utility module to deal with these consistently. For starters in #101 npm avdisory use their own syntax to define these.
We may also need to deal with stored version ranges later.

This is based on this chat:
@NavonilDas wrote:

@pombredanne you can find an example at https://registry.npmjs.org/-/npm/v1/security/advisories?page=67 , with module name "electron"

@pombredanne wrote:

let me check: these are not versions but version ranges.
These would need to be resolved to actual concrete versions... The version ranges seem nice as they are more compact BUT they are not great to query things... so we would want to resolve these to actual real version numbers
so as a first step, having a simple function that takes such a version range for an npm and returns a list of real versions is likely a great first step

@NavonilDas wrote:

if I understand correctly, suppose the version range is >=2.0.0 <2.0.8 then the real version should be 2.0.7 and fixed version should be 2.0.8 am I right?

@pombredanne wrote:

well it should be any version that exist and is between 2.0.0 and 2.0.8. you have to take in small steps

parse the version constraints : hint check pip code for this... may be we can borrow code from that as this could be close enough to this (and the || are a way to split too)

once you have these parsed, the resolution in ranges may need to actually fetch the list of known versions for a given npm

not trivial :P
there is possibly some parsers out there too
Search https://registry.npmjs.org/-/npm/v1/security/advisories in code @ Github or searchco.de

See may be https://github.com/search?l=JavaScript&q=https%3A%2F%2Fregistry.npmjs.org%2F-%2Fnpm%2Fv1%2Fsecurity%2Fadvisories&type=Code and

https://github.com/search?l=Java&q=https%3A%2F%2Fregistry.npmjs.org%2F-%2Fnpm%2Fv1%2Fsecurity%2Fadvisories&type=Code

And here are some pointers:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions