pg->mpse[pmd->pm_type]->set_opt(1);
}
- Mpse::PatternDescriptor desc(pmd->no_case, pmd->negated, pmd->literal);
+ Mpse::PatternDescriptor desc(pmd->no_case, pmd->negated, pmd->literal, pmd->flags);
pg->mpse[pmd->pm_type]->add_pattern(sc, (uint8_t*)pattern, pattern_length, desc, pmx);
}
OptFpList* next = nullptr;
pmd = get_fp_content(otn, next);
- if ( pmd && pmd->fp)
+ if ( pmd && pmd->fp )
{
if (
- pmd->fp && !pmd->relative && !pmd->negated && pmd->fp_only >= 0 &&
+ !pmd->relative && !pmd->negated && pmd->fp_only >= 0 &&
+ // FIXIT-L no_case consideration is mpse specific, delegate
!pmd->offset && !pmd->depth && pmd->no_case )
{
if ( !next || !next->ips_opt || !next->ips_opt->is_relative() )
struct PatternMatchData
{
// used by both
- bool negated; // search for "not this pattern"
- bool fp; // For fast_pattern arguments
- bool no_case; // Toggle case sensitivity
- bool relative; // do relative pattern searching
+ bool negated; // search for "not this pattern"
+ bool fp; // for fast_pattern arguments
+ bool no_case; // toggle case sensitivity
+ bool relative; // do relative pattern searching
+ bool literal; // true for plain contents only
uint16_t fp_offset;
uint16_t fp_length;
int offset; // pattern search start offset
int depth; // pattern search depth
+ unsigned flags; // hyperscan only FIXIT-L need to generalize
unsigned pattern_size; // size of app layer pattern
const char* pattern_buf; // app layer pattern to match on
- bool literal; // set to plain contents
-
// not used by ips_content
int8_t fp_only;
uint8_t pm_type;
bool no_case;
bool negated;
bool literal;
+ unsigned flags;
- PatternDescriptor(bool noc = false, bool neg = false, bool lit = false)
- { no_case = noc; negated = neg; literal = lit; }
+ PatternDescriptor(
+ bool noc = false, bool neg = false, bool lit = false, unsigned f = 0)
+ { no_case = noc; negated = neg; literal = lit; flags = f; }
};
virtual int add_pattern(
PatternMatchData pmd;
std::string re;
hs_database_t* db;
- unsigned flags;
- bool relative;
RegexConfig()
{ reset(); }
memset(&pmd, 0, sizeof(pmd));
re.clear();
db = nullptr;
- flags = 0;
}
};
uint32_t RegexOption::hash() const
{
- uint32_t a = config.flags, b = config.pmd.relative, c = 0;
+ uint32_t a = config.pmd.flags, b = config.pmd.relative, c = 0;
mix_str(a, b, c, config.re.c_str());
mix_str(a, b, c, get_name());
finalize(a, b, c);
RegexOption& rhs = (RegexOption&)ips;
if ( config.re == rhs.config.re and
- config.flags == rhs.config.flags and
+ config.pmd.flags == rhs.config.pmd.flags and
config.pmd.relative == rhs.config.pmd.relative )
return true;
}
else if ( v.is("nocase") )
- config.flags |= HS_FLAG_CASELESS;
-
+ {
+ config.pmd.flags |= HS_FLAG_CASELESS;
+ config.pmd.no_case = true;
+ }
else if ( v.is("dotall") )
- config.flags |= HS_FLAG_DOTALL;
+ config.pmd.flags |= HS_FLAG_DOTALL;
else if ( v.is("multiline") )
- config.flags |= HS_FLAG_MULTILINE;
+ config.pmd.flags |= HS_FLAG_MULTILINE;
else if ( v.is("relative") )
config.pmd.relative = true;
{
hs_compile_error_t* err = nullptr;
- if ( hs_compile(config.re.c_str(), config.flags, HS_MODE_BLOCK, nullptr, &config.db, &err)
+ if ( hs_compile(config.re.c_str(), config.pmd.flags, HS_MODE_BLOCK, nullptr, &config.db, &err)
or !config.db )
{
ParseError("can't compile regex '%s'", config.re.c_str());
{
std::string pat;
unsigned len;
+ unsigned flags;
bool no_case;
bool negate;
len = n;
no_case = d.no_case;
negate = d.negated;
+ flags = d.flags;
user = u;
user_tree = user_list = nullptr;
}
for ( auto& p : pvector )
{
pats.push_back(p.pat.c_str());
- flags.push_back(p.no_case ? HS_FLAG_CASELESS : 0);
+ flags.push_back(p.flags);
ids.push_back(id++);
}