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

Init SCAP directly before XML sync, in case CSV sync fails #1137

Merged
merged 2 commits into from
Jun 17, 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
2 changes: 1 addition & 1 deletion src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3132,7 +3132,7 @@ manage_db_init (const gchar *name)
" false);");

sql ("SELECT drop_scap2 ();");
sql ("DROP FUNCTION drop_scap2 ();");
sql ("DROP FUNCTION IF EXISTS drop_scap2 ();");

sql ("CREATE SCHEMA scap2;");

Expand Down
18 changes: 13 additions & 5 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4710,6 +4710,14 @@ try_load_csv ()
&& g_file_test (file_ovalfiles, G_FILE_TEST_EXISTS)
&& g_file_test (file_affected_ovaldefs, G_FILE_TEST_EXISTS))
{
/* Create a new schema, "scap2". */

if (manage_db_init ("scap"))
{
g_warning ("%s: could not initialize SCAP database 2", __func__);
return -1;
}

sql ("COPY scap2.cves FROM '%s' WITH (FORMAT csv);", file_cves);
g_free (file_cves);

Expand Down Expand Up @@ -4808,6 +4816,11 @@ update_scap (gboolean reset_scap_db)
}
}

/* If there's CSV in the feed, just load it. */

if (try_load_csv () == 0)
return 0;

/* Create a new schema, "scap2". */

if (manage_db_init ("scap"))
Expand All @@ -4816,11 +4829,6 @@ update_scap (gboolean reset_scap_db)
return -1;
}

/* If there's CSV in the feed, just load it. */

if (try_load_csv () == 0)
return 0;

/* Add the indexes and constraints. */

g_debug ("%s: add indexes", __func__);
Expand Down