[Openvas-commits] r11586 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 7 19:44:41 CEST 2011
Author: mattm
Date: 2011-09-07 19:44:40 +0200 (Wed, 07 Sep 2011)
New Revision: 11586
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage_sql.c
Log:
* src/manage_sql.c (scap_loaded): New variable.
(init_manage_process): Set scap_loaded when SCAP db present.
(print_report_xml): Only send SCAP data when db present.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2011-09-07 15:58:38 UTC (rev 11585)
+++ trunk/openvas-manager/ChangeLog 2011-09-07 17:44:40 UTC (rev 11586)
@@ -1,5 +1,11 @@
2011-09-07 Matthew Mundell <matthew.mundell at greenbone.net>
+ * src/manage_sql.c (scap_loaded): New variable.
+ (init_manage_process): Set scap_loaded when SCAP db present.
+ (print_report_xml): Only send SCAP data when db present.
+
+2011-09-07 Matthew Mundell <matthew.mundell at greenbone.net>
+
* src/manage_sql.c (cvss_threat): New function.
(init_manage_process): Attach SCAP database.
(DEF_ACCESS): New macro.
Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c 2011-09-07 15:58:38 UTC (rev 11585)
+++ trunk/openvas-manager/src/manage_sql.c 2011-09-07 17:44:40 UTC (rev 11586)
@@ -264,6 +264,11 @@
*/
gchar* task_db_name = NULL;
+/**
+ * @brief Whether the SCAP database was present.
+ */
+static int scap_loaded = 0;
+
/* SQL helpers. */
@@ -7552,8 +7557,6 @@
}
#endif /* not S_SPLINT_S */
- /* Attach the SCAP database. */
-
if (update_nvt_cache)
{
if (update_nvt_cache == -2)
@@ -7566,11 +7569,32 @@
}
else
{
+ struct stat state;
+ int err;
+
+ /* Attach the SCAP database. */
+
+ err = stat (OPENVAS_STATE_DIR "/scap-data/scap.db", &state);
+ if (err)
+ switch (errno)
+ {
+ case ENOENT:
+ break;
+ default:
+ g_warning ("%s: failed to stat SCAP database: %s\n",
+ __FUNCTION__,
+ strerror (errno));
+ abort ();
+ }
+ else
+ {
+ sql ("ATTACH database '" OPENVAS_STATE_DIR "/scap-data/scap.db'"
+ " AS scap;");
+ scap_loaded = 1;
+ }
+
/* Define functions for SQL. */
- sql ("ATTACH database '" OPENVAS_STATE_DIR "/scap-data/scap.db'"
- " AS scap;");
-
if (sqlite3_create_collation (task_db,
"collate_message_type",
SQLITE_UTF8,
@@ -14982,9 +15006,11 @@
report_host_details_iterator_source_name (&details),
report_host_details_iterator_source_desc (&details));
- if (strcmp (report_host_details_iterator_name (&details),
- "App")
- == 0)
+ if (scap_loaded
+ && (strcmp (report_host_details_iterator_name
+ (&details),
+ "App")
+ == 0))
{
iterator_t prognosis;
int cvss;
More information about the Openvas-commits
mailing list