SCLogDebug("signature %"PRIu32" loaded", sig->id);
good++;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "error parsing signature \"%s\" from "
- "file %s at line %"PRId32"", line, sig_file, lineno - multiline);
+ if (!de_ctx->sigerror_silent) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "error parsing signature \"%s\" from "
+ "file %s at line %"PRId32"", line, sig_file, lineno - multiline);
+ if (!SigStringAppend(&de_ctx->sig_stat, sig_file, line, de_ctx->sigerror, (lineno - multiline))) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Error adding sig \"%s\" from "
+ "file %s at line %"PRId32"", line, sig_file, lineno - multiline);
+ }
+ if (de_ctx->sigerror) {
+ de_ctx->sigerror = NULL;
+ }
+ }
if (rule_engine_analysis_set) {
EngineAnalysisRulesFailure(line, sig_file, lineno - multiline);
}
bad++;
- if (!SigStringAppend(&de_ctx->sig_stat, sig_file, line, de_ctx->sigerror, (lineno - multiline))) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error adding sig \"%s\" from "
- "file %s at line %"PRId32"", line, sig_file, lineno - multiline);
- }
- if (de_ctx->sigerror) {
- de_ctx->sigerror = NULL;
- }
}
multiline = 0;
}
SCFree(sm);
}
+static enum DetectKeywordId SigTableGetIndex(const SigTableElmt *e)
+{
+ const SigTableElmt *table = &sigmatch_table[0];
+ ptrdiff_t offset = e - table;
+ BUG_ON(offset >= DETECT_TBLSIZE);
+ return (enum DetectKeywordId)offset;
+}
+
/* Get the detection module by name */
static SigTableElmt *SigTableGet(char *name)
{
return NULL;
}
+bool SigMatchSilentErrorEnabled(const DetectEngineCtx *de_ctx,
+ const enum DetectKeywordId id)
+{
+ return de_ctx->sm_types_silent_error[id];
+}
+
bool SigMatchStrictEnabled(const enum DetectKeywordId id)
{
if (id < DETECT_TBLSIZE) {
}
if (setup_ret < 0) {
SCLogDebug("\"%s\" failed to setup", st->name);
- goto error;
+
+ /* handle 'silent' error case */
+ if (setup_ret == -2) {
+ enum DetectKeywordId idx = SigTableGetIndex(st);
+ if (de_ctx->sm_types_silent_error[idx] == false) {
+ de_ctx->sm_types_silent_error[idx] = true;
+ return -1;
+ }
+ return -2;
+ }
+ return setup_ret;
}
s->init_data->negated = false;
/* default gid to 1 */
sig->gid = 1;
- if (SigParse(de_ctx, sig, sigstr, dir, &parser) < 0)
+ int ret = SigParse(de_ctx, sig, sigstr, dir, &parser);
+ if (ret == -2) {
+ de_ctx->sigerror_silent = true;
+ goto error;
+ } else if (ret < 0) {
goto error;
+ }
/* signature priority hasn't been overwritten. Using default priority */
if (sig->prio == -1)
SCEnter();
uint32_t oldsignum = de_ctx->signum;
+ de_ctx->sigerror_silent = false;
Signature *sig;
Signature *s, const char *arg, int sm_type, int sm_list,
AppProto alproto);
+bool SigMatchSilentErrorEnabled(const DetectEngineCtx *de_ctx,
+ const enum DetectKeywordId id);
bool SigMatchStrictEnabled(const enum DetectKeywordId id);
const char *DetectListToHumanString(int list);
/** Store rule file and line so that parsers can use them in errors. */
char *rule_file;
int rule_line;
+ bool sigerror_silent;
const char *sigerror;
/** list of keywords that need thread local ctxs */
* set for it. If true, the setup function will have to
* run. */
bool sm_types_prefilter[DETECT_TBLSIZE];
+ bool sm_types_silent_error[DETECT_TBLSIZE];
} DetectEngineCtx;