dependabot-github_actions 0.213.0 → 0.215.0

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: e40718bacbd579d5f066f1951840b92e43e2a4f9d18d35870b02e6cf43352a3d
4
- data.tar.gz: df27ec63cc58ce499478d5d89f35f57b5d171a4cbc3487025e560efe6c4c8219
3
+ metadata.gz: 6fde4fe69c8cd2491cd14866ea06170f56ee5abbe938f4c87f8a7b44c0d5ba90
4
+ data.tar.gz: 49f7860bbf1b24d352abb47f2538683571ef11d5224b5dcdd5b4538152ba1459
5
5
  SHA512:
6
- metadata.gz: 855575e94d06e5749ee006e0a20180c8de9bbdb519b9adb894ac4cd943aaa2c852c1714a92a44ed4e6c7736c64cb9c74af5824825fdc2dd57e0977aee3dcfd6f
7
- data.tar.gz: 8bca4abb38782199a213843eb76a8ffddb204db1d3e68ed1310a794d0893d1f8545e62cf64cfbea87fd62174ffa8af3d3661ff3c646f2540864a2cb49bfa396e
6
+ metadata.gz: 917071c7623f613199a71beea1a48656a010cb598f9868799fdecf6cf60d307b16bea35bb50bf2208c48a819e7ab9f95f1ee53994612a2f2922762797b6a3aac
7
+ data.tar.gz: 8e11c8d489fe57966dec1239730b7109477c9f3e5eeb3a629a2a5542b9ace4f6daa08677f52ae48203206f4bec43288939bd63c93f46b6fc28c8757aaedb97ca
@@ -26,9 +26,16 @@ module Dependabot
26
26
  return fetched_files if fetched_files.any?
27
27
 
28
28
  if incorrectly_encoded_workflow_files.none?
29
+ expected_paths =
30
+ if directory == "/"
31
+ File.join(directory, "action.yml") + " or /.github/workflows/<anything>.yml"
32
+ else
33
+ File.join(directory, "<anything>.yml")
34
+ end
35
+
29
36
  raise(
30
37
  Dependabot::DependencyFileNotFound,
31
- File.join(directory, "action.yml") + " or /.github/workflows/<anything>.yml"
38
+ expected_paths
32
39
  )
33
40
  else
