[Openvas-commits] r12189 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Nov 24 16:23:55 CET 2011
Author: mattm
Date: 2011-11-24 16:23:52 +0100 (Thu, 24 Nov 2011)
New Revision: 12189
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage.h
trunk/openvas-manager/src/manage_sql.c
trunk/openvas-manager/src/omp.c
Log:
* src/manage_sql.c (create_note): Add missing active param.
(note_iterator_end_time, note_iterator_active): Correct position.
* src/manage.h: Update header accordingly.
* src/omp.c (create_note_data_t, create_note_data_reset)
(client_state_t): Add active elements.
(omp_xml_handle_start_element, omp_xml_handle_end_element)
(omp_xml_handle_text): Add ACTIVE to CREATE_NOTE. Missing from last
patch.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2011-11-24 14:53:43 UTC (rev 12188)
+++ trunk/openvas-manager/ChangeLog 2011-11-24 15:23:52 UTC (rev 12189)
@@ -1,3 +1,16 @@
+2011-11-24 Matthew Mundell <matthew.mundell at greenbone.net>
+
+ * src/manage_sql.c (create_note): Add missing active param.
+ (note_iterator_end_time, note_iterator_active): Correct position.
+
+ * src/manage.h: Update header accordingly.
+
+ * src/omp.c (create_note_data_t, create_note_data_reset)
+ (client_state_t): Add active elements.
+ (omp_xml_handle_start_element, omp_xml_handle_end_element)
+ (omp_xml_handle_text): Add ACTIVE to CREATE_NOTE. Missing from last
+ patch.
+
2011-11-22 Matthew Mundell <matthew.mundell at greenbone.net>
Add note end times. Hence increase database version to 54. Add
Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h 2011-11-24 14:53:43 UTC (rev 12188)
+++ trunk/openvas-manager/src/manage.h 2011-11-24 15:23:52 UTC (rev 12189)
@@ -1443,7 +1443,7 @@
int
create_note (const char*, const char*, const char*, const char*, const char*,
- task_t, result_t, note_t*);
+ const char*, task_t, result_t, note_t*);
int
delete_note (note_t);
Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c 2011-11-24 14:53:43 UTC (rev 12188)
+++ trunk/openvas-manager/src/manage_sql.c 2011-11-24 15:23:52 UTC (rev 12189)
@@ -28225,6 +28225,7 @@
/**
* @brief Create a note.
*
+ * @param[in] active NULL or -1 on, 0 off, n on for n days.
* @param[in] nvt OID of noted NVT.
* @param[in] text Note text.
* @param[in] hosts Hosts to apply note to, NULL for any host.
@@ -28237,9 +28238,9 @@
* @return 0 success, -1 error.
*/
int
-create_note (const char* nvt, const char* text, const char* hosts,
- const char* port, const char* threat, task_t task,
- result_t result, note_t *note)
+create_note (const char* active, const char* nvt, const char* text,
+ const char* hosts, const char* port, const char* threat,
+ task_t task, result_t result, note_t *note)
{
gchar *quoted_text, *quoted_hosts, *quoted_port, *quoted_threat;
@@ -28262,10 +28263,10 @@
sql ("INSERT INTO notes"
" (uuid, owner, nvt, creation_time, modification_time, text, hosts,"
- " port, threat, task, result)"
+ " port, threat, task, result, end_time)"
" VALUES"
" (make_uuid (), (SELECT ROWID FROM users WHERE users.uuid = '%s'),"
- " '%s', %i, %i, %s, %s, %s, %s, %llu, %llu);",
+ " '%s', %i, %i, %s, %s, %s, %s, %llu, %llu, %i);",
current_credentials.uuid,
nvt,
time (NULL),
@@ -28275,7 +28276,12 @@
quoted_port,
quoted_threat,
task,
- result);
+ result,
+ (active == NULL || (strcmp (active, "-1") == 0))
+ ? 0
+ : (strcmp (active, "0")
+ ? (time (NULL) + (atoi (active) * 60 * 60 * 24))
+ : 1));
g_free (quoted_text);
g_free (quoted_hosts);
@@ -28688,7 +28694,7 @@
{
int ret;
if (iterator->done) return -1;
- ret = (time_t) sqlite3_column_int (iterator->stmt, 12);
+ ret = (time_t) sqlite3_column_int (iterator->stmt, 11);
return ret;
}
@@ -28704,7 +28710,7 @@
{
int ret;
if (iterator->done) return -1;
- ret = sqlite3_column_int (iterator->stmt, 13);
+ ret = sqlite3_column_int (iterator->stmt, 12);
return ret;
}
Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c 2011-11-24 14:53:43 UTC (rev 12188)
+++ trunk/openvas-manager/src/omp.c 2011-11-24 15:23:52 UTC (rev 12189)
@@ -821,6 +821,7 @@
*/
typedef struct
{
+ char *active; ///< Whether the note is active.
char *hosts; ///< Hosts to which to limit override.
char *nvt_oid; ///< NVT to which to limit override.
char *port; ///< Port to which to limit override.
@@ -838,6 +839,7 @@
static void
create_note_data_reset (create_note_data_t *data)
{
+ free (data->active);
free (data->hosts);
free (data->nvt_oid);
free (data->port);
@@ -2264,7 +2266,7 @@
*/
typedef struct
{
- char *active; ///< Whether the override is active.
+ char *active; ///< Whether the note is active.
char *hosts; ///< Hosts to which to limit override.
char *note_id; ///< ID of note to modify.
char *nvt_oid; ///< NVT to which to limit override.
@@ -3124,6 +3126,7 @@
CLIENT_CREATE_LSC_CREDENTIAL_KEY_PRIVATE,
CLIENT_CREATE_LSC_CREDENTIAL_KEY_PUBLIC,
CLIENT_CREATE_NOTE,
+ CLIENT_CREATE_NOTE_ACTIVE,
CLIENT_CREATE_NOTE_HOSTS,
CLIENT_CREATE_NOTE_NVT,
CLIENT_CREATE_NOTE_PORT,
@@ -6451,7 +6454,9 @@
break;
case CLIENT_CREATE_NOTE:
- if (strcasecmp ("HOSTS", element_name) == 0)
+ if (strcasecmp ("ACTIVE", element_name) == 0)
+ set_client_state (CLIENT_CREATE_NOTE_ACTIVE);
+ else if (strcasecmp ("HOSTS", element_name) == 0)
set_client_state (CLIENT_CREATE_NOTE_HOSTS);
else if (strcasecmp ("NVT", element_name) == 0)
{
@@ -12831,7 +12836,8 @@
return;
}
}
- else switch (create_note (create_note_data->nvt_oid,
+ else switch (create_note (create_note_data->active,
+ create_note_data->nvt_oid,
create_note_data->text,
create_note_data->hosts,
create_note_data->port,
@@ -12863,6 +12869,10 @@
set_client_state (CLIENT_AUTHENTIC);
break;
}
+ case CLIENT_CREATE_NOTE_ACTIVE:
+ assert (strcasecmp ("ACTIVE", element_name) == 0);
+ set_client_state (CLIENT_CREATE_NOTE);
+ break;
case CLIENT_CREATE_NOTE_HOSTS:
assert (strcasecmp ("HOSTS", element_name) == 0);
set_client_state (CLIENT_CREATE_NOTE);
@@ -17996,6 +18006,9 @@
openvas_append_text (&create_escalator_data->part_name, text, text_len);
break;
+ case CLIENT_CREATE_NOTE_ACTIVE:
+ openvas_append_text (&create_note_data->active, text, text_len);
+ break;
case CLIENT_CREATE_NOTE_HOSTS:
openvas_append_text (&create_note_data->hosts, text, text_len);
break;
More information about the Openvas-commits
mailing list