dependabot-maven 0.393.0 → 0.394.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: fff231d12e4c6ebdbdbf645bcc82c18a7b895ecc870ddb6aba549e4296f0ead6
4
- data.tar.gz: a0c24d6534e7bd9c48e7256bd6f03176713f75173f523ac75a8f389b022cc7ff
3
+ metadata.gz: '009515ba93dc3e414380b797fe7b3aa17a388d024e5406e74291c901600f1a0c'
4
+ data.tar.gz: b511053c1259a770b1f7a2d649cf357bec4abcab55ad3aacb34b96ec40482893
5
5
  SHA512:
6
- metadata.gz: 96a5bc8b3c845098794cec76a15763afde0d7b1d31caec84daf558d031a560fbd954d068b115dc9c0ba3a43806619d1d104f68b2d07ecd98c161c1d6bf3e99d1
7
- data.tar.gz: fa5d05a001407b8dcfc41c530caacb1b547c60a42831ca9bfdb6aa6ec6983c1d63178c5d4429a8450aaedbac1f51ad48c747d3f4c4e498054b2564842fe55f93
6
+ metadata.gz: 36c134e6d66d0d445df02dca60b7ae8afe60dd585e7475e8c4668656b22bc6ca3b8917251110772709075112142cc7ffd109564573f5231fcb130adba9aaa2cf
7
+ data.tar.gz: dd730e81dec85d5abb73e201c832087ac4e0f75a5a09284046b87d203a208415f0588e3f9b04c58a588ecf1a55e7c70673551b20a43fd59a3b27bf1a48ea5d7f
@@ -6,6 +6,7 @@ require "open3"
6
6
  require "uri"
7
7
  require "sorbet-runtime"
8
8
  require "nokogiri"
9
+ require "dependabot/errors"
9
10
  require "dependabot/shared_helpers"
10
11
 
11
12
  module Dependabot
@@ -13,6 +14,25 @@ module Dependabot
13
14
  module NativeHelpers
14
15
  extend T::Sig
15
16
 
