dependabot-github_actions 0.213.0 → 0.214.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: b3804334c168c6ac968941c3fd695443875744a48e66825e0247a10089003b77
4
+ data.tar.gz: 92571e11e014c22477a152c8035d77022df7faad94b303677788e937d31d6231
5
5
  SHA512:
6
- metadata.gz: 855575e94d06e5749ee006e0a20180c8de9bbdb519b9adb894ac4cd943aaa2c852c1714a92a44ed4e6c7736c64cb9c74af5824825fdc2dd57e0977aee3dcfd6f
7
- data.tar.gz: 8bca4abb38782199a213843eb76a8ffddb204db1d3e68ed1310a794d0893d1f8545e62cf64cfbea87fd62174ffa8af3d3661ff3c646f2540864a2cb49bfa396e
6
+ metadata.gz: 6397641d12b9fb86fbc34fec837b05c3669f9ebb3a96dd27fa2912098ac1f158dcf6f39995065a417013ba22e169931a4886c2e15109bcf446a4f83191ec03a4
7
+ data.tar.gz: d706bb33be9d40cd470c6977a6268887fddacbf799ea30b604a5569ac50347589b8acf25ad6f9d924ccd78c9ce31b515fe8564118dc1705825e6c73055265e6d
@@ -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
@@ -94,7 +94,7 @@ module Dependabot
94
94
  git_checker = Dependabot::GitCommitChecker.new(dependency: dep, credentials: credentials)
95
95
  next unless git_checker.pinned_ref_looks_like_commit_sha?
96
96
 
97
- resolved = git_checker.local_tag_for_pinned_version
97
+ resolved = git_checker.local_tag_for_pinned_sha
98
98
  next if resolved.nil? || !version_class.correct?(resolved)
99
99
 
100
100
  # 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,7 +81,7 @@ 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
@@ -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) &&
@@ -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,17 @@ 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
+ ).split("\n").map { |branch| branch.strip.gsub("origin/", "") }
190
257
 
191
- current_branch = branches_including_ref.find { |line| line.start_with?("* ") }
258
+ current_branch = branches_including_ref.find { |branch| branch.start_with?("HEAD -> ") }
192
259
 
193
260
  if current_branch
194
- current_branch.delete_prefix("* ")
261
+ current_branch.delete_prefix("HEAD -> ")
195
262
  elsif branches_including_ref.size > 1
196
263
  # 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}!"
264
+ raise "Multiple ambiguous branches (#{branches_including_ref.join(', ')}) include #{sha}!"
198
265
  else
199
266
  branches_including_ref.first
200
267
  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.214.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-01 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.214.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.214.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