dependabot-common 0.153.0 → 0.154.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b925e841b375add05925858919a097192f19103ecb0c8dad020e9715421cccfc
4
- data.tar.gz: cac534a9f4284d6b32a9821974be5004a7b8eaa8074e35de672334cce0e1d2fd
3
+ metadata.gz: db112d90ccd776ed7e343b38e963fa9612bf4e5b814e6a9c4a5867aea1a3c32b
4
+ data.tar.gz: 414df7ccf9cca26acf0d9eb2d95341657b27b0b635662ce001b059fd19cbbb09
5
5
  SHA512:
6
- metadata.gz: edcfde9f70df1bccbb99069846d8edfdfac6d8cbf30c9560a4bceb9f20548dec39c6cfdca6cb38bdeb332825bd23ed5b9e272be2bd646b3b0daf0cc1dbe15eb3
7
- data.tar.gz: a7d41315db7c663d2ec22aa91a61d80ca39f4e0ad4b59eb1ca75733289a85b234a350f72701368acebbcdb29411c96b1a793f2811b8e029e775e01426e051801
6
+ metadata.gz: 613c7b103e9184a4b53f20abf6b9ddb8089642d5beb5036908d8429bfc68e6215115d575ac6162172be2910063d432004d25e10841457119ba65e7e3060870e3
7
+ data.tar.gz: ddb0f753e6b5039f4103378c45abc9981e9607ca33b2da31274c5b22a934cd1e19fc8bae4a7f47e682ccff54f1f6fa8e64fe55d5e6e7b2d8aa32fde6b1ad1d9d
@@ -29,7 +29,7 @@ module Dependabot
29
29
 
30
30
  def initialize(max_retries: 3, **args)
31
31
  @max_retries = max_retries || 3
32
- @client = Bitbucket.new(args)
32
+ @client = Bitbucket.new(**args)
33
33
  end
34
34
 
35
35
  def method_missing(method_name, *args, &block)
@@ -154,7 +154,7 @@ module Dependabot
154
154
  end
155
155
 
156
156
  def symbolize_keys(hash)
157
- Hash[hash.keys.map { |k| [k.to_sym, hash[k]] }]
157
+ hash.keys.map { |k| [k.to_sym, hash[k]] }.to_h
158
158
  end
159
159
  end
160
160
  end
@@ -330,8 +330,8 @@ module Dependabot
330
330
 
331
331
  response.files.map do |file|
332
332
  OpenStruct.new(
333
- name: file.absolute_path,
334
- path: file.absolute_path,
333
+ name: File.basename(file.relative_path),
334
+ path: file.relative_path,
335
335
  type: "file",
336
336
  size: 0 # file size would require new api call per file..
337
337
  )
@@ -25,7 +25,7 @@ module Dependabot
25
25
  status = SharedHelpers.run_shell_command(
26
26
  "git status --untracked-files all --porcelain v1 #{relative_dir}"
27
27
  )
28
- changed_paths = status.split("\n").map { |l| l.split(" ") }
28
+ changed_paths = status.split("\n").map(&:split)
29
29
  changed_paths.map do |type, path|
30
30
  # The following types are possible to be returned:
31
31
  # M = Modified = Default for DependencyFile
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "excon"
4
+ require "open3"
4
5
  require "dependabot/errors"
5
6
 
6
7
  module Dependabot
@@ -52,6 +53,9 @@ module Dependabot
52
53
  response = fetch_raw_upload_pack_for(uri)
53
54
  return response.body if response.status == 200
54
55
 
56
+ response_with_git = fetch_raw_upload_pack_with_git_for(uri)
57
+ return response_with_git.body if response_with_git.status == 200
58
+
55
59
  raise Dependabot::GitDependenciesNotReachable, [uri] unless uri.match?(KNOWN_HOSTS)
56
60
 
57
61
  raise "Unexpected response: #{response.status} - #{response.body}" if response.status < 400
@@ -86,6 +90,23 @@ module Dependabot
86
90
  )
87
91
  end
88
92
 
93
+ def fetch_raw_upload_pack_with_git_for(uri)
94
+ service_pack_uri = uri
95
+ service_pack_uri += ".git" unless service_pack_uri.end_with?(".git")
96
+
97
+ command = "git ls-remote #{service_pack_uri}"
98
+ env = { "PATH" => ENV["PATH"] }
99
+
100
+ stdout, stderr, process = Open3.capture3(env, command)
101
+ # package the command response like a HTTP response so error handling
102
+ # remains unchanged
103
+ if process.success?
104
+ OpenStruct.new(body: stdout, status: 200)
105
+ else
106
+ OpenStruct.new(body: stderr, status: 500)
107
+ end
108
+ end
109
+
89
110
  def tags_for_upload_pack
90
111
  refs_for_upload_pack.
91
112
  select { |ref| ref.ref_type == :tag }.
@@ -106,7 +127,7 @@ module Dependabot
106
127
  peeled_lines = []
107
128
 
108
129
  result = upload_pack.lines.each_with_object({}) do |line, res|
109
- full_ref_name = line.split(" ").last
130
+ full_ref_name = line.split.last
110
131
  next unless full_ref_name.start_with?("refs/tags", "refs/heads")
111
132
 
112
133
  peeled_lines << line && next if line.strip.end_with?("^{}")
