Skip to content

Add support for gems and improve RPM support - #14

Merged
pombredanne merged 917 commits into
mainfrom
refinements
Jan 10, 2022
Merged

Add support for gems and improve RPM support#14
pombredanne merged 917 commits into
mainfrom
refinements

Conversation

@pombredanne

@pombredanne pombredanne commented Nov 30, 2021

Copy link
Copy Markdown
Member

This PR adds support for Rubygems version comparison and improves RPM handling

Fixes for RPM:

Fixes for Rubygems:

deivid-rodriguez and others added 30 commits April 29, 2019 18:22
2756: Added supported versions of Ruby. r=hsbt a=hsbt

# Description:

Fixes #2586

______________

# Tasks:

- [ ] Describe the problem / feature
- [ ] Write tests
- [ ] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
2757: Refactor tests r=bronzdoc a=deivid-rodriguez

# Description:

I was working on adding some tests for installing defafult gems, and I noticed that it's pretty hard to work with installer tests, because the base setup does too much, so sometimes you need to reset state at the beginning of each test to go back to a clean slate.

Instead, I've removed all the common setup, and make each test explicitly do only the stuff it needs to do.

This allows to remove a lot of state resetting from many tests. 

I also included a little follow up to the addition of jruby in ruby/rubygems@309de0e by undoing some skips that are not really necessary.
 
# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
It seems like GitHub can't tell what license this is, despite explicitly
naming it inside the file. These changes make our license file closer to
other license files that GitHub does successfully recognize as MIT.
Hopefully it'll work.
7185: Try to help GitHub recognize the MIT license r=hsbt a=indirect

It seems like GitHub can't tell what license this is, despite explicitly
naming it inside the file. These changes make our license file closer to
other license files that GitHub does successfully recognize as MIT.
Hopefully it'll work.

Co-authored-by: Andre Arko <andre@arko.net>
* 2-0-stable: (89 commits)
  fix changelog 2.0.2 typos
  add v2.0.2 changelog
  bump version to 2.0.2
  Merge #7199
  fix bug where bundler v3 is running a test for bundflet 2
  Merge #6798
  add bors configuation
  port GemHelper from master
  Merge #7080
  Merge #7089
  Merge #7068
  Merge #7036
  Merge #7067
  change Bundler 3 specs in travis to use RubyGems 3.0.3
  bump RubyGems v3 to the latest version on Travis
  Merge #6963
  Merge #7078
  Merge pull request #7061 from bundler/fix_circular_requires
  Merge #6864
  remove linting step in travis (it will still run in each build)
  ...
2613: test_gem.rb - intermittent failure fix r=hsbt a=MSP-Greg

# Description:

Update assert_self_install_permissions method to hopefully stop intermittent failures

File.open -> File.write, move directory creation to top

# Tasks:

- [X] Describe the problem / feature
- [ ] Write tests
- [X] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: MSP-Greg <greg.mpls@gmail.com>
2756: Added supported versions of Ruby. r=hsbt a=hsbt

# Description:

Fixes #2586

______________

# Tasks:

- [ ] Describe the problem / feature
- [ ] Write tests
- [ ] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
Because we can't control 3rd party gems using deprecated rubygems
behavior, and thus outputting warnings to the screen.
2794: Restore 3.0 and 2.0 branches to master. r=hsbt a=hsbt

# Description:

I merged 2.7 and 3.0 branches to master branch. 
______________

# Tasks:

- [ ] Describe the problem / feature
- [ ] Write tests
- [ ] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: SHIBATA Hiroshi <hsbt@ruby-lang.org>
Co-authored-by: Bundlerbot <bot@bundler.io>
Co-authored-by: Grey Baker <greysteil@gmail.com>
And use single quotes consistenly.
`Dir.pwd` may differ from the source path.  Test directories and
files should be resolved from test file paths.
7286: Fix documents to refer to URLs with https r=deivid-rodriguez a=giraffate

### What was the end-user problem that led to this PR?

End-users experience 301 redirect,  or unintentionally visit URL with http and may send email.

### What was your diagnosis of the problem?

I noticed the problem when I was reading codes. Following are some examples using curl to explain this problem.

