Skip to content

Cannot parse vers:nginx/* #19

Description

@Hritik14
>>> VersionRange.from_string("vers:nginx/*")
---------------------------------------------------------------------------
InvalidVersion                            Traceback (most recent call last)
<ipython-input-17-2f9540ab85ba> in <module>
----> 1 VersionRange.from_string("vers:nginx/*")

~/Contrib/vulnerablecode/venv/lib/python3.10/site-packages/univers/version_range.py in from_string(cls, vers)
     84             and_constraints = []
     85             for constraint in or_constraints.split(","):
---> 86                 constraint = VersionConstraint.from_string(
     87                     string=constraint,
     88                     version_class=range_class.version_class,

~/Contrib/vulnerablecode/venv/lib/python3.10/site-packages/univers/version_constraint.py in from_string(cls, string, version_class)
     97             raise ValueError("Empty version")
     98
---> 99         version = version_class(version)
    100         return cls(comparator, version)
    101

~/Contrib/vulnerablecode/venv/lib/python3.10/site-packages/univers/versions.py in __init__(self, string, normalized_string, value)
      5     _inst_dict['normalized_string'] = normalized_string
      6     _inst_dict['value'] = value
----> 7     self.__attrs_post_init__()

~/Contrib/vulnerablecode/venv/lib/python3.10/site-packages/univers/versions.py in __attrs_post_init__(self)
     57         normalized_string = self.normalize(self.string)
     58         if not self.is_valid(normalized_string):
---> 59             raise InvalidVersion(f"{self.string!r} is not a valid {self.__class__!r}")
     60
     61         # See https://www.attrs.org/en/stable/init.html?#post-init

InvalidVersion: '' is not a valid <class 'univers.versions.SemverVersion'>

This happens because there's no version information available for * version constraint and yet creation of a version is attempted:
https://github.com/nexB/univers/blob/a52ea9900d87ef6cd0ed989bf20a41a794cf39c4/src/univers/version_constraint.py#L99-L100

This can be solved by accepting #10

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions