dependabot-common 0.371.0 → 0.373.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 451bcdd11eb4d7fbf86f58780fe91da878ec68966bb805c6fd14d4c4a03ac2dc
4
- data.tar.gz: b284d0c3ae60ccf1619f61900476016c126b73c8d7593712b3385148e67e87f3
3
+ metadata.gz: 3813dcd4d0293e11d9da8b1425d9c800f4c94552e38bf8765d912b51b7c2643c
4
+ data.tar.gz: bb7a4005a51cbb9ecb432a1cd25c67f664cea48dad9f900de65de30f99d9dbcd
5
5
  SHA512:
6
- metadata.gz: c1363650a998b94c3328eecd5ef82d15055f3e00e958765566fe2ae9c5cadcfce7a33cd8ea2eb04b3e922aa7facbed5992e45a2505cd7cfd8e99e7dffbd0d40b
7
- data.tar.gz: d9ea1856d8bf83312b9801e92019b0983579f497d4f8b66f58e3046b0db1f425d358017df74f7113452635e7629d57955e2475781e46c83366e488034234f47e
6
+ metadata.gz: 3cb91b2676a6722670b020f805de186af35e79f73640771927070b103549a74b40fc3696890a4062b5a0045e9ad3f4ab43ddff89a46357f0113b2bd8861f4935
7
+ data.tar.gz: d70c62d66ea75085d88834d51d01504c412e6cd4676aba9c05e779d031ca916e614acacf021f9d71e593c7f976748096878d8aa00aa1c5a9b885c6da9165d1f4
@@ -23,6 +23,13 @@ module Dependabot
23
23
  T.nilable(T.proc.params(data: String).returns(T::Hash[Symbol, T.untyped]))
24
24
  end
25
25
 
26
+ EnvCmdItem = T.type_alias do
27
+ T.any(
28
+ String,
29
+ T::Hash[T.any(String, Symbol), T.untyped]
30
+ )
31
+ end
32
+
26
33
  class ProcessStatus
27
34
  extend T::Sig
28
35
 
@@ -72,7 +79,7 @@ module Dependabot
72
79
  # rubocop:disable Metrics/CyclomaticComplexity
73
80
  sig do
