]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2931 in SNORT/snort3 from ~OSERHIIE/snort3:dump_config to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 9 Jun 2021 13:38:41 +0000 (13:38 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 9 Jun 2021 13:38:41 +0000 (13:38 +0000)
Squashed commit of the following:

commit ddc9f5cae9538ae04a1ce6f161a457b4bb217b53
Author: Oleksandr Serhiienko <oserhiie@cisco.com>
Date:   Mon Jun 7 12:50:48 2021 +0300

    main: fix config dump for list-based inspector aliases

src/main/shell.cc
src/main/shell.h
src/managers/module_manager.cc

index cd2ce0b49e87a39ba27feee63b2bbed646513c05..bf9ea951e87fb45ad5fe65378d873db242512a45 100644 (file)
@@ -180,19 +180,20 @@ void Shell::config_open_table(bool is_root_node, bool is_list, int idx,
             if ( idx )
                 node_type = Parameter::PT_TABLE;
 
-            add_config_child_node(table_name, node_type);
+            add_config_child_node(table_name, node_type, idx);
         }
     }
 }
 
-void Shell::add_config_child_node(const std::string& node_name, snort::Parameter::Type type)
+void Shell::add_config_child_node(const std::string& node_name, snort::Parameter::Type type,
+    bool is_root_list_item)
 {
     if ( !s_config_output || !s_current_node )
         return;
 
-    std::string name;
-    if ( s_current_node->get_name() != node_name )
-        name = node_name;
+    // element of the top-level list is anonymous
+    std::string name = ( !is_root_list_item && s_current_node->get_name() != node_name ) ?
+        node_name : "";
 
     auto new_node = new TreeConfigNode(s_current_node, name, type);
     s_current_node->add_child_node(new_node);
index 356efeff3214704c26de55c7f101f4c5eb5b5b97..93d0b804a133653d3d9c817e8831cc8b56f24dab 100644 (file)
@@ -76,7 +76,8 @@ public:
     static void config_open_table(bool is_root_node, bool is_list, int idx,
         const std::string& table_name, const snort::Parameter* p);
     static void set_config_value(const std::string& fqn, const snort::Value& value);
-    static void add_config_child_node(const std::string& node_name, snort::Parameter::Type type);
+    static void add_config_child_node(const std::string& node_name, snort::Parameter::Type type,
+        bool is_root_list_item);
     static void update_current_config_node(const std::string& node_name = "");
     static void config_close_table();
     static void set_config_output(ConfigOutput* config_output);
index 10e85a15b32348158077cc9f7626f6d76b207f2d..932c67b691fc243e7805700f9eb7dacedba87139 100644 (file)
@@ -543,7 +543,7 @@ static bool begin(Module* m, const Parameter* p, const char* s, int idx, int dep
             {
                 const Parameter* table_item_params = reinterpret_cast<const Parameter*>(p->range);
 
-                Shell::add_config_child_node(get_sub_table(fqn), p->type);
+                Shell::add_config_child_node(get_sub_table(fqn), p->type, false);
 
                 if ( !begin(m, table_item_params, fqn.c_str(), idx, depth+1) )
                     return false;