dependabot-common 0.404.0 → 0.405.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/error_report_context.rb +235 -0
- data/lib/dependabot/errors.rb +1 -0
- data/lib/dependabot/file_updaters/base.rb +16 -0
- data/lib/dependabot/git_metadata_fetcher.rb +3 -2
- data/lib/dependabot/git_tag_details.rb +23 -59
- data/lib/dependabot/package/npm_package_manager_config.rb +6 -0
- data/lib/dependabot/registry_client.rb +13 -4
- data/lib/dependabot/shared_helpers.rb +1 -2
- data/lib/dependabot.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c43177894ceb2d10d4ad30da31e7a1ea5afd87624374c6dbbf6956395a34c4ea
|
|
4
|
+
data.tar.gz: b7e2d13ea0f3585ffa84a3923339bd6ce3b3d03dbdfe6b823546de98b2d19dc9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1b8b65f35473cc30ba1947ece039e2fb86874b7e4569987def24fb7cd5802a5c4d4a6ee3b33ce8d91267c9149430559591c2e03ac7bc4e17e8d7a0de70c00f25
|
|
7
|
+
data.tar.gz: 8ac723eca6a194072b8f4f16b8c68ab653c0dc185df320bb8de60e2ee91994071a3d8e6fe4ad95c76f3be1006fd56e1ccae1522e91d891aab8166cc673f81fe7
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "excon"
|
|
5
|
+
require "sorbet-runtime"
|
|
6
|
+
require "uri"
|
|
7
|
+
|
|
8
|
+
require "dependabot/dependency"
|
|
9
|
+
require "dependabot/errors"
|
|
10
|
+
require "dependabot/shared_helpers"
|
|
11
|
+
|
|
12
|
+
module Dependabot
|
|
13
|
+
# Builds the allowlisted `error-context` hash sent alongside unknown errors so
|
|
14
|
+
# they can be debugged from Sentry without reproducing the job.
|
|
15
|
+
#
|
|
16
|
+
# The context is diagnostic only and must never affect error grouping. It is
|
|
17
|
+
# assembled exclusively from allowlisted keys: raw helper arguments, commands,
|
|
18
|
+
# stderr output and credentials are never forwarded.
|
|
19
|
+
module ErrorReportContext
|
|
20
|
+
extend T::Sig
|
|
21
|
+
|
|
22
|
+
Value = T.type_alias { T.any(String, Integer, Float, T::Boolean, T::Array[String]) }
|
|
23
|
+
Context = T.type_alias { T::Hash[String, Value] }
|
|
24
|
+
|
|
25
|
+
MAX_STRING_LENGTH = 500
|
|
26
|
+
MAX_ARRAY_LENGTH = 50
|
|
27
|
+
MAX_CAUSE_DEPTH = 5
|
|
28
|
+
REDACTED = "<redacted>"
|
|
29
|
+
|
|
30
|
+
# Maps the keys of a HasSentryContext error's `extra` hash that are safe to
|
|
31
|
+
# forward to their `error-context` key. Anything not listed (e.g. a helper's
|
|
32
|
+
# `args`, `command` or `stderr_output`) is dropped.
|
|
33
|
+
SENTRY_EXTRA_KEYS = T.let(
|
|
34
|
+
{
|
|
35
|
+
function: "helper-function",
|
|
36
|
+
process_exit_value: "helper-exit-status",
|
|
37
|
+
process_termsig: "helper-termsig",
|
|
38
|
+
time_taken: "helper-time-taken",
|
|
39
|
+
package_manager: "package-manager-name",
|
|
40
|
+
updated_files: "updated-files",
|
|
41
|
+
dependency_files: "dependency-files"
|
|
42
|
+
}.freeze,
|
|
43
|
+
T::Hash[Symbol, String]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
ATTACHED_CONTEXT_IVAR = :@__dependabot_error_report_context
|
|
47
|
+
|
|
48
|
+
# Attaches context to any exception (including third-party ones such as Excon errors)
|
|
49
|
+
# so it can be reported if the exception is not handled. Keys are converted to
|
|
50
|
+
# kebab-case strings and values are normalised; unsupported values are dropped.
|
|
51
|
+
sig { params(error: Exception, context: T::Hash[T.any(String, Symbol), T.anything]).void }
|
|
52
|
+
def self.attach(error, context)
|
|
53
|
+
return if error.frozen?
|
|
54
|
+
|
|
55
|
+
merged = attached_context(error).merge(normalize(context))
|
|
56
|
+
error.instance_variable_set(ATTACHED_CONTEXT_IVAR, merged)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Returns the context for an error and its causes, or nil when there is
|
|
60
|
+
# nothing to report. Context closer to the reported error takes precedence.
|
|
61
|
+
sig do
|
|
62
|
+
params(
|
|
63
|
+
error: Exception,
|
|
64
|
+
dependency: T.nilable(Dependabot::Dependency)
|
|
65
|
+
).returns(T.nilable(Context))
|
|
66
|
+
end
|
|
67
|
+
def self.build(error:, dependency: nil)
|
|
68
|
+
context = T.let({}, Context)
|
|
69
|
+
context.merge!(dependency_context(dependency)) if dependency
|
|
70
|
+
|
|
71
|
+
error_chain(error).reverse_each { |err| context.merge!(context_for_error(err)) }
|
|
72
|
+
context["cause-class"] = T.must(error.cause).class.name.to_s if error.cause
|
|
73
|
+
|
|
74
|
+
context.empty? ? nil : context
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Returns only the host of a URL: paths can contain private package or
|
|
78
|
+
# organisation names, and some registries embed tokens in them.
|
|
79
|
+
sig { params(url: String).returns(String) }
|
|
80
|
+
def self.host_for(url)
|
|
81
|
+
host = URI.parse(url).host
|
|
82
|
+
host.nil? || host.empty? ? REDACTED : truncate(host)
|
|
83
|
+
rescue URI::Error
|
|
84
|
+
REDACTED
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
sig { params(error: Exception).returns(Context) }
|
|
88
|
+
private_class_method def self.context_for_error(error)
|
|
89
|
+
context = T.let({}, Context)
|
|
90
|
+
context.merge!(excon_context(error))
|
|
91
|
+
context.merge!(sentry_extra_context(error))
|
|
92
|
+
if error.is_a?(Dependabot::SharedHelpers::HelperSubprocessFailed)
|
|
93
|
+
context["helper-error-class"] = truncate(error.error_class)
|
|
94
|
+
end
|
|
95
|
+
context.merge!(attached_context(error))
|
|
96
|
+
context
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
sig { params(error: Exception).returns(T::Array[Exception]) }
|
|
100
|
+
private_class_method def self.error_chain(error)
|
|
101
|
+
chain = T.let([error], T::Array[Exception])
|
|
102
|
+
while chain.length <= MAX_CAUSE_DEPTH
|
|
103
|
+
cause = T.must(chain.last).cause
|
|
104
|
+
break if cause.nil? || chain.include?(cause)
|
|
105
|
+
|
|
106
|
+
chain << cause
|
|
107
|
+
end
|
|
108
|
+
chain
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
sig { params(error: Exception).returns(Context) }
|
|
112
|
+
private_class_method def self.attached_context(error)
|
|
113
|
+
value = T.cast(error.instance_variable_get(ATTACHED_CONTEXT_IVAR), T.nilable(Context))
|
|
114
|
+
value || {}
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
sig { params(error: Exception).returns(Context) }
|
|
118
|
+
private_class_method def self.sentry_extra_context(error)
|
|
119
|
+
return {} unless error.is_a?(Dependabot::HasSentryContext)
|
|
120
|
+
|
|
121
|
+
extra = T.cast(error.sentry_context[:extra], Object)
|
|
122
|
+
return {} unless extra.is_a?(Hash)
|
|
123
|
+
|
|
124
|
+
context = T.let({}, Context)
|
|
125
|
+
SENTRY_EXTRA_KEYS.each do |source_key, target_key|
|
|
126
|
+
value = normalize_value(extra[source_key])
|
|
127
|
+
value = strip_pid(value) if source_key == :process_exit_value
|
|
128
|
+
context[target_key] = value unless value.nil?
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
names = dependency_names(extra[:dependencies])
|
|
132
|
+
context["dependency-names"] = names if names
|
|
133
|
+
context
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
sig { params(error: Exception).returns(Context) }
|
|
137
|
+
private_class_method def self.excon_context(error)
|
|
138
|
+
case error
|
|
139
|
+
when Excon::Error::Socket
|
|
140
|
+
{ "socket-error-class" => error.socket_error.class.name.to_s }
|
|
141
|
+
when Excon::Error::HTTPStatus
|
|
142
|
+
http_status_context(error)
|
|
143
|
+
else
|
|
144
|
+
{}
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
sig { params(error: Excon::Error::HTTPStatus).returns(Context) }
|
|
149
|
+
private_class_method def self.http_status_context(error)
|
|
150
|
+
context = T.let({}, Context)
|
|
151
|
+
request = T.cast(error.request, Object)
|
|
152
|
+
response = T.cast(error.response, Object)
|
|
153
|
+
|
|
154
|
+
if request.is_a?(Hash)
|
|
155
|
+
method = request[:method]
|
|
156
|
+
context["http-method"] = method.to_s.upcase if method
|
|
157
|
+
host = request[:host]
|
|
158
|
+
context["host"] = truncate(host) if host.is_a?(String)
|
|
159
|
+
end
|
|
160
|
+
status = response_status(response)
|
|
161
|
+
context["http-status"] = status if status
|
|
162
|
+
context
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Excon's own middleware wraps responses in Excon::Response, but status
|
|
166
|
+
# errors can also be built directly from a raw response hash.
|
|
167
|
+
sig { params(response: Object).returns(T.nilable(Integer)) }
|
|
168
|
+
private_class_method def self.response_status(response)
|
|
169
|
+
status = case response
|
|
170
|
+
when Excon::Response then response.status
|
|
171
|
+
when Hash then response[:status]
|
|
172
|
+
end
|
|
173
|
+
status.is_a?(Integer) ? status : nil
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
sig { params(dependency: Dependabot::Dependency).returns(Context) }
|
|
177
|
+
private_class_method def self.dependency_context(dependency)
|
|
178
|
+
normalize(
|
|
179
|
+
{
|
|
180
|
+
"dependency-name" => dependency.name,
|
|
181
|
+
"dependency-version" => dependency.version,
|
|
182
|
+
"dependency-previous-version" => dependency.previous_version,
|
|
183
|
+
"dependency-requirement-files" => dependency.requirements.filter_map { |req| req[:file] }.map(&:to_s).uniq
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
sig { params(dependencies: T.nilable(Object)).returns(T.nilable(T::Array[String])) }
|
|
189
|
+
private_class_method def self.dependency_names(dependencies)
|
|
190
|
+
return unless dependencies.is_a?(Array)
|
|
191
|
+
|
|
192
|
+
names = dependencies.filter_map do |dependency|
|
|
193
|
+
case dependency
|
|
194
|
+
when String then dependency
|
|
195
|
+
when Hash then (dependency["name"] || dependency[:name])&.to_s
|
|
196
|
+
when Dependabot::Dependency then dependency.name
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
names.empty? ? nil : names.uniq.first(MAX_ARRAY_LENGTH).map { |name| truncate(name) }
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# `Process::Status#to_s` includes the (meaningless) pid, e.g. "pid 42 exit 1"
|
|
203
|
+
sig { params(value: T.nilable(Value)).returns(T.nilable(Value)) }
|
|
204
|
+
private_class_method def self.strip_pid(value)
|
|
205
|
+
value.is_a?(String) ? value.sub(/\Apid \d+ /, "") : value
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
sig { params(context: T::Hash[T.any(String, Symbol), T.anything]).returns(Context) }
|
|
209
|
+
private_class_method def self.normalize(context)
|
|
210
|
+
context.each_with_object(T.let({}, Context)) do |(key, value), normalized|
|
|
211
|
+
normalized_value = normalize_value(T.cast(value, T.nilable(Object)))
|
|
212
|
+
normalized[key.to_s.tr("_", "-")] = normalized_value unless normalized_value.nil?
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
sig { params(value: T.nilable(Object)).returns(T.nilable(Value)) }
|
|
217
|
+
private_class_method def self.normalize_value(value)
|
|
218
|
+
case value
|
|
219
|
+
when String then truncate(value)
|
|
220
|
+
when Symbol then truncate(value.to_s)
|
|
221
|
+
when Integer, true, false then value
|
|
222
|
+
# NaN and Infinity can't be serialised to JSON
|
|
223
|
+
when Float then value.finite? ? value : nil
|
|
224
|
+
when Array
|
|
225
|
+
strings = value.select { |item| item.is_a?(String) || item.is_a?(Symbol) }
|
|
226
|
+
strings.empty? ? nil : strings.first(MAX_ARRAY_LENGTH).map { |item| truncate(item.to_s) }
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
sig { params(value: String).returns(String) }
|
|
231
|
+
private_class_method def self.truncate(value)
|
|
232
|
+
value.length > MAX_STRING_LENGTH ? "#{value[0, MAX_STRING_LENGTH]}..." : value
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
data/lib/dependabot/errors.rb
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require "sorbet-runtime"
|
|
5
5
|
|
|
6
6
|
require "dependabot/credential"
|
|
7
|
+
require "dependabot/error_report_context"
|
|
7
8
|
require "dependabot/notices"
|
|
8
9
|
|
|
9
10
|
module Dependabot
|
|
@@ -88,6 +89,21 @@ module Dependabot
|
|
|
88
89
|
updated_file.content = content
|
|
89
90
|
updated_file
|
|
90
91
|
end
|
|
92
|
+
|
|
93
|
+
# Builds the error raised when an update unexpectedly changes no files, with the
|
|
94
|
+
# dependency and file names attached as `error-context` to help debug it.
|
|
95
|
+
sig { params(message: String, context: T::Hash[Symbol, T.anything]).returns(RuntimeError) }
|
|
96
|
+
def no_files_changed_error(message, context = {})
|
|
97
|
+
error = RuntimeError.new(message)
|
|
98
|
+
Dependabot::ErrorReportContext.attach(
|
|
99
|
+
error,
|
|
100
|
+
{
|
|
101
|
+
dependency_names: dependencies.map(&:name),
|
|
102
|
+
dependency_files: dependency_files.map(&:name)
|
|
103
|
+
}.merge(context)
|
|
104
|
+
)
|
|
105
|
+
error
|
|
106
|
+
end
|
|
91
107
|
end
|
|
92
108
|
end
|
|
93
109
|
end
|
|
@@ -354,8 +354,9 @@ module Dependabot
|
|
|
354
354
|
|
|
355
355
|
# Change to the cloned repository directory
|
|
356
356
|
Dir.chdir(dir) do
|
|
357
|
-
# Fetch tags and their creation dates
|
|
358
|
-
|
|
357
|
+
# Fetch tags and their creation dates. Keep the time of day: a cooldown is compared in seconds,
|
|
358
|
+
# and a date without a time reads as midnight, which ends the cooldown up to a day early.
|
|
359
|
+
tags_command = 'git for-each-ref --format="%(refname:short) %(creatordate:iso)" refs/tags'
|
|
359
360
|
tags_stdout, stderr, process = Open3.capture3(env, tags_command)
|
|
360
361
|
|
|
361
362
|
return GitResponse.new(body: stderr, status: 500) unless process.success?
|
|
@@ -4,69 +4,33 @@
|
|
|
4
4
|
require "sorbet-runtime"
|
|
5
5
|
|
|
6
6
|
module Dependabot
|
|
7
|
-
# A
|
|
8
|
-
|
|
9
|
-
#
|
|
10
|
-
# {
|
|
11
|
-
# tag: "v1.2.0",
|
|
12
|
-
# version: Dependabot::Version.new("1.2.0"),
|
|
13
|
-
# commit_sha: "a1b2c3...",
|
|
14
|
-
# tag_sha: "d4e5f6..." # nil for lightweight tags
|
|
15
|
-
# }
|
|
16
|
-
#
|
|
17
|
-
# Distinct from Dependabot::GitTagWithDetail, which carries a tag name and
|
|
18
|
-
# release date for cooldown handling.
|
|
19
|
-
#
|
|
20
|
-
# Subclasses Hash so it is a drop-in replacement at the many call sites that
|
|
21
|
-
# read entries with [:key] / fetch, while exposing typed readers for the well-known
|
|
22
|
-
# keys. Instances compare equal (Hash#==) to plain hashes with the same
|
|
23
|
-
# content, so existing comparisons and API payloads are unaffected.
|
|
24
|
-
class GitTagDetails < Hash
|
|
7
|
+
# A tag or ref resolved by GitCommitChecker.
|
|
8
|
+
class GitTagDetails < T::ImmutableStruct
|
|
25
9
|
extend T::Sig
|
|
26
|
-
extend T::Generic
|
|
27
10
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
super()
|
|
42
|
-
self[:tag] = tag
|
|
43
|
-
self[:version] = version
|
|
44
|
-
self[:commit_sha] = commit_sha
|
|
45
|
-
self[:tag_sha] = tag_sha
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# The tag or ref name, e.g. "v1.2.0".
|
|
49
|
-
sig { returns(String) }
|
|
50
|
-
def tag
|
|
51
|
-
T.cast(self[:tag], String)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# The version parsed from the tag name.
|
|
55
|
-
sig { returns(T.nilable(Gem::Version)) }
|
|
56
|
-
def version
|
|
57
|
-
T.cast(self[:version], T.nilable(Gem::Version))
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# The SHA of the commit the tag points at.
|
|
61
|
-
sig { returns(T.nilable(String)) }
|
|
62
|
-
def commit_sha
|
|
63
|
-
T.cast(self[:commit_sha], T.nilable(String))
|
|
11
|
+
const :tag, String
|
|
12
|
+
const :version, T.nilable(Gem::Version), default: nil
|
|
13
|
+
const :commit_sha, T.nilable(String), default: nil
|
|
14
|
+
const :tag_sha, T.nilable(String), default: nil
|
|
15
|
+
|
|
16
|
+
sig { params(other: BasicObject).returns(T::Boolean) }
|
|
17
|
+
def ==(other)
|
|
18
|
+
case other
|
|
19
|
+
when GitTagDetails
|
|
20
|
+
to_h == other.to_h
|
|
21
|
+
else
|
|
22
|
+
false
|
|
23
|
+
end
|
|
64
24
|
end
|
|
65
25
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
26
|
+
sig { returns(T::Hash[Symbol, Object]) }
|
|
27
|
+
def to_h
|
|
28
|
+
{
|
|
29
|
+
tag: tag,
|
|
30
|
+
version: version,
|
|
31
|
+
commit_sha: commit_sha,
|
|
32
|
+
tag_sha: tag_sha
|
|
33
|
+
}
|
|
70
34
|
end
|
|
71
35
|
end
|
|
72
36
|
end
|
|
@@ -10,6 +10,11 @@ module Dependabot
|
|
|
10
10
|
|
|
11
11
|
ObjectHash = T.type_alias { T::Hash[String, Object] }
|
|
12
12
|
|
|
13
|
+
# Engines Dependabot reads (package managers and the Node.js language requirement). Other
|
|
14
|
+
# keys are free-form: npm accepts any value under engines, and tools like Apache Cordova
|
|
15
|
+
# store objects there (engines.cordovaDependencies).
|
|
16
|
+
KNOWN_ENGINES = %w(node npm yarn pnpm bun).freeze
|
|
17
|
+
|
|
13
18
|
const :package_manager, T.nilable(String), default: nil
|
|
14
19
|
const :engines, T.nilable(T::Hash[String, String]), default: nil
|
|
15
20
|
|
|
@@ -35,6 +40,7 @@ module Dependabot
|
|
|
35
40
|
engines = T.let({}, T::Hash[String, String])
|
|
36
41
|
object_hash(raw_engines, "engines").each do |name, raw_requirement|
|
|
37
42
|
next if raw_requirement.nil?
|
|
43
|
+
next if !raw_requirement.is_a?(String) && !KNOWN_ENGINES.include?(name)
|
|
38
44
|
|
|
39
45
|
raise TypeError, "engines.#{name} must be a string" unless raw_requirement.is_a?(String)
|
|
40
46
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "sorbet-runtime"
|
|
5
|
+
require "dependabot/error_report_context"
|
|
5
6
|
require "dependabot/shared_helpers"
|
|
6
7
|
|
|
7
8
|
# This class provides a thin wrapper around our normal usage of Excon as a simple HTTP client in order to
|
|
@@ -36,8 +37,7 @@ module Dependabot
|
|
|
36
37
|
retry_interval: 5
|
|
37
38
|
)
|
|
38
39
|
rescue Excon::Error::Timeout, Excon::Error::Socket => e
|
|
39
|
-
|
|
40
|
-
raise e
|
|
40
|
+
handle_request_error(e, http_method: "GET", url: url)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
sig do
|
|
@@ -57,8 +57,7 @@ module Dependabot
|
|
|
57
57
|
**SharedHelpers.excon_defaults({ headers: headers }.merge(options))
|
|
58
58
|
)
|
|
59
59
|
rescue Excon::Error::Timeout, Excon::Error::Socket => e
|
|
60
|
-
|
|
61
|
-
raise e
|
|
60
|
+
handle_request_error(e, http_method: "HEAD", url: url)
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
sig { void }
|
|
@@ -66,6 +65,16 @@ module Dependabot
|
|
|
66
65
|
@cached_errors = {}
|
|
67
66
|
end
|
|
68
67
|
|
|
68
|
+
sig { params(error: CachedErrorType, http_method: String, url: String).returns(T.noreturn) }
|
|
69
|
+
private_class_method def self.handle_request_error(error, http_method:, url:)
|
|
70
|
+
# Replayed cached errors keep the context of the request that originally failed
|
|
71
|
+
raise error if cached_error_for(url).equal?(error)
|
|
72
|
+
|
|
73
|
+
cache_error(url, error) if cacheable_error?(error)
|
|
74
|
+
ErrorReportContext.attach(error, { http_method: http_method, host: ErrorReportContext.host_for(url) })
|
|
75
|
+
raise error
|
|
76
|
+
end
|
|
77
|
+
|
|
69
78
|
sig { params(url: String, error: CachedErrorType).void }
|
|
70
79
|
private_class_method def self.cache_error(url, error)
|
|
71
80
|
host = URI(url).host
|
|
@@ -624,8 +624,7 @@ module Dependabot
|
|
|
624
624
|
return nil if env.nil?
|
|
625
625
|
|
|
626
626
|
env.transform_keys(&:to_s).each_with_object({}) do |(key, value), result|
|
|
627
|
-
|
|
628
|
-
result[key] = if key.match?(/TOKEN/i)
|
|
627
|
+
result[key] = if key.match?(/TOKEN|(?:^|_)KEY\z/i)
|
|
629
628
|
"<redacted>"
|
|
630
629
|
else
|
|
631
630
|
value
|
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.405.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -540,6 +540,7 @@ files:
|
|
|
540
540
|
- lib/dependabot/dependency_requirement.rb
|
|
541
541
|
- lib/dependabot/ecosystem.rb
|
|
542
542
|
- lib/dependabot/error_details.rb
|
|
543
|
+
- lib/dependabot/error_report_context.rb
|
|
543
544
|
- lib/dependabot/errors.rb
|
|
544
545
|
- lib/dependabot/experiments.rb
|
|
545
546
|
- lib/dependabot/file_fetchers.rb
|
|
@@ -635,7 +636,7 @@ licenses:
|
|
|
635
636
|
- MIT
|
|
636
637
|
metadata:
|
|
637
638
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
638
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
639
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.405.0
|
|
639
640
|
rdoc_options: []
|
|
640
641
|
require_paths:
|
|
641
642
|
- lib
|