Commit 2823acc2 authored by celdem's avatar celdem

Cleanup undefined severity and confidence level from code

parent 55d0427e
......@@ -39,7 +39,7 @@ module Vulnerabilities
}.with_indifferent_access.freeze
SEVERITY_LEVELS = {
undefined: 0,
# undefined: 0, no longer applicable
info: 1,
unknown: 2,
# experimental: 3, formerly used by confidence, no longer applicable
......
......@@ -72,8 +72,8 @@ module Security
# will have highest severity
def sort_by_severity(collection)
collection.sort do |dep_i, dep_j|
level_i = dep_i.dig(:vulnerabilities, 0, :severity) || :undefined
level_j = dep_j.dig(:vulnerabilities, 0, :severity) || :undefined
level_i = dep_i.dig(:vulnerabilities, 0, :severity) || :unknown
level_j = dep_j.dig(:vulnerabilities, 0, :severity) || :unknown
::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_j] <=> ::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_i]
end
......
......@@ -41,7 +41,7 @@ module API
optional :severity,
type: Array[String],
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,
default: ::Vulnerabilities::Occurrence.severities.keys
optional :confidence,
......
......@@ -29,7 +29,7 @@ module Gitlab
end
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_history = Gitlab::Vulnerabilities::HistoryCache.new(vulnerable, project_id).fetch(HISTORY_RANGE)
......
......@@ -21,7 +21,6 @@ module Gitlab
def cached_vulnerability_summary
summary = {
undefined: 0,
info: 0,
unknown: 0,
low: 0,
......
......@@ -103,7 +103,6 @@ describe Groups::Security::VulnerabilityFindingsController do
end
expect(json_response).to eq({
"undefined" => {},
"info" => {},
"unknown" => {},
"low" => {},
......
......@@ -117,7 +117,7 @@ describe Projects::DependenciesController do
it 'returns sorted list' do
expect(json_response['dependencies'].first['name']).to eq('nokogiri')
expect(json_response['dependencies'].second['name']).to eq('debug')
expect(json_response['dependencies'].second['name']).to eq('mini_portile2')
end
end
end
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
describe Vulnerability do
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
{ 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
end
expect(json_response).to eq({
"undefined" => {},
"info" => {},
"unknown" => {},
"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