dependabot-common 0.120.1 → 0.121.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dependabot-common might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/dependabot/clients/azure.rb +10 -8
- data/lib/dependabot/file_fetchers/base.rb +52 -5
- data/lib/dependabot/file_updaters/base.rb +3 -2
- data/lib/dependabot/git_metadata_fetcher.rb +1 -1
- data/lib/dependabot/shared_helpers.rb +19 -3
- data/lib/dependabot/utils.rb +10 -0
- data/lib/dependabot/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e49dd9c04e251ff4d87f90eaef54669476e9c50c0edb30566e642a17ca1f67e5
|
4
|
+
data.tar.gz: 9cfe5407169467cdae03e431795dea225ece22c128eabcdaf2009eb67f3a63b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dae7095e2a8c9b961c24c8f24ed370f55e6033109ff0ac31f01113153454fb3c1f2a75e3efc7d00a9fae3386788d1e51f5de13b1b196e03ddd3a49b97c895c71
|
7
|
+
data.tar.gz: 0f61149cd1a25f5e378250d4b6158faf7954f1893089723ffd0116f9715f63007b242cfc44a57900b60ec2ee940843537b2cf072dab21f0cdc5858f72118d0eb
|
@@ -184,11 +184,12 @@ module Dependabot
|
|
184
184
|
def get(url)
|
185
185
|
response = Excon.get(
|
186
186
|
url,
|
187
|
-
headers: auth_header,
|
188
187
|
user: credentials&.fetch("username", nil),
|
189
188
|
password: credentials&.fetch("password", nil),
|
190
189
|
idempotent: true,
|
191
|
-
**SharedHelpers.excon_defaults
|
190
|
+
**SharedHelpers.excon_defaults(
|
191
|
+
headers: auth_header
|
192
|
+
)
|
192
193
|
)
|
193
194
|
raise NotFound if response.status == 404
|
194
195
|
|
@@ -198,16 +199,17 @@ module Dependabot
|
|
198
199
|
def post(url, json)
|
199
200
|
response = Excon.post(
|
200
201
|
url,
|
201
|
-
headers: auth_header.merge(
|
202
|
-
{
|
203
|
-
"Content-Type" => "application/json"
|
204
|
-
}
|
205
|
-
),
|
206
202
|
body: json,
|
207
203
|
user: credentials&.fetch("username", nil),
|
208
204
|
password: credentials&.fetch("password", nil),
|
209
205
|
idempotent: true,
|
210
|
-
**SharedHelpers.excon_defaults
|
206
|
+
**SharedHelpers.excon_defaults(
|
207
|
+
headers: auth_header.merge(
|
208
|
+
{
|
209
|
+
"Content-Type" => "application/json"
|
210
|
+
}
|
211
|
+
)
|
212
|
+
)
|
211
213
|
)
|
212
214
|
raise NotFound if response.status == 404
|
213
215
|
|
@@ -14,7 +14,7 @@ require "dependabot/shared_helpers"
|
|
14
14
|
module Dependabot
|
15
15
|
module FileFetchers
|
16
16
|
class Base
|
17
|
-
attr_reader :source, :credentials
|
17
|
+
attr_reader :source, :credentials, :repo_contents_path
|
18
18
|
|
19
19
|
CLIENT_NOT_FOUND_ERRORS = [
|
20
20
|
Octokit::NotFound,
|
@@ -32,10 +32,19 @@ module Dependabot
|
|
32
32
|
raise NotImplementedError
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
# Creates a new FileFetcher for retrieving `DependencyFile`s.
|
36
|
+
#
|
37
|
+
# Files are typically grabbed individually via the source's API.
|
38
|
+
# repo_contents_path is an optional empty directory that will be used
|
39
|
+
# to clone the entire source repository on first read.
|
40
|
+
#
|
41
|
+
# If provided, file _data_ will be loaded from the clone.
|
42
|
+
# Submodules and directory listings are _not_ currently supported
|
43
|
+
# by repo_contents_path and still use an API trip.
|
44
|
+
def initialize(source:, credentials:, repo_contents_path: nil)
|
36
45
|
@source = source
|
37
46
|
@credentials = credentials
|
38
|
-
|
47
|
+
@repo_contents_path = repo_contents_path
|
39
48
|
@linked_paths = {}
|
40
49
|
end
|
41
50
|
|
@@ -68,14 +77,24 @@ module Dependabot
|
|
68
77
|
end
|
69
78
|
|
70
79
|
# Returns the path to the cloned repo
|
71
|
-
def clone_repo_contents
|
80
|
+
def clone_repo_contents
|
72
81
|
@clone_repo_contents ||=
|
73
|
-
_clone_repo_contents(target_directory:
|
82
|
+
_clone_repo_contents(target_directory: repo_contents_path)
|
83
|
+
rescue Dependabot::SharedHelpers::HelperSubprocessFailed
|
84
|
+
raise Dependabot::RepoNotFound, source
|
74
85
|
end
|
75
86
|
|
76
87
|
private
|
77
88
|
|
78
89
|
def fetch_file_if_present(filename, fetch_submodules: false)
|
90
|
+
unless repo_contents_path.nil?
|
91
|
+
begin
|
92
|
+
return load_cloned_file_if_present(filename)
|
93
|
+
rescue Dependabot::DependencyFileNotFound
|
94
|
+
return
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
79
98
|
dir = File.dirname(filename)
|
80
99
|
basename = File.basename(filename)
|
81
100
|
|
@@ -91,7 +110,35 @@ module Dependabot
|
|
91
110
|
raise Dependabot::DependencyFileNotFound, path
|
92
111
|
end
|
93
112
|
|
113
|
+
def load_cloned_file_if_present(filename)
|
114
|
+
path = Pathname.new(File.join(directory, filename)).cleanpath.to_path
|
115
|
+
repo_path = File.join(clone_repo_contents, path)
|
116
|
+
unless File.exist?(repo_path)
|
117
|
+
raise Dependabot::DependencyFileNotFound, path
|
118
|
+
end
|
119
|
+
|
120
|
+
content = File.read(repo_path)
|
121
|
+
type = if File.symlink?(repo_path)
|
122
|
+
symlink_target = File.readlink(repo_path)
|
123
|
+
"symlink"
|
124
|
+
else
|
125
|
+
"file"
|
126
|
+
end
|
127
|
+
|
128
|
+
DependencyFile.new(
|
129
|
+
name: Pathname.new(filename).cleanpath.to_path,
|
130
|
+
directory: directory,
|
131
|
+
type: type,
|
132
|
+
content: content,
|
133
|
+
symlink_target: symlink_target
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
94
137
|
def fetch_file_from_host(filename, type: "file", fetch_submodules: false)
|
138
|
+
unless repo_contents_path.nil?
|
139
|
+
return load_cloned_file_if_present(filename)
|
140
|
+
end
|
141
|
+
|
95
142
|
path = Pathname.new(File.join(directory, filename)).cleanpath.to_path
|
96
143
|
content = _fetch_file_content(path, fetch_submodules: fetch_submodules)
|
97
144
|
type = @linked_paths.key?(path.gsub(%r{^/}, "")) ? "symlink" : type
|
@@ -4,18 +4,19 @@ module Dependabot
|
|
4
4
|
module FileUpdaters
|
5
5
|
class Base
|
6
6
|
attr_reader :dependencies, :dependency_files, :repo_contents_path,
|
7
|
-
:credentials
|
7
|
+
:credentials, :options
|
8
8
|
|
9
9
|
def self.updated_files_regex
|
10
10
|
raise NotImplementedError
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(dependencies:, dependency_files:, repo_contents_path: nil,
|
14
|
-
credentials:)
|
14
|
+
credentials:, options: {})
|
15
15
|
@dependencies = dependencies
|
16
16
|
@dependency_files = dependency_files
|
17
17
|
@repo_contents_path = repo_contents_path
|
18
18
|
@credentials = credentials
|
19
|
+
@options = options
|
19
20
|
|
20
21
|
check_required_files
|
21
22
|
end
|
@@ -8,11 +8,17 @@ require "digest"
|
|
8
8
|
require "open3"
|
9
9
|
require "shellwords"
|
10
10
|
|
11
|
+
require "dependabot/version"
|
12
|
+
|
11
13
|
module Dependabot
|
12
14
|
module SharedHelpers
|
13
15
|
BUMP_TMP_FILE_PREFIX = "dependabot_"
|
14
16
|
BUMP_TMP_DIR_PATH = "tmp"
|
15
17
|
GIT_CONFIG_GLOBAL_PATH = File.expand_path("~/.gitconfig")
|
18
|
+
USER_AGENT = "dependabot-core/#{Dependabot::VERSION} "\
|
19
|
+
"#{Excon::USER_AGENT} ruby/#{RUBY_VERSION} "\
|
20
|
+
"(#{RUBY_PLATFORM}) "\
|
21
|
+
"(+https://github.com/dependabot/dependabot-core)"
|
16
22
|
|
17
23
|
class ChildProcessFailed < StandardError
|
18
24
|
attr_reader :error_class, :error_message, :error_backtrace
|
@@ -138,14 +144,24 @@ module Dependabot
|
|
138
144
|
[Excon::Middleware::RedirectFollower]
|
139
145
|
end
|
140
146
|
|
141
|
-
def self.
|
147
|
+
def self.excon_headers(headers = nil)
|
148
|
+
headers ||= {}
|
149
|
+
{
|
150
|
+
"User-Agent" => USER_AGENT
|
151
|
+
}.merge(headers)
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.excon_defaults(options = nil)
|
155
|
+
options ||= {}
|
156
|
+
headers = options.delete(:headers)
|
142
157
|
{
|
143
158
|
connect_timeout: 5,
|
144
159
|
write_timeout: 5,
|
145
160
|
read_timeout: 20,
|
146
161
|
omit_default_port: true,
|
147
|
-
middlewares: excon_middleware
|
148
|
-
|
162
|
+
middlewares: excon_middleware,
|
163
|
+
headers: excon_headers(headers)
|
164
|
+
}.merge(options)
|
149
165
|
end
|
150
166
|
|
151
167
|
def self.with_git_configured(credentials:)
|
data/lib/dependabot/utils.rb
CHANGED
@@ -29,5 +29,15 @@ module Dependabot
|
|
29
29
|
def self.register_requirement_class(package_manager, requirement_class)
|
30
30
|
@requirement_classes[package_manager] = requirement_class
|
31
31
|
end
|
32
|
+
|
33
|
+
@cloning_package_managers = Set[]
|
34
|
+
|
35
|
+
def self.always_clone_for_package_manager?(package_manager)
|
36
|
+
@cloning_package_managers.include?(package_manager)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.register_always_clone(package_manager)
|
40
|
+
@cloning_package_managers << package_manager
|
41
|
+
end
|
32
42
|
end
|
33
43
|
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.121.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-codecommit
|
@@ -292,14 +292,14 @@ dependencies:
|
|
292
292
|
requirements:
|
293
293
|
- - "~>"
|
294
294
|
- !ruby/object:Gem::Version
|
295
|
-
version: 0.
|
295
|
+
version: 0.92.0
|
296
296
|
type: :development
|
297
297
|
prerelease: false
|
298
298
|
version_requirements: !ruby/object:Gem::Requirement
|
299
299
|
requirements:
|
300
300
|
- - "~>"
|
301
301
|
- !ruby/object:Gem::Version
|
302
|
-
version: 0.
|
302
|
+
version: 0.92.0
|
303
303
|
- !ruby/object:Gem::Dependency
|
304
304
|
name: vcr
|
305
305
|
requirement: !ruby/object:Gem::Requirement
|