{
BUG_ON(PatternMatchPrepareGroup(de_ctx, sgh) != 0);
- /* set up engines if needed - independent of 'detect.prefilter.default'
- * setting as the prefilter keyword may have enabled individual sigs */
+ /* set up engines if needed - when prefilter is set to auto we run
+ * all engines, otherwise only those that have been forced by the
+ * prefilter keyword. */
+ const enum DetectEnginePrefilterSetting setting = de_ctx->prefilter_setting;
for (int i = 0; i < DETECT_TBLSIZE; i++)
{
- if (sigmatch_table[i].SetupPrefilter != NULL) {
+ if (sigmatch_table[i].SetupPrefilter != NULL &&
+ (setting == DETECT_PREFILTER_AUTO ||
+ de_ctx->sm_types_prefilter[i]))
+ {
sigmatch_table[i].SetupPrefilter(de_ctx, sgh);
}
}
cd->flags |= DETECT_CONTENT_FAST_PATTERN;
} else {
s->flags |= SIG_FLAG_PREFILTER;
+
+ /* make sure setup function runs for this type. */
+ de_ctx->sm_types_prefilter[sm->type] = true;
}
SCReturnInt(0);
/** signatures stats */
SigFileLoaderStat sig_stat;
+ /** per keyword flag indicating if a prefilter has been
+ * set for it. If true, the setup function will have to
+ * run. */
+ bool sm_types_prefilter[DETECT_TBLSIZE];
+
} DetectEngineCtx;
/* Engine groups profiles (low, medium, high, custom) */