Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Avoid iterating on nil key.
Browse files Browse the repository at this point in the history
Fixes #1351

Signed-off-by: James Maidment james@maidment.org
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
jamesmaidment authored and mssola committed Oct 18, 2017
1 parent 714fd68 commit f19094b
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/portus/security_backends/clair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def layer_vulnerabilities(digest)

res = []
known = []
layer["Features"].each do |f|
Array(layer["Features"]).each do |f|
vulns = f["Vulnerabilities"]
next if vulns.nil?

Expand Down
12 changes: 12 additions & 0 deletions spec/lib/portus/security/clair_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ def expect_cve_match(cves, given, expected)
expect_cve_match(["CVE-2016-6301", "CVE-2016-8859"], res[:clair], proper[:clair])
end

it "returns no CVEs if 'Features' is nil" do
VCR.turn_on!
res = {}

VCR.use_cassette("security/clair_features_nil", record: :none) do
clair = ::Portus::Security.new("coreos/dex", "unrelated")
res = clair.vulnerabilities
end

expect(res[:clair]).to be_empty
end

it "logs the proper debug message when posting is unsuccessful" do
VCR.turn_on!
res = {}
Expand Down
210 changes: 210 additions & 0 deletions spec/vcr_cassettes/security/clair_features_nil.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f19094b

Please sign in to comment.