Commit 75602aba authored by mo khan's avatar mo khan Committed by Lin Jen-Shin

Apply maintainer feedback

parent b024b782
......@@ -59,7 +59,7 @@ module Gitlab
def safe?
severities = occurrences.map(&:severity).compact.map(&:downcase)
(severities & UNSAFE_SEVERITIES).size.zero?
(severities & UNSAFE_SEVERITIES).empty?
end
end
end
......
......@@ -19,7 +19,7 @@ module Gitlab
end
def violates_default_policy?
reports.values.any? { |report| !report.safe? }
reports.values.any? { |report| report.unsafe_severity? }
end
end
end
......
......@@ -6,7 +6,7 @@ describe Gitlab::Ci::Parsers::Security::Sast do
describe '#parse!' do
subject(:parser) { described_class.new }
let(:commit_sha) { Digest::SHA1.hexdigest(SecureRandom.uuid) }
let(:commit_sha) { "d8978e74745e18ce44d88814004d4255ac6a65bb" }
context "when parsing valid reports" do
where(report_format: %i(sast sast_deprecated))
......
......@@ -3,8 +3,8 @@
require 'spec_helper'
describe Gitlab::Ci::Reports::Security::Report do
let(:pipeline) { create(:ci_pipeline) }
let(:report) { described_class.new('sast', pipeline.sha) }
let(:report) { described_class.new('sast', commit_sha) }
let(:commit_sha) { "d8978e74745e18ce44d88814004d4255ac6a65bb" }
it { expect(report.type).to eq('sast') }
......@@ -111,7 +111,7 @@ describe Gitlab::Ci::Reports::Security::Report do
allow(report).to receive(:replace_with!)
end
subject { report.merge!(described_class.new('sast', pipeline.sha)) }
subject { report.merge!(described_class.new('sast', commit_sha)) }
it 'invokes the merge with other report and then replaces this report contents by merge result' do
subject
......@@ -123,8 +123,6 @@ describe Gitlab::Ci::Reports::Security::Report do
describe "#safe?" do
subject { described_class.new('sast', commit_sha) }
let(:commit_sha) { Digest::SHA1.hexdigest(SecureRandom.uuid) }
context "when the sast report has an unsafe vulnerability" do
where(severity: %w[unknown Unknown high High critical Critical])
with_them do
......
......@@ -39,7 +39,6 @@ describe Gitlab::Ci::Reports::Security::Reports do
describe "#violates_default_policy?" do
subject { described_class.new(commit_sha) }
let(:commit_sha) { Digest::SHA1.hexdigest(SecureRandom.uuid) }
let(:low_severity) { build(:ci_reports_security_occurrence, severity: 'low') }
let(:high_severity) { build(:ci_reports_security_occurrence, severity: 'high') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment