From: Mike Stepanek (mstepane) Date: Mon, 29 Jul 2019 20:16:30 +0000 (-0400) Subject: Merge pull request #1685 in SNORT/snort3 from ~SMINUT/snort3:pcre_peg_counts to master X-Git-Tag: 3.0.0-259~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=922ef1f592b4d79a8c5bc5594eb9587738827d61;p=thirdparty%2Fsnort3.git Merge pull request #1685 in SNORT/snort3 from ~SMINUT/snort3:pcre_peg_counts to master Squashed commit of the following: commit 8efc8f5a2de33908a9dd5094f088e06b371e6997 Author: Silviu Minut Date: Thu Jul 18 09:59:13 2019 -0400 pcre: add peg counts for PCRE_ERROR_MATCHLIMIT and PCRE_ERROR_RECURSIONLIMIT return status from pcre_exec(). --- diff --git a/src/ips_options/ips_pcre.cc b/src/ips_options/ips_pcre.cc index 5737c94ef..4a9450c6f 100644 --- a/src/ips_options/ips_pcre.cc +++ b/src/ips_options/ips_pcre.cc @@ -394,8 +394,19 @@ static bool pcre_search( { matched = false; } + else if (result == PCRE_ERROR_MATCHLIMIT) + { + pc.pcre_match_limit++; + matched = false; + } + else if (result == PCRE_ERROR_RECURSIONLIMIT) + { + pc.pcre_recursion_limit++; + matched = false; + } else { + pc.pcre_error++; return false; } diff --git a/src/utils/stats.cc b/src/utils/stats.cc index d4265de1a..533470663 100644 --- a/src/utils/stats.cc +++ b/src/utils/stats.cc @@ -197,6 +197,9 @@ const PegInfo pc_names[] = { CountType::SUM, "offload_fallback", "fast pattern offload search fallback attempts" }, { CountType::SUM, "offload_failures", "fast pattern offload search failures" }, { CountType::SUM, "offload_suspends", "fast pattern search suspends due to offload context chains" }, + { CountType::SUM, "pcre_match_limit", "total number of times pcre hit the match limit" }, + { CountType::SUM, "pcre_recursion_limit", "total number of times pcre hit the recursion limit" }, + { CountType::SUM, "pcre_error", "total number of times pcre returns error" }, { CountType::END, nullptr, nullptr } }; @@ -220,7 +223,7 @@ void DropStats() { LogLabel("Packet Statistics"); ModuleManager::get_module("daq")->show_stats(); - + PacketManager::dump_stats(); LogLabel("Module Statistics"); diff --git a/src/utils/stats.h b/src/utils/stats.h index 6e24ccaee..9ab6bfb03 100644 --- a/src/utils/stats.h +++ b/src/utils/stats.h @@ -60,6 +60,9 @@ struct PacketCount PegCount offload_fallback; PegCount offload_failures; PegCount offload_suspends; + PegCount pcre_match_limit; + PegCount pcre_recursion_limit; + PegCount pcre_error; }; struct ProcessCount @@ -121,4 +124,3 @@ void TimeStart(); void TimeStop(); #endif -