]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1729 in SNORT/snort3 from ~DAVMCPHE/snort3:snort2lua_fix_ignored...
authorDavis McPherson (davmcphe) <davmcphe@cisco.com>
Wed, 4 Sep 2019 19:54:05 +0000 (15:54 -0400)
committerDavis McPherson (davmcphe) <davmcphe@cisco.com>
Wed, 4 Sep 2019 19:54:05 +0000 (15:54 -0400)
Squashed commit of the following:

commit 2abe3e6fc16fa0bf6b217dbb72bf05b4b7a2b361
Author: davis mcpherson <davmcphe@cisco.com>
Date:   Tue Sep 3 12:22:37 2019 -0400

    snort2lua: only emit max_flows and pruning_timeout options in converted lua file if the option is used in the snort2 conf file

tools/snort2lua/preprocessor_states/pps_stream5_global.cc

index 2b312a7b8054d270602c95eb4c9f6f537b25452c..276ea075ebf0eee3a5fe5bb5832bc263a2efcb30 100644 (file)
@@ -45,6 +45,8 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
 
     int tcp_max = 262144, udp_max = 131072, ip_max = 16384, icmp_max = 65536;
     int pruning_timeout = INT_MAX;
+    bool emit_pruning_timeout = false;
+    bool emit_max_flows = false;
 
     while (util::get_string(data_stream, keyword, ","))
     {
@@ -95,6 +97,7 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
                 int val;
                 if (arg_stream >> val)
                     tcp_max = val;
+                emit_max_flows = true;
             }
         }
         else if (keyword == "tcp_cache_nominal_timeout")
@@ -112,6 +115,7 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
                 if (pruning_timeout > val)
                     pruning_timeout = val;
             }
+            emit_pruning_timeout = true;
         }
         else if (keyword == "max_udp")
         {
@@ -121,7 +125,8 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
                 if (arg_stream >> val)
                     udp_max = val;
             }
-        }
+            emit_max_flows = true;
+       }
         else if (keyword == "udp_cache_pruning_timeout")
         {
             int val;
@@ -130,6 +135,7 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
                 if (pruning_timeout > val)
                     pruning_timeout = val;
             }
+            emit_pruning_timeout = true;
         }
         else if (keyword == "udp_cache_nominal_timeout")
         {
@@ -146,6 +152,7 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
                 if (arg_stream >> val)
                     icmp_max = val;
             }
+            emit_max_flows = true;
         }
         else if (keyword == "max_ip")
         {
@@ -155,6 +162,7 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
                 if (arg_stream >> val)
                     ip_max = val;
             }
+            emit_max_flows = true;
         }
         else if (keyword == "show_rebuilt_packets")
         {
@@ -190,8 +198,12 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
             retval = false;
         }
     }
-    table_api.add_option("max_flows", tcp_max + udp_max + icmp_max + ip_max);
-    table_api.add_option("pruning_timeout", INT_MAX == pruning_timeout ? 30 : pruning_timeout);
+    if ( emit_max_flows )
+       table_api.add_option("max_flows", tcp_max + udp_max + icmp_max + ip_max);
+
+    if ( emit_pruning_timeout )
+       table_api.add_option("pruning_timeout", INT_MAX == pruning_timeout ? 30 : pruning_timeout);
+
     return retval;
 }