dependabot-common 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 +4 -4
- data/lib/dependabot/clients/azure.rb +5 -3
- data/lib/dependabot/config.rb +7 -0
- data/lib/dependabot/config/file.rb +78 -0
- data/lib/dependabot/config/file_fetcher.rb +50 -0
- data/lib/dependabot/config/update_config.rb +53 -0
- data/lib/dependabot/file_fetchers/base.rb +1 -0
- data/lib/dependabot/git_commit_checker.rb +5 -5
- data/lib/dependabot/pull_request_creator/branch_namer.rb +13 -12
- data/lib/dependabot/pull_request_updater/azure.rb +5 -1
- data/lib/dependabot/update_checkers/base.rb +5 -5
- data/lib/dependabot/version.rb +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04061b64d2ec9c8ff56b799d8ea0c7426dadcca2701581f1917faa494ba3f76d
|
4
|
+
data.tar.gz: 1129318553b00a3e77274d84cff91987b9c2d20f69a57deb3f171eee4729555a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81049fffec22a52e685fd08d7f8afc8947f6cd66532491d4e16eb6420cd46ba0d65e863f5f11659968572c8bc6b8d3339601fffa57631ffeb0503823ba53e03d
|
7
|
+
data.tar.gz: '0955f36ca302e038b4dae7d97fd4f83d4ffa3a1cb1668eb353e16f7501851ba567c6b7eebf2bed72776343cf39a54116d326c45e2261320514a0c53d3e360aba'
|
@@ -201,9 +201,11 @@ module Dependabot
|
|
201
201
|
}
|
202
202
|
]
|
203
203
|
|
204
|
-
post(source.api_endpoint + source.organization + "/" + source.project +
|
205
|
-
|
206
|
-
|
204
|
+
response = post(source.api_endpoint + source.organization + "/" + source.project +
|
205
|
+
"/_apis/git/repositories/" + source.unscoped_repo +
|
206
|
+
"/refs?api-version=5.0", content.to_json)
|
207
|
+
|
208
|
+
JSON.parse(response.body).fetch("value").first
|
207
209
|
end
|
208
210
|
# rubocop:enable Metrics/ParameterLists
|
209
211
|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dependabot/config/update_config"
|
4
|
+
|
5
|
+
module Dependabot
|
6
|
+
module Config
|
7
|
+
# Configuration for the repository, a parsed dependabot.yaml.
|
8
|
+
class File
|
9
|
+
attr_reader :updates, :registries
|
10
|
+
|
11
|
+
def initialize(updates:, registries: nil)
|
12
|
+
@updates = updates || []
|
13
|
+
@registries = registries || []
|
14
|
+
end
|
15
|
+
|
16
|
+
def update_config(package_manager, directory: nil, target_branch: nil)
|
17
|
+
dir = directory || "/"
|
18
|
+
package_ecosystem = PACKAGE_MANAGER_LOOKUP.invert.fetch(package_manager)
|
19
|
+
cfg = updates.find do |u|
|
20
|
+
u[:"package-ecosystem"] == package_ecosystem && u[:directory] == dir &&
|
21
|
+
(target_branch.nil? || u[:"target-branch"] == target_branch)
|
22
|
+
end
|
23
|
+
Dependabot::Config::UpdateConfig.new(
|
24
|
+
ignore_conditions: ignore_conditions(cfg),
|
25
|
+
commit_message_options: commit_message_options(cfg)
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
PACKAGE_MANAGER_LOOKUP = {
|
30
|
+
"bundler" => "bundler",
|
31
|
+
"cargo" => "cargo",
|
32
|
+
"composer" => "composer",
|
33
|
+
"docker" => "docker",
|
34
|
+
"elm" => "elm",
|
35
|
+
"github-actions" => "github_actions",
|
36
|
+
"gitsubmodule" => "submodules",
|
37
|
+
"gomod" => "go_modules",
|
38
|
+
"gradle" => "gradle",
|
39
|
+
"maven" => "maven",
|
40
|
+
"mix" => "hex",
|
41
|
+
"nuget" => "nuget",
|
42
|
+
"npm" => "npm_and_yarn",
|
43
|
+
"pip" => "pip",
|
44
|
+
"terraform" => "terraform"
|
45
|
+
}.freeze
|
46
|
+
|
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
|
+
def ignore_conditions(cfg)
|
59
|
+
ignores = cfg&.dig(:ignore) || []
|
60
|
+
ignores.map do |ic|
|
61
|
+
Dependabot::Config::UpdateConfig::IgnoreCondition.new(
|
62
|
+
dependency_name: ic[:"dependency-name"],
|
63
|
+
versions: ic[:versions]
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def commit_message_options(cfg)
|
69
|
+
commit_message = cfg&.dig(:"commit-message") || {}
|
70
|
+
Dependabot::Config::UpdateConfig::CommitMessageOptions.new(
|
71
|
+
prefix: commit_message[:prefix],
|
72
|
+
prefix_development: commit_message[:"prefix-development"],
|
73
|
+
include: commit_message[:include]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dependabot/file_fetchers/base"
|
4
|
+
require "dependabot/config/file"
|
5
|
+
|
6
|
+
module Dependabot
|
7
|
+
module Config
|
8
|
+
class FileFetcher < Dependabot::FileFetchers::Base
|
9
|
+
CONFIG_FILE_PATHS = %w(.github/dependabot.yml .github/dependabot.yaml).freeze
|
10
|
+
|
11
|
+
def self.required_files_in?(filenames)
|
12
|
+
CONFIG_FILE_PATHS.any? { |file| filenames.include?(file) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.required_files_message
|
16
|
+
"Repo must contain either a #{CONFIG_FILE_PATHS.join(' or a ')} file"
|
17
|
+
end
|
18
|
+
|
19
|
+
def config_file
|
20
|
+
@config_file ||= files.first
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def fetch_files
|
26
|
+
fetched_files = []
|
27
|
+
|
28
|
+
CONFIG_FILE_PATHS.each do |file|
|
29
|
+
fn = Pathname.new("/#{file}").relative_path_from(directory)
|
30
|
+
|
31
|
+
begin
|
32
|
+
config_file = fetch_file_from_host(fn)
|
33
|
+
if config_file
|
34
|
+
fetched_files << config_file
|
35
|
+
break
|
36
|
+
end
|
37
|
+
rescue Dependabot::DependencyFileNotFound
|
38
|
+
next
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
unless self.class.required_files_in?(fetched_files.map(&:name))
|
43
|
+
raise Dependabot::DependencyFileNotFound, self.class.required_files_message
|
44
|
+
end
|
45
|
+
|
46
|
+
fetched_files
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dependabot
|
4
|
+
module Config
|
5
|
+
# Configuration for a single ecosystem
|
6
|
+
class UpdateConfig
|
7
|
+
attr_reader :commit_message_options
|
8
|
+
|
9
|
+
def initialize(ignore_conditions: nil, commit_message_options: nil)
|
10
|
+
@ignore_conditions = ignore_conditions || []
|
11
|
+
@commit_message_options = commit_message_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def ignored_versions_for(dep)
|
15
|
+
@ignore_conditions.
|
16
|
+
select { |ic| ic.dependency_name == dep.name }. # FIXME: wildcard support
|
17
|
+
map(&:versions).
|
18
|
+
flatten.
|
19
|
+
compact
|
20
|
+
end
|
21
|
+
|
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
|
28
|
+
end
|
29
|
+
|
30
|
+
class CommitMessageOptions
|
31
|
+
attr_reader :prefix, :prefix_development, :include
|
32
|
+
|
33
|
+
def initialize(prefix:, prefix_development:, include:)
|
34
|
+
@prefix = prefix
|
35
|
+
@prefix_development = prefix_development
|
36
|
+
@include = include
|
37
|
+
end
|
38
|
+
|
39
|
+
def include_scope?
|
40
|
+
@include == "scope"
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_h
|
44
|
+
{
|
45
|
+
prefix: @prefix,
|
46
|
+
prefix_development: @prefix_development,
|
47
|
+
include_scope: include_scope?
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -92,7 +92,7 @@ module Dependabot
|
|
92
92
|
local_tags.
|
93
93
|
select { |t| version_tag?(t.name) && matches_existing_prefix?(t.name) }
|
94
94
|
filtered = tags.
|
95
|
-
reject { |t|
|
95
|
+
reject { |t| tag_included_in_ignore_requirements?(t) }
|
96
96
|
raise Dependabot::AllVersionsIgnored if @raise_on_ignored && tags.any? && filtered.empty?
|
97
97
|
|
98
98
|
tag = filtered.
|
@@ -317,8 +317,8 @@ module Dependabot
|
|
317
317
|
listing_repo_git_metadata_fetcher.upload_pack
|
318
318
|
end
|
319
319
|
|
320
|
-
def
|
321
|
-
ignored_versions.
|
320
|
+
def ignore_requirements
|
321
|
+
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
|
322
322
|
end
|
323
323
|
|
324
324
|
def wants_prerelease?
|
@@ -330,9 +330,9 @@ module Dependabot
|
|
330
330
|
version_class.new(version).prerelease?
|
331
331
|
end
|
332
332
|
|
333
|
-
def
|
333
|
+
def tag_included_in_ignore_requirements?(tag)
|
334
334
|
version = tag.name.match(VERSION_REGEX).named_captures.fetch("version")
|
335
|
-
|
335
|
+
ignore_requirements.any? { |r| r.satisfied_by?(version_class.new(version)) }
|
336
336
|
end
|
337
337
|
|
338
338
|
def tag_is_prerelease?(tag)
|
@@ -17,7 +17,6 @@ module Dependabot
|
|
17
17
|
@prefix = prefix
|
18
18
|
end
|
19
19
|
|
20
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
21
20
|
def new_branch_name
|
22
21
|
@name ||=
|
23
22
|
begin
|
@@ -34,23 +33,13 @@ module Dependabot
|
|
34
33
|
tr("@", "")
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
if library? && ref_changed?(dep) && new_ref(dep)
|
40
|
-
"#{dependency_name_part}-#{new_ref(dep)}"
|
41
|
-
elsif library?
|
42
|
-
"#{dependency_name_part}-#{sanitized_requirement(dep)}"
|
43
|
-
else
|
44
|
-
"#{dependency_name_part}-#{new_version(dep)}"
|
45
|
-
end
|
36
|
+
"#{dependency_name_part}-#{branch_version_suffix}"
|
46
37
|
end
|
47
38
|
|
48
39
|
# Some users need branch names without slashes
|
49
40
|
sanitize_ref(File.join(prefixes, @name).gsub("/", separator))
|
50
41
|
end
|
51
42
|
|
52
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
53
|
-
|
54
43
|
private
|
55
44
|
|
56
45
|
def prefixes
|
@@ -98,6 +87,18 @@ module Dependabot
|
|
98
87
|
@dependency_set
|
99
88
|
end
|
100
89
|
|
90
|
+
def branch_version_suffix
|
91
|
+
dep = dependencies.first
|
92
|
+
|
93
|
+
if library? && ref_changed?(dep) && new_ref(dep)
|
94
|
+
new_ref(dep)
|
95
|
+
elsif library?
|
96
|
+
sanitized_requirement(dep)
|
97
|
+
else
|
98
|
+
new_version(dep)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
101
102
|
def sanitized_requirement(dependency)
|
102
103
|
new_library_requirement(dependency).
|
103
104
|
delete(" ").
|
@@ -6,6 +6,8 @@ require "securerandom"
|
|
6
6
|
module Dependabot
|
7
7
|
class PullRequestUpdater
|
8
8
|
class Azure
|
9
|
+
class PullRequestUpdateFailed < Dependabot::DependabotError; end
|
10
|
+
|
9
11
|
OBJECT_ID_FOR_BRANCH_DELETE = "0000000000000000000000000000000000000000"
|
10
12
|
|
11
13
|
attr_reader :source, :files, :base_commit, :old_commit, :credentials,
|
@@ -55,9 +57,11 @@ module Dependabot
|
|
55
57
|
# 1) Push the file changes to a newly created temporary branch (from base commit)
|
56
58
|
new_commit = create_temp_branch
|
57
59
|
# 2) Update PR source branch to point to the temp branch head commit.
|
58
|
-
update_branch(source_branch_name, old_source_branch_commit, new_commit)
|
60
|
+
response = update_branch(source_branch_name, old_source_branch_commit, new_commit)
|
59
61
|
# 3) Delete temp branch
|
60
62
|
update_branch(temp_branch_name, new_commit, OBJECT_ID_FOR_BRANCH_DELETE)
|
63
|
+
|
64
|
+
raise PullRequestUpdateFailed, response.fetch("customMessage", nil) unless response.fetch("success", false)
|
61
65
|
end
|
62
66
|
|
63
67
|
def pull_request
|
@@ -38,7 +38,7 @@ module Dependabot
|
|
38
38
|
|
39
39
|
def can_update?(requirements_to_unlock:)
|
40
40
|
# Can't update if all versions are being ignored
|
41
|
-
return false if
|
41
|
+
return false if ignore_requirements.include?(requirement_class.new(">= 0"))
|
42
42
|
|
43
43
|
if dependency.version
|
44
44
|
version_can_update?(requirements_to_unlock: requirements_to_unlock)
|
@@ -141,6 +141,10 @@ module Dependabot
|
|
141
141
|
security_advisories.any? { |a| a.vulnerable?(version) }
|
142
142
|
end
|
143
143
|
|
144
|
+
def ignore_requirements
|
145
|
+
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
|
146
|
+
end
|
147
|
+
|
144
148
|
private
|
145
149
|
|
146
150
|
def latest_version_resolvable_with_full_unlock?
|
@@ -296,10 +300,6 @@ module Dependabot
|
|
296
300
|
|
297
301
|
changed_requirements.none? { |r| r[:requirement] == :unfixable }
|
298
302
|
end
|
299
|
-
|
300
|
-
def ignore_reqs
|
301
|
-
ignored_versions.map { |req| requirement_class.new(req.split(",")) }
|
302
|
-
end
|
303
303
|
end
|
304
304
|
end
|
305
305
|
end
|
data/lib/dependabot/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -298,14 +298,14 @@ dependencies:
|
|
298
298
|
requirements:
|
299
299
|
- - "~>"
|
300
300
|
- !ruby/object:Gem::Version
|
301
|
-
version: 1.
|
301
|
+
version: 1.13.0
|
302
302
|
type: :development
|
303
303
|
prerelease: false
|
304
304
|
version_requirements: !ruby/object:Gem::Requirement
|
305
305
|
requirements:
|
306
306
|
- - "~>"
|
307
307
|
- !ruby/object:Gem::Version
|
308
|
-
version: 1.
|
308
|
+
version: 1.13.0
|
309
309
|
- !ruby/object:Gem::Dependency
|
310
310
|
name: simplecov
|
311
311
|
requirement: !ruby/object:Gem::Requirement
|
@@ -391,6 +391,10 @@ files:
|
|
391
391
|
- lib/dependabot/clients/codecommit.rb
|
392
392
|
- lib/dependabot/clients/github_with_retries.rb
|
393
393
|
- lib/dependabot/clients/gitlab_with_retries.rb
|
394
|
+
- lib/dependabot/config.rb
|
395
|
+
- lib/dependabot/config/file.rb
|
396
|
+
- lib/dependabot/config/file_fetcher.rb
|
397
|
+
- lib/dependabot/config/update_config.rb
|
394
398
|
- lib/dependabot/dependency.rb
|
395
399
|
- lib/dependabot/dependency_file.rb
|
396
400
|
- lib/dependabot/errors.rb
|
@@ -463,7 +467,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
463
467
|
- !ruby/object:Gem::Version
|
464
468
|
version: 2.7.3
|
465
469
|
requirements: []
|
466
|
-
rubygems_version: 3.2.
|
470
|
+
rubygems_version: 3.2.15
|
467
471
|
signing_key:
|
468
472
|
specification_version: 4
|
469
473
|
summary: Shared code used between Dependabot package managers
|