dependabot-go_modules 0.380.0 → 0.381.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: bd0aa86d8519059a4ced604e4d32202c00c4b73fa451006c3918ff247069d234
4
- data.tar.gz: 7a36751b391d9d8d2a184098d8dd0a2ba521e1de92292b4ee059d9dd0f2c0e0b
3
+ metadata.gz: d755e1ec7cfcbaeba0c4078e462dda1c0dad5a8656671c6951f2bf015af2f181
4
+ data.tar.gz: 604712cc627e5b5fa2510328fd4afc7d4e7833fb606ca98514a3dd81c5e8caa1
5
5
  SHA512:
6
- metadata.gz: 1d46e5b1aabe273dc2d4cbb910259b7c2e64fe67fe55d12b1c6fa0ce557e907f9dedc7609fefeebc76664d63180968c7ae120c2138e93176e9b93600220e4321
7
- data.tar.gz: 54d75e5a9b298b855f2761e87e101ceab4686d8dfe7833493e662b7f977c93538303690d01c65f933b69b10724efa76aa41debf590af2d06fbeec3398dc995b8
6
+ metadata.gz: 84fa95d8b8db24e5ff30cc16b7a7231e26c88ab89b44f6832e75b3575b2fa40b0c4b95200713ebe35315293b64ea86219598c8cdc1776ef357da11e5c9979f22
7
+ data.tar.gz: 1fa01e546e7fb67c4c88356d996046e6cd6c54eced985e3b7485e5295e16dc958fcfc3f6f227d5a720f8766f5da89e77e717f4b0c8362a78df2868ab8a5517cb
@@ -107,6 +107,8 @@ module Dependabot
107
107
  set_goenv_variable
108
108
  set_goproxy_variable
109
109
  set_goprivate_variable
110
+ set_gonoproxy_variable
111
+ set_gonosumdb_variable
110
112
  end
111
113
 
112
114
  sig { void }
@@ -148,6 +150,39 @@ module Dependabot
148
150
  ENV["GOPRIVATE"] = goprivate if goprivate
149
151
  end
150
152
 
153
+ # GONOPROXY explicitly controls which module paths skip the proxy.
154
+ # Setting this overrides GOPRIVATE's default for proxy decisions, letting
155
+ # us keep GOPRIVATE=* (to skip sumdb for unknown enterprise orgs) while
156
+ # still routing public modules through proxy.golang.org. The literal
157
+ # value "none" matches no module paths — see Go's mod_gonoproxy.txt test.
158
+ sig { void }
159
+ def set_gonoproxy_variable
160
+ return if go_env_includes_any?(%w(GONOPROXY GOPRIVATE GOPROXY))
161
+ return if goproxy_credentials.any?
162
+
163
+ gonoproxy = options.fetch(:gonoproxy, nil)
164
+ ENV["GONOPROXY"] = gonoproxy if gonoproxy
165
+ end
166
+
167
+ # GONOSUMDB explicitly controls which module paths skip checksum DB
168
+ # verification. Setting this overrides GOPRIVATE's default for sumdb,
169
+ # letting us narrow the scope independently of proxy routing.
170
+ sig { void }
171
+ def set_gonosumdb_variable
172
+ return if go_env_includes_any?(%w(GONOSUMDB GOPRIVATE))
173
+
174
+ gonosumdb = options.fetch(:gonosumdb, nil)
175
+ ENV["GONOSUMDB"] = gonosumdb if gonosumdb
176
+ end
177
+
178
+ sig { params(keys: T::Array[String]).returns(T::Boolean) }
179
+ def go_env_includes_any?(keys)
180
+ content = go_env&.content
181
+ return false unless content
182
+
183
+ keys.any? { |key| content.include?(key) }
184
+ end
185
+
151
186
  sig { void }
152
187
  def set_goproxy_variable
153
188
  return if go_env&.content&.include?("GOPROXY")
@@ -271,13 +271,7 @@ module Dependabot
271
271
 
272
272
  workspace_module_paths.each do |mod_path|
273
273
  Dir.chdir(mod_path) do
274
- command = "go mod tidy -e"
275
- _, stderr, status = Open3.capture3(command)
276
- if status.success?
277
- Dependabot.logger.info "`go mod tidy` succeeded in #{mod_path}"
278
- else
279
- Dependabot.logger.info "Failed to `go mod tidy` in #{mod_path}: #{stderr}"
280
- end
274
+ run_go_mod_tidy(context: mod_path)
281
275
  end
282
276
  end
283
277
  end
@@ -332,21 +326,28 @@ module Dependabot
332
326
  results
333
327
  end
334
328
 
335
- sig { void }
336
- def run_go_mod_tidy
329
+ sig { params(context: T.nilable(String)).void }
330
+ def run_go_mod_tidy(context: nil)
337
331
  return unless tidy?
