dependabot-maven 0.141.0 → 0.143.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 151a0ba3ce7459d72866cfb1f41905cf273d8511aba880175ee61425b1d926ca
4
- data.tar.gz: b2608b35aed7d66344017049d42c0a245a5611f475768c21a711a82d929180d1
3
+ metadata.gz: 999a155b4286ad444b3ea6994f850c94eb17c3142f82513720e4184948ba80e6
4
+ data.tar.gz: 74e0aba3214a910154d3707bb54c9b720c6207e3b6bc2e8b10b967a23dd9a8ff
5
5
  SHA512:
6
- metadata.gz: 56eee00d65f6ffcd920792299fc18a5478e1989d0a982ad7b1e717d87cace69b39ffc467d40fe8afd723f1a2f0225b164497812670d9d3128bb389f9748cce94
7
- data.tar.gz: 597decbc541d8dbabb9fb9cf193cee11bd7e75523be05177e3dd5dcd813b85317d1815801c923870e4e37c9e306552614fcf388fcdfba578d0133ea500672e3a
6
+ metadata.gz: fc80e0a1337850473d8057b8d7e0dc83e7b226218aa391bc22a19495bab903dc7563bba301a6fbbc4188368e3798fdd368e949f6cfcb2c6da2c12038b9407039
7
+ data.tar.gz: 3aba61db57419b4b321c51213c985977553226316324981663d4aa118966a937b8cfc7a7258727beda118e582c6f17d2c362df8b8d306327d02916182fbfbbc6
@@ -7,6 +7,7 @@ module Dependabot
7
7
  module Maven
8
8
  class Requirement < Gem::Requirement
9
9
  quoted = OPS.keys.map { |k| Regexp.quote k }.join("|")
10
+ OR_SYNTAX = /(?<=\]|\)),/.freeze
10
11
  PATTERN_RAW =
11
12
  "\\s*(#{quoted})?\\s*(#{Maven::Version::VERSION_PATTERN})\\s*"
12
13
  PATTERN = /\A#{PATTERN_RAW}\z/.freeze
@@ -46,7 +47,9 @@ module Dependabot
46
47
  private
47
48
 
48
49
  def self.split_java_requirement(req_string)
49
- req_string.split(/(?<=\]|\)),/).flat_map do |str|
50
+ return [req_string] unless req_string.match?(OR_SYNTAX)
51
+
52
+ req_string.split(OR_SYNTAX).flat_map do |str|
50
53
  next str if str.start_with?("(", "[")
51
54
 
52
55
  exacts, *rest = str.split(/,(?=\[|\()/)
@@ -62,9 +65,14 @@ module Dependabot
62
65
  raise "Can't convert multiple Java reqs to a single Ruby one"
63
66
  end
64
67
 
65
- return convert_java_range_to_ruby_range(req_string) if req_string&.include?(",")
66
-
67
- convert_java_equals_req_to_ruby(req_string)
68
+ # NOTE: Support ruby-style version requirements that are created from
69
+ # PR ignore conditions
70
+ version_reqs = req_string.split(",").map(&:strip)
71
+ if req_string.include?(",") && !version_reqs.all? { |s| PATTERN.match?(s) }
72
+ convert_java_range_to_ruby_range(req_string) if req_string.include?(",")
73
+ else
74
+ version_reqs.map { |r| convert_java_equals_req_to_ruby(r) }
75
+ end
68
76
  end
69
77
 
70
78
  def convert_java_range_to_ruby_range(req_string)
@@ -95,10 +103,11 @@ module Dependabot
95
103
  end
96
104
 
97
105
  def convert_wildcard_req(req_string)
98
- version = req_string.gsub(/(?:\.|^)\+/, "")
99
- return ">= 0" if version.empty?
106
+ version = req_string.split("+").first
107
+ return ">= 0" if version.nil? || version.empty?
100
108
 
101
- "~> #{version}.0"
109
+ version += "0" if version.end_with?(".")
110
+ "~> #{version}"
102
111
  end
103
112
  end
104
113
  end
@@ -14,8 +14,6 @@ module Dependabot
14
14
  class VersionFinder
15
15
  TYPE_SUFFICES = %w(jre android java).freeze
16
16
 
17
- MAVEN_RANGE_REGEX = /[\(\[].*,.*[\)\]]/.freeze
18
-
19
17
  def initialize(dependency:, dependency_files:, credentials:,
20
18
  ignored_versions:, security_advisories:,
21
19
  raise_on_ignored: false)
@@ -95,10 +93,10 @@ module Dependabot
95
93
  filtered = possible_versions
96
94
 
97
95
  ignored_versions.each do |req|
98
- ignore_req = Maven::Requirement.new(parse_requirement_string(req))
96
+ ignore_requirements = Maven::Requirement.requirements_array(req)
99
97
  filtered =
100
98
  filtered.
101
- reject { |v| ignore_req.satisfied_by?(v.fetch(:version)) }
99
+ reject { |v| ignore_requirements.any? { |r| r.satisfied_by?(v.fetch(:version)) } }
102
100
  end
103
101
 
104
102
  raise AllVersionsIgnored if @raise_on_ignored && filtered.empty? && possible_versions.any?
@@ -106,12 +104,6 @@ module Dependabot
106
104
  filtered
107
105
  end
108
106
 
109
- def parse_requirement_string(string)
110
- return string if string.match?(MAVEN_RANGE_REGEX)
111
-
112
- string.split(",").map(&:strip)
113
- end
114
-
115
107
  def filter_vulnerable_versions(possible_versions)
116
108
  versions_array = possible_versions
117
109
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-maven
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.141.0
4
+ version: 0.143.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-12 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.141.0
19
+ version: 0.143.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.141.0
26
+ version: 0.143.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.12.0
103
+ version: 1.13.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.12.0
110
+ version: 1.13.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  - !ruby/object:Gem::Version
221
221
  version: 2.5.0
222
222
  requirements: []
223
- rubygems_version: 3.2.3
223
+ rubygems_version: 3.2.15
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: Maven support for dependabot