Commit 5271e41b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'cleanup-undefined-level' into 'master'

Cleanup undefined severity level from code

See merge request gitlab-org/gitlab!27095
parents 9b28dc85 bd2d5587
...@@ -39,7 +39,7 @@ module Vulnerabilities ...@@ -39,7 +39,7 @@ module Vulnerabilities
}.with_indifferent_access.freeze }.with_indifferent_access.freeze
SEVERITY_LEVELS = { SEVERITY_LEVELS = {
undefined: 0, # undefined: 0, no longer applicable
info: 1, info: 1,
unknown: 2, unknown: 2,
# experimental: 3, formerly used by confidence, no longer applicable # experimental: 3, formerly used by confidence, no longer applicable
......
...@@ -72,8 +72,8 @@ module Security ...@@ -72,8 +72,8 @@ module Security
# will have highest severity # will have highest severity
def sort_by_severity(collection) def sort_by_severity(collection)
collection.sort do |dep_i, dep_j| collection.sort do |dep_i, dep_j|
level_i = dep_i.dig(:vulnerabilities, 0, :severity) || :undefined level_i = dep_i.dig(:vulnerabilities, 0, :severity) || :info
level_j = dep_j.dig(:vulnerabilities, 0, :severity) || :undefined level_j = dep_j.dig(:vulnerabilities, 0, :severity) || :info
::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_j] <=> ::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_i] ::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_j] <=> ::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_i]
end end
......
...@@ -41,7 +41,7 @@ module API ...@@ -41,7 +41,7 @@ module API
optional :severity, optional :severity,
type: Array[String], type: Array[String],
desc: 'Returns vulnerabilities belonging to specified severity level: '\ desc: 'Returns vulnerabilities belonging to specified severity level: '\
'`undefined`, `info`, `unknown`, `low`, `medium`, `high`, or `critical`. Defaults to all', '`info`, `unknown`, `low`, `medium`, `high`, or `critical`. Defaults to all',
values: ::Vulnerabilities::Occurrence.severities.keys, values: ::Vulnerabilities::Occurrence.severities.keys,
default: ::Vulnerabilities::Occurrence.severities.keys default: ::Vulnerabilities::Occurrence.severities.keys
optional :confidence, optional :confidence,
......
...@@ -29,7 +29,7 @@ module Gitlab ...@@ -29,7 +29,7 @@ module Gitlab
end end
def cached_vulnerability_history def cached_vulnerability_history
history = { undefined: {}, info: {}, unknown: {}, low: {}, medium: {}, high: {}, critical: {}, total: {} } history = { info: {}, unknown: {}, low: {}, medium: {}, high: {}, critical: {}, total: {} }
project_ids_to_fetch.each do |project_id| project_ids_to_fetch.each do |project_id|
project_history = Gitlab::Vulnerabilities::HistoryCache.new(vulnerable, project_id).fetch(HISTORY_RANGE) project_history = Gitlab::Vulnerabilities::HistoryCache.new(vulnerable, project_id).fetch(HISTORY_RANGE)
......
...@@ -21,7 +21,6 @@ module Gitlab ...@@ -21,7 +21,6 @@ module Gitlab
def cached_vulnerability_summary def cached_vulnerability_summary
summary = { summary = {
undefined: 0,
info: 0, info: 0,
unknown: 0, unknown: 0,
low: 0, low: 0,
......
...@@ -103,7 +103,6 @@ describe Groups::Security::VulnerabilityFindingsController do ...@@ -103,7 +103,6 @@ describe Groups::Security::VulnerabilityFindingsController do
end end
expect(json_response).to eq({ expect(json_response).to eq({
"undefined" => {},
"info" => {}, "info" => {},
"unknown" => {}, "unknown" => {},
"low" => {}, "low" => {},
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
describe Vulnerability do describe Vulnerability do
let(:state_values) { { detected: 1, dismissed: 2, resolved: 3, confirmed: 4 } } let(:state_values) { { detected: 1, dismissed: 2, resolved: 3, confirmed: 4 } }
let(:severity_values) { { undefined: 0, info: 1, unknown: 2, low: 4, medium: 5, high: 6, critical: 7 } } let(:severity_values) { { info: 1, unknown: 2, low: 4, medium: 5, high: 6, critical: 7 } }
let(:confidence_values) do let(:confidence_values) do
{ undefined: 0, ignore: 1, unknown: 2, experimental: 3, low: 4, medium: 5, high: 6, confirmed: 7 } { undefined: 0, ignore: 1, unknown: 2, experimental: 3, low: 4, medium: 5, high: 6, confirmed: 7 }
......
...@@ -302,7 +302,6 @@ describe 'GET /-/security/vulnerability_findings/history' do ...@@ -302,7 +302,6 @@ describe 'GET /-/security/vulnerability_findings/history' do
end end
expect(json_response).to eq({ expect(json_response).to eq({
"undefined" => {},
"info" => {}, "info" => {},
"unknown" => {}, "unknown" => {},
"low" => {}, "low" => {},
......
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