Skip to content

Commit 12ebed2

Browse files
authored
Merge pull request #9 from nexB/new-skeleton
Improve code, doc and adopt latest skeleton
2 parents 63bd5ae + 92c9db1 commit 12ebed2

82 files changed

Lines changed: 7553 additions & 517 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Ignore all Git auto CR/LF line endings conversions
22
* -text
3+
pyproject.toml export-subst

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
/build
88
/bin
99
/lib
10-
/venv
1110
/scripts
1211
/Scripts
1312
/Lib
1413
/pip-selfcheck.json
1514
/tmp
15+
/venv
1616
.Python
1717
/include
1818
/Include

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ python:
1313
- "3.6"
1414
- "3.7"
1515
- "3.8"
16+
- "3.9"
1617

1718
# Scripts to run at install stage
18-
install: pip install ./ && pip install -r requirements-dev.txt
19+
install: ./configure --dev
1920

2021
# Scripts to run at script stage
21-
script: python -m pytest
22+
script: venv/bin/pytest

AUTHORS.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
The following organizations or individuals have contributed to this repo:
22

3-
-
3+
- Shivam Sandbhor
4+
- nexB Inc.
5+
- Philippe Ombredanne
6+

CHANGELOG.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
Release notes
22
-------------
3+
4+
### Version v30.0.0
5+
6+
- Switching back to semver
7+
- Improve origin and license documentation
8+
- Add tests for carets in RPMs
9+
- Format, stremmline and refactor code
10+
- Improve testing
11+
12+
313
### Version v21.4.9
414

5-
- Added support Gentoo style versions.
15+
- Add support Gentoo style versions.
16+
617

718
### Version v21.4.8
819

9-
- More package types supported.
10-
- Version classes are hashable and frozen now
20+
- Add support for more package types.
21+
- Version classes are now hashable and frozen
22+
1123

1224
### Version v21.4.6
1325

1426
- Initial Release
15-

NOTICE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Copyright (c) nexB Inc. and others.
33
# SPDX-License-Identifier: Apache-2.0
44
#
5-
# Visit https://aboutcode.org and https://github.com/nexB/ for support and download.
5+
# Visit https://aboutcode.org and https://github.com/nexB/vulnerablecode
6+
# for support and download.
67
#
78
# Licensed under the Apache License, Version 2.0 (the "License");
89
# you may not use this file except in compliance with the License.
@@ -15,3 +16,4 @@
1516
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1617
# See the License for the specific language governing permissions and
1718
# limitations under the License.
19+
#

README.rst

Lines changed: 78 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Univers: Ecosystem specific version comparision and conversion
2-
==============================================================
1+
univers: mostly universal version and version ranges comparison and conversion
2+
===============================================================================
33

44
|Build Status| |License| |Python 3.6+|
55

@@ -11,43 +11,76 @@ Univers: Ecosystem specific version comparision and conversion
1111

1212

1313

14-
Why ecosystem specific ?
15-
========================
14+
univers was born out of the need for a mostly univeral way to perform software
15+
package version comparisons in VulnerableCode.
1616

17-
Univers was born out of the need for version comparision at VulnerableCode. Existing
18-
tools follow a particular algorithm to evaluate and compare versions. This is not
19-
accurate across different ecosystems, since they follow different versioning rules. For
20-
example there's no concept of 'epoch' in semver based ecosystem like npm or ruby gems, but
21-
epochs do exist in debian ecosystem. The tools solely based on semver or dpkg version spec therefore
22-
give different and wrong results in both cases.
17+
Package version ranges and version constraints are useful and essential:
2318

24-
Univers is different, it considers the ecosystem of version.
19+
- When resolving the dependencies of a package to express which subset of the
20+
versions are supported. For instance a dependency requirement statement such
21+
as "I require package foo, version 2.0 and later versions" defines a range of
22+
acceptable foo versions.
2523

26-
How Univers works ?
27-
===================
24+
- When relating a known vulnerability or bug to a range of affected package
25+
versions. For instance a statement such as "vulnerability 123 affects
26+
package bar, version 3.1 and version 4.2 but not version 5" also defines a
27+
range of affected bar versions.
2828

