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

Fix SQL errors in SCAP and CERT update (20.08) #1343

Merged
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 @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Always check for 'All' when deleting selectors [#1342](https://github.com/greenbone/gvmd/pull/1342)
- Do not inherit settings from deleted users [#1328](https://github.com/greenbone/gvmd/pull/1328)
- Delete TLS certificate sources when deleting users [#1334](https://github.com/greenbone/gvmd/pull/1334)
- Fix SQL errors in SCAP and CERT update [#1343](https://github.com/greenbone/gvmd/pull/1343)

### Removed
- Remove DROP from vulns creation [#1281](http://github.com/greenbone/gvmd/pull/1281)
Expand Down
20 changes: 10 additions & 10 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -32882,7 +32882,7 @@ check_for_new_scap ()
if (manage_scap_loaded ())
{
if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cves"
" (SELECT * FROM scap.cves"
" WHERE creation_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -32892,7 +32892,7 @@ check_for_new_scap ()
event (EVENT_NEW_SECINFO, "cve", 0, 0);

if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cpes"
" (SELECT * FROM scap.cpes"
" WHERE creation_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -32902,7 +32902,7 @@ check_for_new_scap ()
event (EVENT_NEW_SECINFO, "cpe", 0, 0);

if (sql_int ("SELECT EXISTS"
" (SELECT * FROM ovaldefs"
" (SELECT * FROM scap.ovaldefs"
" WHERE creation_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -32922,7 +32922,7 @@ check_for_new_cert ()
if (manage_cert_loaded ())
{
if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cert_bund_advs"
" (SELECT * FROM cert.cert_bund_advs"
" WHERE creation_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -32932,7 +32932,7 @@ check_for_new_cert ()
event (EVENT_NEW_SECINFO, "cert_bund_adv", 0, 0);

if (sql_int ("SELECT EXISTS"
" (SELECT * FROM dfn_cert_advs"
" (SELECT * FROM cert.dfn_cert_advs"
" WHERE creation_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand Down Expand Up @@ -33642,7 +33642,7 @@ check_for_updated_scap ()
if (manage_scap_loaded ())
{
if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cves"
" (SELECT * FROM scap.cves"
" WHERE modification_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -33658,7 +33658,7 @@ check_for_updated_scap ()
event (EVENT_UPDATED_SECINFO, "cve", 0, 0);

if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cpes"
" (SELECT * FROM scap.cpes"
" WHERE modification_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -33674,7 +33674,7 @@ check_for_updated_scap ()
event (EVENT_UPDATED_SECINFO, "cpe", 0, 0);

if (sql_int ("SELECT EXISTS"
" (SELECT * FROM ovaldefs"
" (SELECT * FROM scap.ovaldefs"
" WHERE modification_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -33700,7 +33700,7 @@ check_for_updated_cert ()
if (manage_cert_loaded ())
{
if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cert_bund_advs"
" (SELECT * FROM cert.cert_bund_advs"
" WHERE modification_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -33716,7 +33716,7 @@ check_for_updated_cert ()
event (EVENT_UPDATED_SECINFO, "cert_bund_adv", 0, 0);

if (sql_int ("SELECT EXISTS"
" (SELECT * FROM dfn_cert_advs"
" (SELECT * FROM cert.dfn_cert_advs"
" WHERE modification_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand Down
25 changes: 17 additions & 8 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4445,7 +4445,7 @@ update_cvss_cert_bund (int updated_cert_bund, int last_cert_update,
static int
sync_cert ()
{
int last_feed_update, last_cert_update, last_scap_update, updated_dfn_cert;
int last_feed_update, last_cert_update, updated_dfn_cert;
int updated_cert_bund;

if (manage_cert_db_exists ())
Expand Down Expand Up @@ -4506,15 +4506,24 @@ sync_cert ()

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

last_scap_update = 0;
if (manage_scap_loaded ())
last_scap_update = sql_int ("SELECT coalesce ((SELECT value FROM scap.meta"
" WHERE name = 'last_update'),"
" '0');");
g_debug ("%s: last_scap_update: %i", __func__, last_scap_update);
{
int last_scap_update;

update_cvss_dfn_cert (updated_dfn_cert, last_cert_update, last_scap_update);
update_cvss_cert_bund (updated_cert_bund, last_cert_update, last_scap_update);
last_scap_update
= sql_int ("SELECT coalesce ((SELECT value FROM scap.meta"
" WHERE name = 'last_update'),"
" '0');");
g_debug ("%s: last_scap_update: %i", __func__, last_scap_update);
g_debug ("%s: last_cert_update: %i", __func__, last_cert_update);

update_cvss_dfn_cert (updated_dfn_cert,
last_cert_update,
last_scap_update);
update_cvss_cert_bund (updated_cert_bund,
last_cert_update,
last_scap_update);
}

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

Expand Down