Skip to content

Commit

Permalink
Merge branch 'main' into cache-pref-counts
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmundell authored Oct 26, 2023
2 parents fbc4d15 + e2c5ac0 commit 268228c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cmake_minimum_required (VERSION 3.0)
message ("-- Configuring Greenbone Vulnerability Manager...")

project (gvm
VERSION 23.0.1
VERSION 23.0.2
LANGUAGES C)

if (POLICY CMP0005)
Expand Down
18 changes: 10 additions & 8 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -5834,7 +5834,6 @@ get_nvt_xml (iterator_t *nvts, int details, int pref_count,
"<modification_time>%s</modification_time>"
"<category>%d</category>"
"<family>%s</family>"
"<cvss_base>%s</cvss_base>"
"<qod>"
"<value>%s</value>"
"<type>%s</type>"
Expand All @@ -5850,9 +5849,6 @@ get_nvt_xml (iterator_t *nvts, int details, int pref_count,
: "",
nvt_iterator_category (nvts),
family_text,
nvt_iterator_cvss_base (nvts)
? nvt_iterator_cvss_base (nvts)
: "",
nvt_iterator_qod (nvts),
nvt_iterator_qod_type (nvts),
refs_str->str,
Expand All @@ -5861,7 +5857,7 @@ get_nvt_xml (iterator_t *nvts, int details, int pref_count,
}

g_string_append_printf (buffer,
"<severities score=\"%s\">",
"<cvss_base>%s</cvss_base>",
nvt_iterator_cvss_base (nvts)
? nvt_iterator_cvss_base (nvts)
: "");
Expand All @@ -5870,6 +5866,12 @@ get_nvt_xml (iterator_t *nvts, int details, int pref_count,
{
iterator_t severities;

g_string_append_printf (buffer,
"<severities score=\"%s\">",
nvt_iterator_cvss_base (nvts)
? nvt_iterator_cvss_base (nvts)
: "");

init_nvt_severity_iterator (&severities, oid);
while (next (&severities))
{
Expand All @@ -5888,10 +5890,10 @@ get_nvt_xml (iterator_t *nvts, int details, int pref_count,
nvt_severity_iterator_value (&severities));
}
cleanup_iterator (&severities);
}

g_string_append_printf (buffer,
"</severities>");
g_string_append_printf (buffer,
"</severities>");
}

g_free (family_text);
g_string_free (nvt_tags, 1);
Expand Down
49 changes: 31 additions & 18 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -27503,6 +27503,22 @@ init_v2_delta_iterator (report_t report, iterator_t *results, report_t delta,
"nvts_cols");

extra_with = g_strdup_printf(" comparison AS ("
" WITH r1 as (SELECT results.id, description, host, report, port,"
" severity, nvt, results.qod, results.uuid, hostname,"
" path, r1_lateral.new_severity as new_severity "
" FROM results "
" LEFT JOIN (SELECT cvss_base, oid AS nvts_oid from nvts)"
" AS nvts_cols"
" ON nvts_cols.nvts_oid = results.nvt"
" %s, LATERAL %s AS r1_lateral"
" WHERE report = %llu),"
" r2 as (SELECT results.*, r2_lateral.new_severity AS new_severity"
" FROM results"
" LEFT JOIN (SELECT cvss_base, oid AS nvts_oid from nvts)"
" AS nvts_cols"
" ON nvts_cols.nvts_oid = results.nvt"
" %s, LATERAL %s AS r2_lateral"
" WHERE report = %llu)"
" SELECT r1.id AS result1_id,"
" r2.id AS result2_id,"
" compare_results("
Expand Down Expand Up @@ -27531,28 +27547,25 @@ init_v2_delta_iterator (report_t report, iterator_t *results, report_t delta,
RESULT_HOSTNAME_SQL("r2.hostname", "r2.host", "r2.report")
" AS delta_hostname,"
" r2.nvt_version AS delta_nvt_version"
" FROM (SELECT results.id, description, host, report, port,"
" severity, nvt, results.qod, results.uuid, hostname,"
" path, r1_lateral.new_severity as new_severity "
" FROM results "
" LEFT JOIN (SELECT cvss_base, oid AS nvts_oid from nvts)"
" AS nvts_cols"
" ON nvts_cols.nvts_oid = results.nvt"
" %s, LATERAL %s AS r1_lateral"
" WHERE report = %llu)"
" AS r1"
" FULL OUTER JOIN (SELECT results.*, r2_lateral.new_severity AS new_severity"
" FROM results"
" LEFT JOIN (SELECT cvss_base, oid AS nvts_oid from nvts)"
" AS nvts_cols"
" ON nvts_cols.nvts_oid = results.nvt"
" %s, LATERAL %s AS r2_lateral"
" WHERE report = %llu)"
" AS r2"
" FROM r1"
" FULL OUTER JOIN r2"
" ON r1.host = r2.host"
" AND normalize_port(r1.port) = normalize_port(r2.port)"
" AND r1.nvt = r2.nvt "
" AND (r1.new_severity = 0) = (r2.new_severity = 0)"
" AND (r1.description = r2.description"
" OR NOT EXISTS (SELECT * FROM r2"
" WHERE r1.description = r2.description"
" AND r1.host = r2.host"
" AND normalize_port(r1.port) = normalize_port(r2.port)"
" AND r1.nvt = r2.nvt"
" AND (r1.new_severity = 0) = (r2.new_severity = 0))"
" OR NOT EXISTS (SELECT * FROM r1"
" WHERE r1.description = r2.description"
" AND r1.host = r2.host"
" AND normalize_port(r1.port) = normalize_port(r2.port)"
" AND r1.nvt = r2.nvt"
" AND (r1.new_severity = 0) = (r2.new_severity = 0)))"
" )",
opts_tables,
with_lateral,
Expand Down
4 changes: 2 additions & 2 deletions src/manage_sql_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ init_nvt_preference_iterator (iterator_t* iterator, const char *oid)
" AND name != 'nasl_no_signature_check'"
" AND name != 'network_targets'"
" AND name != 'ntp_save_sessions'"
" AND name != '%s:0:entry:Timeout'"
" AND name != '%s:0:entry:timeout'"
" AND name NOT %s 'server_info_%%'"
/* Task preferences. */
" AND name != 'max_checks'"
Expand All @@ -1782,7 +1782,7 @@ init_nvt_preference_iterator (iterator_t* iterator, const char *oid)
" AND name != 'nasl_no_signature_check'"
" AND name != 'network_targets'"
" AND name != 'ntp_save_sessions'"
" AND name NOT %s '%%:0:entry:Timeout'"
" AND name NOT %s '%%:0:entry:timeout'"
" AND name NOT %s 'server_info_%%'"
/* Task preferences. */
" AND name != 'max_checks'"
Expand Down
2 changes: 1 addition & 1 deletion src/manage_sql_nvts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ char *
nvt_default_timeout (const char* oid)
{
return sql_string ("SELECT value FROM nvt_preferences"
" WHERE name = '%s:0:entry:Timeout'",
" WHERE name = '%s:0:entry:timeout'",
oid);
}

Expand Down

0 comments on commit 268228c

Please sign in to comment.