29-
Univers, can be considered as a wrapper around many version comparision libraries, each of which
30-
solving the problem for the respective ecosystem. It delegates the actual comparision to these libraries
31-
depending upon the ecosystem.
29+
Existing tools support typically a single algorithm to parse and compare
30+
versions and this is not accurate across different ecosystems, since each
31+
follow different versioning rules. For example there's no concept of 'epoch' in
32+
semver versioning as used in package types and ecosystem such as npm or
33+
rubygems, but epochs do exist in debian versions. A tool designed for semver or
34+
dpkg versions processing would not be able to handle correctly the other version
35+
scheme.
3236

37+
univers is different and considers the ecosystem-specific version scheme used.
3338

34-
The supported ecosystems and underlying libraries are:
3539

36-
- npm, golang, php-composer, ruby-gems and others which follow the semver spec. These use `semantic_version <https://github.com/rbarrois/python-semanticversion>`_ library.
37-
- debian, this is handled by `debian-inspector <https://github.com/sbs2001/univers/blob/main/src/univers/debian.py.ABOUT>`_ library.
38-
- pypi, this is handled by Python's ``packaging.version`` module.
39-
- maven, this is handled by `rpm_vercmp <https://github.com/sbs2001/univers/blob/main/src/univers/rpm.py.ABOUT>`_ library.
40-
- ebuild/gentoo, this is handled by `gentoo_vercmp <https://github.com/sbs2001/univers/blob/main/src/univers/gentoo.py.ABOUT>`_ module.
40+
How does univers work ?
41+
=========================
42+
43+
univers wraps, embeds or implements multiple version comparision libraries, each
44+
focused on specific ecosystem version scheme.
45+
46+
It also implements an experimental unified syntax for version ranges specifier
47+
and can parse and convert existing version range strings to this unified syntax.
48+
49+
50+
The supported package ecosystems versioning schemes and underlying libraries are:
51+
52+
- semver: npm, golang, PHP composer, rubygems and others that follow the semver
53+
spec, using `semantic_version <https://github.com/rbarrois/python-semanticversion>`_ library.
54+
- debian: handled by the
55+
`debian-inspector <https://github.com/sbs2001/univers/blob/main/src/univers/debian.py.ABOUT>`_
56+
library.
57+
- pypi: handled by Python's packaging library and the standard ``packaging.version`` module.
58+
- maven: handled by the embedded `rpm_vercmp <https://github.com/sbs2001/univers/blob/main/src/univers/rpm.py.ABOUT>`_ library.
59+
- ebuild/gentoo: handled by the embedded `gentoo_vercmp <https://github.com/sbs2001/univers/blob/main/src/univers/gentoo.py.ABOUT>`_ module.
60+
61+
As we grow, new schemes will be implemented accordingly.
62+
63+
64+
Alternative
65+
============
66+
67+
Rather than using ecosystem-specific version schemes and code, another approach
68+
is to use a single procedure for all the versions as implemented in `libversion
69+
<https://github.com/repology/libversion>`_. This works in the most common case
70+
but may not work correctly for specific tasks that demand accurate version
71+
comparison such as for dependency resolution and vulnerabilities checks.
72+
4173

4274
Installation
4375
============
4476

45-
$ pip install univers
77+
$ pip install univers
78+
4679

4780
Examples
4881
========
4982

50-
Comparing discrete versions
83+
Compare two versions using the Python comparison operators:
5184

5285
.. code:: python
5386
@@ -57,7 +90,7 @@ Comparing discrete versions
5790
assert v1 < v2 == True
5891
5992
60-
Evaluating version ranges
93+
Test if a version is within or outside of a version range:
6194

