]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Added checking of negated "totals" and "threads" config values for stats. 1845/head
authorMaxtors <moe.andreas@gmail.com>
Mon, 1 Feb 2016 13:54:29 +0000 (14:54 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 9 Feb 2016 13:37:41 +0000 (14:37 +0100)
src/log-stats.c
src/output-json-stats.c
src/util-error.c
src/util-error.h

index 385dec2bb4fcc70c4e5445375cb452c421f5ddd4..8507deb301c620a9036d9e93b0f6977326b9feb8 100644 (file)
@@ -245,6 +245,15 @@ OutputCtx *LogStatsLogInitCtx(ConfNode *conf)
         const char *nulls = ConfNodeLookupChildValue(conf, "null-values");
         SCLogDebug("totals %s threads %s", totals, threads);
 
+        if ((totals != NULL && ConfValIsFalse(totals)) &&
+                (threads != NULL && ConfValIsFalse(threads))) {
+            LogFileFreeCtx(file_ctx);
+            SCFree(statslog_ctx);
+            SCLogError(SC_ERR_STATS_LOG_NEGATED,
+                    "Cannot disable both totals and threads in stats logging");
+            return NULL;
+        }
+
         if (totals != NULL && ConfValIsFalse(totals)) {
             statslog_ctx->flags &= ~LOG_STATS_TOTALS;
         }
index fea7177aa8fb0d62309b866f9cd4436bae93ac01..a22f9d6b967596de361ec991eaf15f2b93f6f2e1 100644 (file)
@@ -327,6 +327,14 @@ OutputCtx *OutputStatsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
         const char *deltas = ConfNodeLookupChildValue(conf, "deltas");
         SCLogDebug("totals %s threads %s deltas %s", totals, threads, deltas);
 
+        if ((totals != NULL && ConfValIsFalse(totals)) &&
+                (threads != NULL && ConfValIsFalse(threads))) {
+            SCFree(stats_ctx);
+            SCLogError(SC_ERR_JSON_STATS_LOG_NEGATED,
+                    "Cannot disable both totals and threads in stats logging");
+            return NULL;
+        }
+
         if (totals != NULL && ConfValIsFalse(totals)) {
             stats_ctx->flags &= ~JSON_STATS_TOTALS;
         }
index 7f2caf00d25949c07cdfb97e046a5854da6268f5..8ea229b5988d0ad693d70a98dd16f73f5b2f9ee0 100644 (file)
@@ -312,6 +312,8 @@ const char * SCErrorToString(SCError err)
         CASE_CODE (SC_ERR_MT_NO_MAPPING);
         CASE_CODE (SC_ERR_NO_JSON_SUPPORT);
         CASE_CODE (SC_ERR_INVALID_RULE_ARGUMENT);
+        CASE_CODE (SC_ERR_STATS_LOG_NEGATED);
+        CASE_CODE (SC_ERR_JSON_STATS_LOG_NEGATED);
     }
 
     return "UNKNOWN_ERROR";
index cd2ce24927c6593eb7fda4fecafded6f54b68f75..fec09d04a7bf76a654aac4c3fb05aeebe934aba6 100644 (file)
@@ -302,6 +302,8 @@ typedef enum {
     SC_ERR_INVALID_RULE_ARGUMENT, /**< Generic error code for invalid
                                    * rule argument. */
     SC_ERR_MT_NO_MAPPING,
+    SC_ERR_STATS_LOG_NEGATED, /** When totals and threads are both NO in yaml **/
+    SC_ERR_JSON_STATS_LOG_NEGATED, /** When totals and threads are both NO in yaml **/
 } SCError;
 
 const char *SCErrorToString(SCError);