[Openvas-commits] r11694 - in trunk/openvas-manager: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 27 08:10:50 CEST 2011


Author: mattm
Date: 2011-09-27 08:10:49 +0200 (Tue, 27 Sep 2011)
New Revision: 11694

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage_sql.c
Log:
	* src/manage_sql.c (result_iterator_nvt_cvss_base_double): New function.
	(result_cmp): Include CVSS base in comparison, as this was recently added
	to the init_result_iterator sorting.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2011-09-26 17:12:17 UTC (rev 11693)
+++ trunk/openvas-manager/ChangeLog	2011-09-27 06:10:49 UTC (rev 11694)
@@ -1,6 +1,12 @@
+2011-09-27  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	* src/manage_sql.c (result_iterator_nvt_cvss_base_double): New function.
+	(result_cmp): Include CVSS base in comparison, as this was recently added
+	to the init_result_iterator sorting.
+
 2011-09-25  Henri Doreau <henri.doreau at greenbone.net>
 
-	* src/manage.c, src/CMakeLists.txt, CMakeLists.txt: Fix	path to the
+	* src/manage.c, src/CMakeLists.txt, CMakeLists.txt: Fix path to the
 	SCAP data directory.
 
 2011-09-23  Henri Doreau <henri.doreau at greenbone.net>

Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c	2011-09-26 17:12:17 UTC (rev 11693)
+++ trunk/openvas-manager/src/manage_sql.c	2011-09-27 06:10:49 UTC (rev 11694)
@@ -11863,6 +11863,20 @@
  */
 DEF_ACCESS (descr, 7);
 
+/**
+ * @brief Get the CVSS base from a result iterator.
+ *
+ * @param[in]  iterator  Iterator.
+ *
+ * @return CVSS base of result NVT.
+ */
+double
+result_iterator_nvt_cvss_base_double (iterator_t* iterator)
+{
+  if (iterator->done) return -1;
+  return sqlite3_column_double (iterator->stmt, 8);
+}
+
 #undef DEF_ACCESS
 
 /**
@@ -14348,6 +14362,7 @@
   const char *host, *delta_host, *port, *delta_port, *type, *delta_type;
   const char *nvt, *delta_nvt;
   int ret;
+  double cvss, delta_cvss;
 
   if (sort_field == NULL) sort_field = "type";
 
@@ -14360,6 +14375,9 @@
   type = result_iterator_type (results);
   delta_type = result_iterator_type (delta_results);
 
+  cvss = result_iterator_nvt_cvss_base_double (results);
+  delta_cvss = result_iterator_nvt_cvss_base_double (delta_results);
+
   nvt = result_iterator_nvt_oid (results);
   delta_nvt = result_iterator_nvt_oid (delta_results);
 
@@ -14374,21 +14392,29 @@
                                               " port,"
                                               " new_type"
                                               " COLLATE collate_message_type DESC,"
+                                              " (CAST (cvss_base AS REAL)) DESC,"
+                                              " nvt,"
                                               " description"
                                             : " ORDER BY host COLLATE collate_ip,"
                                               " new_type COLLATE collate_message_type,"
                                               " port,"
+                                              " (CAST (cvss_base AS REAL)) DESC,"
+                                              " nvt,"
                                               " description"))
                                     : ((strcmp (sort_field, "port") == 0)
                                         ? " ORDER BY host COLLATE collate_ip,"
                                           " port DESC,"
                                           " new_type"
                                           " COLLATE collate_message_type DESC,"
+                                          " (CAST (cvss_base AS REAL)) DESC,"
+                                          " nvt,"
                                           " description"
                                         : " ORDER BY host COLLATE collate_ip,"
                                           " new_type"
                                           " COLLATE collate_message_type DESC,"
                                           " port,"
+                                          " (CAST (cvss_base AS REAL)) DESC,"
+                                          " nvt,"
                                           " description")),
   */
 
@@ -14428,6 +14454,18 @@
           if (ret)
             return -ret;
 
+          tracef ("   delta: %s: cvss: %e VS %e",
+                  __FUNCTION__, cvss, delta_cvss);
+          if (cvss >= 0 && delta_cvss >= 0)
+            {
+              tracef ("   delta: %s: (NVTs: %s AND %s)",
+                      __FUNCTION__, nvt, delta_nvt);
+              if (cvss > delta_cvss)
+                return -1;
+              if (cvss < delta_cvss)
+                return 1;
+            }
+
           ret = strcmp (nvt, delta_nvt);
           tracef ("   delta: %s: NVT: %s VS %s (%i)",
                   __FUNCTION__, nvt, delta_nvt, ret);
@@ -14455,6 +14493,18 @@
       if (ret)
         return ret;
 
+      tracef ("   delta: %s: cvss: %e VS %e",
+              __FUNCTION__, cvss, delta_cvss);
+      if (cvss >= 0 && delta_cvss >= 0)
+        {
+          tracef ("   delta: %s: (NVTs: %s AND %s)",
+                  __FUNCTION__, nvt, delta_nvt);
+          if (cvss > delta_cvss)
+            return -1;
+          if (cvss < delta_cvss)
+            return 1;
+        }
+
       ret = strcmp (nvt, delta_nvt);
       tracef ("   delta: %s: NVT: %s VS %s (%i)",
               __FUNCTION__, nvt, delta_nvt, ret);
@@ -14486,6 +14536,18 @@
       if (ret)
         return ret;
 
+      tracef ("   delta: %s: cvss: %e VS %e",
+              __FUNCTION__, cvss, delta_cvss);
+      if (cvss >= 0 && delta_cvss >= 0)
+        {
+          tracef ("   delta: %s: (NVTs: %s AND %s)",
+                  __FUNCTION__, nvt, delta_nvt);
+          if (cvss > delta_cvss)
+            return -1;
+          if (cvss < delta_cvss)
+            return 1;
+        }
+
       ret = collate_message_type (NULL,
                                   strlen (type), type,
                                   strlen (delta_type), delta_type);
@@ -14493,6 +14555,8 @@
         return -ret;
 
       ret = strcmp (nvt, delta_nvt);
+      tracef ("   delta: %s: NVT: %s VS %s (%i)",
+              __FUNCTION__, nvt, delta_nvt, ret);
       if (ret)
         return ret;
 
@@ -14513,7 +14577,21 @@
   if (ret)
     return ret;
 
+  tracef ("   delta: %s: cvss: %e VS %e",
+          __FUNCTION__, cvss, delta_cvss);
+  if (cvss >= 0 && delta_cvss >= 0)
+    {
+      tracef ("   delta: %s: (NVTs: %s AND %s)",
+              __FUNCTION__, nvt, delta_nvt);
+      if (cvss > delta_cvss)
+        return -1;
+      if (cvss < delta_cvss)
+        return 1;
+    }
+
   ret = strcmp (nvt, delta_nvt);
+  tracef ("   delta: %s: NVT: %s VS %s (%i)",
+          __FUNCTION__, nvt, delta_nvt, ret);
   if (ret)
     return ret;
 



More information about the Openvas-commits mailing list