Skip to content

Commit

Permalink
Merge pull request #1316 from janowagner/drop_severity_debug
Browse files Browse the repository at this point in the history
Drop severity type "debug"
  • Loading branch information
mattmundell authored Oct 12, 2020
2 parents b174ef2 + 4e09687 commit 3867d22
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 245 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Removed Severity Classes [#1288](https://github.com/greenbone/gvmd/pull/1288)
- Remove remaining use of "Severity Class" in where_levels_auto [#1311](https://github.com/greenbone/gvmd/pull/1311)
- Remove the functionality "autofp" (Auto False Positives) [#1300](https://github.com/greenbone/gvmd/pull/1300)
- Remove severity type "debug" [#1316](https://github.com/greenbone/gvmd/pull/1316)

[21.4]: https://github.com/greenbone/gvmd/compare/gvmd-20.08...master

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2009-2019 Greenbone Networks GmbH
# Copyright (C) 2009-2020 Greenbone Networks GmbH
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
Expand Down Expand Up @@ -96,7 +96,7 @@ include (CPack)

## Variables

set (GVMD_DATABASE_VERSION 235)
set (GVMD_DATABASE_VERSION 236)

set (GVMD_SCAP_DATABASE_VERSION 16)

Expand Down
10 changes: 4 additions & 6 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17039,7 +17039,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
report_t running_report;
char *owner, *observers;
int target_in_trash, scanner_in_trash;
int debugs, holes = 0, infos = 0, logs, warnings = 0;
int holes = 0, infos = 0, logs, warnings = 0;
int holes_2 = 0, infos_2 = 0, warnings_2 = 0;
int false_positives, task_scanner_type;
int target_available, config_available;
Expand Down Expand Up @@ -17148,7 +17148,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
{
// TODO Could skip this count for tasks page.
if (report_counts (first_report_id,
&debugs, &holes_2, &infos_2, &logs,
&holes_2, &infos_2, &logs,
&warnings_2, &false_positives,
&severity_2, apply_overrides, min_qod))
g_error ("%s: GET_TASKS: error getting counts for"
Expand All @@ -17164,7 +17164,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
if (((first_report_id == NULL)
|| (strcmp (second_last_report_id, first_report_id)))
&& report_counts (second_last_report_id,
&debugs, &holes_2, &infos_2,
&holes_2, &infos_2,
&logs, &warnings_2,
&false_positives, &severity_2,
apply_overrides, min_qod))
Expand Down Expand Up @@ -17218,7 +17218,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
{
if (report_counts
(last_report_id,
&debugs, &holes, &infos, &logs,
&holes, &infos, &logs,
&warnings, &false_positives, &severity,
apply_overrides, min_qod))
g_error ("%s: GET_TASKS: error getting counts for"
Expand Down Expand Up @@ -17279,7 +17279,6 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
"<scan_start>%s</scan_start>"
"<scan_end>%s</scan_end>"
"<result_count>"
"<debug>%i</debug>"
"<hole>%i</hole>"
"<info>%i</info>"
"<log>%i</log>"
Expand All @@ -17297,7 +17296,6 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
timestamp,
scan_start,
scan_end,
debugs,
holes,
infos,
logs,
Expand Down
20 changes: 2 additions & 18 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,6 @@ threat_message_type (const char *threat)
return "Alarm";
if (strcasecmp (threat, "Log") == 0)
return "Log Message";
if (strcasecmp (threat, "Debug") == 0)
return "Debug Message";
if (strcasecmp (threat, "Error") == 0)
return "Error Message";
if (strcasecmp (threat, "False Positive") == 0)
Expand Down Expand Up @@ -833,8 +831,6 @@ message_type_threat (const char *type)
return "Low";
if (strcasecmp (type, "Log Message") == 0)
return "Log";
if (strcasecmp (type, "Debug Message") == 0)
return "Debug";
if (strcasecmp (type, "Error Message") == 0)
return "Error";
if (strcasecmp (type, "False Positive") == 0)
Expand Down Expand Up @@ -880,8 +876,6 @@ severity_to_level (double severity, int mode)
return "Log";
else if (severity == SEVERITY_FP)
return "False Positive";
else if (severity == SEVERITY_DEBUG)
return "Debug";
else if (severity == SEVERITY_ERROR)
return "Error";
else if (severity > 0.0 && severity <= 10.0)
Expand Down Expand Up @@ -919,8 +913,6 @@ severity_to_type (double severity)
return "Log Message";
else if (severity == SEVERITY_FP)
return "False Positive";
else if (severity == SEVERITY_DEBUG)
return "Debug Message";
else if (severity == SEVERITY_ERROR)
return "Error Message";
else if (severity > 0.0 && severity <= 10.0)
Expand Down Expand Up @@ -1031,8 +1023,7 @@ severity_data_index (double severity)
int ret;
if (severity >= 0.0)
ret = (int)(round (severity * SEVERITY_SUBDIVISIONS)) + ZERO_SEVERITY_INDEX;
else if (severity == SEVERITY_FP || severity == SEVERITY_DEBUG
|| severity == SEVERITY_ERROR)
else if (severity == SEVERITY_FP || severity == SEVERITY_ERROR)
ret = (int)(round (severity)) + ZERO_SEVERITY_INDEX;
else
ret = 0;
Expand Down Expand Up @@ -1158,7 +1149,6 @@ severity_data_range_count (const severity_data_t* severity_data,
*
* @param[in] severity_data The severity counts data to evaluate.
* @param[out] errors The number of error messages.
* @param[out] debugs The number of debug messages.
* @param[out] false_positives The number of False Positives.
* @param[out] logs The number of Log messages.
* @param[out] lows The number of Low severity results.
Expand All @@ -1167,7 +1157,7 @@ severity_data_range_count (const severity_data_t* severity_data,
*/
void
severity_data_level_counts (const severity_data_t *severity_data,
int *errors, int *debugs, int *false_positives,
int *errors, int *false_positives,
int *logs, int *lows, int *mediums, int *highs)
{
if (errors)
Expand All @@ -1176,12 +1166,6 @@ severity_data_level_counts (const severity_data_t *severity_data,
level_min_severity ("Error"),
level_max_severity ("Error"));

if (debugs)
*debugs
= severity_data_range_count (severity_data,
level_min_severity ("Debug"),
level_max_severity ("Debug"));

if (false_positives)
*false_positives
= severity_data_range_count (severity_data,
Expand Down
6 changes: 3 additions & 3 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ severity_data_add_count (severity_data_t*, double, int);

void
severity_data_level_counts (const severity_data_t*,
int*, int*, int*, int*, int*, int*, int*);
int*, int*, int*, int*, int*, int*);


/* General task facilities. */
Expand Down Expand Up @@ -1255,11 +1255,11 @@ report_scan_result_count (report_t, const char*, const char*, int, const char*,
const char*, int, int, int*);

int
report_counts (const char*, int*, int*, int*, int*, int*, int*, double*,
report_counts (const char*, int*, int*, int*, int*, int*, double*,
int, int);

int
report_counts_id (report_t, int*, int*, int*, int*, int*, int*, double*,
report_counts_id (report_t, int*, int*, int*, int*, int*, double*,
const get_data_t*, const char*);

int
Expand Down
37 changes: 36 additions & 1 deletion src/manage_migrators.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2013-2019 Greenbone Networks GmbH
/* Copyright (C) 2013-2020 Greenbone Networks GmbH
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*
Expand Down Expand Up @@ -2391,6 +2391,40 @@ migrate_234_to_235 ()
return 0;
}

/**
* @brief Migrate the database from version 235 to version 236.
*
* @return 0 success, -1 error.
*/
int
migrate_235_to_236 ()
{
sql_begin_immediate ();

/* Ensure that the database is currently version 235. */

if (manage_db_version () != 235)
{
sql_rollback ();
return -1;
}

/* Update the database. */

/* Replace any result type "Debug Message" by "Error Message". */

sql ("UPDATE results SET type = 'Error Message' WHERE type = 'Debug Message';");
sql ("UPDATE results_trash SET type = 'Error Message' WHERE type = 'Debug Message';");

/* Set the database version to 236. */

set_db_version (236);

sql_commit ();

return 0;
}

#undef UPDATE_DASHBOARD_SETTINGS

/**
Expand Down Expand Up @@ -2432,6 +2466,7 @@ static migrator_t database_migrators[] = {
{233, migrate_232_to_233},
{234, migrate_233_to_234},
{235, migrate_234_to_235},
{236, migrate_235_to_236},
/* End marker. */
{-1, NULL}};

Expand Down
40 changes: 3 additions & 37 deletions src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ manage_create_sql_functions ()
" v := " G_STRINGIFY (SEVERITY_LOG) ";"
" WHEN lower (lvl) = 'false positive' THEN"
" v := " G_STRINGIFY (SEVERITY_FP) ";"
" WHEN lower (lvl) = 'debug' THEN"
" v := " G_STRINGIFY (SEVERITY_DEBUG) ";"
" WHEN lower (lvl) = 'error' THEN"
" v := " G_STRINGIFY (SEVERITY_ERROR) ";"
" ELSE"
Expand Down Expand Up @@ -260,8 +258,6 @@ manage_create_sql_functions ()
" v := " G_STRINGIFY (SEVERITY_LOG) ";"
" WHEN lower (lvl) = 'false positive' THEN"
" v := " G_STRINGIFY (SEVERITY_FP) ";"
" WHEN lower (lvl) = 'debug' THEN"
" v := " G_STRINGIFY (SEVERITY_DEBUG) ";"
" WHEN lower (lvl) = 'error' THEN"
" v := " G_STRINGIFY (SEVERITY_ERROR) ";"
" ELSE"
Expand Down Expand Up @@ -485,28 +481,6 @@ manage_create_sql_functions ()
"$$ LANGUAGE plpgsql"
" IMMUTABLE;");

sql ("CREATE OR REPLACE FUNCTION order_message_type (text)"
" RETURNS integer AS $$"
" BEGIN"
" IF $1 = 'Security Hole' THEN"
" RETURN 1;"
" ELSIF $1 = 'Security Warning' THEN"
" RETURN 2;"
" ELSIF $1 = 'Security Note' THEN"
" RETURN 3;"
" ELSIF $1 = 'Log Message' THEN"
" RETURN 4;"
" ELSIF $1 = 'Debug Message' THEN"
" RETURN 5;"
" ELSIF $1 = 'Error Message' THEN"
" RETURN 6;"
" ELSE"
" RETURN 7;"
" END IF;"
" END;"
"$$ LANGUAGE plpgsql"
" IMMUTABLE;");

sql ("CREATE OR REPLACE FUNCTION order_port (text)"
" RETURNS integer AS $$"
" BEGIN"
Expand Down Expand Up @@ -544,14 +518,12 @@ manage_create_sql_functions ()
" RETURN 3;"
" ELSIF $1 = 'Log' THEN"
" RETURN 4;"
" ELSIF $1 = 'Debug' THEN"
" RETURN 5;"
" ELSIF $1 = 'False Positive' THEN"
" RETURN 6;"
" RETURN 5;"
" ELSIF $1 = 'None' THEN"
" RETURN 7;"
" RETURN 6;"
" ELSE"
" RETURN 8;"
" RETURN 7;"
" END IF;"
" END;"
"$$ LANGUAGE plpgsql"
Expand All @@ -566,8 +538,6 @@ manage_create_sql_functions ()
" RETURN 'Log Message';"
" ELSIF $1 = " G_STRINGIFY (SEVERITY_FP) " THEN"
" RETURN 'False Positive';"
" ELSIF $1 = " G_STRINGIFY (SEVERITY_DEBUG) " THEN"
" RETURN 'Debug Message';"
" ELSIF $1 = " G_STRINGIFY (SEVERITY_ERROR) " THEN"
" RETURN 'Error Message';"
" ELSIF $1 > 0.0 AND $1 <= 10.0 THEN"
Expand Down Expand Up @@ -1468,8 +1438,6 @@ manage_create_sql_functions ()
" THEN 'Log'"
" WHEN $1::double precision = " G_STRINGIFY (SEVERITY_FP)
" THEN 'False Positive'"
" WHEN $1::double precision = " G_STRINGIFY (SEVERITY_DEBUG)
" THEN 'Debug'"
" WHEN $1::double precision = " G_STRINGIFY (SEVERITY_ERROR)
" THEN 'Error'"
" WHEN $1::double precision > 0.0"
Expand Down Expand Up @@ -1501,8 +1469,6 @@ manage_create_sql_functions ()
" THEN 'Log'"
" WHEN $1 = " G_STRINGIFY (SEVERITY_FP)
" THEN 'False Positive'"
" WHEN $1 = " G_STRINGIFY (SEVERITY_DEBUG)
" THEN 'Debug'"
" WHEN $1 = " G_STRINGIFY (SEVERITY_ERROR)
" THEN 'Error'"
" WHEN $1 > 0.0 AND $1 <= 10.0"
Expand Down
Loading

0 comments on commit 3867d22

Please sign in to comment.