dependabot-common 0.143.1 → 0.143.6

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: 04061b64d2ec9c8ff56b799d8ea0c7426dadcca2701581f1917faa494ba3f76d
4
- data.tar.gz: 1129318553b00a3e77274d84cff91987b9c2d20f69a57deb3f171eee4729555a
3
+ metadata.gz: c507c27ae833e3fe63860d4dc1540e660a1552174fd9144e10234bb74f94407f
4
+ data.tar.gz: 459365a8dafc748237967f3090a10e0d6f7be7f2ecbf9b9b3726a475973eb4d7
5
5
  SHA512:
6
- metadata.gz: 81049fffec22a52e685fd08d7f8afc8947f6cd66532491d4e16eb6420cd46ba0d65e863f5f11659968572c8bc6b8d3339601fffa57631ffeb0503823ba53e03d
7
- data.tar.gz: '0955f36ca302e038b4dae7d97fd4f83d4ffa3a1cb1668eb353e16f7501851ba567c6b7eebf2bed72776343cf39a54116d326c45e2261320514a0c53d3e360aba'
6
+ metadata.gz: 12870c6cddfb8447569d35e08e769c492aef0d05cc9d74e81ea80497b8e487d3ce6e763fa21073abc3ac8f88b72938b753a0acef80574c5ec0c954082b2e5514
7
+ data.tar.gz: dba3dab805156d4f6eb84fd7122861e8b9f5c4df06aad5146bc974c2e8e9cff06a3594061b6bed6bc3a3017b829b3c900f820abb78591cb09c60efe571cd53f5
@@ -26,6 +26,17 @@ module Dependabot
26
26
  )
27
27
  end
28
28
 
29
+ # Parse the YAML config file
30
+ def self.parse(config)
31
+ parsed = YAML.safe_load(config, symbolize_names: true)
32
+ version = parsed[:version]
33
+ raise InvalidConfigError, "invalid version #{version}" if version && version != 2
34
+
35
+ File.new(updates: parsed[:updates], registries: parsed[:registries])
36
+ end
37
+
38
+ private
39
+
29
40
  PACKAGE_MANAGER_LOOKUP = {
30
41
  "bundler" => "bundler",
31
42
  "cargo" => "cargo",
@@ -44,23 +55,13 @@ module Dependabot
44
55
  "terraform" => "terraform"
45
56
  }.freeze
46
57
 
47
- # Parse the YAML config file
48
- def self.parse(config)
49
- parsed = YAML.safe_load(config, symbolize_names: true)
50
- version = parsed[:version]
51
- raise InvalidConfigError, "invalid version #{version}" if version && version != 2
52
-
53
- File.new(updates: parsed[:updates], registries: parsed[:registries])
54
- end
55
-
56
- private
57
-
58
58
  def ignore_conditions(cfg)
59
59
  ignores = cfg&.dig(:ignore) || []
60
60
  ignores.map do |ic|