```
curl -I http://slack.bundler.io/
HTTP/1.1 200 OK
Server: Cowboy
Connection: keep-alive
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 3726
Etag: W/"3Shz0DQR5y/DyBrYbyUBAQ=="
Date: Fri, 09 Aug 2019 14:16:23 GMT
Via: 1.1 vegur
```
```
curl -I http://contributor-covenant.org
HTTP/1.1 301 Moved Permanently
Cache-Control: public, max-age=0, must-revalidate
Content-Length: 49
Content-Type: text/plain
Date: Sun, 04 Aug 2019 09:47:02 GMT
Location: https://contributor-covenant.org/
Age: 448201
Connection: keep-alive
Server: Netlify
X-NF-Request-ID: 3de60b71-391e-4a6e-8cd4-74a12f217c80-14980829
```

### What is your fix for the problem, implemented in this PR?

My fix is to replace http URLs with https URLs.

### Why did you choose this fix out of the possible options?

It's because this fix is simple and easy.


Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
Previously it wouldn't play nice with the bundler version finder.
Reference: #5
Reported-by: Oliver Chang @oliverchang
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This is a vers wrapper on the gem.py Rubygems version implmentation.

Reference: #5
Reported-by: Oliver Chang @oliverchang
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
The isue has been fixed the previous merge

Reference: #2
Reference: https://github.com/sassoftware/python-rpm-vercmp/issues/2
Reference: https://github.com/sassoftware/python-rpm-vercmp/issues/4
Reported-by: Shivam Sandbhor @sbs2001
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This was referenced Dec 7, 2021
@pombredanne pombredanne changed the title Add support for gems Add support for gems and improve RPM support Dec 7, 2021
@pombredanne
pombredanne marked this pull request as ready for review December 7, 2021 23:06

@pombredanne pombredanne left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

A typo to fix

Comment thread src/univers/rpm.py Outdated
Fix typo in docstring

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Using full comparator set and single constraints list

Reference: package-url/purl-spec#139
Reference: package-url/purl-spec@5430731
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This is a minor refactoring, mostly cosmetic.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
In partucular a star range has a None version and not an empty string

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Use simplify, not dedupe as a function name and implement latest spec.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Debian version and release can have trailing punctuations. We were
arbitrarily disabling this.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Use share function split_req() to split Debian relationships and
RPM requirements that are highly similar.

Also introduce VersionRange.from_natives() using a list input in addition
to VersionRange.from_native() using a single string.

Add empty provisoional from_cve_v4() from_cve_v5() and from_osv_v1()
placeholder functions.

Add or improve various minor docstring

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
@Gitii

Gitii commented Jan 8, 2022

Copy link
Copy Markdown

Hi @pombredanne,

I just came across your PR and wanted to add something briefly. I hope it helps you further.
In one of my side projects, I needed to port the vercmp stuff to c# and I also needed to adapt this part:
https://github.com/nexB/univers/blob/8b84788c7f43271bd10274785f315c05c476b61d/src/univers/rpm.py#L214

Instead of comparing the length of the ascii encoded numbers, I had to parse it and compare the actual numbers:

var m1_num = Int32.Parse(m1_head);
var m2_num = Int32.Parse(m2_head);

var cmp = m1_num.CompareTo(m2_num);

if (cmp < 0)
{
    return -1;
}

if (cmp > 0)
{
    return 1;
}

Together with your fixes (thanks!) all except one broken tests are green now (my tests are based on https://raw.githubusercontent.com/rpm-software-management/rpm/master/tests/rpmvercmp.at).
For example "1.0" < "2.0" was failing.

Edit:
All green now with this additional check after line https://github.com/nexB/univers/blob/8b84788c7f43271bd10274785f315c05c476b61d/src/univers/rpm.py#L221

else
{
    var head_cmp = String.Compare(m1_head, m2_head, StringComparison.Ordinal);

    if (head_cmp < 0)
    {
        return -1;
    }

    if (head_cmp > 0)
    {
        return 1;
    }
}

Maybe python works differently, but it will still help you.

@pombredanne
pombredanne merged commit ca2cf4d into main Jan 10, 2022
@pombredanne
pombredanne deleted the refinements branch January 10, 2022 16:20
TG1999 pushed a commit to TG1999/univers that referenced this pull request Mar 8, 2023
Add support for gems and improve RPM support
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.

rubygems is not semver