34
41
  raise(
@@ -41,16 +48,22 @@ module Dependabot
41
48
  def workflow_files
42
49
  return @workflow_files if defined? @workflow_files
43
50
 
44
- @workflow_files = [fetch_file_if_present("action.yml"), fetch_file_if_present("action.yaml")].compact
51
+ @workflow_files = []
45
52
 
46
53
  # In the special case where the root directory is defined we also scan
47
54
  # the .github/workflows/ folder.
48
- return @workflow_files unless directory == "/"
55
+ if directory == "/"
56
+ @workflow_files += [fetch_file_if_present("action.yml"), fetch_file_if_present("action.yaml")].compact
57
+
58
+ workflows_dir = ".github/workflows"
59
+ else
60
+ workflows_dir = "."
61
+ end
49
62
 
50
63
  @workflow_files +=
51
- repo_contents(dir: ".github/workflows", raise_errors: false).
64
+ repo_contents(dir: workflows_dir, raise_errors: false).
52
65
  select { |f| f.type == "file" && f.name.match?(/\.ya?ml$/) }.
53
- map { |f| fetch_file_from_host(".github/workflows/#{f.name}") }
66
+ map { |f| fetch_file_from_host("#{workflows_dir}/#{f.name}") }
54
67
  end
55
68
 
56
69
  def referenced_local_workflow_files
@@ -92,9 +92,7 @@ module Dependabot
92
92
  next unless dep.version.nil?
93
93
 
94
94
  git_checker = Dependabot::GitCommitChecker.new(dependency: dep, credentials: credentials)
95
- next unless git_checker.pinned_ref_looks_like_commit_sha?
96
-
97
- resolved = git_checker.local_tag_for_pinned_version
95
+ resolved = git_checker.local_tag_for_pinned_sha
98
96
  next if resolved.nil? || !version_class.correct?(resolved)
99
97
 
100
98
  # Build a Dependency with the resolved version, and rely on DependencySet's merge
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "dependabot/update_checkers"
4
4
  require "dependabot/update_checkers/base"
5
+ require "dependabot/update_checkers/version_filters"
5
6
  require "dependabot/errors"
6
7
  require "dependabot/github_actions/version"
7
8
  require "dependabot/github_actions/requirement"
@@ -23,6 +24,15 @@ module Dependabot
23
24
  dependency.version
24
25
  end
25
26
 
27
+ def lowest_security_fix_version
28
+ @lowest_security_fix_version ||= fetch_lowest_security_fix_version
29
+ end
30
+
31
+ def lowest_resolvable_security_fix_version
32
+ # Resolvability isn't an issue for GitHub Actions.
33
+ lowest_security_fix_version
34
+ end
35
+
26
36
  def updated_requirements # rubocop:disable Metrics/PerceivedComplexity
27
37
  previous = dependency_source_details
28
38
  updated = updated_source
@@ -42,6 +52,12 @@ module Dependabot
42
52
 
43
53
  private
44
54
 
55
+ def active_advisories
56
+ security_advisories.select do |advisory|
57
+ advisory.vulnerable?(version_class.new(git_commit_checker.most_specific_tag_equivalent_to_pinned_ref))
58
+ end
59
+ end
60
+
45
61
  def latest_version_resolvable_with_full_unlock?
46
62
  # Full unlock checks aren't relevant for GitHub Actions
47
63
  false
@@ -65,14 +81,14 @@ module Dependabot
65
81
  # we want to update that tag.
66
82
  if git_commit_checker.pinned_ref_looks_like_version? && latest_version_tag
67
83
  latest_version = latest_version_tag.fetch(:version)
68
- return version_class.new(dependency.version) if shortened_semver_eq?(dependency.version, latest_version.to_s)
84
+ return current_version if shortened_semver_eq?(dependency.version, latest_version.to_s)
69
85
 
70
86
  return latest_version
71
87
  end
72
88
 
73
89
  if git_commit_checker.pinned_ref_looks_like_commit_sha? && latest_version_tag
74
90
  latest_version = latest_version_tag.fetch(:version)
75
- return latest_commit_for_pinned_ref unless git_commit_checker.branch_or_ref_in_release?(latest_version)
91
+ return latest_commit_for_pinned_ref unless git_commit_checker.local_tag_for_pinned_sha
76
92
 
77
93
  return latest_version
78
94
  end
@@ -82,35 +98,85 @@ module Dependabot
82
98
  nil
83
99
  end
84
100
 
101
+ def fetch_lowest_security_fix_version
102
+ # TODO: Support Docker sources
103
+ return unless git_dependency?
104
+
105
+ fetch_lowest_security_fix_version_for_git_dependency
106
+ end
107
+
108
+ def fetch_lowest_security_fix_version_for_git_dependency
109
+ lowest_security_fix_version_tag.fetch(:version)
110
+ end
111
+
112
+ def lowest_security_fix_version_tag
113
+ @lowest_security_fix_version_tag ||= begin
114
+ tags_matching_precision = git_commit_checker.local_tags_for_allowed_versions_matching_existing_precision
115
+ lowest_fixed_version = find_lowest_secure_version(tags_matching_precision)
116
+ if lowest_fixed_version
117
+ lowest_fixed_version
118
+ else
119
+ tags = git_commit_checker.local_tags_for_allowed_versions
120
+ find_lowest_secure_version(tags)
121
+ end
122
+ end
123
+ end
124
+
125
+ def find_lowest_secure_version(tags)
126
+ relevant_tags = Dependabot::UpdateCheckers::VersionFilters.filter_vulnerable_versions(tags, security_advisories)
127
+ relevant_tags = filter_lower_tags(relevant_tags)
128
+
129
+ relevant_tags.min_by { |tag| tag.fetch(:version) }
130
+ end
131
+
85
132
  def latest_commit_for_pinned_ref
86
- @latest_commit_for_pinned_ref ||=
87
- SharedHelpers.in_a_temporary_repo_directory("/", repo_contents_path) do
88
- ref_branch = find_container_branch(current_commit)
133
+ @latest_commit_for_pinned_ref ||= begin
134
+ head_commit_for_ref_sha = git_commit_checker.head_commit_for_pinned_ref
135
+ if head_commit_for_ref_sha
136
+ head_commit_for_ref_sha
137
+ else
138
+ url = dependency_source_details[:url]
139
+ source = Source.from_url(url)
140
+
141
+ SharedHelpers.in_a_temporary_directory(File.dirname(source.repo)) do |temp_dir|
142
+ repo_contents_path = File.join(temp_dir, File.basename(source.repo))
143
+
144
+ SharedHelpers.run_shell_command("git clone --no-recurse-submodules #{url} #{repo_contents_path}")
89
145
 
90
- git_commit_checker.head_commit_for_local_branch(ref_branch)
146
+ Dir.chdir(repo_contents_path) do
147
+ ref_branch = find_container_branch(dependency_source_details[:ref])
148
+
149
+ git_commit_checker.head_commit_for_local_branch(ref_branch)
150
+ end
151
+ end
91
152
  end
153
+ end
92
154
  end
93
155
 
94
156
  def latest_version_tag
95
157
  @latest_version_tag ||= begin
96
158
  return git_commit_checker.local_tag_for_latest_version if dependency.version.nil?
97
159
 
98
- latest_tags = git_commit_checker.local_tags_for_latest_version_commit_sha
99
-
100
- # Find the latest version with the same precision as the pinned version.
101
- current_precision = precision(dependency.version)
102
- latest_tags.select { |tag| precision(tag[:version].to_s) == current_precision }.max_by { |tag| tag[:version] }
160
+ git_commit_checker.local_ref_for_latest_version_matching_existing_precision
103
161
  end
104
162
  end
105
163
 
106
- def precision(version)
107
- version.split(".").length
164
+ def filter_lower_tags(tags_array)
165
+ return tags_array unless current_version
166
+
167
+ tags_array.
168
+ select { |tag| tag.fetch(:version) > current_version }
108
169
  end
109
170
 
110
171
  def updated_source
111
172
  # TODO: Support Docker sources
112
173
  return dependency_source_details unless git_dependency?
113
174
 
175
+ if vulnerable? &&
176
+ (new_tag = lowest_security_fix_version_tag)
177
+ return dependency_source_details.merge(ref: new_tag.fetch(:tag))
178
+ end
179
+
114
180
  # Update the git tag if updating a pinned version
115
181
  if git_commit_checker.pinned_ref_looks_like_version? &&
116
182
  (new_tag = latest_version_tag) &&
@@ -133,7 +199,7 @@ module Dependabot
133
199
  new_tag = latest_version_tag
134
200
  return unless new_tag
135
201
 
136
- if git_commit_checker.branch_or_ref_in_release?(new_tag.fetch(:version))
202
+ if git_commit_checker.local_tag_for_pinned_sha
137
203
  new_tag.fetch(:commit_sha)
138
204
  else
139
205
  latest_commit_for_pinned_ref
@@ -169,7 +235,8 @@ module Dependabot
169
235
  dependency: dependency,
170
236
  credentials: credentials,
171
237
  ignored_versions: ignored_versions,
172
- raise_on_ignored: raise_on_ignored
238
+ raise_on_ignored: raise_on_ignored,
239
+ consider_version_branches_pinned: true
173
240
  )
