dependabot-core 0.89.5 → 0.90.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/dependabot/file_fetchers.rb +1 -3
- data/lib/dependabot/file_parsers.rb +1 -3
- data/lib/dependabot/file_updaters.rb +1 -3
- data/lib/dependabot/metadata_finders.rb +1 -3
- data/lib/dependabot/update_checkers.rb +1 -3
- data/lib/dependabot/utils.rb +2 -6
- data/lib/dependabot/version.rb +1 -1
- metadata +2 -23
- data/helpers/go/Makefile +0 -9
- data/helpers/go/go.mod +0 -8
- data/helpers/go/go.sum +0 -2
- data/helpers/go/importresolver/go.mod +0 -1
- data/helpers/go/importresolver/main.go +0 -34
- data/helpers/go/main.go +0 -67
- data/lib/dependabot/file_fetchers/go/dep.rb +0 -69
- data/lib/dependabot/file_parsers/go/dep.rb +0 -188
- data/lib/dependabot/file_updaters/go/dep.rb +0 -77
- data/lib/dependabot/file_updaters/go/dep/lockfile_updater.rb +0 -222
- data/lib/dependabot/file_updaters/go/dep/manifest_updater.rb +0 -155
- data/lib/dependabot/metadata_finders/go/dep.rb +0 -56
- data/lib/dependabot/update_checkers/go/dep.rb +0 -311
- data/lib/dependabot/update_checkers/go/dep/file_preparer.rb +0 -221
- data/lib/dependabot/update_checkers/go/dep/latest_version_finder.rb +0 -169
- data/lib/dependabot/update_checkers/go/dep/requirements_updater.rb +0 -223
- data/lib/dependabot/update_checkers/go/dep/version_resolver.rb +0 -168
- data/lib/dependabot/utils/go/path_converter.rb +0 -74
- data/lib/dependabot/utils/go/requirement.rb +0 -152
- data/lib/dependabot/utils/go/shared_helper.rb +0 -20
- data/lib/dependabot/utils/go/version.rb +0 -42
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "excon"
|
4
|
-
require "nokogiri"
|
5
|
-
|
6
|
-
require "dependabot/shared_helpers"
|
7
|
-
require "dependabot/source"
|
8
|
-
require "dependabot/utils/go/shared_helper"
|
9
|
-
|
10
|
-
module Dependabot
|
11
|
-
module Utils
|
12
|
-
module Go
|
13
|
-
module PathConverter
|
14
|
-
def self.git_url_for_path(path)
|
15
|
-
# Save a query by manually converting golang.org/x names
|
16
|
-
import_path = path.gsub(%r{^golang\.org/x}, "github.com/golang")
|
17
|
-
|
18
|
-
SharedHelpers.run_helper_subprocess(
|
19
|
-
command: Go::SharedHelper.path,
|
20
|
-
function: "getVcsRemoteForImport",
|
21
|
-
args: { import: import_path }
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Used in dependabot-backend, which doesn't have access to any Go
|
26
|
-
# helpers.
|
27
|
-
# TODO: remove the need for this.
|
28
|
-
def self.git_url_for_path_without_go_helper(path)
|
29
|
-
# Save a query by manually converting golang.org/x names
|
30
|
-
tmp_path = path.gsub(%r{^golang\.org/x}, "github.com/golang")
|
31
|
-
|
32
|
-
# Currently, Dependabot::Source.new will return `nil` if it can't
|
33
|
-
# find a git SCH associated with a path. If it is ever extended to
|
34
|
-
# handle non-git sources we'll need to add an additional check here.
|
35
|
-
return Source.from_url(tmp_path).url if Source.from_url(tmp_path)
|
36
|
-
return "https://#{tmp_path}" if tmp_path.end_with?(".git")
|
37
|
-
return unless (metadata_response = fetch_path_metadata(path))
|
38
|
-
|
39
|
-
# Look for a GitHub, Bitbucket or GitLab URL in the response
|
40
|
-
metadata_response.scan(Dependabot::Source::SOURCE_REGEX) do
|
41
|
-
source_url = Regexp.last_match.to_s
|
42
|
-
return Source.from_url(source_url).url
|
43
|
-
end
|
44
|
-
|
45
|
-
# If none are found, parse the response and return the go-import path
|
46
|
-
doc = Nokogiri::XML(metadata_response)
|
47
|
-
doc.remove_namespaces!
|
48
|
-
import_details =
|
49
|
-
doc.xpath("//meta").
|
50
|
-
find { |n| n.attributes["name"]&.value == "go-import" }&.
|
51
|
-
attributes&.fetch("content")&.value&.split(/\s+/)
|
52
|
-
return unless import_details && import_details[1] == "git"
|
53
|
-
|
54
|
-
import_details[2]
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.fetch_path_metadata(path)
|
58
|
-
# TODO: This is not robust! Instead, we should shell out to Go and
|
59
|
-
# use https://github.com/Masterminds/vcs.
|
60
|
-
response = Excon.get(
|
61
|
-
"https://#{path}?go-get=1",
|
62
|
-
idempotent: true,
|
63
|
-
**SharedHelpers.excon_defaults
|
64
|
-
)
|
65
|
-
|
66
|
-
return unless response.status == 200
|
67
|
-
|
68
|
-
response.body
|
69
|
-
end
|
70
|
-
private_class_method :fetch_path_metadata
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,152 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
################################################################################
|
4
|
-
# For more details on Go version constraints, see: #
|
5
|
-
# - https://github.com/Masterminds/semver #
|
6
|
-
# - https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md #
|
7
|
-
################################################################################
|
8
|
-
|
9
|
-
require "dependabot/utils/go/version"
|
10
|
-
|
11
|
-
module Dependabot
|
12
|
-
module Utils
|
13
|
-
module Go
|
14
|
-
class Requirement < Gem::Requirement
|
15
|
-
WILDCARD_REGEX = /(?:\.|^)[xX*]/.freeze
|
16
|
-
OR_SEPARATOR = /(?<=[a-zA-Z0-9*])\s*\|{2}/.freeze
|
17
|
-
|
18
|
-
# Override the version pattern to allow a 'v' prefix
|
19
|
-
quoted = OPS.keys.map { |k| Regexp.quote(k) }.join("|")
|
20
|
-
version_pattern = "v?#{Utils::Go::Version::VERSION_PATTERN}"
|
21
|
-
|
22
|
-
PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{version_pattern})\\s*"
|
23
|
-
PATTERN = /\A#{PATTERN_RAW}\z/.freeze
|
24
|
-
|
25
|
-
# Use Utils::Go::Version rather than Gem::Version to ensure that
|
26
|
-
# pre-release versions aren't transformed.
|
27
|
-
def self.parse(obj)
|
28
|
-
if obj.is_a?(Gem::Version)
|
29
|
-
return ["=", Utils::Go::Version.new(obj.to_s)]
|
30
|
-
end
|
31
|
-
|
32
|
-
unless (matches = PATTERN.match(obj.to_s))
|
33
|
-
msg = "Illformed requirement [#{obj.inspect}]"
|
34
|
-
raise BadRequirementError, msg
|
35
|
-
end
|
36
|
-
|
37
|
-
return DefaultRequirement if matches[1] == ">=" && matches[2] == "0"
|
38
|
-
|
39
|
-
[matches[1] || "=", Utils::Go::Version.new(matches[2])]
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns an array of requirements. At least one requirement from the
|
43
|
-
# returned array must be satisfied for a version to be valid.
|
44
|
-
def self.requirements_array(requirement_string)
|
45
|
-
return [new(nil)] if requirement_string.nil?
|
46
|
-
|
47
|
-
requirement_string.strip.split(OR_SEPARATOR).map do |req_string|
|
48
|
-
new(req_string)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def initialize(*requirements)
|
53
|
-
requirements = requirements.flatten.flat_map do |req_string|
|
54
|
-
req_string.split(",").map do |r|
|
55
|
-
convert_go_constraint_to_ruby_constraint(r.strip)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
super(requirements)
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def convert_go_constraint_to_ruby_constraint(req_string)
|
65
|
-
req_string = req_string
|
66
|
-
req_string = convert_wildcard_characters(req_string)
|
67
|
-
|
68
|
-
if req_string.match?(WILDCARD_REGEX)
|
69
|
-
ruby_range(req_string.gsub(WILDCARD_REGEX, "").gsub(/^[^\d]/, ""))
|
70
|
-
elsif req_string.match?(/^~[^>]/) then convert_tilde_req(req_string)
|
71
|
-
elsif req_string.include?(" - ") then convert_hyphen_req(req_string)
|
72
|
-
elsif req_string.match?(/^[\dv^]/) then convert_caret_req(req_string)
|
73
|
-
elsif req_string.match?(/[<=>]/) then req_string
|
74
|
-
else ruby_range(req_string)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def convert_wildcard_characters(req_string)
|
79
|
-
if req_string.match?(/^[\dv^>~]/)
|
80
|
-
replace_wildcard_in_lower_bound(req_string)
|
81
|
-
elsif req_string.start_with?("<")
|
82
|
-
parts = req_string.split(".")
|
83
|
-
parts.map.with_index do |part, index|
|
84
|
-
next "0" if part.match?(WILDCARD_REGEX)
|
85
|
-
next part.to_i + 1 if parts[index + 1]&.match?(WILDCARD_REGEX)
|
86
|
-
|
87
|
-
part
|
88
|
-
end.join(".")
|
89
|
-
else
|
90
|
-
req_string
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def replace_wildcard_in_lower_bound(req_string)
|
95
|
-
after_wildcard = false
|
96
|
-
|
97
|
-
if req_string.start_with?("~")
|
98
|
-
req_string = req_string.gsub(/(?:(?:\.|^)[xX*])(\.[xX*])+/, "")
|
99
|
-
end
|
100
|
-
|
101
|
-
req_string.split(".").
|
102
|
-
map do |part|
|
103
|
-
part.split("-").map.with_index do |p, i|
|
104
|
-
# Before we hit a wildcard we just return the existing part
|
105
|
-
next p unless p.match?(WILDCARD_REGEX) || after_wildcard
|
106
|
-
|
107
|
-
# On or after a wildcard we replace the version part with zero
|
108
|
-
after_wildcard = true
|
109
|
-
i.zero? ? "0" : "a"
|
110
|
-
end.join("-")
|
111
|
-
end.join(".")
|
112
|
-
end
|
113
|
-
|
114
|
-
def convert_tilde_req(req_string)
|
115
|
-
version = req_string.gsub(/^~/, "")
|
116
|
-
parts = version.split(".")
|
117
|
-
parts << "0" if parts.count < 3
|
118
|
-
"~> #{parts.join('.')}"
|
119
|
-
end
|
120
|
-
|
121
|
-
def convert_hyphen_req(req_string)
|
122
|
-
lower_bound, upper_bound = req_string.split(/\s+-\s+/)
|
123
|
-
[">= #{lower_bound}", "<= #{upper_bound}"]
|
124
|
-
end
|
125
|
-
|
126
|
-
def ruby_range(req_string)
|
127
|
-
parts = req_string.split(".")
|
128
|
-
|
129
|
-
# If we have three or more parts then this is an exact match
|
130
|
-
return req_string if parts.count >= 3
|
131
|
-
|
132
|
-
# If we have no parts then the version is completely unlocked
|
133
|
-
return ">= 0" if parts.count.zero?
|
134
|
-
|
135
|
-
# If we have fewer than three parts we do a partial match
|
136
|
-
parts << "0"
|
137
|
-
"~> #{parts.join('.')}"
|
138
|
-
end
|
139
|
-
|
140
|
-
# Note: Dep's caret notation implementation doesn't distinguish between
|
141
|
-
# pre and post-1.0.0 requirements (unlike in JS)
|
142
|
-
def convert_caret_req(req_string)
|
143
|
-
version = req_string.gsub(/^\^?v?/, "")
|
144
|
-
parts = version.split(".")
|
145
|
-
upper_bound = [parts.first.to_i + 1, 0, 0, "a"].map(&:to_s).join(".")
|
146
|
-
|
147
|
-
[">= #{version}", "< #{upper_bound}"]
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Dependabot
|
4
|
-
module Utils
|
5
|
-
module Go
|
6
|
-
module SharedHelper
|
7
|
-
def self.path
|
8
|
-
project_root = File.join(File.dirname(__FILE__), "../../../..")
|
9
|
-
platform =
|
10
|
-
case RbConfig::CONFIG["arch"]
|
11
|
-
when /linux/ then "linux"
|
12
|
-
when /darwin/ then "darwin"
|
13
|
-
else raise "Invalid platform #{RbConfig::CONFIG['arch']}"
|
14
|
-
end
|
15
|
-
File.join(project_root, "helpers/go/go-helpers.#{platform}64")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rubygems_version_patch"
|
4
|
-
|
5
|
-
# Go pre-release versions use 1.0.1-rc1 syntax, which Gem::Version
|
6
|
-
# converts into 1.0.1.pre.rc1. We override the `to_s` method to stop that
|
7
|
-
# alteration.
|
8
|
-
# Best docs are at https://github.com/Masterminds/semver
|
9
|
-
|
10
|
-
module Dependabot
|
11
|
-
module Utils
|
12
|
-
module Go
|
13
|
-
class Version < Gem::Version
|
14
|
-
VERSION_PATTERN = '[0-9]+[0-9a-zA-Z]*(?>\.[0-9a-zA-Z]+)*' \
|
15
|
-
'(-[0-9A-Za-z-]+(\.[0-9a-zA-Z-]+)*)?' \
|
16
|
-
'(\+incompatible)?'
|
17
|
-
ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/.freeze
|
18
|
-
|
19
|
-
def self.correct?(version)
|
20
|
-
version = version.gsub(/^v/, "") if version.is_a?(String)
|
21
|
-
version = version.to_s.split("+").first if version.to_s.include?("+")
|
22
|
-
super(version)
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize(version)
|
26
|
-
@version_string = version.to_s.gsub(/^v/, "")
|
27
|
-
version = version.gsub(/^v/, "") if version.is_a?(String)
|
28
|
-
version = version.to_s.split("+").first if version.to_s.include?("+")
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
def inspect # :nodoc:
|
33
|
-
"#<#{self.class} #{@version_string.inspect}>"
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_s
|
37
|
-
@version_string
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|