flags = d.flags;
user = u;
user_tree = user_list = nullptr;
+
+ if ( no_case )
+ flags |= HS_FLAG_CASELESS;
+
+ flags |= HS_FLAG_SINGLEMATCH;
}
void Pattern::escape(const uint8_t* s, unsigned n, bool literal)
for ( auto& p : pvector )
{
pats.push_back(p.pat.c_str());
- flags.push_back(p.flags | HS_FLAG_SINGLEMATCH);
+ flags.push_back(p.flags);
ids.push_back(id++);
}
CHECK(hits == 1);
}
+TEST(mpse_hs_match, nocase)
+{
+ Mpse::PatternDescriptor desc(true, true, false);
+
+ CHECK(hs->add_pattern(nullptr, (uint8_t*)"foo", 3, desc, s_user) == 0);
+ CHECK(hs->prep_patterns(snort_conf) == 0);
+ CHECK(hs->get_pattern_count() == 1);
+
+ hyperscan_setup(snort_conf);
+
+ int state = 0;
+ CHECK(hs->search((uint8_t*)"foo", 3, match, nullptr, &state) == 0);
+ CHECK(hs->search((uint8_t*)"fOo", 3, match, nullptr, &state) == 0);
+ CHECK(hits == 2);
+}
+
TEST(mpse_hs_match, other)
{
Mpse::PatternDescriptor desc(false, true, false);
CHECK(hs->add_pattern(nullptr, (uint8_t*)"foo", 3, desc, s_user) == 0);
- CHECK(hs->add_pattern(nullptr, (uint8_t*)"\rbar\n", 3, desc, s_user) == 0);
- CHECK(hs->add_pattern(nullptr, (uint8_t*)"\\(baz\\)", 3, desc, s_user) == 0);
-
CHECK(hs->prep_patterns(snort_conf) == 0);
- CHECK(hs->get_pattern_count() == 3);
+ CHECK(hs->get_pattern_count() == 1);
hyperscan_setup(snort_conf);
int state = 0;
CHECK(hs->search((uint8_t*)"foo", 3, match, nullptr, &state) == 0);
+ CHECK(hs->search((uint8_t*)"fOo", 3, match, nullptr, &state) == 0);
CHECK(hits == 1);
}