174
241
  end
175
242
 
@@ -184,17 +251,18 @@ module Dependabot
184
251
  end
185
252
 
186
253
  def find_container_branch(sha)
187
- SharedHelpers.run_shell_command("git fetch #{current_commit}")
188
-
189
- branches_including_ref = SharedHelpers.run_shell_command("git branch --contains #{sha}").split("\n")
254
+ branches_including_ref = SharedHelpers.run_shell_command(
255
+ "git branch --remotes --contains #{sha}",
256
+ fingerprint: "git branch --remotes --contains <sha>"
257
+ ).split("\n").map { |branch| branch.strip.gsub("origin/", "") }
190
258
 
191
- current_branch = branches_including_ref.find { |line| line.start_with?("* ") }
259
+ current_branch = branches_including_ref.find { |branch| branch.start_with?("HEAD -> ") }
192
260
 
193
261
  if current_branch
194
- current_branch.delete_prefix("* ")
262
+ current_branch.delete_prefix("HEAD -> ")
195
263
  elsif branches_including_ref.size > 1
196
264
  # If there are multiple non default branches including the pinned SHA, then it's unclear how we should proceed
197
- raise "Multiple ambiguous branches (#{branches_including_ref.join(', ')}) include #{current_commit}!"
265
+ raise "Multiple ambiguous branches (#{branches_including_ref.join(', ')}) include #{sha}!"
198
266
  else
199
267
  branches_including_ref.first
200
268
  end
@@ -22,6 +22,3 @@ Dependabot::PullRequestCreator::Labeler.
22
22
  require "dependabot/dependency"
23
23
  Dependabot::Dependency.
24
24
  register_production_check("github_actions", ->(_) { true })
25
-
26
- require "dependabot/utils"
27
- Dependabot::Utils.register_always_clone("github_actions")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-github_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.213.0
4
+ version: 0.215.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-31 00:00:00.000000000 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.213.0
19
+ version: 0.215.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.213.0
26
+ version: 0.215.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.13.0
61
+ version: 4.0.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.13.0
68
+ version: 4.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.37.1
117
+ version: 1.39.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.37.1
124
+ version: 1.39.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop-performance
127
127
  requirement: !ruby/object:Gem::Requirement