dependabot-common 0.405.0 → 0.406.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.
- checksums.yaml +4 -4
- data/lib/dependabot/clients/azure.rb +20 -2
- data/lib/dependabot/clients/bitbucket.rb +11 -12
- data/lib/dependabot/clients/comparison_commit.rb +21 -0
- data/lib/dependabot/clients/json_response_parser.rb +0 -8
- data/lib/dependabot/command_helpers.rb +3 -3
- data/lib/dependabot/file_parsers/hcl2_json_document.rb +207 -0
- data/lib/dependabot/file_parsers/hcl_module_source.rb +185 -0
- data/lib/dependabot/metadata_finders/base/commit_response_parser.rb +0 -8
- data/lib/dependabot/metadata_finders/base/commits_finder.rb +2 -17
- data/lib/dependabot/package/npm_package_json.rb +6 -0
- data/lib/dependabot.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 424b2083a55394433c470067d24924a788cb775aac25c49c94feb872f6488d46
|
|
4
|
+
data.tar.gz: 5146fb6e1f481c80a088d0a7d8971eb37598f901160b4d76f34b7597e275805c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd04daebff6d5817bef3dfd8d11083a0eaf7bc0779a87d10eaa344523cbdd2a0cb5e628581f7b1bcc73f7c5dceda280c83a18aaccb45b3c161b8a63d7c7afd96
|
|
7
|
+
data.tar.gz: e2d3160cff4c120bbbcc1420a80a13be66e15e4c20ec64092f89ed8db389a4093f649d9d03574326ec3e0e6d4535b54857caff2e955c5d4f051d02b54215959c
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
require "dependabot/shared_helpers"
|
|
5
5
|
require "dependabot/clients/json_response_parser"
|
|
6
|
+
require "dependabot/clients/comparison_commit"
|
|
6
7
|
require "excon"
|
|
7
8
|
require "sorbet-runtime"
|
|
8
9
|
|
|
@@ -372,7 +373,7 @@ module Dependabot
|
|
|
372
373
|
new_tag: T.nilable(String),
|
|
373
374
|
type: String
|
|
374
375
|
)
|
|
375
|
-
.returns(
|
|
376
|
+
.returns(T::Array[ComparisonCommit])
|
|
376
377
|
end
|
|
377
378
|
def compare(previous_tag, new_tag, type)
|
|
378
379
|
response = get(
|
|
@@ -386,7 +387,13 @@ module Dependabot
|
|
|
386
387
|
)
|
|
387
388
|
|
|
388
389
|
root = parse_json_object(response.body, "commit comparison")
|
|
389
|
-
object_array_field(root, "value", "commit comparison")
|
|
390
|
+
object_array_field(root, "value", "commit comparison").map do |commit|
|
|
391
|
+
ComparisonCommit.new(
|
|
392
|
+
sha: comparison_string(commit, "commitId"),
|
|
393
|
+
message: comparison_string(commit, "comment"),
|
|
394
|
+
html_url: comparison_string(commit, "remoteUrl")
|
|
395
|
+
)
|
|
396
|
+
end
|
|
390
397
|
end
|
|
391
398
|
|
|
392
399
|
sig { params(url: String).returns(Excon::Response) }
|
|
@@ -487,6 +494,17 @@ module Dependabot
|
|
|
487
494
|
|
|
488
495
|
private
|
|
489
496
|
|
|
497
|
+
sig { params(commit: JsonObject, key: String).returns(String) }
|
|
498
|
+
def comparison_string(commit, key)
|
|
499
|
+
value = commit[key]
|
|
500
|
+
return value if value.is_a?(String)
|
|
501
|
+
|
|
502
|
+
raise Dependabot::PrivateSourceBadResponse.new(
|
|
503
|
+
source.url,
|
|
504
|
+
"Malformed Azure commit response: commit #{key} must be a string"
|
|
505
|
+
)
|
|
506
|
+
end
|
|
507
|
+
|
|
490
508
|
sig { returns([String, String]) }
|
|
491
509
|
def response_identity
|
|
492
510
|
["Azure", source.url]
|
|
@@ -5,6 +5,7 @@ require "excon"
|
|
|
5
5
|
require "sorbet-runtime"
|
|
6
6
|
|
|
7
7
|
require "dependabot/clients/json_response_parser"
|
|
8
|
+
require "dependabot/clients/comparison_commit"
|
|
8
9
|
require "dependabot/shared_helpers"
|
|
9
10
|
|
|
10
11
|
module Dependabot
|
|
@@ -309,24 +310,22 @@ module Dependabot
|
|
|
309
310
|
object_array_field(root, "values", "tags")
|
|
310
311
|
end
|
|
311
312
|
|
|
312
|
-
sig
|
|
313
|
-
params(
|
|
314
|
-
repo: String,
|
|
315
|
-
previous_tag: String,
|
|
316
|
-
new_tag: String
|
|
317
|
-
)
|
|
318
|
-
.returns(JsonObjects)
|
|
319
|
-
end
|
|
313
|
+
sig { params(repo: String, previous_tag: String, new_tag: String).returns(T::Array[ComparisonCommit]) }
|
|
320
314
|
def compare(repo, previous_tag, new_tag)
|
|
321
315
|
path = "#{repo}/commits/?include=#{new_tag}&exclude=#{previous_tag}"
|
|
322
316
|
response = get(base_url + path)
|
|
323
317
|
|
|
324
318
|
root = parse_json_object(response.body, "commit comparison")
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
319
|
+
object_array_field(root, "values", "commit comparison").map do |commit|
|
|
320
|
+
summary = object_field(commit, "summary", "commit comparison")
|
|
321
|
+
links = object_field(commit, "links", "commit comparison")
|
|
322
|
+
html = object_field(links, "html", "commit comparison")
|
|
323
|
+
ComparisonCommit.new(
|
|
324
|
+
sha: string_field(commit, "hash", "commit comparison"),
|
|
325
|
+
message: string_field(summary, "raw", "commit comparison"),
|
|
326
|
+
html_url: string_field(html, "href", "commit comparison")
|
|
327
|
+
)
|
|
328
328
|
end
|
|
329
|
-
commits
|
|
330
329
|
end
|
|
331
330
|
|
|
332
331
|
sig { params(url: String).returns(Excon::Response) }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "sorbet-runtime"
|
|
5
|
+
|
|
6
|
+
module Dependabot
|
|
7
|
+
module Clients
|
|
8
|
+
class ComparisonCommit < T::ImmutableStruct
|
|
9
|
+
extend T::Sig
|
|
10
|
+
|
|
11
|
+
const :sha, String
|
|
12
|
+
const :message, String
|
|
13
|
+
const :html_url, String
|
|
14
|
+
|
|
15
|
+
sig { returns(T::Hash[Symbol, String]) }
|
|
16
|
+
def to_h
|
|
17
|
+
{ message: message, sha: sha, html_url: html_url }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -77,14 +77,6 @@ module Dependabot
|
|
|
77
77
|
raise_bad_response(context, "#{key} must contain at least one object")
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
sig { params(object: JsonObject, context: String, paths: T::Array[T::Array[String]]).void }
|
|
81
|
-
def validate_string_paths(object, context, paths)
|
|
82
|
-
paths.each do |path|
|
|
83
|
-
current = T.must(path[0...-1]).reduce(object) { |value, key| object_field(value, key, context) }
|
|
84
|
-
string_field(current, T.must(path.last), context)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
80
|
sig { params(context: String, message: String).returns(T.noreturn) }
|
|
89
81
|
def raise_bad_response(context, message)
|
|
90
82
|
provider, source = response_identity
|
|
@@ -97,7 +97,7 @@ module Dependabot
|
|
|
97
97
|
timeout: TIMEOUTS::DEFAULT,
|
|
98
98
|
output_observer: nil
|
|
99
99
|
)
|
|
100
|
-
stdout = T.let("", String)
|
|
100
|
+
stdout = T.let(+"", String)
|
|
101
101
|
stderr = T.let("", String)
|
|
102
102
|
status = T.let(nil, T.nilable(ProcessStatus))
|
|
103
103
|
pid = T.let(nil, T.nilable(Integer))
|
|
@@ -172,10 +172,10 @@ module Dependabot
|
|
|
172
172
|
|
|
173
173
|
# 4. Append data to the appropriate stream
|
|
174
174
|
if io == stdout_io
|
|
175
|
-
stdout
|
|
175
|
+
stdout << data
|
|
176
176
|
else
|
|
177
177
|
stderr += data unless stderr_to_stdout
|
|
178
|
-
stdout
|
|
178
|
+
stdout << data if stderr_to_stdout
|
|
179
179
|
end
|
|
180
180
|
|
|
181
181
|
# Observe the output if an observer is provided.
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "json"
|
|
5
|
+
require "sorbet-runtime"
|
|
6
|
+
require "dependabot/dependency_file"
|
|
7
|
+
require "dependabot/errors"
|
|
8
|
+
|
|
9
|
+
module Dependabot
|
|
10
|
+
module FileParsers
|
|
11
|
+
class Hcl2JsonDocument
|
|
12
|
+
extend T::Sig
|
|
13
|
+
|
|
14
|
+
ObjectHash = T.type_alias { T::Hash[String, Object] }
|
|
15
|
+
ModuleBlocks = T.type_alias { T::Hash[String, T::Array[ObjectHash]] }
|
|
16
|
+
|
|
17
|
+
class Declaration
|
|
18
|
+
extend T::Sig
|
|
19
|
+
|
|
20
|
+
sig { params(name: String, fields: ObjectHash, path: String).void }
|
|
21
|
+
def initialize(name:, fields:, path:)
|
|
22
|
+
@name = name
|
|
23
|
+
@fields = fields
|
|
24
|
+
@path = path
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
sig { returns(String) }
|
|
28
|
+
attr_reader :name
|
|
29
|
+
|
|
30
|
+
sig { returns(T.nilable(String)) }
|
|
31
|
+
def version
|
|
32
|
+
optional_string("version")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
protected
|
|
36
|
+
|
|
37
|
+
sig { params(key: String).returns(String) }
|
|
38
|
+
def string(key)
|
|
39
|
+
value = @fields[key]
|
|
40
|
+
return value if value.is_a?(String)
|
|
41
|
+
|
|
42
|
+
raise DependencyFileNotParseable.new(@path, "#{@name}.#{key} must be a string")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
sig { params(key: String).returns(T.nilable(String)) }
|
|
46
|
+
def optional_string(key)
|
|
47
|
+
string(key) unless @fields[key].nil?
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class ModuleDeclaration < Declaration
|
|
52
|
+
extend T::Sig
|
|
53
|
+
|
|
54
|
+
sig { returns(String) }
|
|
55
|
+
def source
|
|
56
|
+
string("source")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class ProviderDeclaration < Declaration
|
|
61
|
+
extend T::Sig
|
|
62
|
+
|
|
63
|
+
sig { returns(T.nilable(String)) }
|
|
64
|
+
def source
|
|
65
|
+
optional_string("source")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class DeprecatedProvider < T::ImmutableStruct
|
|
70
|
+
const :name, String
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Provider = T.type_alias { T.any(ProviderDeclaration, DeprecatedProvider) }
|
|
74
|
+
|
|
75
|
+
sig { params(output: String, file: DependencyFile).returns(Hcl2JsonDocument) }
|
|
76
|
+
def self.from_helper_output(output, file:)
|
|
77
|
+
new(T.cast(JSON.parse(output), Object), file.path)
|
|
78
|
+
rescue JSON::ParserError => e
|
|
79
|
+
raise DependencyFileNotParseable.new(file.path, e.message)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
sig { params(data: Object, path: String).void }
|
|
83
|
+
def initialize(data, path)
|
|
84
|
+
@path = path
|
|
85
|
+
@data = T.let(object(data, "root"), ObjectHash)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
sig { params(overrides: T::Array[Hcl2JsonDocument]).returns(T::Array[ModuleDeclaration]) }
|
|
89
|
+
def module_declarations(overrides: [])
|
|
90
|
+
modules = module_blocks
|
|
91
|
+
overrides.each { |override| modules = merge_modules(override.module_blocks, modules) }
|
|
92
|
+
modules.map do |name, entries|
|
|
93
|
+
fields = entries.first
|
|
94
|
+
invalid!("module.#{name} must contain a block") unless fields
|
|
95
|
+
|
|
96
|
+
ModuleDeclaration.new(name: name, fields: fields, path: @path)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
sig { returns(T::Array[Provider]) }
|
|
101
|
+
def provider_declarations
|
|
102
|
+
blocks("terraform").flat_map { |block| providers_for(block) }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
sig { returns(T::Array[String]) }
|
|
106
|
+
def terragrunt_sources
|
|
107
|
+
blocks("terraform").filter_map do |block|
|
|
108
|
+
value = block["source"]
|
|
109
|
+
next unless value
|
|
110
|
+
|
|
111
|
+
invalid!("terraform.source must be a string") unless value.is_a?(String)
|
|
112
|
+
value
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
sig { returns(T::Hash[String, String]) }
|
|
117
|
+
def local_strings
|
|
118
|
+
blocks("locals").each_with_object(T.let({}, T::Hash[String, String])) do |block, result|
|
|
119
|
+
block.each { |name, value| result[name] = value if value.is_a?(String) }
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
sig { params(source: String).returns(T.nilable(String)) }
|
|
124
|
+
def provider_version(source)
|
|
125
|
+
value = @data["provider"]
|
|
126
|
+
return if value.nil?
|
|
127
|
+
|
|
128
|
+
entries = object(value, "provider")[source]
|
|
129
|
+
return if entries.nil?
|
|
130
|
+
|
|
131
|
+
entry = array(entries, "provider.#{source}").first
|
|
132
|
+
return if entry.nil?
|
|
133
|
+
|
|
134
|
+
version = object(entry, "provider.#{source}")["version"]
|
|
135
|
+
return if version.nil?
|
|
136
|
+
|
|
137
|
+
invalid!("provider.#{source}.version must be a string") unless version.is_a?(String)
|
|
138
|
+
version
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
protected
|
|
142
|
+
|
|
143
|
+
sig { returns(ModuleBlocks) }
|
|
144
|
+
def module_blocks
|
|
145
|
+
object(@data.fetch("module", {}), "module").to_h do |name, entries|
|
|
146
|
+
[name, array(entries, "module.#{name}").map { |entry| object(entry, "module.#{name}") }]
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
private
|
|
151
|
+
|
|
152
|
+
sig { params(overrides: ModuleBlocks, base: ModuleBlocks).returns(ModuleBlocks) }
|
|
153
|
+
def merge_modules(overrides, base)
|
|
154
|
+
merged = base.dup
|
|
155
|
+
overrides.each do |name, entries|
|
|
156
|
+
existing = merged[name]
|
|
157
|
+
merged[name] = if existing
|
|
158
|
+
fields = entries.first
|
|
159
|
+
invalid!("module.#{name} override must contain a block") unless fields
|
|
160
|
+
|
|
161
|
+
existing.map { |entry| entry.merge(fields) }
|
|
162
|
+
else
|
|
163
|
+
entries
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
merged
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
sig { params(block: ObjectHash).returns(T::Array[Provider]) }
|
|
170
|
+
def providers_for(block)
|
|
171
|
+
array(block.fetch("required_providers", []), "terraform.required_providers").flat_map do |group|
|
|
172
|
+
object(group, "required_providers").map do |name, value|
|
|
173
|
+
if value.is_a?(String)
|
|
174
|
+
DeprecatedProvider.new(name: name)
|
|
175
|
+
else
|
|
176
|
+
ProviderDeclaration.new(name: name, fields: object(value, "provider.#{name}"), path: @path)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
sig { params(key: String).returns(T::Array[ObjectHash]) }
|
|
183
|
+
def blocks(key)
|
|
184
|
+
array(@data.fetch(key, []), key).map { |entry| object(entry, key) }
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
sig { params(value: Object, field: String).returns(ObjectHash) }
|
|
188
|
+
def object(value, field)
|
|
189
|
+
invalid!("#{field} must be an object") unless value.is_a?(Hash)
|
|
190
|
+
|
|
191
|
+
T.let(value, ObjectHash)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
sig { params(value: Object, field: String).returns(T::Array[Object]) }
|
|
195
|
+
def array(value, field)
|
|
196
|
+
invalid!("#{field} must be an array") unless value.is_a?(Array)
|
|
197
|
+
|
|
198
|
+
value.map { |entry| T.cast(entry, Object) }
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
sig { params(message: String).returns(T.noreturn) }
|
|
202
|
+
def invalid!(message)
|
|
203
|
+
raise DependencyFileNotParseable.new(@path, message)
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "digest"
|
|
5
|
+
require "uri"
|
|
6
|
+
require "sorbet-runtime"
|
|
7
|
+
require "dependabot/errors"
|
|
8
|
+
require "dependabot/git_commit_checker"
|
|
9
|
+
require "dependabot/source"
|
|
10
|
+
|
|
11
|
+
module Dependabot
|
|
12
|
+
module FileParsers
|
|
13
|
+
module HclModuleSource
|
|
14
|
+
extend T::Sig
|
|
15
|
+
|
|
16
|
+
RequirementSource = T.type_alias { T::Hash[Symbol, T.nilable(String)] }
|
|
17
|
+
|
|
18
|
+
class Git < T::ImmutableStruct
|
|
19
|
+
extend T::Sig
|
|
20
|
+
|
|
21
|
+
const :url, String
|
|
22
|
+
const :ref, T.nilable(String)
|
|
23
|
+
const :proxy_url, T.nilable(String)
|
|
24
|
+
|
|
25
|
+
sig { params(module_name: String).returns(String) }
|
|
26
|
+
def dependency_name(module_name)
|
|
27
|
+
source = Source.from_url(url)
|
|
28
|
+
repository =
|
|
29
|
+
if source
|
|
30
|
+
"#{source.provider}::#{source.repo}"
|
|
31
|
+
else
|
|
32
|
+
"git_provider::repo_name/git_repo(#{Digest::SHA1.hexdigest(url)})"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
[module_name, repository, ref].compact.join("::")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
sig { returns(T.nilable(String)) }
|
|
39
|
+
def version
|
|
40
|
+
ref&.match(GitCommitChecker::VERSION_REGEX)&.named_captures&.fetch("version")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
sig { returns(RequirementSource) }
|
|
44
|
+
def to_requirement_source
|
|
45
|
+
HclModuleSource.with_proxy_url({ type: "git", url: url, branch: nil, ref: ref }, proxy_url)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class Registry < T::ImmutableStruct
|
|
50
|
+
extend T::Sig
|
|
51
|
+
|
|
52
|
+
const :registry_hostname, String
|
|
53
|
+
const :module_identifier, String
|
|
54
|
+
const :proxy_url, T.nilable(String)
|
|
55
|
+
|
|
56
|
+
sig { returns(RequirementSource) }
|
|
57
|
+
def to_requirement_source
|
|
58
|
+
HclModuleSource.with_proxy_url(
|
|
59
|
+
{ type: "registry", registry_hostname: registry_hostname, module_identifier: module_identifier },
|
|
60
|
+
proxy_url
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
class UrlKind < T::Enum
|
|
66
|
+
enums do
|
|
67
|
+
HttpArchive = new("http_archive")
|
|
68
|
+
Mercurial = new("mercurial")
|
|
69
|
+
S3 = new("s3")
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class Url < T::ImmutableStruct
|
|
74
|
+
extend T::Sig
|
|
75
|
+
|
|
76
|
+
const :url, String
|
|
77
|
+
const :kind, UrlKind
|
|
78
|
+
const :proxy_url, T.nilable(String)
|
|
79
|
+
|
|
80
|
+
sig { returns(RequirementSource) }
|
|
81
|
+
def to_requirement_source
|
|
82
|
+
HclModuleSource.with_proxy_url({ type: kind.serialize, url: url }, proxy_url)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class Interpolation < T::ImmutableStruct; end
|
|
87
|
+
|
|
88
|
+
Variant = T.type_alias { T.any(Git, Registry, Url) }
|
|
89
|
+
|
|
90
|
+
sig do
|
|
91
|
+
params(
|
|
92
|
+
source: String,
|
|
93
|
+
default_registry: String,
|
|
94
|
+
archive_extensions: T::Array[String],
|
|
95
|
+
proxy_url: T.nilable(String)
|
|
96
|
+
).returns(T.nilable(T.any(Variant, Interpolation)))
|
|
97
|
+
end
|
|
98
|
+
def self.parse(source, default_registry:, archive_extensions:, proxy_url:)
|
|
99
|
+
return Interpolation.new if interpolation?(source)
|
|
100
|
+
return if source.start_with?(".")
|
|
101
|
+
return git_from(source, proxy_url) if source.start_with?("github.com/", "bitbucket.org/", "git::", "git@")
|
|
102
|
+
|
|
103
|
+
kind = url_kind(source, archive_extensions)
|
|
104
|
+
return Url.new(url: source, kind: kind, proxy_url: proxy_url) if kind
|
|
105
|
+
|
|
106
|
+
registry_from(source, default_registry, proxy_url)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
sig { params(source: String).returns(T::Boolean) }
|
|
110
|
+
def self.interpolation?(source)
|
|
111
|
+
source.include?("${")
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
sig { params(url: T.nilable(String)).returns(String) }
|
|
115
|
+
def self.terragrunt_name(url)
|
|
116
|
+
# Preserve the error for sources without a URL, such as a registry source.
|
|
117
|
+
Source.from_url(url)&.repo || T.must(url)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
sig { params(fields: RequirementSource, proxy_url: T.nilable(String)).returns(RequirementSource) }
|
|
121
|
+
def self.with_proxy_url(fields, proxy_url)
|
|
122
|
+
fields[:proxy_url] = proxy_url if proxy_url
|
|
123
|
+
fields
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
sig { params(source: String, proxy_url: T.nilable(String)).returns(Git) }
|
|
127
|
+
def self.git_from(source, proxy_url)
|
|
128
|
+
url = source.strip.gsub(/^git::/, "")
|
|
129
|
+
url = "https://" + url unless url.start_with?("git@") || url.include?("://")
|
|
130
|
+
|
|
131
|
+
bare_uri =
|
|
132
|
+
if url.include?("git@")
|
|
133
|
+
T.must(url.split("git@").last).sub(":", "/")
|
|
134
|
+
else
|
|
135
|
+
url.sub(%r{(?:\w{3,5})?://}, "")
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
query = URI.parse("https://" + bare_uri).query
|
|
139
|
+
ref = URI.decode_www_form(query.to_s).to_h["ref"]&.split(%r{(?<!:)//})&.first
|
|
140
|
+
Git.new(url: T.must(url.gsub("?#{query}", "").split(%r{(?<!:)//}).first), ref: ref, proxy_url: proxy_url)
|
|
141
|
+
end
|
|
142
|
+
private_class_method :git_from
|
|
143
|
+
|
|
144
|
+
sig { params(source: String, default_registry: String, proxy_url: T.nilable(String)).returns(Registry) }
|
|
145
|
+
def self.registry_from(source, default_registry, proxy_url)
|
|
146
|
+
address = source.split("//").first
|
|
147
|
+
# Preserve the legacy error when the source has no address at all.
|
|
148
|
+
raise NoMethodError, "undefined method 'split' for nil" unless address
|
|
149
|
+
|
|
150
|
+
parts = address.split("/")
|
|
151
|
+
hostname, identifier =
|
|
152
|
+
case parts.length
|
|
153
|
+
when 3 then [default_registry, address]
|
|
154
|
+
when 4 then [parts.fetch(0), parts.drop(1).join("/")]
|
|
155
|
+
else raise DependencyFileNotEvaluatable, "Invalid registry source specified: '#{source}'"
|
|
156
|
+
end
|
|
157
|
+
Registry.new(registry_hostname: hostname.downcase, module_identifier: identifier.downcase, proxy_url: proxy_url)
|
|
158
|
+
end
|
|
159
|
+
private_class_method :registry_from
|
|
160
|
+
|
|
161
|
+
sig { params(source: String, archive_extensions: T::Array[String]).returns(T.nilable(UrlKind)) }
|
|
162
|
+
def self.url_kind(source, archive_extensions)
|
|
163
|
+
return UrlKind::Mercurial if source.start_with?("hg::")
|
|
164
|
+
return UrlKind::S3 if source.start_with?("s3::")
|
|
165
|
+
|
|
166
|
+
raise "Unknown src: #{source}" if source.split("/").first&.include?("::")
|
|
167
|
+
|
|
168
|
+
return unless source.start_with?("http")
|
|
169
|
+
return UrlKind::HttpArchive if http_archive?(source, archive_extensions)
|
|
170
|
+
|
|
171
|
+
raise "HTTP source, but not an archive!"
|
|
172
|
+
end
|
|
173
|
+
private_class_method :url_kind
|
|
174
|
+
|
|
175
|
+
sig { params(source: String, archive_extensions: T::Array[String]).returns(T::Boolean) }
|
|
176
|
+
def self.http_archive?(source, archive_extensions)
|
|
177
|
+
path_uri = URI.parse(T.must(source.split(%r{(?<!:)//}).first))
|
|
178
|
+
query_uri = URI.parse(source)
|
|
179
|
+
|
|
180
|
+
archive_extensions.any? { |ext| path_uri.path&.end_with?(ext) } || query_uri.query.to_s.include?("archive=")
|
|
181
|
+
end
|
|
182
|
+
private_class_method :http_archive?
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
@@ -47,14 +47,6 @@ module Dependabot
|
|
|
47
47
|
raise_bad_response("GitLab", "#{context} #{key} must be a string")
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
sig { params(object: T::Hash[String, Object], key: String, context: String).returns(String) }
|
|
51
|
-
def object_string(object, key, context)
|
|
52
|
-
value = object[key]
|
|
53
|
-
return value if value.is_a?(String)
|
|
54
|
-
|
|
55
|
-
raise_bad_response("Azure", "#{context} #{key} must be a string")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
50
|
sig { params(provider: String, message: String).returns(T.noreturn) }
|
|
59
51
|
def raise_bad_response(provider, message)
|
|
60
52
|
raise Dependabot::PrivateSourceBadResponse.new(
|
|
@@ -310,16 +310,7 @@ module Dependabot
|
|
|
310
310
|
def fetch_bitbucket_commits
|
|
311
311
|
bitbucket_client
|
|
312
312
|
.compare(T.must(source).repo, T.must(previous_tag), T.must(new_tag))
|
|
313
|
-
.map
|
|
314
|
-
summary = T.cast(commit.fetch("summary"), Dependabot::Clients::Bitbucket::JsonObject)
|
|
315
|
-
links = T.cast(commit.fetch("links"), Dependabot::Clients::Bitbucket::JsonObject)
|
|
316
|
-
html = T.cast(links.fetch("html"), Dependabot::Clients::Bitbucket::JsonObject)
|
|
317
|
-
{
|
|
318
|
-
message: T.cast(summary.fetch("raw"), String),
|
|
319
|
-
sha: T.cast(commit.fetch("hash"), String),
|
|
320
|
-
html_url: T.cast(html.fetch("href"), String)
|
|
321
|
-
}
|
|
322
|
-
end
|
|
313
|
+
.map(&:to_h)
|
|
323
314
|
rescue Dependabot::Clients::Bitbucket::NotFound,
|
|
324
315
|
Dependabot::Clients::Bitbucket::Unauthorized,
|
|
325
316
|
Dependabot::Clients::Bitbucket::Forbidden,
|
|
@@ -356,13 +347,7 @@ module Dependabot
|
|
|
356
347
|
type = git_sha?(new_tag) ? "commit" : "tag"
|
|
357
348
|
azure_client
|
|
358
349
|
.compare(previous_tag, new_tag, type)
|
|
359
|
-
.map
|
|
360
|
-
{
|
|
361
|
-
message: commit_response_parser.object_string(commit, "comment", "commit"),
|
|
362
|
-
sha: commit_response_parser.object_string(commit, "commitId", "commit"),
|
|
363
|
-
html_url: commit_response_parser.object_string(commit, "remoteUrl", "commit")
|
|
364
|
-
}
|
|
365
|
-
end
|
|
350
|
+
.map(&:to_h)
|
|
366
351
|
rescue Dependabot::Clients::Azure::NotFound,
|
|
367
352
|
Dependabot::Clients::Azure::Unauthorized,
|
|
368
353
|
Dependabot::Clients::Azure::Forbidden,
|
|
@@ -44,6 +44,12 @@ module Dependabot
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
sig { params(type: String).returns(T.nilable(T::Array[String])) }
|
|
48
|
+
def dependency_names(type)
|
|
49
|
+
value = @data[type]
|
|
50
|
+
object_hash(value, type).keys if value
|
|
51
|
+
end
|
|
52
|
+
|
|
47
53
|
sig { returns(T.nilable(String)) }
|
|
48
54
|
def name
|
|
49
55
|
value = @data["name"]
|
data/lib/dependabot.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.
|
|
4
|
+
version: 0.406.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -518,6 +518,7 @@ files:
|
|
|
518
518
|
- lib/dependabot/clients/bitbucket.rb
|
|
519
519
|
- lib/dependabot/clients/bitbucket_with_retries.rb
|
|
520
520
|
- lib/dependabot/clients/codecommit.rb
|
|
521
|
+
- lib/dependabot/clients/comparison_commit.rb
|
|
521
522
|
- lib/dependabot/clients/github_release.rb
|
|
522
523
|
- lib/dependabot/clients/github_resource_parser.rb
|
|
523
524
|
- lib/dependabot/clients/github_with_retries.rb
|
|
@@ -551,6 +552,8 @@ files:
|
|
|
551
552
|
- lib/dependabot/file_parsers/README.md
|
|
552
553
|
- lib/dependabot/file_parsers/base.rb
|
|
553
554
|
- lib/dependabot/file_parsers/base/dependency_set.rb
|
|
555
|
+
- lib/dependabot/file_parsers/hcl2_json_document.rb
|
|
556
|
+
- lib/dependabot/file_parsers/hcl_module_source.rb
|
|
554
557
|
- lib/dependabot/file_updaters.rb
|
|
555
558
|
- lib/dependabot/file_updaters/README.md
|
|
556
559
|
- lib/dependabot/file_updaters/artifact_updater.rb
|
|
@@ -636,7 +639,7 @@ licenses:
|
|
|
636
639
|
- MIT
|
|
637
640
|
metadata:
|
|
638
641
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
639
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
642
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.406.0
|
|
640
643
|
rdoc_options: []
|
|
641
644
|
require_paths:
|
|
642
645
|
- lib
|