]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
engine analysis is a running mode
authorEric Leblond <eric@regit.org>
Tue, 7 May 2013 12:11:49 +0000 (14:11 +0200)
committerEric Leblond <eric@regit.org>
Tue, 30 Jul 2013 13:22:33 +0000 (15:22 +0200)
src/detect.c
src/runmodes.h
src/suricata.c

index cf5eba58366f03e41167ef77c31d273d54c44a0d..9dd9e43112643d07207ad640f59bd3c8f02b427f 100644 (file)
@@ -385,7 +385,7 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, int sig_file_excl
     int sigtotal = 0;
     char *sfile = NULL;
 
-    if (engine_analysis) {
+    if (RunmodeGetCurrent() == RUNMODE_ENGINE_ANALYSIS) {
         fp_engine_analysis_set = SetupFPAnalyzer();
         rule_engine_analysis_set = SetupRuleAnalyzer();
     }
@@ -468,7 +468,7 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, int sig_file_excl
     ret = 0;
 
  end:
-    if (engine_analysis) {
+    if (RunmodeGetCurrent() == RUNMODE_ENGINE_ANALYSIS) {
         if (rule_engine_analysis_set) {
             CleanupRuleAnalyzer();
         }
index d9c7a1d0b122dd8cf53867a6a9c349297d6b49ec..b238902f648b95c95aa41b34459d39979ae0340b 100644 (file)
@@ -49,6 +49,7 @@ enum {
     RUNMODE_DUMP_CONFIG,
     RUNMODE_CONF_TEST,
     RUNMODE_LIST_UNITTEST,
+    RUNMODE_ENGINE_ANALYSIS,
 #ifdef OS_WIN32
     RUNMODE_INSTALL_SERVICE,
     RUNMODE_REMOVE_SERVICE,
index 5f5bcad5bec0db9027c1c6aee0309dd50c58bf45..d89e2bcba555b4a2d8556b5a9f9de72be93f1438 100644 (file)
@@ -185,10 +185,6 @@ uint8_t suricata_ctl_flags = 0;
 /** Run mode selected */
 int run_mode = RUNMODE_UNKNOWN;
 
-/** engine_analysis.  disabled(0) by default, unless enabled by the user by
-  * running the engine with --engine-analysis */
-int engine_analysis = 0;
-
 /** Engine mode: inline (ENGINE_MODE_IPS) or just
   * detection mode (ENGINE_MODE_IDS by default) */
 uint8_t engine_mode = ENGINE_MODE_IDS;
@@ -953,6 +949,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
     int list_keywords = 0;
     int build_info = 0;
     int conf_test = 0;
+    int engine_analysis = 0;
 
 #ifdef UNITTESTS
     coverage_unittests = 0;
@@ -1467,6 +1464,8 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
         suri->run_mode = RUNMODE_DUMP_CONFIG;
     if (conf_test)
         suri->run_mode = RUNMODE_CONF_TEST;
+    if (engine_analysis)
+        suri->run_mode = RUNMODE_ENGINE_ANALYSIS;
 
     return TM_ECODE_OK;
 }
@@ -1699,18 +1698,16 @@ int main(int argc, char **argv)
 
     /* Load the Host-OS lookup. */
     SCHInfoLoadFromConfig();
-    if (run_mode != RUNMODE_UNIX_SOCKET) {
+    if (suri.run_mode != RUNMODE_UNIX_SOCKET) {
         DefragInit();
     }
 
-    if (run_mode == RUNMODE_UNKNOWN) {
-        if (!engine_analysis && !(suri.run_mode == RUNMODE_CONF_TEST)) {
-            usage(argv[0]);
-            exit(EXIT_FAILURE);
-        }
+    if (suri.run_mode == RUNMODE_UNKNOWN) {
+        usage(argv[0]);
+        exit(EXIT_FAILURE);
     }
 
-    if (engine_analysis) {
+    if (suri.run_mode == RUNMODE_ENGINE_ANALYSIS) {
         SCLogInfo("== Carrying out Engine Analysis ==");
         char *temp = NULL;
         if (ConfGet("engine-analysis", &temp) == 0) {
@@ -1884,9 +1881,9 @@ int main(int argc, char **argv)
         exit(EXIT_FAILURE);
 
     /* In offline mode delayed init of detect is a bad idea */
-    if ((run_mode == RUNMODE_PCAP_FILE) ||
-        (run_mode == RUNMODE_ERF_FILE) ||
-        engine_analysis) {
+    if ((suri.run_mode == RUNMODE_PCAP_FILE) ||
+        (suri.run_mode == RUNMODE_ERF_FILE) ||
+        (suri.run_mode == RUNMODE_ENGINE_ANALYSIS)) {
         suri.delayed_detect = 0;
     } else {
         ConfNode *denode = NULL;
@@ -1916,7 +1913,7 @@ int main(int argc, char **argv)
             if (de_ctx->failure_fatal)
                 exit(EXIT_FAILURE);
         }
-        if (engine_analysis) {
+        if (suri.run_mode == RUNMODE_ENGINE_ANALYSIS) {
             exit(EXIT_SUCCESS);
         }
     }