]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2216 in SNORT/snort3 from ~BBANTWAL/snort3:sort_ilist_by_type...
authorBhagya Tholpady (bbantwal) <bbantwal@cisco.com>
Tue, 19 May 2020 13:47:42 +0000 (13:47 +0000)
committerBhagya Tholpady (bbantwal) <bbantwal@cisco.com>
Tue, 19 May 2020 13:47:42 +0000 (13:47 +0000)
Squashed commit of the following:

commit 8439e633309782e799d1adbf410c12cff413c0ba
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date:   Mon May 18 22:24:24 2020 -0400

    managers: print alphabetically sorted verbose inspector config output within an inspection policy

commit 5a085e5a729027f8f85cafb90970fa9d024651f5
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date:   Mon May 18 22:18:34 2020 -0400

    Revert "Merge pull request #2185 in SNORT/snort3 from ~BBANTWAL/snort3:sort_inspectors to master"

    This reverts commit f19685fd2b8b3443369f1181ca8f0f98c85df49d.

src/managers/inspector_manager.cc

index cbf257edecd774596c61370245904e450a98993c..9cff9f4f57d62f9e5b3ee910dea424c82bed2a3e 100644 (file)
@@ -113,7 +113,7 @@ struct PHInstance
     ~PHInstance();
 
     static bool comp(PHInstance* a, PHInstance* b)
-    { return ( a->name < b->name ); }
+    { return ( a->pp_class.api.type < b->pp_class.api.type ); }
 
     void set_name(const char* s)
     { name = s; }
@@ -1004,11 +1004,7 @@ void InspectorManager::print_config(SnortConfig* sc)
         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());
-
+        std::map<const std::string, const PHInstance*> sorted_ilist;
         for ( const auto* p : inspection->framework_policy->ilist )
         {
             std::string inspector_name(p->pp_class.api.base.name);
@@ -1016,8 +1012,18 @@ void InspectorManager::print_config(SnortConfig* sc)
                 inspector_name += " (" + p->name + "):";
             else
                 inspector_name += ":";
-            LogLabel(inspector_name.c_str());
-            p->handler->show(sc);
+            sorted_ilist.emplace(inspector_name, p);
+        }
+
+        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 : sorted_ilist )
+        {
+            LogLabel(p.first.c_str());
+            p.second->handler->show(sc);
         }
     }
 }