]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2129 in SNORT/snort3 from ~SELYSENK/snort3:verbose_output to...
authorBhagya Tholpady (bbantwal) <bbantwal@cisco.com>
Tue, 21 Apr 2020 17:30:41 +0000 (17:30 +0000)
committerBhagya Tholpady (bbantwal) <bbantwal@cisco.com>
Tue, 21 Apr 2020 17:30:41 +0000 (17:30 +0000)
Squashed commit of the following:

commit d09df74ea4a243e502ba15b7b246ad1c53eeb185
Author: Serhii Lysenko <selysenk@cisco.com>
Date:   Mon Apr 13 09:38:56 2020 -0400

    managers: print inspectors' config output for every inspection policy configured

    For each inspection policy print lua file name and policy id and dump
    inspectors' config within that policy.

src/main/policy.h
src/managers/inspector_manager.cc

index afc0b7edfb86e29e84056cd2a10bf14c7ef0c889..2a8a1ac7bf60f6fdf28586b5af0142ee034c5c3e 100644 (file)
@@ -248,6 +248,9 @@ public:
     unsigned network_policy_count()
     { return network_policy.size(); }
 
+    unsigned shells_count()
+    { return shells.size(); }
+
     void set_cloned(bool state)
     { cloned = state; }
 
index 39dea1609de46625e2822de22104444db86350bd..53d0d6319f3432701c347f52186dad06c8350bdf 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "inspector_manager.h"
 
+#include <cstring>
 #include <list>
 #include <vector>
 
@@ -32,6 +33,7 @@
 #include "flow/flow.h"
 #include "flow/session.h"
 #include "log/messages.h"
+#include "main/shell.h"
 #include "main/snort.h"
 #include "main/snort_config.h"
 #include "main/thread_config.h"
@@ -985,20 +987,32 @@ bool InspectorManager::configure(SnortConfig* sc, bool cloned)
 
 void InspectorManager::print_config(SnortConfig* sc)
 {
-    InspectionPolicy* pi = get_inspection_policy();
-
-    if ( !pi->framework_policy )
-        return;
+    const auto shell_number = sc->policy_map->shells_count();
 
-    for ( auto* p : pi->framework_policy->ilist )
+    for ( unsigned shell_id = 0; shell_id < shell_number; shell_id++ )
     {
-        std::string inspector_name(p->pp_class.api.base.name);
-        if ( p->name != inspector_name )
-            inspector_name += " (" + p->name + "):";
-        else
-            inspector_name += ":";
-        LogLabel(inspector_name.c_str());
-        p->handler->show(sc);
+        const auto shell = sc->policy_map->get_shell(shell_id);
+        const auto policies = sc->policy_map->get_policies(shell);
+        const auto inspection = policies->inspection;
+
+        if ( !(inspection and inspection->framework_policy) )
+            continue;
+
+        const std::string label = "Inspection Policy : policy id " +
+            std::to_string(inspection->user_policy_id) + " : " +
+            shell->get_file();
+        LogLabel(label.c_str());
+
+        for ( const auto* p : inspection->framework_policy->ilist )
+        {
+            std::string inspector_name(p->pp_class.api.base.name);
+            if ( p->name != inspector_name )
+                inspector_name += " (" + p->name + "):";
+            else
+                inspector_name += ":";
+            LogLabel(inspector_name.c_str());
+            p->handler->show(sc);
+        }
     }
 }