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

Now the CPE dictionary is no longer continuously parsed again if the dictionary is corrupt. #2127

Merged
merged 2 commits into from
Jan 19, 2024
Merged
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
65 changes: 35 additions & 30 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,7 @@ check_cert_db_version ()
*
* @return 0 success, -1 error.
*/
static int
static void
update_cert_timestamp ()
{
GError *error;
Expand All @@ -3082,7 +3082,7 @@ update_cert_timestamp ()
g_warning ("%s: Failed to get timestamp: %s",
__func__,
error->message);
return -1;
stamp = time(NULL);
}
}
else
Expand All @@ -3093,22 +3093,22 @@ update_cert_timestamp ()
__func__,
timestamp);
g_free (timestamp);
return -1;
stamp = time(NULL);
}
else
{
timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
stamp = time(NULL);
}

timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
return -1;
}

g_debug ("%s: setting last_update: %lld", __func__, (long long) stamp);
sql ("UPDATE cert.meta SET value = '%lld' WHERE name = 'last_update';",
(long long) stamp);

return 0;
}

/**
Expand Down Expand Up @@ -3276,14 +3276,14 @@ sync_cert ()

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

if (update_cert_timestamp ())
goto fail;
update_cert_timestamp ();

g_info ("%s: Updating CERT info succeeded.", __func__);

return 0;

fail:
update_cert_timestamp ();
return -1;
}

Expand Down Expand Up @@ -3333,7 +3333,7 @@ check_scap_db_version ()
*
* @return 0 success, -1 error.
*/
static int
static void
update_scap_timestamp ()
{
GError *error;
Expand All @@ -3353,7 +3353,7 @@ update_scap_timestamp ()
g_warning ("%s: Failed to get timestamp: %s",
__func__,
error->message);
return -1;
stamp = time(NULL);
}
}
else
Expand All @@ -3364,22 +3364,22 @@ update_scap_timestamp ()
__func__,
timestamp);
g_free (timestamp);
return -1;
stamp = time(NULL);
}
else
{
timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
stamp = time(NULL);
}

timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
return -1;
}

g_debug ("%s: setting last_update: %lld", __func__, (long long) stamp);
sql ("UPDATE scap2.meta SET value = '%lld' WHERE name = 'last_update';",
(long long) stamp);

return 0;
}

/**
Expand Down Expand Up @@ -3436,8 +3436,7 @@ update_scap_end ()

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

if (update_scap_timestamp ())
return -1;
update_scap_timestamp ();

/* Replace the real scap schema with the new one. */

Expand Down Expand Up @@ -3657,13 +3656,19 @@ update_scap (gboolean reset_scap_db)
setproctitle ("Syncing SCAP: Updating CPEs");

if (update_scap_cpes () == -1)
return -1;
{
update_scap_timestamp ();
return -1;
}

g_debug ("%s: update cves", __func__);
setproctitle ("Syncing SCAP: Updating CVEs");

if (update_scap_cves () == -1)
return -1;
{
update_scap_timestamp ();
return -1;
}

g_debug ("%s: updating user defined data", __func__);

Expand Down
Loading