74
81
  params(
75
- env_cmd: T::Array[T.any(T::Hash[String, String], String)],
82
+ env_cmd: T::Array[EnvCmdItem],
76
83
  stdin_data: T.nilable(String),
77
84
  stderr_to_stdout: T::Boolean,
78
85
  timeout: Integer,
@@ -95,12 +102,15 @@ module Dependabot
95
102
  begin
96
103
  T.unsafe(Open3).popen3(*env_cmd) do |stdin, stdout_io, stderr_io, wait_thr| # rubocop:disable Metrics/BlockLength
97
104
  pid = wait_thr.pid
105
+ command_string = command_string_for_logging(env_cmd)
106
+ log_level = short_git_config_command?(command_string) ? :debug : :info
98
107
  sanitized_env_cmd = if env_cmd.first.is_a?(Hash)
99
108
  [SharedHelpers.send(:sanitize_env_for_logging, env_cmd.first), *env_cmd[1..]]
100
109
  else
101
110
  env_cmd
102
111
  end
103
- Dependabot.logger.info("Started process PID: #{pid} with command: #{sanitized_env_cmd.join(' ')}")
112
+ command_for_log = sanitized_env_cmd.join(" ")
113
+ Dependabot.logger.public_send(log_level, "Started process PID: #{pid} with command: #{command_for_log}")
104
114
 
105
115
  # Write to stdin if input data is provided
106
116
  begin
@@ -179,7 +189,7 @@ module Dependabot
179
189
  end
180
190
 
181
191
  status = ProcessStatus.new(wait_thr.value)
182
- Dependabot.logger.info("Process PID: #{pid} completed with status: #{status}")
192
+ Dependabot.logger.public_send(log_level, "Process PID: #{pid} completed with status: #{status}")
183
193
  end
184
194
  rescue Timeout::Error => e
185
195
  Dependabot.logger.error("Process PID: #{pid} failed due to timeout: #{e.message}")
@@ -195,7 +205,8 @@ module Dependabot
195
205
  end
196
206
 
197
207
  elapsed_time = Time.now - start_time
198
- Dependabot.logger.info("Total execution time: #{elapsed_time.round(2)} seconds")
208
+ log_level = short_git_config_command?(command_string_for_logging(env_cmd)) ? :debug : :info
209
+ Dependabot.logger.public_send(log_level, "Total execution time: #{elapsed_time.round(2)} seconds")
199
210
  [stdout, stderr, status, elapsed_time]
200
211
  end
201
212
  # rubocop:enable Metrics/AbcSize
@@ -249,5 +260,19 @@ module Dependabot
249
260
  command_parts = command.split.map(&:strip).reject(&:empty?)
250
261
  Shellwords.join(command_parts)
251
262
  end
263
+
264
+ sig { params(env_cmd: T::Array[EnvCmdItem]).returns(T.nilable(String)) }
265
+ def self.command_string_for_logging(env_cmd)
266
+ T.cast(env_cmd.find { |item| item.is_a?(String) }, T.nilable(String))
267
+ end
268
+ private_class_method :command_string_for_logging
269
+
270
+ sig { params(command: T.nilable(String)).returns(T::Boolean) }
271
+ def self.short_git_config_command?(command)
272
+ return false if command.nil?
273
+
274
+ command.start_with?("git config --global ")
275
+ end
276
+ private_class_method :short_git_config_command?
252
277
  end
253
278
  end
@@ -87,6 +87,7 @@ module Dependabot
87
87
  "pre-commit" => "pre_commit",
88
88
  "pub" => "pub",
89
89
  "rust-toolchain" => "rust_toolchain",
90
+ "sbt" => "sbt",
90
91
  "swift" => "swift",
91
92
  "terraform" => "terraform",
92
93
  "uv" => "uv",
@@ -100,18 +100,37 @@ module Dependabot
100
100
 
101
101
  sig { params(dependency: Dependabot::Dependency).returns(T::Array[Dependabot::Dependency]) }
102
102
  def safe_fetch_subdependencies(dependency)
103
- return [] if @errored_fetching_subdependencies
103
+ return [] if errored_fetching_subdependencies
104
104
 
105
105
  fetch_subdependencies(dependency).filter_map do |dependency_name|
106
106
  dependencies_by_name[dependency_name]
107
107
  end
108
108
  rescue StandardError => e
109
- @errored_fetching_subdependencies = true
109
+ errored_fetching_subdependencies!
110
110
  @subdependency_error = T.let(e, T.nilable(StandardError))
111
111
  Dependabot.logger.error("Error fetching subdependencies: #{e.message}")
112
112
  []
113
113
  end
114
114
 
115
+ # TODO(brrygrdn): Replace this with a `degraded` flag and a `reason` string/enum
116
+ #
117
+ # Nearly all failure modes we have so far amount to 'we couldn't get the full tree for some reason' which is
118
+ # semantically the same as failing to fetch subdependencies, but it is elides some specific information we
119
+ # could use to improve user-facing errors in future, e.g.
120
+ # - Auth failure doing a necessary operation; fix your auth please
121
+ # - Auth failure generating an ephemeral lockfile; fix your auth -or- check in your lockfile
122
+ #
123
+ # The reason this isn't precise enough is that in some ecosystems, the degradation from an ephemeral lockfile
124
+ # goes further and we cannot actually tell versions of top-level dependencies either.
125
+ #
126
+ # To reflect this properly as we expand our ecosystems, setting a generic degraded flag along with user
127
+ # guidance from the ecosystem-specific implementation will allow us to be clearer on remediation in UIs
128
+ # in addition to the job logs.
129
+ sig { void }
130
+ def errored_fetching_subdependencies!
131
+ @errored_fetching_subdependencies = true
132
+ end
133
+
115
134
  # Each grapher is expected to implement a method to look up the parents of a given dependency.
116
135
  #
117
136
  # The strategy that should be used is highly dependent on the ecosystem, in some cases the parser
@@ -196,7 +196,8 @@ module Dependabot
196
196
 
197
197
  sig { returns(T.nilable(String)) }
198
198
  def commit
199
- return T.must(cloned_commit) if cloned_commit
199
+ resolved_cloned_commit = cloned_commit
200
+ return resolved_cloned_commit if resolved_cloned_commit
200
201
  return T.must(source.commit) if source.commit
201
202
 
202
203
  branch = target_branch || default_branch_for_repo
@@ -214,6 +214,7 @@ module Dependabot
214
214
  sig { returns(String) }
215
215
  def solo_pr_name
216
216
  name = library? ? library_pr_name : application_pr_name
217
+ name += " (via audit fix)" if dependencies.any? { |dep| dep.metadata[:audit_fix_used] }
217
218
  "#{name}#{pr_name_directory}"
218
219
  end
219
220
 
@@ -200,10 +200,12 @@ module Dependabot
200
200
  return unless (msg = last_dependabot_commit_title)
201
201
 
202
202
  return :gitmoji if msg.start_with?("⬆️")
203
- return :conventional_prefix if msg.match?(/\A(chore|build|upgrade):/i)
204
- return unless msg.match?(/\A(chore|build|upgrade)\(/i)
205
203
 
206
- :conventional_prefix_with_scope
204
+ prefixes = (ANGULAR_PREFIXES + ESLINT_PREFIXES).uniq(&:downcase).join("|")
205
+ return :conventional_prefix if msg.match?(/\A(#{prefixes}):/i)
206
+ return :conventional_prefix_with_scope if msg.match?(/\A(#{prefixes})\(/i)
207
+
208
+ nil
207
209
  end
208
210
 
209
211
  sig { returns(T.nilable(String)) }
@@ -46,7 +46,8 @@ module Dependabot
46
46
  credentials: T::Array[Dependabot::Credential],
47
47
  pull_request_number: Integer,
48
48
  author_details: T.nilable(T::Hash[Symbol, T.untyped]),
49
- signature_key: T.nilable(String)
49
+ signature_key: T.nilable(String),
50
+ commit_message: T.nilable(String)
50
51
  )
51
52
  .void
52
53
  end
@@ -58,7 +59,8 @@ module Dependabot
58
59
  credentials:,
59
60
  pull_request_number:,
60
61
  author_details: nil,
61
- signature_key: nil
62
+ signature_key: nil,
63
+ commit_message: nil
62
64
  )
63
65
  @source = source
64
66
  @base_commit = base_commit
@@ -68,6 +70,7 @@ module Dependabot
68
70
  @pull_request_number = pull_request_number
69
71
  @author_details = author_details
70
72
  @signature_key = signature_key
73
+ @commit_message = T.let(commit_message, T.nilable(String))
71
74
  end
72
75
 
73
76
  sig { returns(T.nilable(Sawyer::Resource)) }
@@ -255,6 +258,9 @@ module Dependabot
255
258
 
256
259
  sig { returns(String) }
257
260
  def commit_message
261
+ msg = @commit_message
262
+ return msg unless msg.nil? || msg.empty?
263
+
258
264
  fallback_message =
259
265
  "#{pull_request.title}" \
260
266
  "\n\n" \
@@ -37,6 +37,9 @@ module Dependabot
37
37
  sig { returns(T.nilable(String)) }
38
38
  attr_reader :signature_key
39
39
 
40
+ sig { returns(T.nilable(String)) }
41
+ attr_reader :commit_message
42
+
40
43
  sig { returns(T::Hash[Symbol, T.untyped]) }
41
44
  attr_reader :provider_metadata
42
45
 
@@ -50,6 +53,7 @@ module Dependabot
50
53
  pull_request_number: Integer,
51
54
  author_details: T.nilable(T::Hash[Symbol, String]),
52
55
  signature_key: T.nilable(String),
56
+ commit_message: T.nilable(String),
53
57
  provider_metadata: T::Hash[Symbol, T.untyped]
54
58
  )
55
59
  .void
@@ -63,6 +67,7 @@ module Dependabot
63
67
  pull_request_number:,
64
68
  author_details: nil,
65
69
  signature_key: nil,
70
+ commit_message: nil,
66
71
  provider_metadata: {}
67
72
  )
68
73
  @source = source
@@ -73,6 +78,7 @@ module Dependabot
73
78
  @pull_request_number = pull_request_number
74
79
  @author_details = author_details
75
80
  @signature_key = signature_key
81
+ @commit_message = commit_message
76
82
  @provider_metadata = provider_metadata
77
83
  end
78
84
 
@@ -100,7 +106,8 @@ module Dependabot
100
106
  credentials: credentials,
101
107
  pull_request_number: pull_request_number,
102
108
  author_details: author_details,
103
- signature_key: signature_key
109
+ signature_key: signature_key,
110
+ commit_message: commit_message
104
111
  )
105
112
  end
106
113
 
data/lib/dependabot.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Dependabot
5
- VERSION = "0.371.0"
5
+ VERSION = "0.373.0"
6
6
  end
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.371.0
4
+ version: 0.373.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -617,7 +617,7 @@ licenses:
617
617
  - MIT
618
618
  metadata:
619
619
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
620
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.371.0
620
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.373.0
621
621
  rdoc_options: []
622
622
  require_paths:
623
623
  - lib