"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/utils/test/js_test_utils.cc" between
snort3-3.1.29.0.tar.gz and snort3-3.1.30.0.tar.gz

About: Snort 3 is a network intrusion prevention and detection system (IDS/IPS) combining the benefits of signature, protocol and anomaly-based inspection.

js_test_utils.cc  (snort3-3.1.29.0):js_test_utils.cc  (snort3-3.1.30.0)
skipping to change at line 74 skipping to change at line 74
bool JSTokenizerTester::is_unescape_nesting_seen() const bool JSTokenizerTester::is_unescape_nesting_seen() const
{ {
return normalizer.is_unescape_nesting_seen(); return normalizer.is_unescape_nesting_seen();
} }
void test_scope(const char* context, const std::list<JSProgramScopeType>& stack) void test_scope(const char* context, const std::list<JSProgramScopeType>& stack)
{ {
std::string buf(context); std::string buf(context);
buf += "</script>"; buf += "</script>";
JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids); JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids, s_igno red_props);
JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth); JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth);
normalizer.normalize(buf.c_str(), buf.size()); normalizer.normalize(buf.c_str(), buf.size());
CHECK(ident_ctx.get_types() == stack); CHECK(ident_ctx.get_types() == stack);
} }
void test_normalization(const char* source, const char* expected) void test_normalization(const char* source, const char* expected)
{ {
JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids); JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids, s_igno red_props);
JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth); JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth);
normalizer.normalize(source, strlen(source)); normalizer.normalize(source, strlen(source));
std::string result_buf(normalizer.get_script(), normalizer.script_size()); std::string result_buf(normalizer.get_script(), normalizer.script_size());
CHECK(result_buf == expected); CHECK(result_buf == expected);
} }
void test_normalization_bad(const char* source, const char* expected, JSTokenize r::JSRet eret) void test_normalization_bad(const char* source, const char* expected, JSTokenize r::JSRet eret)
{ {
JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids); JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids, s_igno red_props);
JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth); JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth);
auto ret = normalizer.normalize(source, strlen(source)); auto ret = normalizer.normalize(source, strlen(source));
std::string result_buf(normalizer.get_script(), normalizer.script_size()); std::string result_buf(normalizer.get_script(), normalizer.script_size());
CHECK(eret == ret); CHECK(eret == ret);
CHECK(result_buf == expected); CHECK(result_buf == expected);
} }
void test_normalization_mixed_encoding(const char* source, const char* expected) void test_normalization_mixed_encoding(const char* source, const char* expected)
{ {
JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids); JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids, s_igno red_props);
JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth); JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth);
auto ret = normalizer.normalize(source, strlen(source)); auto ret = normalizer.normalize(source, strlen(source));
std::string result_buf(normalizer.get_script(), normalizer.script_size()); std::string result_buf(normalizer.get_script(), normalizer.script_size());
CHECK(ret == JSTokenizer::JSRet::SCRIPT_CONTINUE); CHECK(ret == JSTokenizer::JSRet::SCRIPT_CONTINUE);
CHECK(normalizer.is_mixed_encoding_seen()); CHECK(normalizer.is_mixed_encoding_seen());
CHECK(result_buf == expected); CHECK(result_buf == expected);
} }
void test_normalization(const std::vector<PduCase>& pdus) void test_normalization(const std::vector<PduCase>& pdus)
{ {
JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids); JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids, s_igno red_props);
JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth); JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth);
for (const auto& pdu : pdus) for (const auto& pdu : pdus)
{ {
const char* source = pdu.first; const char* source = pdu.first;
const char* expected = pdu.second; const char* expected = pdu.second;
normalizer.normalize(source, strlen(source)); normalizer.normalize(source, strlen(source));
std::string result_buf(normalizer.get_script(), normalizer.script_size() ); std::string result_buf(normalizer.get_script(), normalizer.script_size() );
CHECK(result_buf == expected); CHECK(result_buf == expected);
} }
} }
void test_normalization(const std::list<ScopedPduCase>& pdus) void test_normalization(const std::list<ScopedPduCase>& pdus)
{ {
JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids); JSIdentifierCtx ident_ctx(norm_depth, max_scope_depth, s_ignored_ids, s_igno red_props);
JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth); JSNormalizer normalizer(ident_ctx, norm_depth, max_template_nesting, max_bra cket_depth);
for (auto pdu:pdus) for (auto pdu:pdus)
{ {
const char* source; const char* source;
const char* expected; const char* expected;
std::list<JSProgramScopeType> stack; std::list<JSProgramScopeType> stack;
std::tie(source,expected,stack) = pdu; std::tie(source,expected,stack) = pdu;
normalizer.normalize(source, strlen(source)); normalizer.normalize(source, strlen(source));
std::string result_buf(normalizer.get_script(), normalizer.script_size() ); std::string result_buf(normalizer.get_script(), normalizer.script_size() );
CHECK(ident_ctx.get_types() == stack); CHECK(ident_ctx.get_types() == stack);
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)