61
- Dependabot::Config::UpdateConfig::IgnoreCondition.new(
61
+ Dependabot::Config::IgnoreCondition.new(
62
62
  dependency_name: ic[:"dependency-name"],
63
- versions: ic[:versions]
63
+ versions: ic[:versions],
64
+ update_types: ic[:"update-types"]
64
65
  )
65
66
  end
66
67
  end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dependabot
4
+ module Config
5
+ # Filters versions that should not be considered for dependency updates
6
+ class IgnoreCondition
7
+ PATCH_VERSION_TYPE = "version-update:semver-patch"
8
+ MINOR_VERSION_TYPE = "version-update:semver-minor"
9
+ MAJOR_VERSION_TYPE = "version-update:semver-major"
10
+
11
+ ALL_VERSIONS = ">= 0"
12
+
13
+ attr_reader :dependency_name, :versions, :update_types
14
+
15
+ def initialize(dependency_name:, versions: nil, update_types: nil)
16
+ @dependency_name = dependency_name
17
+ @versions = versions || []
18
+ @update_types = update_types || []
19
+ end
20
+
21
+ def ignored_versions(dependency, security_updates_only)
22
+ return versions if security_updates_only
23
+ return [ALL_VERSIONS] if versions.empty? && transformed_update_types.empty?
24
+
25
+ versions_by_type(dependency) + versions
26
+ end
27
+
28
+ private
29
+
30
+ def transformed_update_types
31
+ update_types.map(&:downcase).map(&:strip).compact
32
+ end
33
+
34
+ def versions_by_type(dependency)
35
+ transformed_update_types.flat_map do |t|
36
+ case t
37
+ when PATCH_VERSION_TYPE
38
+ ignore_patch(dependency.version)
39
+ when MINOR_VERSION_TYPE
40
+ ignore_minor(dependency.version)
41
+ when MAJOR_VERSION_TYPE
42
+ ignore_major(dependency.version)
43
+ else
44
+ []
45
+ end
46
+ end.compact
47
+ end
48
+
49
+ def ignore_patch(version)
50
+ return [] unless rubygems_compatible?(version)
51
+
52
+ parts = version.split(".")
53
+ version_parts = parts.fill(0, parts.length...2)
54
+ upper_parts = version_parts.first(1) + [version_parts[1].to_i + 1]
55
+ lower_bound = "> #{version}"
56
+ upper_bound = "< #{upper_parts.join('.')}"
57
+
58
+ ["#{lower_bound}, #{upper_bound}"]
59
+ end
60
+
61
+ def ignore_minor(version)
62
+ return [] unless rubygems_compatible?(version)
63
+
64
+ parts = version.split(".")
65
+ version_parts = parts.fill(0, parts.length...2)
66
+ lower_parts = version_parts.first(1) + [version_parts[1].to_i + 1] + ["a"]
67
+ upper_parts = version_parts.first(0) + [version_parts[0].to_i + 1]
68
+ lower_bound = ">= #{lower_parts.join('.')}"
69
+ upper_bound = "< #{upper_parts.join('.')}"
70
+
71
+ ["#{lower_bound}, #{upper_bound}"]
72
+ end
73
+
74
+ def ignore_major(version)
75
+ return [] unless rubygems_compatible?(version)
76
+
77
+ version_parts = version.split(".")
78
+ lower_parts = [version_parts[0].to_i + 1] + ["a"]
79
+ lower_bound = ">= #{lower_parts.join('.')}"
80
+
81
+ [lower_bound]
82
+ end
83
+
84
+ def rubygems_compatible?(version)
85
+ return false if version.nil? || version.empty?
86
+
87
+ Gem::Version.correct?(version)
88
+ end
89
+ end
90
+ end
91
+ end
@@ -1,30 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "dependabot/config/ignore_condition"
4
+
3
5
  module Dependabot
4
6
  module Config
5
7
  # Configuration for a single ecosystem
6
8
  class UpdateConfig
7
- attr_reader :commit_message_options
8
-
9
+ attr_reader :commit_message_options, :ignore_conditions
9
10
  def initialize(ignore_conditions: nil, commit_message_options: nil)
10
11
  @ignore_conditions = ignore_conditions || []
11
12
  @commit_message_options = commit_message_options
12
13
  end
13
14
 
14
- def ignored_versions_for(dep)
15
+ def ignored_versions_for(dependency, security_updates_only: false)
16
+ normalizer = name_normaliser_for(dependency)
17
+ dep_name = name_normaliser_for(dependency).call(dependency.name)
18
+
15
19
  @ignore_conditions.
16
- select { |ic| ic.dependency_name == dep.name }. # FIXME: wildcard support
17
- map(&:versions).
20
+ select { |ic| self.class.wildcard_match?(normalizer.call(ic.dependency_name), dep_name) }.
21
+ map { |ic| ic.ignored_versions(dependency, security_updates_only) }.
18
22
  flatten.
19
- compact
23
+ compact.
24
+ uniq
20
25
  end
21
26
 
22
- class IgnoreCondition
23
- attr_reader :dependency_name, :versions
24
- def initialize(dependency_name:, versions:)
25
- @dependency_name = dependency_name
26
- @versions = versions
27
- end
27
+ def self.wildcard_match?(wildcard_string, candidate_string)
28
+ return false unless wildcard_string && candidate_string
29
+
30
+ regex_string = "a#{wildcard_string.downcase}a".split("*").
31
+ map { |p| Regexp.quote(p) }.
32
+ join(".*").gsub(/^a|a$/, "")
33
+ regex = /^#{regex_string}$/
34
+ regex.match?(candidate_string.downcase)
35
+ end
36
+
37
+ private
38
+
39
+ def name_normaliser_for(dep)
40
+ name_normaliser ||= {}
41
+ name_normaliser[dep] ||= Dependency.name_normaliser_for_package_manager(dep.package_manager)
28
42
  end
29
43
 
30
44
  class CommitMessageOptions
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.143.1"
4
+ VERSION = "0.143.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.143.1
4
+ version: 0.143.6
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-21 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -394,6 +394,7 @@ files:
394
394
  - lib/dependabot/config.rb
395
395
  - lib/dependabot/config/file.rb
396
396
  - lib/dependabot/config/file_fetcher.rb
397
+ - lib/dependabot/config/ignore_condition.rb
397
398
  - lib/dependabot/config/update_config.rb
398
399
  - lib/dependabot/dependency.rb
399
400
  - lib/dependabot/dependency_file.rb