dependabot-maven 0.141.1 → 0.143.2

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: 8fb530a1c8378e43ace00ea44e5f683ee64142c696f628c57830574e352097bd
4
- data.tar.gz: cf0777299e97975ea4ce97ba926608346d11f003ec01fec6e5e3a19c8936fdf8
3
+ metadata.gz: 16fd9bc66bd0adf75ddf046b3c3d16a62eb23129bd3125ffee8c0cf874567153
4
+ data.tar.gz: 731a3832bc1433f5ca981ab0d20a02d81ccd22c9750178afc2175e76a6ed125c
5
5
  SHA512:
6
- metadata.gz: 9acafa33468546c704a6118ed35837832341a5d928f18dcfa2638c29828d66a2fc880e93cdc2c42a944e3ec01405b6a6922819ac759ede0687498dc42399a975
7
- data.tar.gz: 9017b597915608f49972db123e5dc655b3f28ceee1fff1bb44eced063786b97ff37cb9f0b9af57882b6be48802eb2555381517e262c7dbdaac2a1eccd3f0b2d3
6
+ metadata.gz: e6d17ebf6c3b84d430cdd1bae7f7ec2a8e2f1f0bf5805c012082b960fda9172e8a466fd2264d25b52c198dcc9b7e9f484ac704289dc143a819a49e4afe12b768
7
+ data.tar.gz: bd6887791bdccb84c820077f7ecece2d4d9673a5123d4e42e9910ab2dcd7165ad568cebbd918dd1fa78afbef35a00ac5bc18216764ca43361c58021648e2adc5
@@ -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.1
4
+ version: 0.143.2
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-13 00:00:00.000000000 Z
11
+ date: 2021-04-23 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.1
19
+ version: 0.143.2
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.1
26
+ version: 0.143.2
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