Skip to content

feat(supply-chain): add support for version ranges to dependency definitions#445

Draft
nhakmiller wants to merge 1 commit intomainfrom
nhakmiller-add-version-ranges
Draft

feat(supply-chain): add support for version ranges to dependency definitions#445
nhakmiller wants to merge 1 commit intomainfrom
nhakmiller-add-version-ranges

Conversation

@nhakmiller
Copy link
Copy Markdown
Contributor

@nhakmiller nhakmiller commented Mar 25, 2026

Context

I'm investigating what it could look like to support unpinned versions of dependencies, at least in processing requirements.txt (a special case of dependency source file which is kind of like a manifest file but also kind of like a lockfile.

This change adds a field for us to optionally track a version_specifier on a found_dependency in addition to a package name and version. We will consume this on the CLI to track non exact pinned versions.

  • I ran make setup && make to update the generated code after editing a .atd file
  • I made sure we're still backward compatible with old versions of the CLI.
    For example, the Semgrep backend need to still be able to consume data
    generated by Semgrep 1.50.0.
    See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades
    Note that the types related to the semgrep-core JSON output or the
    semgrep-core RPC do not need to be backward compatible!
  • Any accompanying changes in semgrep-proprietary are approved and ready to merge once this PR is merged

(* alt: sca_dependency? *)
type found_dependency <ocaml attr="deriving ord"> = {
package: string;
version: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think should go here when version_specifier is provided? I wonder if version_specifier should just replace version? It couple then be one of Exact string | Constraints version_constraint list or something

When present, indicates the dependency version is a range rather than a
pinned version, and matching should use range overlap instead of exact
version comparison.">
: string option;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about parsing this out in to something like

type version_constraint = [
| Gt of string
| Lt of string
| Geq of string
| Leq of string
]

Where the string in each is a version string? I'm thinking this could be better because there are all kinds of funky version specifiers used that can be package manager specific (`>` vs `~` and `^` etc) and it would be nice to have the parsers handle the package-manager-specific stuff.

Copy link
Copy Markdown
Contributor

@bkettle bkettle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other thing we need to think about is how the app will handle this stuff and put it into its database, since the DB currently expects an exact version as well. You probably know the most about what's feasible there from your experience with the version filters

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.

2 participants