static DetectEngineThreadCtx *DetectEngineThreadCtxInitForReload(
ThreadVars *tv, DetectEngineCtx *new_de_ctx, int mt);
-static uint8_t DetectEngineCtxLoadConf(DetectEngineCtx *);
+static int DetectEngineCtxLoadConf(DetectEngineCtx *);
static DetectEngineMasterCtx g_master_de_ctx = { SCMUTEX_INITIALIZER, 0, NULL, NULL, TENANT_SELECTOR_UNKNOWN, NULL,};
{
DetectEngineCtx *de_ctx;
- ConfNode *seq_node = NULL;
- ConfNode *insp_recursion_limit_node = NULL;
- ConfNode *de_engine_node = NULL;
- char *insp_recursion_limit = NULL;
-
de_ctx = SCMalloc(sizeof(DetectEngineCtx));
if (unlikely(de_ctx == NULL))
goto error;
SCLogDebug("ConfGetBool could not load the value.");
}
- de_engine_node = ConfGetNode("detect-engine");
- if (de_engine_node != NULL) {
- TAILQ_FOREACH(seq_node, &de_engine_node->head, next) {
- if (strcmp(seq_node->val, "inspection-recursion-limit") != 0)
- continue;
-
- insp_recursion_limit_node = ConfNodeLookupChild(seq_node, seq_node->val);
- if (insp_recursion_limit_node == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Error retrieving conf "
- "entry for detect-engine:inspection-recursion-limit");
- break;
- }
- insp_recursion_limit = insp_recursion_limit_node->val;
- SCLogDebug("Found detect-engine:inspection-recursion-limit - %s:%s",
- insp_recursion_limit_node->name, insp_recursion_limit_node->val);
-
- break;
- }
- }
-
- if (insp_recursion_limit != NULL) {
- de_ctx->inspection_recursion_limit = atoi(insp_recursion_limit);
- } else {
- de_ctx->inspection_recursion_limit =
- DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT;
- }
-
- if (de_ctx->inspection_recursion_limit == 0)
- de_ctx->inspection_recursion_limit = -1;
-
- SCLogDebug("de_ctx->inspection_recursion_limit: %d",
- de_ctx->inspection_recursion_limit);
-
de_ctx->mpm_matcher = PatternMatchDefaultMatcher();
DetectEngineCtxLoadConf(de_ctx);
* \retval 0 if no config provided, 1 if config was provided
* and loaded successfuly
*/
-static uint8_t DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx)
+static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx)
{
uint8_t profile = ENGINE_PROFILE_UNKNOWN;
+ char *max_uniq_toclient_groups_str = NULL;
+ char *max_uniq_toserver_groups_str = NULL;
+ char *sgh_mpm_context = NULL;
char *de_ctx_profile = NULL;
- const char *max_uniq_toclient_groups_str = NULL;
- const char *max_uniq_toserver_groups_str = NULL;
-
- char *sgh_mpm_context = NULL;
+ (void)ConfGet("detect.profile", &de_ctx_profile);
+ (void)ConfGet("detect.sgh-mpm-context", &sgh_mpm_context);
ConfNode *de_ctx_custom = ConfGetNode("detect-engine");
ConfNode *opt = NULL;
if (de_ctx_custom != NULL) {
TAILQ_FOREACH(opt, &de_ctx_custom->head, next) {
- if (strcmp(opt->val, "profile") == 0) {
- de_ctx_profile = opt->head.tqh_first->val;
- } else if (strcmp(opt->val, "sgh-mpm-context") == 0) {
- sgh_mpm_context = opt->head.tqh_first->val;
+ if (de_ctx_profile == NULL) {
+ if (strcmp(opt->val, "profile") == 0) {
+ de_ctx_profile = opt->head.tqh_first->val;
+ }
+ }
+
+ if (sgh_mpm_context == NULL) {
+ if (strcmp(opt->val, "sgh-mpm-context") == 0) {
+ sgh_mpm_context = opt->head.tqh_first->val;
+ }
}
}
}
de_ctx->sgh_mpm_context = ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL;
}
+ /* parse profile custom-values */
opt = NULL;
switch (profile) {
case ENGINE_PROFILE_LOW:
break;
case ENGINE_PROFILE_CUSTOM:
- TAILQ_FOREACH(opt, &de_ctx_custom->head, next) {
- if (strcmp(opt->val, "custom-values") == 0) {
- max_uniq_toclient_groups_str = ConfNodeLookupChildValue
- (opt->head.tqh_first, "toclient-groups");
- max_uniq_toserver_groups_str = ConfNodeLookupChildValue
- (opt->head.tqh_first, "toserver-groups");
+ (void)ConfGet("detect.custom-values.toclient-groups",
+ &max_uniq_toclient_groups_str);
+ (void)ConfGet("detect.custom-values.toserver-groups",
+ &max_uniq_toserver_groups_str);
+
+ if (de_ctx_custom != NULL) {
+ TAILQ_FOREACH(opt, &de_ctx_custom->head, next) {
+ if (strcmp(opt->val, "custom-values") == 0) {
+ if (max_uniq_toclient_groups_str == NULL) {
+ max_uniq_toclient_groups_str = (char *)ConfNodeLookupChildValue
+ (opt->head.tqh_first, "toclient-groups");
+ }
+ if (max_uniq_toserver_groups_str == NULL) {
+ max_uniq_toserver_groups_str = (char *)ConfNodeLookupChildValue
+ (opt->head.tqh_first, "toserver-groups");
+ }
+ }
}
}
if (max_uniq_toclient_groups_str != NULL) {
break;
}
- if (profile == ENGINE_PROFILE_UNKNOWN)
- return 0;
- return 1;
+ if (profile == ENGINE_PROFILE_UNKNOWN) {
+ goto error;
+ }
+
+ intmax_t value = 0;
+ if (ConfGetInt("detect.inspection-recursion-limit", &value) == 1)
+ {
+ if (value >= 0 && value <= INT_MAX) {
+ de_ctx->inspection_recursion_limit = (int)value;
+ }
+
+ /* fall back to old config parsing */
+ } else {
+ ConfNode *insp_recursion_limit_node = NULL;
+ char *insp_recursion_limit = NULL;
+
+ if (de_ctx_custom != NULL) {
+ opt = NULL;
+ TAILQ_FOREACH(opt, &de_ctx_custom->head, next) {
+ if (strcmp(opt->val, "inspection-recursion-limit") != 0)
+ continue;
+
+ insp_recursion_limit_node = ConfNodeLookupChild(opt, opt->val);
+ if (insp_recursion_limit_node == NULL) {
+ SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Error retrieving conf "
+ "entry for detect-engine:inspection-recursion-limit");
+ break;
+ }
+ insp_recursion_limit = insp_recursion_limit_node->val;
+ SCLogDebug("Found detect-engine.inspection-recursion-limit - %s:%s",
+ insp_recursion_limit_node->name, insp_recursion_limit_node->val);
+ break;
+ }
+
+ if (insp_recursion_limit != NULL) {
+ de_ctx->inspection_recursion_limit = atoi(insp_recursion_limit);
+ } else {
+ de_ctx->inspection_recursion_limit =
+ DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT;
+ }
+ }
+ }
+
+ if (de_ctx->inspection_recursion_limit == 0)
+ de_ctx->inspection_recursion_limit = -1;
+
+ SCLogDebug("de_ctx->inspection_recursion_limit: %d",
+ de_ctx->inspection_recursion_limit);
+
+ return 0;
+error:
+ return -1;
}
/*