return NULL;
}
+bool SigMatchStrictEnabled(const enum DetectKeywordId id)
+{
+ if (id < DETECT_TBLSIZE) {
+ return ((sigmatch_table[id].flags & SIGMATCH_STRICT_PARSING) != 0);
+ }
+ return false;
+}
+
+void SigTableApplyStrictCommandlineOption(const char *str)
+{
+ if (str == NULL) {
+ /* nothing to be done */
+ return;
+ }
+
+ /* "all" just sets the flag for each keyword */
+ if (strcmp(str, "all") == 0) {
+ for (int i = 0; i < DETECT_TBLSIZE; i++) {
+ SigTableElmt *st = &sigmatch_table[i];
+ st->flags |= SIGMATCH_STRICT_PARSING;
+ }
+ return;
+ }
+
+ char *copy = SCStrdup(str);
+ if (copy == NULL)
+ FatalError(SC_ERR_MEM_ALLOC, "could not duplicate opt string");
+
+ char *xsaveptr = NULL;
+ char *key = strtok_r(copy, ",", &xsaveptr);
+ while (key != NULL) {
+ SigTableElmt *st = SigTableGet(key);
+ if (st != NULL) {
+ st->flags |= SIGMATCH_STRICT_PARSING;
+ } else {
+ SCLogWarning(SC_ERR_CMD_LINE, "'strict' command line "
+ "argument '%s' not found", key);
+ }
+ key = strtok_r(NULL, ",", &xsaveptr);
+ }
+
+ SCFree(copy);
+}
+
/**
* \brief Append a SigMatch to the list type.
*
Signature *s, const char *arg, int sm_type, int sm_list,
AppProto alproto);
+bool SigMatchStrictEnabled(const enum DetectKeywordId id);
+
const char *DetectListToHumanString(int list);
const char *DetectListToString(int list);
+void SigTableApplyStrictCommandlineOption(const char *str);
+
SigMatch *DetectGetLastSM(const Signature *);
SigMatch *DetectGetLastSMFromMpmLists(const DetectEngineCtx *de_ctx, const Signature *s);
SigMatch *DetectGetLastSMFromLists(const Signature *s, ...);
#define SIGMATCH_INFO_STICKY_BUFFER BIT_U16(9)
/** keyword is deprecated: used to suggest an alternative */
#define SIGMATCH_INFO_DEPRECATED BIT_U16(10)
+/** strict parsing is enabled */
+#define SIGMATCH_STRICT_PARSING BIT_U16(11)
enum DetectEngineTenantSelectors
{
{"pcap-file-delete", 0, 0, 0},
{"simulate-ips", 0, 0 , 0},
{"no-random", 0, &g_disable_randomness, 1},
+ {"strict-rule-keywords", optional_argument, 0, 0},
/* AFL app-layer options. */
{"afl-http-request", required_argument, 0 , 0},
return TM_ECODE_FAILED;
}
suri->set_datadir = true;
+ } else if (strcmp((long_opts[option_index]).name , "strict-rule-keywords") == 0){
+ if (optarg == NULL) {
+ suri->strict_rule_parsing_string = SCStrdup("all");
+ } else {
+ suri->strict_rule_parsing_string = SCStrdup(optarg);
+ }
+ if (suri->strict_rule_parsing_string == NULL) {
+ FatalError(SC_ERR_MEM_ALLOC, "failed to duplicate 'strict' string");
+ }
}
break;
case 'c':
/* hardcoded initialization code */
SigTableSetup(); /* load the rule keywords */
+ SigTableApplyStrictCommandlineOption(suri->strict_rule_parsing_string);
TmqhSetup();
CIDRInit();
const char *log_dir;
const char *progname; /**< pointer to argv[0] */
const char *conf_filename;
+ char *strict_rule_parsing_string;
} SCInstance;