@@ -174,7 +195,7 @@ module Dependabot
174
195
  end
175
196
 
176
197
  def sha_for_update_pack_line(line)
177
- line.split(" ").first.chars.last(40).join
198
+ line.split.first.chars.last(40).join
178
199
  end
179
200
 
180
201
  def excon_defaults
@@ -167,7 +167,7 @@ module Dependabot
167
167
 
168
168
  def serialize_release(release)
169
169
  rel = release
170
- title = "## #{rel.name.to_s != '' ? rel.name : rel.tag_name}\n"
170
+ title = "## #{rel.name.to_s == '' ? rel.tag_name : rel.name}\n"
171
171
  body = if rel.body.to_s.gsub(/\n*\z/m, "") == ""
172
172
  "No release notes provided."
173
173
  else
@@ -178,7 +178,7 @@ module Dependabot
178
178
  end
179
179
 
180
180
  def release_body_includes_title?(release)
181
- title = release.name.to_s != "" ? release.name : release.tag_name
181
+ title = release.name.to_s == "" ? release.tag_name : release.name
182
182
  release.body.to_s.match?(/\A\s*\#*\s*#{Regexp.quote(title)}/m)
183
183
  end
184
184
 
@@ -267,7 +267,7 @@ module Dependabot
267
267
 
268
268
  def add_reviewers_to_pull_request(pull_request)
269
269
  reviewers_hash =
270
- Hash[reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }]
270
+ reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }.to_h
271
271
 
272
272
  github_client_for_source.request_pull_request_review(
273
273
  source.repo,
@@ -297,7 +297,7 @@ module Dependabot
297
297
 
298
298
  def comment_with_invalid_reviewer(pull_request, message)
299
299
  reviewers_hash =
300
- Hash[reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }]
300
+ reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }.to_h
301
301
  reviewers = []
302
302
  reviewers += reviewers_hash[:reviewers] || []
303
303
  reviewers += (reviewers_hash[:team_reviewers] || []).
@@ -153,7 +153,7 @@ module Dependabot
153
153
 
154
154
  def add_approvers_to_merge_request(merge_request)
155
155
  approvers_hash =
156
- Hash[approvers.keys.map { |k| [k.to_sym, approvers[k]] }]
156
+ approvers.keys.map { |k| [k.to_sym, approvers[k]] }.to_h
157
157
 
158
158
  gitlab_client_for_source.edit_merge_request_approvers(
159
159
  source.repo,
@@ -51,10 +51,10 @@ module Dependabot
51
51
  doc.walk do |node|
52
52
  if node.type == :text &&
53
53
  node.string_content.match?(MENTION_REGEX)
54
- nodes = if !parent_node_link?(node)
55
- build_mention_nodes(node.string_content)
56
- else
54
+ nodes = if parent_node_link?(node)
57
55
  build_mention_link_text_nodes(node.string_content)
56
+ else
57
+ build_mention_nodes(node.string_content)
58
58
  end
59
59
 
60
60
  nodes.each do |n|
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "json"
4
- require "tmpdir"
5
- require "excon"
6
- require "English"
7
3
  require "digest"
4
+ require "English"
5
+ require "excon"
6
+ require "fileutils"
7
+ require "json"
8
8
  require "open3"
9
9
  require "shellwords"
10
+ require "tmpdir"
10
11
 
11
12
  require "dependabot/utils"
12
13
  require "dependabot/errors"
@@ -64,7 +65,7 @@ module Dependabot
64
65
 
65
66
  # Escapes all special characters, e.g. = & | <>
66
67
  def self.escape_command(command)
67
- command_parts = command.split(" ").map(&:strip).reject(&:empty?)
68
+ command_parts = command.split.map(&:strip).reject(&:empty?)
68
69
  Shellwords.join(command_parts)
69
70
  end
70
71
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dependabot
4
+ module UpdateCheckers
5
+ module VersionFilters
6
+ def self.filter_vulnerable_versions(versions_array, security_advisories)
7
+ versions_array.reject do |v|
8
+ security_advisories.any? do |a|
9
+ if v.is_a?(Gem::Version)
10
+ a.vulnerable?(v)
11
+ else
12
+ a.vulnerable?(v.fetch(:version))
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.153.0"
4
+ VERSION = "0.154.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.153.0
4
+ version: 0.154.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-14 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -81,7 +81,7 @@ dependencies:
81
81
  version: 0.20.1
82
82
  - - "<"
83
83
  - !ruby/object:Gem::Version
84
- version: 0.22.0
84
+ version: 0.23.0
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
@@ -91,7 +91,7 @@ dependencies:
91
91
  version: 0.20.1
92
92
  - - "<"
93
93
  - !ruby/object:Gem::Version
94
- version: 0.22.0
94
+ version: 0.23.0
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: docker_registry2
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -446,6 +446,7 @@ files:
446
446
  - lib/dependabot/update_checkers.rb
447
447
  - lib/dependabot/update_checkers/README.md
448
448
  - lib/dependabot/update_checkers/base.rb
449
+ - lib/dependabot/update_checkers/version_filters.rb
449
450
  - lib/dependabot/utils.rb
450
451
  - lib/dependabot/version.rb
451
452
  - lib/rubygems_version_patch.rb