6295
.. code:: python
6396
@@ -70,3 +103,23 @@ Evaluating version ranges
70103
71104
assert (v1 in vs ) == True
72105
assert (v2 in vs ) == False
106+
107+
108+
Development
109+
============
110+
111+
Starting from a git clone of https://github.com/nexB/univers run these::
112+
113+
$ configure --dev
114+
$ source venv/bin/active
115+
$ pytest -vvs
116+
117+
118+
We use the same development process as other AboutCode projects.
119+
120+
Visit https://github.com/nexB/univers and
121+
https://gitter.im/aboutcode-org/vulnerablecode and
122+
https://gitter.im/aboutcode-org/aboutcode for support and chat.
123+
124+
Primary license: Apache-2.0
125+
SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause AND MIT

azure-pipelines.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,50 @@
77

88
jobs:
99

10-
- template: etc/ci/azure-linux.yml
11-
parameters:
12-
job_name: ubuntu16_cpython
13-
image_name: ubuntu-16.04
14-
python_versions: ['3.6', '3.7', '3.8', '3.9']
15-
test_suites:
16-
all: tmp/bin/pytest -vvs
17-
18-
- template: etc/ci/azure-linux.yml
10+
- template: etc/ci/azure-posix.yml
1911
parameters:
2012
job_name: ubuntu18_cpython
2113
image_name: ubuntu-18.04
22-
python_versions: ['3.6', '3.7', '3.8', '3.9']
14+
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
2315
test_suites:
24-
all: tmp/bin/pytest -n 2 -vvs
16+
all: venv/bin/pytest -n 2 -vvs
2517

26-
- template: etc/ci/azure-linux.yml
18+
- template: etc/ci/azure-posix.yml
2719
parameters:
2820
job_name: ubuntu20_cpython
2921
image_name: ubuntu-20.04
30-
python_versions: ['3.6', '3.7', '3.8', '3.9']
22+
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
3123
test_suites:
32-
all: tmp/bin/pytest -n 2 -vvs
24+
all: venv/bin/pytest -n 2 -vvs
3325

34-
- template: etc/ci/azure-mac.yml
26+
- template: etc/ci/azure-posix.yml
3527
parameters:
3628
job_name: macos1014_cpython
3729
image_name: macos-10.14
3830
python_versions: ['3.6', '3.7', '3.8', '3.9']
3931
test_suites:
40-
all: tmp/bin/pytest -n 2 -vvs
32+
all: venv/bin/pytest -n 2 -vvs
4133

42-
- template: etc/ci/azure-mac.yml
34+
- template: etc/ci/azure-posix.yml
4335
parameters:
4436
job_name: macos1015_cpython
4537
image_name: macos-10.15
46-
python_versions: ['3.6', '3.7', '3.8', '3.9']
38+
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
4739
test_suites:
48-
all: tmp/bin/pytest -n 2 -vvs
40+
all: venv/bin/pytest -n 2 -vvs
4941

5042
- template: etc/ci/azure-win.yml
5143
parameters:
5244
job_name: win2016_cpython
5345
image_name: vs2017-win2016
54-
python_versions: ['3.6', '3.7', '3.8', '3.9']
46+
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
5547
test_suites:
56-
all: tmp\Scripts\pytest -n 2 -vvs
48+
all: venv\Scripts\pytest -n 2 -vvs
5749

5850
- template: etc/ci/azure-win.yml
5951
parameters:
6052
job_name: win2019_cpython
6153
image_name: windows-2019
62-
python_versions: ['3.6', '3.7', '3.8', '3.9']
54+
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
6355
test_suites:
64-
all: tmp\Scripts\pytest -n 2 -vvs
56+
all: venv\Scripts\pytest -n 2 -vvs

bsd-new.LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Redistribution and use in source and binary forms, with or without modification,
2+
are permitted provided that the following conditions are met:
3+
4+
Redistributions of source code must retain the above copyright notice, this list
5+
of conditions and the following disclaimer.
6+
7+
Redistributions in binary form must reproduce the above copyright notice, this
8+
list of conditions and the following disclaimer in the documentation and/or
9+
other materials provided with the distribution.
10+
11+
Neither the name of the ORGANIZATION nor the names of its contributors may be
12+
used to endorse or promote products derived from this software without specific
13+
prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
19+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
24+
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)