Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check DB versions before CERT severity updates #1376

Merged
merged 2 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix severity_in_level SQL function [#1312](https://github.com/greenbone/gvmd/pull/1312)
- Fix and simplify SecInfo migration [#1331](https://github.com/greenbone/gvmd/pull/1331)
- Prevent CPE/NVD_ID from being "(null)" [#1369](https://github.com/greenbone/gvmd/pull/1369)
- Check DB versions before CERT severity updates [#1376](https://github.com/greenbone/gvmd/pull/1376)

### Removed
- Remove solution element from VT tags [#886](https://github.com/greenbone/gvmd/pull/886)
Expand Down
31 changes: 28 additions & 3 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4397,6 +4397,7 @@ update_cvss_cert_bund (int updated_cert_bund, int last_cert_update,
static int
sync_cert ()
{
int scap_db_version;
int last_feed_update, last_cert_update, updated_dfn_cert;
int updated_cert_bund;

Expand Down Expand Up @@ -4458,7 +4459,19 @@ sync_cert ()

g_debug ("%s: update cvss", __func__);

if (manage_scap_loaded ())
/* Update CERT data that depends on SCAP. */
scap_db_version = manage_scap_db_version();

if (scap_db_version == -1)
g_info ("SCAP database does not exist (yet),"
" skipping CERT severity score update");
else if (scap_db_version < GVMD_SCAP_DATABASE_VERSION)
g_info ("SCAP database has to be migrated,"
" skipping CERT severity score update");
else if (scap_db_version > GVMD_SCAP_DATABASE_VERSION)
g_warning ("SCAP database is newer than supported version,"
" skipping CERT severity score update");
else
{
int last_scap_update;

Expand Down Expand Up @@ -4644,6 +4657,8 @@ update_scap_placeholders ()
static int
update_scap_end ()
{
int cert_db_version;

g_debug ("%s: update timestamp", __func__);

if (update_scap_timestamp ())
Expand All @@ -4666,8 +4681,18 @@ update_scap_end ()
sql ("ALTER SCHEMA scap2 RENAME TO scap;");

/* Update CERT data that depends on SCAP. */

if (manage_cert_loaded ())
cert_db_version = manage_cert_db_version();

if (cert_db_version == -1)
g_info ("CERT database does not exist (yet),"
" skipping CERT severity score update");
else if (cert_db_version < GVMD_CERT_DATABASE_VERSION)
g_info ("CERT database has to be migrated,"
" skipping CERT severity score update");
else if (cert_db_version > GVMD_CERT_DATABASE_VERSION)
g_warning ("CERT database is newer than supported version,"
" skipping CERT severity score update");
else
{
int last_cert_update, last_scap_update;

Expand Down