17
+ # Matches Maven's "Could not transfer artifact" failures, capturing the
18
+ # repository URL and HTTP status so we can classify auth vs. other errors.
19
+ TRANSFER_FAILURE_REGEX =
20
+ %r{Could not transfer artifact (?<artifact>[^ ]+) from/to (?<repository_name>[^ ]+) \((?<repository_url>[^ ]+)\): status code: (?<status_code>[0-9]+)} # rubocop:disable Layout/LineLength
21
+
22
+ # Matches Maven's "Plugin ... could not be resolved" failures, used to
23
+ # detect when the wrapper plugin itself is unavailable behind the proxy.
24
+ WRAPPER_PLUGIN_UNRESOLVED_REGEX =
25
+ /Plugin org\.apache\.maven\.plugins:maven-wrapper-plugin[^ ]* .*could not be resolved/
26
+
27
+ # Upper bound on the length of the Maven error summary included in raised errors,
28
+ # to avoid oversized error payloads while retaining the relevant failure detail.
29
+ MAX_ERROR_SUMMARY_LENGTH = 2_000
30
+
31
+ # Matches ANSI/VT100 control sequences. Maven can be configured to emit colored
32
+ # output (e.g. `-Dstyle.color=always`), wrapping markers like `[ERROR]` in escape
33
+ # codes; we strip these so classification and the surfaced summary see plain text.
34
+ ANSI_ESCAPE_REGEX = %r{\e\[[0-9;?]*[ -/]*[@-~]}
35
+
16
36
  pom_path = File.join(__dir__, "pom.xml")
17
37
 
18
38
  version = File.open(pom_path) do |f|
@@ -43,9 +63,8 @@ module Dependabot
43
63
 
44
64
  sig { params(output: String).void }
45
65
  def self.handle_tool_error(output)
46
- if (match = output.match(
47
- %r{Could not transfer artifact (?<artifact>[^ ]+) from/to (?<repository_name>[^ ]+) \((?<repository_url>[^ ]+)\): status code: (?<status_code>[0-9]+)} # rubocop:disable Layout/LineLength
48
- )) && (match[:status_code] == "403" || match[:status_code] == "401")
66
+ if (match = output.match(TRANSFER_FAILURE_REGEX)) &&
67
+ (match[:status_code] == "403" || match[:status_code] == "401")
49
68
  raise Dependabot::PrivateSourceAuthenticationFailure, match[:repository_url]
50
69
  end
51
70
 
@@ -91,7 +110,63 @@ module Dependabot
91
110
  # to parse. An argument vector is executed without an intermediate shell.
92
111
  cmd = ["mvn"] + standard_args
93
112
  run_cwd = cwd && cwd != "." ? cwd : nil
94
- SharedHelpers.run_shell_command(cmd, env: env, cwd: run_cwd)
113
+
114
+ output = SharedHelpers.run_shell_command(cmd, env: env, cwd: run_cwd)
115
+ Dependabot.logger.info("mvn wrapper output: STDOUT:#{output}")
116
+ output
117
+ rescue SharedHelpers::HelperSubprocessFailed => e
118
+ # `run_shell_command` raises HelperSubprocessFailed on a non-zero exit, and the
119
+ # updater sanitizes that into an opaque `SubprocessFailed` that only reports the
120
+ # command and hides the real Maven output. Log the full output and re-raise a
121
+ # classified Dependabot error so operators get an actionable message, mirroring
122
+ # the `run_mvn_dependency_tree_plugin` path.
123
+ Dependabot.logger.warn("mvn wrapper command failed:\n#{e.message}")
124
+ handle_wrapper_error(e)
125
+ end
126
+
127
+ # Classifies a failed Maven Wrapper invocation into an actionable Dependabot
128
+ # error. Known auth and plugin-resolution failures are mapped to their specific
129
+ # error types, and genuine Maven diagnostics are surfaced via MisconfiguredTooling.
130
+ # `run_shell_command` also reports inactivity timeouts and a missing `mvn`
131
+ # executable as HelperSubprocessFailed; those carry no Maven `[ERROR]` markers, so
132
+ # we re-raise the original error and let it follow normal unknown-error routing
133
+ # instead of mislabelling infrastructure/runtime failures as tooling misconfigurations.
134
+ sig { params(error: SharedHelpers::HelperSubprocessFailed).returns(T.noreturn) }
135
+ def self.handle_wrapper_error(error)
136
+ # Strip ANSI color codes up front so classification and the surfaced summary see
137
+ # plain text even when Maven is configured to emit colored output.
138
+ output = error.message.gsub(ANSI_ESCAPE_REGEX, "")
139
+
140
+ if (match = output.match(TRANSFER_FAILURE_REGEX)) &&
141
+ (match[:status_code] == "403" || match[:status_code] == "401")
142
+ raise Dependabot::PrivateSourceAuthenticationFailure, match[:repository_url]
143
+ end
144
+
145
+ if output.match?(WRAPPER_PLUGIN_UNRESOLVED_REGEX)
146
+ raise Dependabot::DependencyFileNotResolvable, "Could not resolve the Maven Wrapper plugin."
147
+ end
148
+
149
+ # Only reclassify when Maven emitted its own `[ERROR]` diagnostics. Otherwise the
150
+ # failure is not a Maven misconfiguration (e.g. timeout or missing executable), so
151
+ # re-raise the original error; its full output is already in the job log.
152
+ summary = mvn_error_summary(output)
153
+ raise error unless summary
154
+
155
+ raise Dependabot::MisconfiguredTooling.new("Maven Wrapper", summary)
156
+ end
157
+
158
+ # Extracts Maven's own `[ERROR]` lines from the combined tool output so that raised
159
+ # errors surface the relevant failure reason without leaking unrelated build noise or
160
+ # arbitrary subprocess output (which may contain sensitive file contents or paths) into
161
+ # the reported error. Returns nil when Maven produced no `[ERROR]` diagnostics, and caps
162
+ # the length to keep error payloads reasonable.
163
+ sig { params(output: String).returns(T.nilable(String)) }
164
+ def self.mvn_error_summary(output)
165
+ error_lines = output.lines.map(&:chomp).select { |line| line.include?("[ERROR]") }
166
+ return nil if error_lines.empty?
167
+
168
+ summary = error_lines.join("\n")
169
+ summary.length > MAX_ERROR_SUMMARY_LENGTH ? "#{summary[0, MAX_ERROR_SUMMARY_LENGTH]}..." : summary
95
170
  end
96
171
  end
97
172
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-maven
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.393.0
4
+ version: 0.394.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.393.0
18
+ version: 0.394.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.393.0
25
+ version: 0.394.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rexml
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -183,14 +183,14 @@ dependencies:
183
183
  requirements:
184
184
  - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: '0.22'
186
+ version: '1.1'
187
187
  type: :development
188
188
  prerelease: false
189
189
  version_requirements: !ruby/object:Gem::Requirement
190
190
  requirements:
191
191
  - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: '0.22'
193
+ version: '1.1'
194
194
  - !ruby/object:Gem::Dependency
195
195
  name: turbo_tests
196
196
  requirement: !ruby/object:Gem::Requirement
@@ -296,7 +296,7 @@ licenses:
296
296
  - MIT
297
297
  metadata:
298
298
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
299
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.393.0
299
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.394.0
300
300
  rdoc_options: []
301
301
  require_paths:
302
302
  - lib