From: Davis McPherson (davmcphe) Date: Wed, 4 Sep 2019 19:54:05 +0000 (-0400) Subject: Merge pull request #1729 in SNORT/snort3 from ~DAVMCPHE/snort3:snort2lua_fix_ignored... X-Git-Tag: 3.0.0-261~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4dc8e90d03ba8afc39fe0be4672dedbfe8e9454f;p=thirdparty%2Fsnort3.git Merge pull request #1729 in SNORT/snort3 from ~DAVMCPHE/snort3:snort2lua_fix_ignored to master Squashed commit of the following: commit 2abe3e6fc16fa0bf6b217dbb72bf05b4b7a2b361 Author: davis mcpherson 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 --- diff --git a/tools/snort2lua/preprocessor_states/pps_stream5_global.cc b/tools/snort2lua/preprocessor_states/pps_stream5_global.cc index 2b312a7b8..276ea075e 100644 --- a/tools/snort2lua/preprocessor_states/pps_stream5_global.cc +++ b/tools/snort2lua/preprocessor_states/pps_stream5_global.cc @@ -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; }