Merge in SNORT/snort3 from ~VHORBAN/snort3:fix_tsan_warning to master
Squashed commit of the following:
commit
2b4ebd297a3b7088f6b4ba46e1b12698d876423f
Author: Oleksandr Serhiienko <oserhiie@cisco.com>
Date: Sat Jul 16 18:41:34 2022 +0300
utils: add static initialization of norm_names
commit
217831f9c1de3ea40bde105c7efc92e742447941
Author: Volodymyr Horban <vhorban@cisco.com>
Date: Mon Jul 18 15:20:58 2022 +0300
http_inspect: remove dependency of JS normalization depth on HTTP depth
const HttpParaList::JsNormParam& js_norm_param_) :
uri_param(uri_param_),
js_norm_param(js_norm_param_),
- detection_depth(UINT64_MAX),
mpse_otag(nullptr),
mpse_attr(nullptr),
mpse_type(nullptr)
debug_logf(4, http_trace, TRACE_JS_PROC, current_packet,
"input data was %s\n", final_portion ? "last one in PDU" : "a part of PDU");
- uint32_t data_len = std::min(detection_depth, js_ctx.script_size());
+ uint32_t data_len = js_ctx.script_size();
if (data_len)
{
"input data was %s\n", final_portion ? "last one in PDU" : "a part of PDU");
auto js_ctx = ssn->js_normalizer;
- uint32_t data_len = std::min(detection_depth, js_ctx->script_size());
+ uint32_t data_len = js_ctx->script_size();
if (data_len)
{
const HttpParaList::JsNormParam& js_norm_param_);
~HttpJsNorm();
- void set_detection_depth(size_t depth)
- { detection_depth = depth; }
-
void do_legacy(const Field& input, Field& output, HttpInfractions*, HttpEventGen*,
int max_javascript_whitespaces) const;
void do_inline(const Field& input, Field& output, HttpInfractions*, HttpFlowData*, bool) const;
const HttpParaList::UriParam& uri_param;
const HttpParaList::JsNormParam& js_norm_param;
- size_t detection_depth;
bool configure_once = false;
snort::SearchTool* mpse_otag;
void HttpMsgBody::bookkeeping_regular_flush(uint32_t& partial_detect_length,
uint8_t*& partial_detect_buffer, uint32_t& partial_js_detect_length, int32_t detect_length)
{
- params->js_norm_param.js_norm->set_detection_depth(session_data->detect_depth_remaining[source_id]);
-
session_data->detect_depth_remaining[source_id] -= detect_length;
partial_detect_buffer = nullptr;
partial_detect_length = 0;
const int64_t& depth = (source_id == SRC_CLIENT) ? params->request_depth :
params->response_depth;
session_data->detect_depth_remaining[source_id] = (depth != -1) ? depth : INT64_MAX;
- params->js_norm_param.js_norm->set_detection_depth(session_data->detect_depth_remaining[source_id]);
}
else
{
static void init_norm_names()
{
- static bool once = false;
-
- if (once)
- return;
-
- once = true;
-
char* c = norm_names;
const char hex[] = "0123456789abcdef";
assert(sizeof(norm_names) == c - norm_names);
}
+static int _init_norm_names __attribute__((unused)) = (init_norm_names(), 0);
+
JSIdentifierCtx::JSIdentifierCtx(int32_t depth, uint32_t max_scope_depth,
const std::unordered_set<std::string>& ignored_ids_list,
const std::unordered_set<std::string>& ignored_props_list)
: ignored_ids_list(ignored_ids_list), ignored_props_list(ignored_props_list),
max_scope_depth(max_scope_depth)
{
- init_norm_names();
-
norm_name = norm_names;
norm_name_end = norm_names + NORM_NAME_SIZE * std::min(depth, NORM_NAME_CNT);
scopes.emplace_back(JSProgramScopeType::GLOBAL);