]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2982 in SNORT/snort3 from ~VHORBATO/snort3:js_bytes_pegcount...
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 20 Jul 2021 12:21:59 +0000 (12:21 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 20 Jul 2021 12:21:59 +0000 (12:21 +0000)
Squashed commit of the following:

commit af890287cb5c3b13031b0b018e48c78ff804b7ca
Author: Vitalii <vhorbato@cisco.com>
Date:   Wed Jul 14 19:10:31 2021 +0300

    http_inspect: add peg count for script bytes processed

src/service_inspectors/http_inspect/http_enum.h
src/service_inspectors/http_inspect/http_js_norm.cc
src/service_inspectors/http_inspect/http_tables.cc

index 17c81ceaebaeac4a2caf306bc651c74e00e382c5..51cd88432fdaf69f43a3f62370001011b31018bb 100755 (executable)
@@ -64,7 +64,7 @@ enum PEG_COUNT { PEG_FLOW = 0, PEG_SCAN, PEG_REASSEMBLE, PEG_INSPECT, PEG_REQUES
     PEG_CONCURRENT_SESSIONS, PEG_MAX_CONCURRENT_SESSIONS, PEG_SCRIPT_DETECTION,
     PEG_PARTIAL_INSPECT, PEG_EXCESS_PARAMS, PEG_PARAMS, PEG_CUTOVERS, PEG_SSL_SEARCH_ABND_EARLY,
     PEG_PIPELINED_FLOWS, PEG_PIPELINED_REQUESTS, PEG_TOTAL_BYTES, PEG_JS_INLINE, PEG_JS_EXTERNAL,
-    PEG_COUNT_MAX };
+    PEG_JS_BYTES, PEG_COUNT_MAX };
 
 // Result of scanning by splitter
 enum ScanResult { SCAN_NOT_FOUND, SCAN_NOT_FOUND_ACCELERATE, SCAN_FOUND, SCAN_FOUND_PIECE,
index b989e647729d5ea01a1533c992a3fc23f3a97e7d..a851f85f798121cb7be1c450e486225d6f098104 100644 (file)
@@ -37,7 +37,11 @@ static inline JSTokenizer::JSRet js_normalize(JSNormalizer& ctx, const char* con
     const char* dst_end, const char*& ptr, char*& dst)
 {
     auto ret = ctx.normalize(ptr, end - ptr, dst, dst_end - dst);
-    ptr = ctx.get_src_next();
+    
+    auto next = ctx.get_src_next();
+    HttpModule::increment_peg_counts(PEG_JS_BYTES, next - ptr);
+
+    ptr = next;   
     dst = ctx.get_dst_next();
 
     return ret;
index af9dbdf6a91f3b6c5f20744d8cde131e8b3b47b8..ab1ba12aad912fc6045d465b4df606fe96bbae9f 100755 (executable)
@@ -470,6 +470,7 @@ const PegInfo HttpModule::peg_names[PEG_COUNT_MAX+1] =
     { CountType::SUM, "total_bytes", "total HTTP data bytes inspected" },
     { CountType::SUM, "js_inline_scripts", "total number of inline JavaScripts processed" },
     { CountType::SUM, "js_external_scripts", "total number of external JavaScripts processed" },
+    { CountType::SUM, "js_bytes", "total number of JavaScript bytes processed" },
     { CountType::END, nullptr, nullptr }
 };