dependabot-go_modules 0.362.0 → 0.363.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5965746c422a57549c538c2b97ce0a49b8d2d48f909a702bc0ae1c3eb8d703be
|
|
4
|
+
data.tar.gz: dac70528a9b16c8fc626876f8d624b0b83415aa55183437a37524a9796be90d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe95cd8a7772a0129b312a38470f8460dad450e019c7cd5364c577aab9b4d13d8850d9f68504b1fe24b5b599735857cbf25f6fc93936d62edc126bcac4b27bab
|
|
7
|
+
data.tar.gz: ef222139597a40135a9e6bf7d29c7717d1a2a868e0f49592364d2ae89a245de87a47206a20ebee567c5cdeb220536b824362d01c8e0ff64c1a4f64fda295b614
|
|
@@ -57,6 +57,8 @@ module Dependabot
|
|
|
57
57
|
/go(?: get)?: .*: unknown revision/m,
|
|
58
58
|
# Package pointing to a proxy that 404s
|
|
59
59
|
/go(?: get)?: .*: unrecognized import path/m,
|
|
60
|
+
# Private repository cannot be fetched over a secure protocol
|
|
61
|
+
Dependabot::GoModules::ResolvabilityErrors::INSECURE_PROTOCOL_REPOSITORY_REGEX,
|
|
60
62
|
# Package not being referenced correctly
|
|
61
63
|
/go:.*imports.*package.+is not in std/m,
|
|
62
64
|
# Invalid version due to missing go.mod files at specified revision
|
|
@@ -94,12 +96,22 @@ module Dependabot
|
|
|
94
96
|
T::Array[Regexp]
|
|
95
97
|
)
|
|
96
98
|
|
|
99
|
+
PATH_DEPENDENCY_ERROR_REGEXES = T.let(
|
|
100
|
+
[
|
|
101
|
+
/replaced by (?<path>[^)\s]+)\): reading .*go\.mod: open .*: no such file or directory/
|
|
102
|
+
].freeze,
|
|
103
|
+
T::Array[Regexp]
|
|
104
|
+
)
|
|
105
|
+
|
|
97
106
|
GO_LANG = "Go"
|
|
98
107
|
|
|
99
108
|
AMBIGUOUS_ERROR_MESSAGE = /ambiguous import: found package (?<package>.*) in multiple modules/
|
|
100
109
|
|
|
101
110
|
GO_VERSION_MISMATCH = /requires go (?<current_ver>.*) .*running go (?<req_ver>.*);/
|
|
102
111
|
|
|
112
|
+
GITHUB_403_REGEX =
|
|
113
|
+
%r{https://github\.com/(?<repo>[^/'\s]+/[^/'\s]+)/?': The requested URL returned error: 403}
|
|
114
|
+
|
|
103
115
|
GO_MOD_VERSION = /^go 1\.\d+(\.\d+)?$/
|
|
104
116
|
|
|
105
117
|
sig do
|
|
@@ -326,11 +338,8 @@ module Dependabot
|
|
|
326
338
|
def handle_subprocess_error(stderr) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
327
339
|
stderr = stderr.gsub(Dir.getwd, "")
|
|
328
340
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
error_message = filter_error_message(message: stderr, regex: go_mod_parse_error_regex)
|
|
332
|
-
raise Dependabot::DependencyFileNotParseable.new(go_mod_path, error_message)
|
|
333
|
-
end
|
|
341
|
+
raise_for_go_mod_parse_error(stderr)
|
|
342
|
+
raise_for_path_dependency_error(stderr)
|
|
334
343
|
|
|
335
344
|
# Package version doesn't match the module major version
|
|
336
345
|
error_regex = RESOLVABILITY_ERROR_REGEXES.find { |r| stderr =~ r }
|
|
@@ -343,8 +352,12 @@ module Dependabot
|
|
|
343
352
|
raise Dependabot::PrivateSourceAuthenticationFailure, matches[:url]
|
|
344
353
|
end
|
|
345
354
|
|
|
355
|
+
if github_credentials_configured? && (matches = stderr.match(GITHUB_403_REGEX))
|
|
356
|
+
raise Dependabot::PrivateSourceAuthenticationFailure, "https://github.com/#{matches[:repo]}"
|
|
357
|
+
end
|
|
358
|
+
|
|
346
359
|
repo_error_regex = REPO_RESOLVABILITY_ERROR_REGEXES.find { |r| stderr =~ r }
|
|
347
|
-
ResolvabilityErrors.handle(stderr) if repo_error_regex
|
|
360
|
+
Dependabot::GoModules::ResolvabilityErrors.handle(stderr) if repo_error_regex
|
|
348
361
|
|
|
349
362
|
path_regex = MODULE_PATH_MISMATCH_REGEXES.find { |r| stderr =~ r }
|
|
350
363
|
if path_regex
|
|
@@ -387,6 +400,44 @@ module Dependabot
|
|
|
387
400
|
message.match(regex).to_s
|
|
388
401
|
end
|
|
389
402
|
|
|
403
|
+
sig { params(message: String).returns(T.nilable(String)) }
|
|
404
|
+
def extract_replacement_path(message)
|
|
405
|
+
PATH_DEPENDENCY_ERROR_REGEXES.each do |regex|
|
|
406
|
+
match = regex.match(message)
|
|
407
|
+
return match[:path] if match
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
nil
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
sig { returns(T::Boolean) }
|
|
414
|
+
def github_credentials_configured?
|
|
415
|
+
credentials.any? do |credential|
|
|
416
|
+
credential["type"] == "git_source" && credential["host"] == "github.com"
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
sig { params(stderr: String).void }
|
|
421
|
+
def raise_for_go_mod_parse_error(stderr)
|
|
422
|
+
go_mod_parse_error_regex = GO_MOD_PARSE_ERROR_REGEXES.find { |r| stderr =~ r }
|
|
423
|
+
return unless go_mod_parse_error_regex
|
|
424
|
+
|
|
425
|
+
error_message = filter_error_message(message: stderr, regex: go_mod_parse_error_regex)
|
|
426
|
+
raise Dependabot::DependencyFileNotParseable.new(go_mod_path, error_message)
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
sig { params(stderr: String).void }
|
|
430
|
+
def raise_for_path_dependency_error(stderr)
|
|
431
|
+
path_error_regex = PATH_DEPENDENCY_ERROR_REGEXES.find { |r| stderr =~ r }
|
|
432
|
+
return unless path_error_regex
|
|
433
|
+
|
|
434
|
+
dependency_path = extract_replacement_path(stderr)
|
|
435
|
+
raise Dependabot::PathDependenciesNotReachable, [dependency_path] if dependency_path
|
|
436
|
+
|
|
437
|
+
error_message = filter_error_message(message: stderr, regex: path_error_regex)
|
|
438
|
+
raise Dependabot::DependencyFileNotResolvable, error_message
|
|
439
|
+
end
|
|
440
|
+
|
|
390
441
|
sig { returns(String) }
|
|
391
442
|
def go_mod_path
|
|
392
443
|
return "go.mod" if directory == "/"
|
|
@@ -110,14 +110,14 @@ module Dependabot
|
|
|
110
110
|
|
|
111
111
|
req_string.split(".")
|
|
112
112
|
.map do |part|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
part.split("-").map.with_index do |p, i|
|
|
114
|
+
# Before we hit a wildcard we just return the existing part
|
|
115
|
+
next p unless p.match?(WILDCARD_REGEX) || after_wildcard
|
|
116
|
+
|
|
117
|
+
# On or after a wildcard we replace the version part with zero
|
|
118
|
+
after_wildcard = true
|
|
119
|
+
i.zero? ? "0" : "a"
|
|
120
|
+
end.join("-")
|
|
121
121
|
end.join(".")
|
|
122
122
|
end
|
|
123
123
|
|
|
@@ -8,27 +8,41 @@ module Dependabot
|
|
|
8
8
|
module ResolvabilityErrors
|
|
9
9
|
extend T::Sig
|
|
10
10
|
|
|
11
|
-
GITHUB_REPO_REGEX = %r{github.com/[^:@ ]*}
|
|
11
|
+
GITHUB_REPO_REGEX = T.let(%r{github.com/[^:@ '\n]*}, Regexp)
|
|
12
|
+
INSECURE_PROTOCOL_REPOSITORY_REGEX = T.let(
|
|
13
|
+
/go(?: get)?: .*: no secure protocol found for repository/m,
|
|
14
|
+
Regexp
|
|
15
|
+
)
|
|
16
|
+
GO_MODULE_WITH_VERSION_REGEX = T.let(/go(?: get)?:\s*(?<module>[^\s@]+)@/, Regexp)
|
|
17
|
+
GO_PREFIXED_HOSTED_REPO_REGEX = T.let(
|
|
18
|
+
%r{(?:^|\n)\s*go(?: get)?:\s*(?<repo>[a-z0-9.-]+\.[a-z]{2,}/[^:@\s]+)(?:[:\s]|$)}i,
|
|
19
|
+
Regexp
|
|
20
|
+
)
|
|
21
|
+
REACHABILITY_CHECK_HINTS = T.let(
|
|
22
|
+
[
|
|
23
|
+
/If this is a private repository/i,
|
|
24
|
+
/Write access to repository not granted/i,
|
|
25
|
+
/Authentication failed/i
|
|
26
|
+
].freeze,
|
|
27
|
+
T::Array[Regexp]
|
|
28
|
+
)
|
|
12
29
|
|
|
13
30
|
sig { params(message: String).void }
|
|
14
31
|
def self.handle(message)
|
|
15
|
-
mod_path = message
|
|
16
|
-
|
|
17
|
-
|
|
32
|
+
mod_path = extract_module_path(message)
|
|
33
|
+
|
|
34
|
+
if mod_path && insecure_protocol_repo_error?(message)
|
|
35
|
+
raise Dependabot::GitDependenciesNotReachable, [repo_path_for(mod_path)]
|
|
18
36
|
end
|
|
19
37
|
|
|
20
|
-
|
|
21
|
-
|
|
38
|
+
raise Dependabot::DependencyFileNotResolvable, message unless mod_path && requires_reachability_check?(message)
|
|
39
|
+
|
|
40
|
+
# Module not found in the module repository (e.g., GitHub, Gerrit) - query for _any_ version
|
|
41
|
+
# to know if it doesn't exist (or is private) or we were just given a bad revision by this manifest
|
|
22
42
|
SharedHelpers.in_a_temporary_directory do
|
|
23
43
|
File.write("go.mod", "module dummy\n")
|
|
24
44
|
|
|
25
|
-
|
|
26
|
-
mod_split = mod_path.split("/")
|
|
27
|
-
repo_path = if mod_split.size > 3
|
|
28
|
-
T.must(mod_split[0..2]).join("/")
|
|
29
|
-
else
|
|
30
|
-
mod_path
|
|
31
|
-
end
|
|
45
|
+
repo_path = repo_path_for(mod_path)
|
|
32
46
|
|
|
33
47
|
_, _, status = Open3.capture3(SharedHelpers.escape_command("go list -m -versions #{repo_path}"))
|
|
34
48
|
raise Dependabot::DependencyFileNotResolvable, message if status.success?
|
|
@@ -36,6 +50,46 @@ module Dependabot
|
|
|
36
50
|
raise Dependabot::GitDependenciesNotReachable, [repo_path]
|
|
37
51
|
end
|
|
38
52
|
end
|
|
53
|
+
|
|
54
|
+
sig { params(message: String).returns(T.nilable(String)) }
|
|
55
|
+
def self.extract_module_path(message)
|
|
56
|
+
github_repo_paths = T.let(
|
|
57
|
+
message.scan(GITHUB_REPO_REGEX).filter_map do |match|
|
|
58
|
+
next match if match.is_a?(String)
|
|
59
|
+
|
|
60
|
+
match.first
|
|
61
|
+
end,
|
|
62
|
+
T::Array[String]
|
|
63
|
+
)
|
|
64
|
+
return github_repo_paths.last&.delete_suffix("/") if github_repo_paths.any?
|
|
65
|
+
|
|
66
|
+
module_with_version_match = message.match(GO_MODULE_WITH_VERSION_REGEX)
|
|
67
|
+
return module_with_version_match[:module] if module_with_version_match
|
|
68
|
+
|
|
69
|
+
hosted_repo_match = message.match(GO_PREFIXED_HOSTED_REPO_REGEX)
|
|
70
|
+
return hosted_repo_match[:repo] if hosted_repo_match
|
|
71
|
+
|
|
72
|
+
nil
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
sig { params(message: String).returns(T::Boolean) }
|
|
76
|
+
def self.requires_reachability_check?(message)
|
|
77
|
+
REACHABILITY_CHECK_HINTS.any? { |regex| message.match?(regex) }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
sig { params(message: String).returns(T::Boolean) }
|
|
81
|
+
def self.insecure_protocol_repo_error?(message)
|
|
82
|
+
message.match?(INSECURE_PROTOCOL_REPOSITORY_REGEX)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
sig { params(mod_path: String).returns(String) }
|
|
86
|
+
def self.repo_path_for(mod_path)
|
|
87
|
+
normalized_mod_path = mod_path.delete_suffix("/")
|
|
88
|
+
mod_split = normalized_mod_path.split("/")
|
|
89
|
+
return normalized_mod_path unless mod_split.first == "github.com" && mod_split.size > 3
|
|
90
|
+
|
|
91
|
+
T.must(mod_split[0..2]).join("/")
|
|
92
|
+
end
|
|
39
93
|
end
|
|
40
94
|
end
|
|
41
95
|
end
|
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.
|
|
4
|
+
version: 0.363.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.
|
|
18
|
+
version: 0.363.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.
|
|
25
|
+
version: 0.363.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: debug
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,14 +85,14 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
88
|
+
version: '2.0'
|
|
89
89
|
type: :development
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
95
|
+
version: '2.0'
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: rspec-sorbet
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -273,7 +273,7 @@ licenses:
|
|
|
273
273
|
- MIT
|
|
274
274
|
metadata:
|
|
275
275
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
276
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
276
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.363.0
|
|
277
277
|
rdoc_options: []
|
|
278
278
|
require_paths:
|
|
279
279
|
- lib
|