dependabot-common 0.95.36 → 0.95.37
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f84e3f8b023a6cf787eca7dc3ed71b932495d297d8b36c732427998dd243c87
|
|
4
|
+
data.tar.gz: a60c2c05ab9c9107513daf426405881603d3dc6ceb68d0ed20c39f856fa94ab7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9cd41a89bb9ba29d7fd78c96e064585a29ffb86fb7174cf79d1fc015ce3cbb304210095b2c5cac385b0370cb5818ba89c8768e990ec0a89d8f980b816291a28
|
|
7
|
+
data.tar.gz: cfb13c360a37753c3a1373b93b1ff00b9f1705016defa754169008a263e1d767233c27ae1f7fdb3bdd9a8cc251fbc02da97b491c17ac59a853c5e51c7daa1dab
|
|
@@ -7,12 +7,13 @@ require "dependabot/metadata_finders"
|
|
|
7
7
|
require "dependabot/errors"
|
|
8
8
|
require "dependabot/utils"
|
|
9
9
|
require "dependabot/source"
|
|
10
|
+
require "dependabot/dependency"
|
|
11
|
+
require "dependabot/git_metadata_fetcher"
|
|
10
12
|
|
|
11
13
|
# rubocop:disable Metrics/ClassLength
|
|
12
14
|
module Dependabot
|
|
13
15
|
class GitCommitChecker
|
|
14
16
|
VERSION_REGEX = /(?<version>[0-9]+\.[0-9]+(?:\.[a-zA-Z0-9\-]+)*)$/.freeze
|
|
15
|
-
KNOWN_HOSTS = /github\.com|bitbucket\.org|gitlab.com/.freeze
|
|
16
17
|
|
|
17
18
|
def initialize(dependency:, credentials:, ignored_versions: [],
|
|
18
19
|
requirement_class: nil, version_class: nil)
|
|
@@ -137,99 +138,19 @@ module Dependabot
|
|
|
137
138
|
end
|
|
138
139
|
|
|
139
140
|
def local_upload_pack
|
|
140
|
-
|
|
141
|
-
fetch_upload_pack_for(dependency_source_details.fetch(:url))
|
|
141
|
+
local_repo_git_metadata_fetcher.upload_pack
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
def local_tags
|
|
145
|
-
|
|
145
|
+
tags = local_repo_git_metadata_fetcher.tags
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def tags_for_upload_pack(upload_pack)
|
|
151
|
-
peeled_lines = []
|
|
152
|
-
unpeeled_lines = []
|
|
153
|
-
|
|
154
|
-
upload_pack.lines.each do |line|
|
|
155
|
-
next unless line.split(" ").last.start_with?("refs/tags")
|
|
156
|
-
|
|
157
|
-
if line.strip.end_with?("^{}") then peeled_lines << line
|
|
158
|
-
else unpeeled_lines << line
|
|
147
|
+
if dependency_source_details&.fetch(:ref, nil)&.start_with?("tags/")
|
|
148
|
+
tags = tags.map do |tag|
|
|
149
|
+
tag.dup.tap { |t| t.name = "tags/#{tag.name}" }
|
|
159
150
|
end
|
|
160
151
|
end
|
|
161
152
|
|
|
162
|
-
|
|
163
|
-
tag_name = line.split(" refs/tags/").last.strip
|
|
164
|
-
tag_sha = sha_for_update_pack_line(line)
|
|
165
|
-
peeled_line = peeled_lines.find do |pl|
|
|
166
|
-
pl.split(" refs/tags/").last.strip == "#{tag_name}^{}"
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
commit_sha =
|
|
170
|
-
peeled_line ? sha_for_update_pack_line(peeled_line) : tag_sha
|
|
171
|
-
|
|
172
|
-
if dependency_source_details&.fetch(:ref, nil)&.start_with?("tags/")
|
|
173
|
-
tag_name = "tags/#{tag_name}"
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
OpenStruct.new(name: tag_name, tag_sha: tag_sha, commit_sha: commit_sha)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
|
181
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
|
182
|
-
def fetch_upload_pack_for(uri)
|
|
183
|
-
response = Excon.get(
|
|
184
|
-
service_pack_uri(uri),
|
|
185
|
-
idempotent: true,
|
|
186
|
-
**SharedHelpers.excon_defaults
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
return response.body if response.status == 200
|
|
190
|
-
if response.status >= 500 && uri.match?(KNOWN_HOSTS)
|
|
191
|
-
raise "Server error at #{uri}: #{response.body}"
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
raise Dependabot::GitDependenciesNotReachable, [uri]
|
|
195
|
-
rescue Excon::Error::Socket, Excon::Error::Timeout
|
|
196
|
-
retry_count ||= 0
|
|
197
|
-
retry_count += 1
|
|
198
|
-
|
|
199
|
-
sleep(rand(0.9)) && retry if retry_count < 2 && uri.match?(KNOWN_HOSTS)
|
|
200
|
-
raise if uri.match?(KNOWN_HOSTS)
|
|
201
|
-
|
|
202
|
-
raise Dependabot::GitDependenciesNotReachable, [uri]
|
|
203
|
-
end
|
|
204
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
205
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
|
206
|
-
|
|
207
|
-
def service_pack_uri(uri)
|
|
208
|
-
service_pack_uri = uri_with_auth(uri)
|
|
209
|
-
service_pack_uri = service_pack_uri.gsub(%r{/$}, "")
|
|
210
|
-
service_pack_uri += ".git" unless service_pack_uri.end_with?(".git")
|
|
211
|
-
service_pack_uri + "/info/refs?service=git-upload-pack"
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def uri_with_auth(uri)
|
|
215
|
-
bare_uri =
|
|
216
|
-
if uri.include?("git@") then uri.split("git@").last.sub(":", "/")
|
|
217
|
-
else uri.sub(%r{.*?://}, "")
|
|
218
|
-
end
|
|
219
|
-
cred = credentials.select { |c| c["type"] == "git_source" }.
|
|
220
|
-
find { |c| bare_uri.start_with?(c["host"]) }
|
|
221
|
-
|
|
222
|
-
if bare_uri.match?(%r{[^/]+:[^/]+@})
|
|
223
|
-
# URI already has authentication details
|
|
224
|
-
"https://#{bare_uri}"
|
|
225
|
-
elsif cred
|
|
226
|
-
# URI doesn't have authentication details, but we have credentials
|
|
227
|
-
auth_string = "#{cred.fetch('username')}:#{cred.fetch('password')}"
|
|
228
|
-
"https://#{auth_string}@#{bare_uri}"
|
|
229
|
-
else
|
|
230
|
-
# No credentials, so just return the https URI
|
|
231
|
-
"https://#{bare_uri}"
|
|
232
|
-
end
|
|
153
|
+
tags
|
|
233
154
|
end
|
|
234
155
|
|
|
235
156
|
def commit_included_in_tag?(tag:, commit:, allow_identical: false)
|
|
@@ -363,9 +284,17 @@ module Dependabot
|
|
|
363
284
|
end
|
|
364
285
|
|
|
365
286
|
def listing_tags
|
|
366
|
-
return [] unless
|
|
287
|
+
return [] unless listing_source_url
|
|
367
288
|
|
|
368
|
-
|
|
289
|
+
tags = listing_repo_git_metadata_fetcher.tags
|
|
290
|
+
|
|
291
|
+
if dependency_source_details&.fetch(:ref, nil)&.start_with?("tags/")
|
|
292
|
+
tags = tags.map do |tag|
|
|
293
|
+
tag.dup.tap { |t| t.name = "tags/#{tag.name}" }
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
tags
|
|
369
298
|
rescue GitDependenciesNotReachable
|
|
370
299
|
[]
|
|
371
300
|
end
|
|
@@ -373,7 +302,7 @@ module Dependabot
|
|
|
373
302
|
def listing_upload_pack
|
|
374
303
|
return unless listing_source_url
|
|
375
304
|
|
|
376
|
-
|
|
305
|
+
listing_repo_git_metadata_fetcher.upload_pack
|
|
377
306
|
end
|
|
378
307
|
|
|
379
308
|
def ignore_reqs
|
|
@@ -414,6 +343,22 @@ module Dependabot
|
|
|
414
343
|
def sha_for_update_pack_line(line)
|
|
415
344
|
line.split(" ").first.chars.last(40).join
|
|
416
345
|
end
|
|
346
|
+
|
|
347
|
+
def local_repo_git_metadata_fetcher
|
|
348
|
+
@local_repo_git_metadata_fetcher ||=
|
|
349
|
+
GitMetadataFetcher.new(
|
|
350
|
+
url: dependency_source_details.fetch(:url),
|
|
351
|
+
credentials: credentials
|
|
352
|
+
)
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
def listing_repo_git_metadata_fetcher
|
|
356
|
+
@listing_repo_git_metadata_fetcher ||=
|
|
357
|
+
GitMetadataFetcher.new(
|
|
358
|
+
url: listing_source_url,
|
|
359
|
+
credentials: credentials
|
|
360
|
+
)
|
|
361
|
+
end
|
|
417
362
|
end
|
|
418
363
|
end
|
|
419
364
|
# rubocop:enable Metrics/ClassLength
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "excon"
|
|
4
|
+
require "dependabot/errors"
|
|
5
|
+
|
|
6
|
+
module Dependabot
|
|
7
|
+
class GitMetadataFetcher
|
|
8
|
+
KNOWN_HOSTS = /github\.com|bitbucket\.org|gitlab.com/.freeze
|
|
9
|
+
|
|
10
|
+
def initialize(url:, credentials:)
|
|
11
|
+
@url = url
|
|
12
|
+
@credentials = credentials
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def upload_pack
|
|
16
|
+
@upload_pack ||= fetch_upload_pack_for(url)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def tags
|
|
20
|
+
return [] unless upload_pack
|
|
21
|
+
|
|
22
|
+
@tags ||= tags_for_upload_pack(upload_pack)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
attr_reader :url, :credentials
|
|
28
|
+
|
|
29
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
|
30
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
31
|
+
def fetch_upload_pack_for(uri)
|
|
32
|
+
response = Excon.get(
|
|
33
|
+
service_pack_uri(uri),
|
|
34
|
+
idempotent: true,
|
|
35
|
+
**SharedHelpers.excon_defaults
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return response.body if response.status == 200
|
|
39
|
+
if response.status >= 500 && uri.match?(KNOWN_HOSTS)
|
|
40
|
+
raise "Server error at #{uri}: #{response.body}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
raise Dependabot::GitDependenciesNotReachable, [uri]
|
|
44
|
+
rescue Excon::Error::Socket, Excon::Error::Timeout
|
|
45
|
+
retry_count ||= 0
|
|
46
|
+
retry_count += 1
|
|
47
|
+
|
|
48
|
+
sleep(rand(0.9)) && retry if retry_count < 2 && uri.match?(KNOWN_HOSTS)
|
|
49
|
+
raise if uri.match?(KNOWN_HOSTS)
|
|
50
|
+
|
|
51
|
+
raise Dependabot::GitDependenciesNotReachable, [uri]
|
|
52
|
+
end
|
|
53
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
|
54
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
55
|
+
|
|
56
|
+
def tags_for_upload_pack(upload_pack)
|
|
57
|
+
peeled_lines = []
|
|
58
|
+
|
|
59
|
+
result = upload_pack.lines.each_with_object({}) do |line, res|
|
|
60
|
+
next unless line.split(" ").last.start_with?("refs/tags")
|
|
61
|
+
|
|
62
|
+
peeled_lines << line && next if line.strip.end_with?("^{}")
|
|
63
|
+
|
|
64
|
+
tag_name = line.split(" refs/tags/").last.strip
|
|
65
|
+
sha = sha_for_update_pack_line(line)
|
|
66
|
+
|
|
67
|
+
res[tag_name] =
|
|
68
|
+
OpenStruct.new(name: tag_name, tag_sha: sha, commit_sha: sha)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Loop through the peeled lines, updating the commit_sha for any matching
|
|
72
|
+
# tags in our results hash
|
|
73
|
+
peeled_lines.each do |line|
|
|
74
|
+
tag_name = line.split(" refs/tags/").last.strip.gsub(/\^{}$/, "")
|
|
75
|
+
next unless result[tag_name]
|
|
76
|
+
|
|
77
|
+
result[tag_name].commit_sha = sha_for_update_pack_line(line)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
result.values
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def service_pack_uri(uri)
|
|
84
|
+
service_pack_uri = uri_with_auth(uri)
|
|
85
|
+
service_pack_uri = service_pack_uri.gsub(%r{/$}, "")
|
|
86
|
+
service_pack_uri += ".git" unless service_pack_uri.end_with?(".git")
|
|
87
|
+
service_pack_uri + "/info/refs?service=git-upload-pack"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def uri_with_auth(uri)
|
|
91
|
+
bare_uri =
|
|
92
|
+
if uri.include?("git@") then uri.split("git@").last.sub(":", "/")
|
|
93
|
+
else uri.sub(%r{.*?://}, "")
|
|
94
|
+
end
|
|
95
|
+
cred = credentials.select { |c| c["type"] == "git_source" }.
|
|
96
|
+
find { |c| bare_uri.start_with?(c["host"]) }
|
|
97
|
+
|
|
98
|
+
if bare_uri.match?(%r{[^/]+:[^/]+@})
|
|
99
|
+
# URI already has authentication details
|
|
100
|
+
"https://#{bare_uri}"
|
|
101
|
+
elsif cred
|
|
102
|
+
# URI doesn't have authentication details, but we have credentials
|
|
103
|
+
auth_string = "#{cred.fetch('username')}:#{cred.fetch('password')}"
|
|
104
|
+
"https://#{auth_string}@#{bare_uri}"
|
|
105
|
+
else
|
|
106
|
+
# No credentials, so just return the https URI
|
|
107
|
+
"https://#{bare_uri}"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def sha_for_update_pack_line(line)
|
|
112
|
+
line.split(" ").first.chars.last(40).join
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -4,6 +4,7 @@ require "dependabot/clients/github_with_retries"
|
|
|
4
4
|
require "dependabot/clients/gitlab"
|
|
5
5
|
require "dependabot/clients/bitbucket"
|
|
6
6
|
require "dependabot/shared_helpers"
|
|
7
|
+
require "dependabot/git_metadata_fetcher"
|
|
7
8
|
require "dependabot/metadata_finders/base"
|
|
8
9
|
|
|
9
10
|
module Dependabot
|
|
@@ -125,21 +126,11 @@ module Dependabot
|
|
|
125
126
|
def fetch_dependency_tags
|
|
126
127
|
return [] unless source
|
|
127
128
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
when "gitlab"
|
|
134
|
-
gitlab_client.tags(source.repo).map(&:name)
|
|
135
|
-
when "azure"
|
|
136
|
-
[] # TODO: Fetch Azure tags
|
|
137
|
-
else raise "Unexpected source provider '#{source.provider}'"
|
|
138
|
-
end
|
|
139
|
-
rescue Octokit::NotFound, Gitlab::Error::NotFound,
|
|
140
|
-
Dependabot::Clients::Bitbucket::NotFound,
|
|
141
|
-
Dependabot::Clients::Bitbucket::Unauthorized,
|
|
142
|
-
Dependabot::Clients::Bitbucket::Forbidden
|
|
129
|
+
GitMetadataFetcher.
|
|
130
|
+
new(url: source.url, credentials: credentials).
|
|
131
|
+
tags.
|
|
132
|
+
map(&:name)
|
|
133
|
+
rescue Dependabot::GitDependenciesNotReachable
|
|
143
134
|
[]
|
|
144
135
|
end
|
|
145
136
|
|
data/lib/dependabot/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dependabot-common
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.95.
|
|
4
|
+
version: 0.95.37
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -328,6 +328,7 @@ files:
|
|
|
328
328
|
- lib/dependabot/file_updaters/README.md
|
|
329
329
|
- lib/dependabot/file_updaters/base.rb
|
|
330
330
|
- lib/dependabot/git_commit_checker.rb
|
|
331
|
+
- lib/dependabot/git_metadata_fetcher.rb
|
|
331
332
|
- lib/dependabot/metadata_finders.rb
|
|
332
333
|
- lib/dependabot/metadata_finders/README.md
|
|
333
334
|
- lib/dependabot/metadata_finders/base.rb
|