338
332
 
339
- command = "go mod tidy -e"
333
+ label = context ? " in #{context}" : ""
340
334
 
341
- # we explicitly don't raise an error for 'go mod tidy' and silently
342
- # continue with an info log here. `go mod tidy` shouldn't block
343
- # updating versions because there are some edge cases where it's OK to fail
344
- # (such as generated files not available yet to us).
335
+ # Run a strict `go mod tidy` (without the `-e` flag). `-e` tells tidy
336
+ # to continue despite errors loading packages, which silently
337
+ # tolerates unreachable/private modules and can over-prune `/go.mod`
338
+ # checksum entries from go.sum for unrelated modules. We surface the
339
+ # real error instead so the underlying dependency problem is visible
340
+ # and can be fixed by giving Dependabot the same access to
341
+ # dependencies as the rest of the team.
342
+ command = "go mod tidy"
345
343
  _, stderr, status = Open3.capture3(command)
346
344
  if status.success?
347
- Dependabot.logger.info "`go mod tidy` succeeded"
345
+ Dependabot.logger.info "`#{command}` succeeded#{label}"
348
346
  else
349
- Dependabot.logger.info "Failed to `go mod tidy`: #{stderr}"
347
+ # Log the failing module before raising, as handle_subprocess_error
348
+ # scrubs the working directory from the message.
349
+ Dependabot.logger.info "Failed to `#{command}`#{label}: #{stderr}"
350
+ handle_subprocess_error(stderr)
350
351
  end
351
352
  end
352
353
 
@@ -253,6 +253,11 @@ module Dependabot
253
253
  def fetch_lowest_security_fix_version(language_version: nil)
254
254
  relevant_versions = available_versions_details
255
255
  relevant_versions = filter_prerelease_versions(relevant_versions)
256
+ # Add pseudo-versions from advisory boundaries after the prerelease filter.
257
+ # The Go proxy only indexes tagged releases, so commit-based pseudo-version
258
+ # fix boundaries won't appear in the version list. They're not traditional
259
+ # prereleases and must always be considered as candidates.
260
+ relevant_versions += pseudo_versions_from_advisory_boundaries
256
261
  relevant_versions = Dependabot::UpdateCheckers::VersionFilters.filter_vulnerable_versions(
257
262
  relevant_versions,
258
263
  security_advisories
@@ -264,6 +269,37 @@ module Dependabot
264
269
  end
265
270
  # rubocop:enable Lint/UnusedMethodArgument
266
271
 
272
+ # When an advisory's fix boundary is a pseudo-version (e.g. "< 2.3.1-0.20260320110106-0b84568fffcc"),
273
+ # the Go module proxy won't include it in its version list. Extract those pseudo-versions
274
+ # from the advisory requirement strings so they can be considered as fix candidates.
275
+ # Only pseudo-versions strictly greater than the current version are returned to avoid
276
+ # unnecessary processing of versions that would be discarded by filter_lower_versions anyway.
277
+ sig { returns(T::Array[Dependabot::Package::PackageRelease]) }
278
+ def pseudo_versions_from_advisory_boundaries
279
+ current = dependency.numeric_version
280
+
281
+ security_advisories.flat_map do |advisory|
282
+ advisory.vulnerable_version_strings.flat_map do |req_string|
283
+ # Parse each constraint in requirement strings like
284
+ # ">= 1.1.0, < 2.3.1-0.20260320110106-0b84568fffcc" and extract
285
+ # any pseudo-version boundary that represents a possible fix.
286
+ req_string.to_s.split(",").filter_map do |constraint|
287
+ version_str = constraint.gsub(/\A\s*[<>=!~^]+\s*v?/, "").strip
288
+ next unless PSEUDO_VERSION_REGEX.match?(version_str)
289
+ next unless version_class.correct?(version_str)
290
+
291
+ candidate = version_class.new(version_str)
292
+ next if current && candidate <= current
293
+
294
+ Dependabot::Package::PackageRelease.new(
295
+ version: candidate,
296
+ details: { "version_string" => version_str }
297
+ )
298
+ end
299
+ end
300
+ end.uniq(&:version)
301
+ end
302
+
267
303
  sig { returns(T::Boolean) }
268
304
  def wants_prerelease?
269
305
  @wants_prerelease ||= T.let(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-go_modules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.380.0
4
+ version: 0.381.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.380.0
18
+ version: 0.381.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.380.0
25
+ version: 0.381.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -275,7 +275,7 @@ licenses:
275
275
  - MIT
276
276
  metadata:
277
277
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
278
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.380.0
278
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.381.0
279
279
  rdoc_options: []
280
280
  require_paths:
281
281
  - lib