From: Mike Stepanek (mstepane) Date: Tue, 20 Jul 2021 12:21:59 +0000 (+0000) Subject: Merge pull request #2982 in SNORT/snort3 from ~VHORBATO/snort3:js_bytes_pegcount... X-Git-Tag: 3.1.9.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f28877d3aaa0c3ad114e513ca750e8fd59214fc;p=thirdparty%2Fsnort3.git Merge pull request #2982 in SNORT/snort3 from ~VHORBATO/snort3:js_bytes_pegcount to master Squashed commit of the following: commit af890287cb5c3b13031b0b018e48c78ff804b7ca Author: Vitalii Date: Wed Jul 14 19:10:31 2021 +0300 http_inspect: add peg count for script bytes processed --- diff --git a/src/service_inspectors/http_inspect/http_enum.h b/src/service_inspectors/http_inspect/http_enum.h index 17c81ceae..51cd88432 100755 --- a/src/service_inspectors/http_inspect/http_enum.h +++ b/src/service_inspectors/http_inspect/http_enum.h @@ -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, diff --git a/src/service_inspectors/http_inspect/http_js_norm.cc b/src/service_inspectors/http_inspect/http_js_norm.cc index b989e6477..a851f85f7 100644 --- a/src/service_inspectors/http_inspect/http_js_norm.cc +++ b/src/service_inspectors/http_inspect/http_js_norm.cc @@ -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; diff --git a/src/service_inspectors/http_inspect/http_tables.cc b/src/service_inspectors/http_inspect/http_tables.cc index af9dbdf6a..ab1ba12aa 100755 --- a/src/service_inspectors/http_inspect/http_tables.cc +++ b/src/service_inspectors/http_inspect/http_tables.cc @@ -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 } };