summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deps/log/log.h17
-rw-r--r--docs/scan_api.md4
-rw-r--r--include/maat.h19
-rw-r--r--scanner/expr_matcher/adapter_hs/adapter_hs.cpp22
-rw-r--r--scanner/expr_matcher/adapter_rs/adapter_rs.cpp12
-rw-r--r--scanner/expr_matcher/expr_matcher.cpp12
-rw-r--r--src/inc_internal/maat_compile.h10
-rw-r--r--src/inc_internal/maat_utils.h8
-rw-r--r--src/json2iris.c103
-rw-r--r--src/maat_api.c213
-rw-r--r--src/maat_bool_plugin.c28
-rw-r--r--src/maat_command.c14
-rw-r--r--src/maat_compile.c394
-rw-r--r--src/maat_config_monitor.c32
-rw-r--r--src/maat_expr.c88
-rw-r--r--src/maat_flag.c47
-rw-r--r--src/maat_fqdn_plugin.c32
-rw-r--r--src/maat_group.c38
-rw-r--r--src/maat_interval.c46
-rw-r--r--src/maat_ip.c84
-rw-r--r--src/maat_ip_plugin.c36
-rw-r--r--src/maat_ipport_plugin.c34
-rw-r--r--src/maat_plugin.c38
-rw-r--r--src/maat_redis_monitor.c64
-rw-r--r--src/maat_rule.c16
-rw-r--r--src/maat_stat.c24
-rw-r--r--src/maat_table.c58
-rw-r--r--src/maat_virtual.c6
-rw-r--r--test/benchmark/benchmark_hs_gtest.cpp94
-rw-r--r--test/benchmark/benchmark_rs_gtest.cpp80
-rw-r--r--test/group_exclude/group_exclude_gtest.cpp16
-rw-r--r--test/maat_framework_gtest.cpp1425
-rw-r--r--test/maat_framework_perf_gtest.cpp42
-rw-r--r--test/maat_json.json491
-rw-r--r--tools/maat_redis_tool.cpp24
35 files changed, 2724 insertions, 947 deletions
diff --git a/deps/log/log.h b/deps/log/log.h
index d815ed4..2d1cd21 100644
--- a/deps/log/log.h
+++ b/deps/log/log.h
@@ -22,14 +22,21 @@ extern "C"
struct log_handle;
-enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
+enum {
+ LOG_TRACE,
+ LOG_DEBUG,
+ LOG_INFO,
+ LOG_WARN,
+ LOG_ERROR,
+ LOG_FATAL
+};
#define log_debug(handle, module, fmt, ...) log_print(handle, LOG_DEBUG, module, fmt, ##__VA_ARGS__)
#define log_trace(handle, module, fmt, ...) log_print(handle, LOG_TRACE, module, fmt, ##__VA_ARGS__)
-#define log_info(handle, module, fmt, ...) log_print(handle, LOG_INFO, module, fmt, ##__VA_ARGS__)
-#define log_warn(handle, module, fmt, ...) log_print(handle, LOG_WARN, module, fmt, ##__VA_ARGS__)
-#define log_error(handle, module, fmt, ...) log_print(handle, LOG_ERROR, module, fmt, ##__VA_ARGS__)
-#define log_fatal(handle, module, fmt, ...) log_print(handle, LOG_FATAL, module, fmt, ##__VA_ARGS__)
+#define log_info(handle, module, fmt, ...) log_print(handle, LOG_INFO, module, fmt, ##__VA_ARGS__)
+#define log_warn(handle, module, fmt, ...) log_print(handle, LOG_WARN, module, fmt, ##__VA_ARGS__)
+#define log_error(handle, module, fmt, ...) log_print(handle, LOG_ERROR, module, fmt, ##__VA_ARGS__)
+#define log_fatal(handle, module, fmt, ...) log_print(handle, LOG_FATAL, module, fmt, ##__VA_ARGS__)
void log_print(struct log_handle *, int level, const char *module, const char *fmt, ...);
void log_options_set_enable(struct log_handle *, int enable);
diff --git a/docs/scan_api.md b/docs/scan_api.md
index 76e3fed..6a4226f 100644
--- a/docs/scan_api.md
+++ b/docs/scan_api.md
@@ -4,7 +4,7 @@
多命中情况下,按包含分组数由多到少返回,分组数相同时,按编译配置ID由大到小的顺序返回。
-多命中扫描的最大命中次数,受MAX_SCANNER_HIT_NUM宏控制,当前为4096条。
+多命中扫描的最大命中次数,受MAX_HIT_NUM宏控制,当前为4096条。
如果命中条数超出4096,则按照配置在IRIS库表文件出现的顺序返回。
@@ -18,7 +18,7 @@
## 结果缓存复用
-另外为了提高系统的性能,为每个scanner分配了一个region_rslt_buff,用以缓存域扫描命中的中间结果。通过malloc分配,长度为sizeof(scan_result_t)*MAX_SCANNER_HIT_NUM*scan_thread_num,当外部调用扫描时,根据thread_num参数,分配region_rslt_buff+MAX_SCANNER_HIT_NUM*thread_num供当前线程保存域中间扫描结果。
+另外为了提高系统的性能,为每个scanner分配了一个region_rslt_buff,用以缓存域扫描命中的中间结果。通过malloc分配,长度为sizeof(scan_result_t)*MAX_HIT_NUM*scan_thread_num,当外部调用扫描时,根据thread_num参数,分配region_rslt_buff+MAX_HIT_NUM*thread_num供当前线程保存域中间扫描结果。
### 命中结果返回条件
diff --git a/include/maat.h b/include/maat.h
index d2bd748..7af3bf1 100644
--- a/include/maat.h
+++ b/include/maat.h
@@ -265,9 +265,18 @@ int maat_scan_ipv6(struct maat *instance, int table_id,
size_t *n_hit_result, struct maat_state *state);
int maat_scan_string(struct maat *instance, int table_id,
- const char *data, size_t data_len, long long *results,
- size_t n_result, size_t *n_hit_result,
- struct maat_state *state);
+ const char *data, size_t data_len,
+ long long *results, size_t n_result,
+ size_t *n_hit_result, struct maat_state *state);
+
+int maat_scan_group(struct maat *instance, int table_id,
+ long long *group_ids, size_t n_group_id,
+ long long *results, size_t n_result,
+ size_t *n_hit_result, struct maat_state *state);
+
+int maat_scan_not_logic(struct maat *instance, int table_id,
+ long long *results, size_t n_result,
+ size_t *n_hit_result, struct maat_state *state);
struct maat_stream;
struct maat_stream *maat_stream_new(struct maat *instance, int table_id,
@@ -286,10 +295,6 @@ void maat_state_reset(struct maat_state *state);
void maat_state_free(struct maat_state *state);
-void maat_state_set_logic_not_disabled(struct maat_state *state);
-
-void maat_state_set_logic_not_enabled(struct maat_state *state);
-
int maat_state_set_scan_district(struct maat_state *state, int table_id,
const char *district, size_t district_len);
diff --git a/scanner/expr_matcher/adapter_hs/adapter_hs.cpp b/scanner/expr_matcher/adapter_hs/adapter_hs.cpp
index 0d3ed41..c5ebfa9 100644
--- a/scanner/expr_matcher/adapter_hs/adapter_hs.cpp
+++ b/scanner/expr_matcher/adapter_hs/adapter_hs.cpp
@@ -107,7 +107,7 @@ static int _hs_alloc_scratch(hs_database_t *db, hs_scratch_t **scratches,
size_t scratch_size = 0;
if (hs_alloc_scratch(db, &scratches[0]) != HS_SUCCESS) {
- log_error(logger, MODULE_ADAPTER_HS,
+ log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Unable to allocate scratch space. Exiting.",
__FUNCTION__, __LINE__);
return -1;
@@ -116,7 +116,7 @@ static int _hs_alloc_scratch(hs_database_t *db, hs_scratch_t **scratches,
for (size_t i = 1; i < n_worker_thread; i++) {
hs_error_t err = hs_clone_scratch(scratches[0], &scratches[i]);
if (err != HS_SUCCESS) {
- log_error(logger, MODULE_ADAPTER_HS,
+ log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Unable to clone scratch",
__FUNCTION__, __LINE__);
return -1;
@@ -124,7 +124,7 @@ static int _hs_alloc_scratch(hs_database_t *db, hs_scratch_t **scratches,
err = hs_scratch_size(scratches[i], &scratch_size);
if (err != HS_SUCCESS) {
- log_error(logger, MODULE_ADAPTER_HS,
+ log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Unable to query scratch size",
__FUNCTION__, __LINE__);
return -1;
@@ -187,7 +187,7 @@ static int adpt_hs_build_database(struct adapter_hs_runtime *hs_rt,
&hs_rt->literal_db, &compile_err);
if (err != HS_SUCCESS) {
if (compile_err) {
- log_error(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s",
+ log_fatal(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s",
__FUNCTION__, __LINE__, compile_err->message);
}
@@ -203,7 +203,7 @@ static int adpt_hs_build_database(struct adapter_hs_runtime *hs_rt,
NULL, &hs_rt->regex_db, &compile_err);
if (err != HS_SUCCESS) {
if (compile_err) {
- log_error(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s",
+ log_fatal(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s",
__FUNCTION__, __LINE__, compile_err->message);
}
hs_free_compile_error(compile_err);
@@ -342,7 +342,7 @@ static int verify_regex_expression(const char *regex_str, struct log_handle *log
if (err != HS_SUCCESS) {
// Expression will fail compilation and report error elsewhere.
if (logger != NULL) {
- log_error(logger, MODULE_ADAPTER_HS,
+ log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] illegal regex expression: \"%s\": %s",
__FUNCTION__, __LINE__, regex_str, error->message);
}
@@ -412,7 +412,7 @@ void *adapter_hs_new(struct expr_rule *rules, size_t n_rule,
"Adapter_hs module: build bool matcher of %zu expressions"
" with %zu bytes memory", n_rule, mem_size);
} else {
- log_error(logger, MODULE_ADAPTER_HS,
+ log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Adapter_hs module: build bool matcher failed",
__FUNCTION__, __LINE__);
@@ -667,7 +667,7 @@ void *adapter_hs_stream_open(void *hs_instance, int thread_id)
err = hs_open_stream(hs_inst->hs_rt->literal_db, 0,
&hs_stream->literal_stream);
if (err != HS_SUCCESS) {
- log_error(hs_inst->logger, MODULE_ADAPTER_HS,
+ log_fatal(hs_inst->logger, MODULE_ADAPTER_HS,
"hs_open_stream failed, hs err:%d", err);
err_count++;
}
@@ -677,7 +677,7 @@ void *adapter_hs_stream_open(void *hs_instance, int thread_id)
err = hs_open_stream(hs_inst->hs_rt->regex_db, 0,
&hs_stream->regex_stream);
if (err != HS_SUCCESS) {
- log_error(hs_inst->logger, MODULE_ADAPTER_HS,
+ log_fatal(hs_inst->logger, MODULE_ADAPTER_HS,
"hs_open_stream failed, hs err:%d", err);
err_count++;
}
@@ -843,7 +843,7 @@ int adapter_hs_scan_stream(void *hs_stream, const char *data, size_t data_len,
err_count++;
}
} else {
- log_error(stream->logger, MODULE_ADAPTER_HS,
+ log_fatal(stream->logger, MODULE_ADAPTER_HS,
"literal_scratches is null, thread_id:%d", thread_id);
err_scratch_flag++;
}
@@ -858,7 +858,7 @@ int adapter_hs_scan_stream(void *hs_stream, const char *data, size_t data_len,
err_count++;
}
} else {
- log_error(stream->logger, MODULE_ADAPTER_HS,
+ log_fatal(stream->logger, MODULE_ADAPTER_HS,
"regex_scratches is null, thread_id:%d", thread_id);
err_scratch_flag++;
}
diff --git a/scanner/expr_matcher/adapter_rs/adapter_rs.cpp b/scanner/expr_matcher/adapter_rs/adapter_rs.cpp
index 97d48f6..369c385 100644
--- a/scanner/expr_matcher/adapter_rs/adapter_rs.cpp
+++ b/scanner/expr_matcher/adapter_rs/adapter_rs.cpp
@@ -98,7 +98,7 @@ int adapter_rs_verify_regex_expression(const char *regex_expr,
{
int ret = rs_verify_regex(regex_expr);
if (ret == 0) {
- log_error(logger, MODULE_ADAPTER_RS,
+ log_fatal(logger, MODULE_ADAPTER_RS,
"[%s:%d] illegal regex expression: \"%s\"",
__FUNCTION__, __LINE__, regex_expr);
}
@@ -125,7 +125,7 @@ static int adpt_rs_build_database(struct adapter_rs_runtime *rs_rt,
ret = rs_compile_lit(literal_cd->patterns, literal_cd->n_patterns,
&rs_rt->literal_db);
if (ret < 0) {
- log_error(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error",
+ log_fatal(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error",
__FUNCTION__, __LINE__);
return -1;
}
@@ -136,7 +136,7 @@ static int adpt_rs_build_database(struct adapter_rs_runtime *rs_rt,
ret = rs_compile_regex(regex_cd->patterns, regex_cd->n_patterns,
n_worker_thread, &rs_rt->regex_db, &n_failed_pats);
if (ret < 0) {
- log_error(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error",
+ log_fatal(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error",
__FUNCTION__, __LINE__);
return -1;
}
@@ -283,7 +283,7 @@ void *adapter_rs_new(struct expr_rule *rules, size_t n_rule,
"Adapter_rs module: build bool matcher of %zu expressions"
" with %zu bytes memory", n_rule, mem_size);
} else {
- log_error(logger, MODULE_ADAPTER_RS,
+ log_fatal(logger, MODULE_ADAPTER_RS,
"[%s:%d] Adapter_rs module: build bool matcher failed",
__FUNCTION__, __LINE__);
@@ -507,7 +507,7 @@ void *adapter_rs_stream_open(void *rs_instance, int thread_id)
if (rs_inst->rs_rt->literal_db != NULL) {
rs_stream->literal_stream = rs_open_stream(rs_inst->rs_rt->literal_db, 0, 128);
if (NULL == rs_stream->literal_stream) {
- log_error(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed");
+ log_fatal(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed");
err_count++;
}
}
@@ -515,7 +515,7 @@ void *adapter_rs_stream_open(void *rs_instance, int thread_id)
if (rs_inst->rs_rt->regex_db != NULL) {
rs_stream->regex_stream = rs_open_stream(rs_inst->rs_rt->regex_db, 0, 128);
if (NULL == rs_stream->regex_stream) {
- log_error(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed");
+ log_fatal(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed");
err_count++;
}
}
diff --git a/scanner/expr_matcher/expr_matcher.cpp b/scanner/expr_matcher/expr_matcher.cpp
index 3a37383..64fbe97 100644
--- a/scanner/expr_matcher/expr_matcher.cpp
+++ b/scanner/expr_matcher/expr_matcher.cpp
@@ -98,7 +98,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
{
if (NULL == rules || 0 == n_rule || 0 == n_worker_thread ||
(engine_type != EXPR_ENGINE_TYPE_HS && engine_type != EXPR_ENGINE_TYPE_RS)) {
- log_error(logger, MODULE_EXPR_MATCHER, "[%s:%d]engine type:%d is illegal",
+ log_fatal(logger, MODULE_EXPR_MATCHER, "[%s:%d]engine type:%d is illegal",
__FUNCTION__, __LINE__, engine_type);
return NULL;
}
@@ -109,7 +109,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
for (i = 0; i < n_rule; i++) {
if (rules[i].n_patterns > MAX_EXPR_PATTERN_NUM) {
- log_error(logger, MODULE_EXPR_MATCHER,
+ log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d] the number of patterns in one expression should less than"
" %d", __FUNCTION__, __LINE__, MAX_EXPR_PATTERN_NUM);
return NULL;
@@ -118,7 +118,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
for (j = 0; j < rules[i].n_patterns; j++) {
/* pat_len should not 0 */
if (0 == rules[i].patterns[j].pat_len) {
- log_error(logger, MODULE_EXPR_MATCHER,
+ log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d] expr pattern length should not 0",
__FUNCTION__, __LINE__);
return NULL;
@@ -133,7 +133,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
}
if (0 == literal_pat_num && 0 == regex_pat_num) {
- log_error(logger, MODULE_EXPR_MATCHER,
+ log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d] exprs has no valid pattern", __FUNCTION__, __LINE__);
return NULL;
}
@@ -142,7 +142,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
regex_pat_num, n_worker_thread,
logger);
if (NULL == engine) {
- log_error(logger, MODULE_EXPR_MATCHER,
+ log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d]expr_matcher engine_new failed.", __FUNCTION__, __LINE__);
return NULL;
}
@@ -193,7 +193,7 @@ expr_matcher_stream_open(struct expr_matcher *matcher, int thread_id)
void *s_handle = expr_engine_ops[matcher->engine_type].engine_stream_open(matcher->engine,
thread_id);
if (NULL == s_handle) {
- log_error(matcher->logger, MODULE_EXPR_MATCHER,
+ log_fatal(matcher->logger, MODULE_EXPR_MATCHER,
"[%s:%d] expr_matcher engine_stream_open failed.",
__FUNCTION__, __LINE__);
return NULL;
diff --git a/src/inc_internal/maat_compile.h b/src/inc_internal/maat_compile.h
index 042dfe5..3a5f716 100644
--- a/src/inc_internal/maat_compile.h
+++ b/src/inc_internal/maat_compile.h
@@ -92,8 +92,14 @@ void compile_state_reset(struct compile_state *compile_state);
void compile_state_free(struct compile_state *compile_state,
struct maat *maat_instance, int thread_id);
-int compile_state_update(int vtable_id, struct maat_item *hit_items,
- size_t n_hit_item, struct maat_state *state);
+int compile_state_update(struct compile_state *compile_state, struct maat *maat_inst,
+ int vtable_id, int custom_compile_tbl_id, int Nth_scan,
+ struct maat_item *hit_items, size_t n_hit_item);
+
+void compile_state_not_logic_update(struct compile_state *compile_state,
+ struct compile_runtime *compile_rt,
+ struct maat *maat_inst, int vtable_id,
+ int Nth_scan);
size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
struct compile_runtime *compile_rt,
diff --git a/src/inc_internal/maat_utils.h b/src/inc_internal/maat_utils.h
index 96fa22c..0204b66 100644
--- a/src/inc_internal/maat_utils.h
+++ b/src/inc_internal/maat_utils.h
@@ -52,10 +52,10 @@ extern "C"
(type *)( (char *)__mptr - offsetof(type,member) );})
#endif
-#define MAX_HIT_PATH_NUM 4096
-#define MAX_SCANNER_HIT_COMPILE_NUM 4096
-#define MAX_SCANNER_HIT_GROUP_NUM 4096
-#define MAX_SCANNER_HIT_ITEM_NUM 4096
+#define MAX_HIT_PATH_NUM 4096
+#define MAX_HIT_COMPILE_NUM 4096
+#define MAX_HIT_GROUP_NUM 4096
+#define MAX_HIT_ITEM_NUM 4096
#define IPV4 4
#define IPV6 6
diff --git a/src/json2iris.c b/src/json2iris.c
index 19fa64b..56758cf 100644
--- a/src/json2iris.c
+++ b/src/json2iris.c
@@ -30,6 +30,7 @@
const int json_version = 1;
const char *untitled_group_name="Untitled";
+long long untitled_group_id = 123456789;
enum maat_group_relation {
PARENT_TYPE_COMPILE = 0,
@@ -242,7 +243,7 @@ static int write_plugin_line(cJSON *plug_table_json, int sequence,
{
cJSON *item = cJSON_GetObjectItem(plug_table_json, "table_name");
if (NULL == item || item->type != cJSON_String) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] The %d plugin_table's table_name "
"not defined or format error", __FUNCTION__,
__LINE__, sequence);
@@ -252,7 +253,7 @@ static int write_plugin_line(cJSON *plug_table_json, int sequence,
cJSON *table_content = cJSON_GetObjectItem(plug_table_json, "table_content");
if (NULL == table_content || table_content->type != cJSON_Array) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %d plugin_table's table_content not defined or format error",
__FUNCTION__, __LINE__, sequence);
return -1;
@@ -266,7 +267,7 @@ static int write_plugin_line(cJSON *plug_table_json, int sequence,
for (int i = 0; i < line_cnt; i++) {
each_line = cJSON_GetArrayItem(table_content, i);
if (NULL == each_line || each_line->type != cJSON_String) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] plugin_table %s's line %d format error",
__FUNCTION__, __LINE__, table_info->table_name, i + 1);
continue;
@@ -293,41 +294,17 @@ static struct group_info *group_info_read(struct group_info *group_name_map,
return node;
}
-static int get_group_seq(struct iris_description *iris_cfg)
+static struct group_info *
+group_info_add_unsafe(struct iris_description *p_iris, const char *group_name,
+ long long group_id)
{
- redisReply *data_reply=NULL;
- int sequence = 0;
-
- if (NULL == iris_cfg->redis_write_ctx) {
- sequence = iris_cfg->group_cnt;
- } else {
- data_reply = maat_wrap_redis_command(iris_cfg->redis_write_ctx,
- "INCRBY %s 1", mr_group_id_var);
- sequence = (int)data_reply->integer - 1;
- freeReplyObject(data_reply);
- data_reply = NULL;
- }
- iris_cfg->group_cnt++;
-
- return sequence;
-}
+ struct group_info *group_info = ALLOC(struct group_info, 1);
+ group_info->group_id = group_id;
+ strncpy(group_info->group_name, group_name, sizeof(group_info->group_name));
-static struct group_info *group_info_add_unsafe(struct iris_description *p_iris,
- const char *group_name)
-{
- static struct group_info untitled_group;
- struct group_info *group_info = NULL;
+ HASH_ADD_KEYPTR(hh, p_iris->group_name_map, group_info->group_name,
+ strlen(group_name), group_info);
- if (0 == strncasecmp(group_name, untitled_group_name, strlen(untitled_group_name))) {
- group_info = &untitled_group;
- group_info->group_id = get_group_seq(p_iris);
- } else {
- group_info = ALLOC(struct group_info, 1);
- group_info->group_id = get_group_seq(p_iris);
- strncpy(group_info->group_name, group_name, sizeof(group_info->group_name));
- HASH_ADD_KEYPTR(hh, p_iris->group_name_map, group_info->group_name,
- strlen(group_name), group_info);
- }
return group_info;
}
@@ -367,7 +344,7 @@ static int direct_write_rule(cJSON *json, struct maat_kv_store *str2int,
}
if (NULL == item || item->type != cmd[i].json_type) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %s not defined or wrong format",
__FUNCTION__, __LINE__, cmd[i].json_string);
ret = -1;
@@ -379,7 +356,7 @@ static int direct_write_rule(cJSON *json, struct maat_kv_store *str2int,
char *p = item->valuestring;
ret = maat_kv_read(str2int, p, &int_value, 1);
if (ret < 0) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %s's value %s is not valid format",
__FUNCTION__, __LINE__, cmd[i].json_string, p);
FREE(p);
@@ -618,7 +595,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
{
cJSON *item = cJSON_GetObjectItem(region_json, "table_name");
if (NULL == item || item->type != cJSON_String) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d's table_name not defined "
"or format error", __FUNCTION__, __LINE__, compile_id);
return -1;
@@ -627,7 +604,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
item = cJSON_GetObjectItem(region_json, "table_type");
if (NULL == item || item->type != cJSON_String) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d's table name %s's table_type "
"not defined or format error", __FUNCTION__, __LINE__,
compile_id, table_name);
@@ -638,7 +615,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
long long table_type_int;
int ret = maat_kv_read(p_iris->str2int_map, table_type_str, &table_type_int, 1);
if (ret != 1) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d table name %s's table_type %s invalid",
__FUNCTION__, __LINE__, compile_id, table_name, table_type_str);
return -1;
@@ -646,7 +623,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
cJSON *table_content = cJSON_GetObjectItem(region_json, "table_content");
if (NULL == table_content || table_content->type != cJSON_Object) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d table name %s's table_content "
"not defined or format error", __FUNCTION__, __LINE__,
compile_id, table_name);
@@ -737,6 +714,7 @@ static int write_group_rule(cJSON *group_json, int parent_id,
int clause_index = 0, is_exclude = 0;
const char *str_parent_type[2] = {"compile", "group"};
const char *group_name = NULL;
+ long long group_id = -1;
const char *virtual_table = NULL;
struct iris_table *g2c_table = NULL;
@@ -747,6 +725,11 @@ static int write_group_rule(cJSON *group_json, int parent_id,
group_name = item->valuestring;
}
+ item = cJSON_GetObjectItem(group_json, "group_id");
+ if (item != NULL && item->type == cJSON_Number) {
+ group_id = item->valueint;
+ }
+
item = cJSON_GetObjectItem(group_json, "is_exclude");
if (NULL == item || item->type != cJSON_Number) {
is_exclude = 0;
@@ -788,7 +771,18 @@ static int write_group_rule(cJSON *group_json, int parent_id,
struct group_info *group_info = group_info_read(p_iris->group_name_map, group_name);
//exist group name, regions and sub groups will be ommit.
if (NULL == group_info) {
- group_info = group_info_add_unsafe(p_iris, group_name);
+ if (0 == strncasecmp(group_name, untitled_group_name, strlen(untitled_group_name))) {
+ group_id = untitled_group_id;
+ }
+
+ if (-1 == group_id) {
+ log_fatal(logger, MODULE_JSON2IRIS,
+ "[%s:%d] group_name:<%s> has no group_id",
+ __FUNCTION__, __LINE__, group_name);
+ return -1;
+ }
+
+ group_info = group_info_add_unsafe(p_iris, group_name, group_id);
cJSON *region_json = cJSON_GetObjectItem(group_json, "regions");
if (region_json != NULL) {
cJSON *region_rule = NULL;
@@ -796,7 +790,7 @@ static int write_group_rule(cJSON *group_json, int parent_id,
ret = write_region_rule(region_rule, tracking_compile_id,
group_info->group_id, p_iris, logger);
if (ret < 0) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d write region error",
__FUNCTION__, __LINE__, tracking_compile_id);
return -1;
@@ -834,7 +828,7 @@ static int write_group_rule(cJSON *group_json, int parent_id,
}
if (ret < 0) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %s rule %d write group error",
__FUNCTION__, __LINE__, str_parent_type[parent_type], parent_id);
return -1;
@@ -848,7 +842,7 @@ static int write_compile_line(cJSON *compile, struct iris_description *p_iris,
{
cJSON *item=cJSON_GetObjectItem(compile, "compile_id");
if (item->type != cJSON_Number) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile_id format not number", __FUNCTION__, __LINE__);
return -1;
}
@@ -990,7 +984,7 @@ static int write_index_file(struct iris_description *p_iris,
{
p_iris->idx_fp = fopen(p_iris->index_path, "w");
if (NULL == p_iris->idx_fp) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] index file %s fopen error %s",
__FUNCTION__, __LINE__, p_iris->index_path, strerror(errno));
return -1;
@@ -1038,11 +1032,12 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
parent_group = group_info_read(p_iris->group_name_map, parent_group_name);
if(NULL == parent_group) {
- parent_group = group_info_add_unsafe(p_iris, parent_group_name);
+ parent_group = group_info_add_unsafe(p_iris, parent_group_name,
+ untitled_group_id);
}
- ret = write_group_rule(group_obj, parent_group->group_id, PARENT_TYPE_GROUP,
- 0, 0, p_iris, logger);
+ ret = write_group_rule(group_obj, parent_group->group_id,
+ PARENT_TYPE_GROUP, 0, 0, p_iris, logger);
if (ret < 0) {
return -1;
}
@@ -1060,14 +1055,14 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
cJSON_ArrayForEach(compile_obj, compile_array) {
int compile_id = write_compile_line(compile_obj, p_iris, logger);
if (compile_id < 0) {
- log_error(logger, MODULE_JSON2IRIS, "[%s:%d] In %d compile rule",
+ log_fatal(logger, MODULE_JSON2IRIS, "[%s:%d] In %d compile rule",
__FUNCTION__, __LINE__, i);
return -1;
}
group_array = cJSON_GetObjectItem(compile_obj, "groups");
if (NULL == group_array) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d have no group",
__FUNCTION__, __LINE__, compile_id);
return -1;
@@ -1075,7 +1070,7 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
int group_cnt = cJSON_GetArraySize(group_array);
if (group_cnt <= 0) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d have no groups",
__FUNCTION__, __LINE__, compile_id);
return -1;
@@ -1117,7 +1112,7 @@ int json2iris(const char *json_buff, const char *json_filename,
cJSON *json = cJSON_Parse(json_buff);
if (!json) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] error message: %-200.200s",
__FUNCTION__, __LINE__, cJSON_GetErrorPtr());
goto error_out;
@@ -1147,7 +1142,7 @@ int json2iris(const char *json_buff, const char *json_filename,
ret = create_tmp_dir(&iris_cfg);
if (ret < 0) {
- log_error(logger, MODULE_JSON2IRIS,
+ log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] create tmp folder %s error",
__FUNCTION__, __LINE__, iris_cfg.tmp_iris_dir);
goto error_out;
diff --git a/src/maat_api.c b/src/maat_api.c
index 8460e19..923f5c0 100644
--- a/src/maat_api.c
+++ b/src/maat_api.c
@@ -385,7 +385,7 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
if (maat_inst->opts.input_mode != DATA_SOURCE_IRIS_FILE &&
maat_inst->opts.input_mode != DATA_SOURCE_JSON_FILE &&
maat_inst->opts.input_mode != DATA_SOURCE_REDIS) {
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] data source(%d) unsupported",
__FUNCTION__, __LINE__, maat_inst->opts.input_mode);
goto failed;
@@ -412,7 +412,7 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
if (1 == maat_inst->opts.stat_on) {
int ret = maat_stat_init(maat_inst->stat, maat_inst->tbl_mgr, maat_inst->garbage_bin);
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] maat_stat_init failed.", __FUNCTION__, __LINE__);
goto failed;
}
@@ -516,7 +516,7 @@ int maat_table_callback_register(struct maat *maat_inst, int table_id,
void *schema = table_manager_get_schema(maat_inst->tbl_mgr, table_id);
if (NULL == schema) {
pthread_mutex_unlock(&(maat_inst->background_update_mutex));
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table(table_id:%d) schema is NULL, register callback failed",
__FUNCTION__, __LINE__, table_id);
return -1;
@@ -539,7 +539,7 @@ int maat_table_callback_register(struct maat *maat_inst, int table_id,
enum table_type table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type != TABLE_TYPE_PLUGIN) {
pthread_mutex_unlock(&(maat_inst->background_update_mutex));
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table type:%d illegal", __FUNCTION__, __LINE__, table_type);
return -1;
}
@@ -578,7 +578,7 @@ static int generic_plugin_table_set_ex_schema(struct table_manager *tbl_mgr, int
{
void *schema = table_manager_get_schema(tbl_mgr, table_id);
if (NULL == schema) {
- log_error(logger, MODULE_MAAT_API,
+ log_fatal(logger, MODULE_MAAT_API,
"[%s:%d], table(table_id:%d) is not registered, can't "
"register ex_container_schema", __FUNCTION__, __LINE__, table_id);
return -1;
@@ -614,7 +614,7 @@ static int generic_plugin_table_set_ex_schema(struct table_manager *tbl_mgr, int
free, argl, argp);
break;
default:
- log_error(logger, MODULE_MAAT_API,
+ log_fatal(logger, MODULE_MAAT_API,
"[%s:%d], table(table_id:%d) is not plugin table, can't set ex schema",
__FUNCTION__, __LINE__, table_id);
return -1;
@@ -735,7 +735,7 @@ static int generic_plugin_runtime_commit_ex_schema(void *runtime, void *schema,
struct log_handle *logger)
{
if (NULL == runtime || NULL == schema || valid_column < 0) {
- log_error(logger, MODULE_MAAT_API,
+ log_fatal(logger, MODULE_MAAT_API,
"[%s:%d] input parameter invalid, runtime:%p, schema:%p, valid_column:%d",
__FUNCTION__, __LINE__, runtime, schema, valid_column);
return -1;
@@ -758,7 +758,7 @@ static int generic_plugin_runtime_commit_ex_schema(void *runtime, void *schema,
bool_plugin_runtime_commit_ex_schema(runtime, schema, table_name, valid_column);
break;
default:
- log_error(logger, MODULE_MAAT_API,
+ log_fatal(logger, MODULE_MAAT_API,
"[%s:%d] table_type:%d invalid", __FUNCTION__, __LINE__, table_type);
return -1;
}
@@ -790,7 +790,7 @@ static int generic_plugin_table_ex_schema_register(struct maat *maat_inst,
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID || valid_column < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table_type:%d or valid_column:%d invalid",
__FUNCTION__, __LINE__, table_type, valid_column);
return -1;
@@ -812,7 +812,7 @@ int maat_plugin_table_ex_schema_register(struct maat *maat_inst,
long argl, void *argp)
{
if (NULL == maat_inst || NULL == table_name) {
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] [table:%s] ex_schema register input parameter is invalid.",
__FUNCTION__, __LINE__, table_name);
return -1;
@@ -820,7 +820,7 @@ int maat_plugin_table_ex_schema_register(struct maat *maat_inst,
int table_id = maat_get_table_id(maat_inst, table_name);
if (table_id < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] [table:%s] is not registered before.",
__FUNCTION__, __LINE__, table_name);
return -1;
@@ -992,14 +992,6 @@ int maat_bool_plugin_table_get_ex_data(struct maat *maat_inst, int table_id,
ex_data_array, array_size);
}
-static size_t hit_group_to_compile(void *compile_runtime, long long *compile_ids,
- size_t compile_ids_size, struct maat_state *state)
-{
- size_t n_hit_compile = compile_runtime_match((struct compile_runtime *)compile_runtime,
- compile_ids, compile_ids_size, state);
- return n_hit_compile;
-}
-
static int flag_scan(struct table_manager *tbl_mgr, int thread_id, long long flag,
int phy_table_id, int vtable_id, struct maat_state *state)
{
@@ -1185,25 +1177,24 @@ static size_t group_to_compile(struct maat *maat_inst, long long *results,
if (state->compile_table_id > 0) {
compile_table_id = state->compile_table_id;
- }
+ }
void *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr, compile_table_id);
if (NULL == compile_rt) {
return 0;
}
- size_t n_hit_compile = hit_group_to_compile(compile_rt, results, n_result, state);
-
- return n_hit_compile;
+ return compile_runtime_match((struct compile_runtime *)compile_rt,
+ results, n_result, state);
}
int maat_scan_flag(struct maat *maat_inst, int table_id,
long long flag, long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
- if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM
- || (NULL == results) || (0 == n_result) || (NULL == state) ||
- (state->thread_id < 0)) {
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (NULL == results) || (0 == n_result) || (NULL == n_hit_result) ||
+ (NULL == state) || (state->thread_id < 0)) {
return MAAT_SCAN_ERR;
}
@@ -1285,9 +1276,9 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
long long integer, long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
- if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM
- || (NULL == results) || (0 == n_result) || (NULL == state) ||
- (state->thread_id < 0)) {
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (NULL == results) || (0 == n_result) || (NULL == n_hit_result) ||
+ (NULL == state) || (state->thread_id < 0)) {
return MAAT_SCAN_ERR;
}
@@ -1369,9 +1360,9 @@ int maat_scan_ipv4(struct maat *maat_inst, int table_id, uint32_t ip_addr,
uint16_t port, int protocol, long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
- if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM
- || (protocol < -1) || (NULL == results) || (0 == n_result)
- || (NULL == state) || (state->thread_id < 0)) {
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (protocol < -1) || (NULL == results) || (0 == n_result) ||
+ (NULL == n_hit_result) || (NULL == state) || (state->thread_id < 0)) {
return MAAT_SCAN_ERR;
}
@@ -1454,9 +1445,10 @@ int maat_scan_ipv6(struct maat *maat_inst, int table_id,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
- if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM
- || (protocol < -1) || (NULL == ip_addr) || (NULL == results)
- || (0 == n_result) || (NULL == state) || (state->thread_id < 0)) {
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (protocol < -1) || (NULL == ip_addr) || (NULL == results) ||
+ (0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
+ (state->thread_id < 0)) {
return MAAT_SCAN_ERR;
}
@@ -1534,13 +1526,15 @@ int maat_scan_ipv6(struct maat *maat_inst, int table_id,
}
}
-int maat_scan_string(struct maat *maat_inst, int table_id, const char *data,
- size_t data_len, long long *results, size_t n_result,
+int maat_scan_string(struct maat *maat_inst, int table_id,
+ const char *data, size_t data_len,
+ long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
- if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM
- || (NULL == data) || (0 == data_len) || (NULL == results)
- || (0 == n_result) || (NULL == state) || (state->thread_id < 0)) {
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (NULL == data) || (0 == data_len) || (NULL == results) ||
+ (0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
+ (state->thread_id < 0)) {
return MAAT_SCAN_ERR;
}
@@ -1618,11 +1612,130 @@ int maat_scan_string(struct maat *maat_inst, int table_id, const char *data,
}
}
+static void maat_state_add_hit_group(struct maat_state *state, int table_id,
+ long long *group_ids, size_t n_group_id)
+{
+ struct maat *maat_inst = state->maat_inst;
+
+ if (NULL == state->compile_state) {
+ state->compile_state = compile_state_new();
+ alignment_int64_array_add(maat_inst->stat->compile_state_cnt,
+ state->thread_id, 1);
+ }
+
+ size_t n_hit_item = n_group_id;
+ if (n_group_id >= MAX_HIT_GROUP_NUM) {
+ n_hit_item = MAX_HIT_GROUP_NUM;
+ }
+
+ struct maat_item hit_items[n_hit_item];
+ for (size_t i = 0; i < n_hit_item; i++) {
+ hit_items[i].item_id = 0;
+ hit_items[i].group_id = group_ids[i];
+ }
+
+ compile_state_update(state->compile_state, maat_inst, table_id,
+ state->compile_table_id, state->scan_cnt,
+ hit_items, n_hit_item);
+}
+
+static void maat_state_activate_hit_not_group(struct maat_state *state, int table_id)
+{
+ if (NULL == state) {
+ return;
+ }
+
+ struct maat *maat_inst = state->maat_inst;
+ int compile_table_id = table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
+ if (state->compile_table_id > 0) {
+ compile_table_id = state->compile_table_id;
+ }
+
+ struct compile_runtime *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
+ compile_table_id);
+ if (NULL == compile_rt) {
+ return;
+ }
+
+ compile_state_not_logic_update(state->compile_state, compile_rt, maat_inst,
+ table_id, state->scan_cnt);
+}
+
+int maat_scan_group(struct maat *maat_inst, int table_id,
+ long long *group_ids, size_t n_group_id,
+ long long *results, size_t n_result,
+ size_t *n_hit_result, struct maat_state *state)
+{
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (NULL == group_ids) || (0 == n_group_id) || (NULL == results) ||
+ (0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
+ (state->thread_id < 0)) {
+ return -1;
+ }
+
+ state->scan_cnt++;
+
+ struct maat_runtime *maat_rt = maat_inst->maat_rt;
+ if (NULL == maat_rt) {
+ return MAAT_SCAN_OK;
+ }
+
+ maat_runtime_ref_inc(maat_rt, state->thread_id);
+ alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
+
+ maat_state_add_hit_group(state, table_id, group_ids, n_group_id);
+ size_t hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
+ *n_hit_result = hit_compile_cnt;
+
+ maat_runtime_ref_dec(maat_rt, state->thread_id);
+ if (hit_compile_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_cnt, state->thread_id, 1);
+ return MAAT_SCAN_HIT;
+ }
+
+ return MAAT_SCAN_OK;
+}
+
+int maat_scan_not_logic(struct maat *maat_inst, int table_id,
+ long long *results, size_t n_result,
+ size_t *n_hit_result, struct maat_state *state)
+{
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (NULL == results) || (0 == n_result) || (NULL == n_hit_result) ||
+ (NULL == state) || (state->thread_id < 0)) {
+ return -1;
+ }
+
+ if (NULL == state->compile_state) {
+ return 0;
+ }
+
+ struct maat_runtime *maat_rt = maat_inst->maat_rt;
+ if (NULL == maat_rt) {
+ return MAAT_SCAN_OK;
+ }
+
+ maat_runtime_ref_inc(maat_rt, state->thread_id);
+ alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
+
+ maat_state_activate_hit_not_group(state, table_id);
+ size_t hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
+ *n_hit_result = hit_compile_cnt;
+
+ maat_runtime_ref_dec(maat_rt, state->thread_id);
+ if (hit_compile_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_cnt, state->thread_id, 1);
+ return MAAT_SCAN_HIT;
+ }
+
+ return MAAT_SCAN_OK;
+}
+
struct maat_stream *maat_stream_new(struct maat *maat_inst, int table_id,
struct maat_state *state)
{
- if (NULL == maat_inst || table_id < 0 || table_id > MAX_TABLE_NUM
- || NULL == state || state->thread_id < 0) {
+ if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
+ (NULL == state) || (state->thread_id < 0)) {
return NULL;
}
@@ -1825,16 +1938,6 @@ void maat_state_free(struct maat_state *state)
thread_id, sizeof(struct maat_state));
}
-void maat_state_set_logic_not_disabled(struct maat_state *state)
-{
-
-}
-
-void maat_state_set_logic_not_enabled(struct maat_state *state)
-{
-
-}
-
int maat_state_set_scan_district(struct maat_state *state, int table_id,
const char *district, size_t district_len)
{
@@ -1846,7 +1949,7 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
assert(maat_inst != NULL);
if (NULL == maat_inst->maat_rt) {
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"maat runtime is NULL, can't set district");
return -1;
}
@@ -1855,7 +1958,7 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type != TABLE_TYPE_FLAG_PLUS && table_type != TABLE_TYPE_EXPR_PLUS &&
table_type != TABLE_TYPE_INTERVAL_PLUS && table_type != TABLE_TYPE_VIRTUAL) {
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"table_type:%d is invalid, can't set district", table_type);
return -1;
}
@@ -1886,7 +1989,7 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
district, district_len, &district_id);
break;
default:
- log_error(maat_inst->logger, MODULE_MAAT_API,
+ log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table_type:%d can't set district",
__FUNCTION__, __LINE__, table_type);
break;
diff --git a/src/maat_bool_plugin.c b/src/maat_bool_plugin.c
index 328ba31..bf04e5d 100644
--- a/src/maat_bool_plugin.c
+++ b/src/maat_bool_plugin.c
@@ -54,7 +54,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -62,7 +62,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -72,7 +72,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -82,7 +82,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->bool_expr_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no bool_expr column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -126,7 +126,7 @@ int bool_plugin_table_set_ex_container_schema(void *bool_plugin_schema, int tabl
struct bool_plugin_schema *schema = (struct bool_plugin_schema *)bool_plugin_schema;
if (1 == schema->container_schema.set_flag) {
- log_error(schema->logger, MODULE_BOOL_PLUGIN,
+ log_fatal(schema->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table(table_id:%d) ex_container_schema"
" has been set, can't set again", __FUNCTION__, __LINE__, table_id);
return -1;
@@ -270,7 +270,7 @@ static int bool_plugin_accept_tag_match(struct bool_plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
@@ -282,14 +282,14 @@ static int bool_plugin_accept_tag_match(struct bool_plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str);
if (TAG_MATCH_ERR == ret) {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
}
if (TAG_MATCH_UNMATCHED == ret) {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED;
@@ -319,7 +319,7 @@ bool_plugin_expr_new(struct bool_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -328,7 +328,7 @@ bool_plugin_expr_new(struct bool_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->bool_expr_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no bool_expr in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -345,7 +345,7 @@ bool_plugin_expr_new(struct bool_plugin_schema *schema, const char *table_name,
ret = sscanf(sub_token, "%llu", items + n_item);
n_item++;
if (ret != 1 || n_item > MAX_ITEMS_PER_BOOL_EXPR) {
- log_error(logger, MODULE_BOOL_PLUGIN,
+ log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has invalid format of "
"bool_expr in line:%s", __FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -386,7 +386,7 @@ int bool_plugin_runtime_update(void *bool_plugin_runtime, void *bool_plugin_sche
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
+ log_fatal(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -396,7 +396,7 @@ int bool_plugin_runtime_update(void *bool_plugin_runtime, void *bool_plugin_sche
int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len);
if (ret < 0) {
- log_error(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
+ log_fatal(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line);
@@ -488,7 +488,7 @@ int bool_plugin_runtime_commit(void *bool_plugin_runtime, const char *table_name
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_bool_matcher) {
- log_error(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
+ log_fatal(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] table[%s] rebuild bool_matcher engine failed when "
"update %zu bool_plugin rules", __FUNCTION__, __LINE__,
table_name, rule_cnt);
diff --git a/src/maat_command.c b/src/maat_command.c
index c3a8948..b85dda0 100644
--- a/src/maat_command.c
+++ b/src/maat_command.c
@@ -68,7 +68,7 @@ redisContext *maat_connect_redis(const char *redis_ip, int redis_port,
printf("Unable to connect redis server %s:%d db%d, error: %s",
redis_ip, redis_port, redis_db, c == NULL ? "Unknown" : c->errstr);
} else {
- log_error(logger, MODULE_MAAT_COMMAND,
+ log_fatal(logger, MODULE_MAAT_COMMAND,
"[%s:%d] Unable to connect redis server %s:%d db%d, error: %s",
__FUNCTION__, __LINE__, redis_ip, redis_port, redis_db,
c == NULL ? "Unknown" : c->errstr);
@@ -268,7 +268,7 @@ int maat_cmd_set_line(struct maat *maat_inst, const struct maat_cmd_line *line_r
int table_id = table_manager_get_table_id(maat_inst->tbl_mgr, line_rule->table_name);
if (table_id < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_COMMAND,
+ log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] Command set line id %lld failed: unknown table %s",
__FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name);
FREE(s_rule);
@@ -277,7 +277,7 @@ int maat_cmd_set_line(struct maat *maat_inst, const struct maat_cmd_line *line_r
int valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id);
if (valid_column < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_COMMAND,
+ log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] Command set line id %lld failed: table %s is not a plugin or ip_plugin table",
__FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name);
FREE(s_rule);
@@ -286,7 +286,7 @@ int maat_cmd_set_line(struct maat *maat_inst, const struct maat_cmd_line *line_r
int valid_offset = maat_get_valid_flag_offset(line_rule->table_line, valid_column);
if (valid_offset < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_COMMAND,
+ log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] Command set line id %lld failed: table %s valid_offset error",
__FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name);
FREE(s_rule);
@@ -322,7 +322,7 @@ int maat_cmd_set_file(struct maat *maat_inst, const char *key, const char *value
{
redisContext *ctx = maat_inst->opts.redis_ctx.write_ctx;
if (NULL == ctx) {
- log_error(maat_inst->logger, MODULE_MAAT_COMMAND,
+ log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] failed: Redis is not connected.",
__FUNCTION__, __LINE__);
return -1;
@@ -342,7 +342,7 @@ int maat_cmd_set_file(struct maat *maat_inst, const char *key, const char *value
redisReply *reply = NULL;
if (0 != strncmp(key, foreign_key_prefix, strlen(foreign_key_prefix))) {
- log_error(maat_inst->logger, MODULE_MAAT_COMMAND,
+ log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"Invalid File key, prefix %s is mandatory.", foreign_key_prefix);
return -1;
}
@@ -361,7 +361,7 @@ int maat_cmd_set_file(struct maat *maat_inst, const char *key, const char *value
}
if (NULL == reply || reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) {
- log_error(maat_inst->logger, MODULE_MAAT_COMMAND,
+ log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"Set file failed, maybe Redis is busy.");
freeReplyObject(reply);
reply = NULL;
diff --git a/src/maat_compile.c b/src/maat_compile.c
index 8625ed0..8da7589 100644
--- a/src/maat_compile.c
+++ b/src/maat_compile.c
@@ -30,7 +30,6 @@
#define MAX_SUPER_GROUP_CNT 128
#define MAX_NOT_CLAUSE_NUM 8
-#define VTABLE_MAX_NOT_GROUP_NUM 8
enum clause_not_flag {
CLAUSE_NOT_FLAG_UNSET = 0,
@@ -85,9 +84,17 @@ struct literal_clause {
UT_hash_handle hh;
};
-struct table_not_clause {
- int table_id;
- int not_clause_num;
+struct table_clause {
+ int vtable_id;
+ int actual_clause_num;
+ UT_array *clause_ids;
+ UT_array *group_ids;
+ UT_hash_handle hh;
+};
+
+struct table_group {
+ int vtable_id;
+ UT_array *group_ids;
UT_hash_handle hh;
};
@@ -113,7 +120,7 @@ struct group2compile_runtime {
long long rule_num;
long long update_err_cnt;
struct compile_runtime *ref_compile_rt;
- struct table_not_clause *not_clause_hash;
+ struct table_clause *tbl_not_clause_hash; //each virtual table's not clause number <= MAX_NOT_CLAUSE_NUM
};
struct maat_clause {
@@ -155,18 +162,22 @@ struct compile2table_id {
struct compile_state {
int Nth_scan;
+ int this_scan_not_logic;
time_t compile_rt_version;
UT_array *internal_hit_paths;
UT_array *all_hit_clauses;
UT_array *this_scan_hit_clauses;
+ UT_array *this_scan_hit_not_clauses;
UT_array *direct_hit_groups;
UT_array *indirect_hit_groups;
UT_array *hit_compile_table_ids;
+ struct table_group *hit_not_groups;
};
UT_icd ut_literal_id_icd = {sizeof(struct literal_id), NULL, NULL, NULL};
UT_icd ut_clause_id_icd = {sizeof(long long), NULL, NULL, NULL};
+UT_icd ut_compile_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
UT_icd ut_maat_hit_group_icd = {sizeof(struct maat_hit_group), NULL, NULL, NULL};
UT_icd ut_hit_path_icd = {sizeof(struct internal_hit_path), NULL, NULL, NULL};
UT_icd ut_hit_compile_table_id_icd = {sizeof(struct compile2table_id), NULL, NULL, NULL};
@@ -213,7 +224,7 @@ static int compile_accept_tag_match(struct compile_schema *schema, const char *l
int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
@@ -225,14 +236,14 @@ static int compile_accept_tag_match(struct compile_schema *schema, const char *l
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str);
if (TAG_MATCH_ERR == ret) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
}
if (TAG_MATCH_UNMATCHED == ret) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED;
@@ -259,7 +270,7 @@ compile_item_new(const char *table_line, struct compile_schema *schema,
ret = get_column_pos(table_line, schema->compile_id_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has no compile_id in line:%s",
__FUNCTION__, __LINE__, table_name, table_line);
goto error;
@@ -269,7 +280,7 @@ compile_item_new(const char *table_line, struct compile_schema *schema,
ret = get_column_pos(table_line, schema->declared_clause_num_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has no clause_num in line:%s",
__FUNCTION__, __LINE__, table_name, table_line);
goto error;
@@ -278,7 +289,7 @@ compile_item_new(const char *table_line, struct compile_schema *schema,
compile_item->declared_clause_num = atoi(table_line + column_offset);
if (compile_item->declared_clause_num < 0 ||
compile_item->declared_clause_num > MAX_NOT_CLAUSE_NUM) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> clause_num:%d exceed maximum:%d in line:%s",
__FUNCTION__, __LINE__, table_name, compile_item->declared_clause_num,
MAX_NOT_CLAUSE_NUM, table_line);
@@ -355,7 +366,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -363,7 +374,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -373,7 +384,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->compile_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no compile_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -388,7 +399,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->declared_clause_num_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no clause_num column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -416,7 +427,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
g2c_schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -426,7 +437,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
g2c_schema->asso_compile_table_id = item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no associated_compile_table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -434,7 +445,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -444,7 +455,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->group_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -454,7 +465,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->compile_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no compile_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -464,7 +475,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->not_flag_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no not_flag column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -474,7 +485,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->vtable_name_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no virtual_table_name column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -484,7 +495,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->clause_index_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no clause_index column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -520,7 +531,7 @@ void *compile_runtime_new(void *compile_schema, size_t max_thread_num,
struct compile_runtime *compile_rt = ALLOC(struct compile_runtime, 1);
compile_rt->expr_match_buff = ALLOC(struct bool_expr_match,
- max_thread_num * MAX_SCANNER_HIT_COMPILE_NUM);
+ max_thread_num * MAX_HIT_COMPILE_NUM);
compile_rt->version = time(NULL);
compile_rt->cfg_hash = rcu_hash_new(rcu_compile_cfg_free, NULL, 0);
compile_rt->tbl_cfg_hash = rcu_hash_new(rcu_compile_table_cfg_free, NULL, 0);
@@ -612,7 +623,7 @@ void *group2compile_runtime_new(void *g2c_schema, size_t max_thread_num,
}
struct group2compile_runtime *g2c_rt = ALLOC(struct group2compile_runtime, 1);
- g2c_rt->not_clause_hash = NULL;
+ g2c_rt->tbl_not_clause_hash = NULL;
return g2c_rt;
}
@@ -631,14 +642,14 @@ void group2compile_runtime_free(void *g2c_runtime)
}
struct group2compile_runtime *g2c_rt = (struct group2compile_runtime *)g2c_runtime;
- if (g2c_rt->not_clause_hash != NULL) {
- struct table_not_clause *not_clause = NULL, *tmp_not_clause = NULL;
- HASH_ITER(hh, g2c_rt->not_clause_hash, not_clause, tmp_not_clause) {
- HASH_DEL(g2c_rt->not_clause_hash, not_clause);
+ if (g2c_rt->tbl_not_clause_hash != NULL) {
+ struct table_clause *not_clause = NULL, *tmp_not_clause = NULL;
+ HASH_ITER(hh, g2c_rt->tbl_not_clause_hash, not_clause, tmp_not_clause) {
+ HASH_DEL(g2c_rt->tbl_not_clause_hash, not_clause);
FREE(not_clause);
}
}
- assert(g2c_rt->not_clause_hash == NULL);
+ assert(g2c_rt->tbl_not_clause_hash == NULL);
FREE(g2c_runtime);
}
@@ -672,7 +683,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
int ret = get_column_pos(line, g2c_schema->group_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -682,7 +693,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->compile_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no compile_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -692,7 +703,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->not_flag_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no NOT_flag in line:%s ",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -701,7 +712,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->not_flag = atoi(line + column_offset);
if (g2c_item->not_flag != CLAUSE_NOT_FLAG_SET &&
g2c_item->not_flag != CLAUSE_NOT_FLAG_UNSET) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> NOT_flag:%d is illegal in line:%s ",
__FUNCTION__, __LINE__, table_name, g2c_item->not_flag, line);
goto error;
@@ -710,14 +721,14 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->vtable_name_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no virtual_table_name in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
if (column_len > MAX_NAME_STR_LEN) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> virtual_table_name length exceed "
"maxium:%d in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_NAME_STR_LEN, line);
@@ -731,7 +742,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->vtable_id = table_manager_get_table_id(g2c_schema->ref_tbl_mgr,
vtable_name);
if (g2c_item->vtable_id < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has unknown virtual table:%s in line:%s",
__FUNCTION__, __LINE__, table_name, vtable_name, line);
goto error;
@@ -741,7 +752,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->clause_index_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no clause_index in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -749,7 +760,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->clause_index = atoi(line + column_offset);
if (g2c_item->clause_index < 0 || g2c_item->clause_index >= MAX_NOT_CLAUSE_NUM) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> clause_index:%d exceed maximum:%d in line:%s",
__FUNCTION__, __LINE__, table_name, g2c_item->clause_index,
MAX_NOT_CLAUSE_NUM, line);
@@ -910,7 +921,7 @@ maat_compile_bool_matcher_new(struct compile_runtime *compile_rt, size_t *compil
// STEP 3, build bool matcher
size_t mem_size = 0;
if (0 == expr_cnt) {
- log_error(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] No bool expression to build bool matcher.",
__FUNCTION__, __LINE__);
FREE(bool_expr_array);
@@ -923,7 +934,7 @@ maat_compile_bool_matcher_new(struct compile_runtime *compile_rt, size_t *compil
"Build bool matcher of %zu expressions with %zu bytes memory.",
expr_cnt, mem_size);
} else {
- log_error(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] Build bool matcher failed!", __FUNCTION__, __LINE__);
}
@@ -1058,17 +1069,28 @@ static int maat_compile_has_clause(struct maat_compile *compile, long long claus
static size_t compile_state_if_new_hit_compile(struct compile_state *compile_state,
struct maat_compile *compile)
{
+ size_t i = 0;
size_t r_in_c_cnt = 0;
int ret = 0;
long long new_hit_clause_id = 0;
- for (size_t i = 0; i < utarray_len(compile_state->this_scan_hit_clauses); i++) {
- new_hit_clause_id = *(long long*)utarray_eltptr(compile_state->this_scan_hit_clauses, i);
- ret = maat_compile_has_clause(compile, new_hit_clause_id);
- if (ret) {
- r_in_c_cnt++;
- }
- }
+ if (0 == compile_state->this_scan_not_logic) {
+ for (i = 0; i < utarray_len(compile_state->this_scan_hit_clauses); i++) {
+ new_hit_clause_id = *(long long*)utarray_eltptr(compile_state->this_scan_hit_clauses, i);
+ ret = maat_compile_has_clause(compile, new_hit_clause_id);
+ if (ret) {
+ r_in_c_cnt++;
+ }
+ }
+ } else {
+ for (i = 0; i < utarray_len(compile_state->this_scan_hit_not_clauses); i++) {
+ new_hit_clause_id = *(long long*)utarray_eltptr(compile_state->this_scan_hit_not_clauses, i);
+ ret = maat_compile_has_clause(compile, new_hit_clause_id);
+ if (ret) {
+ r_in_c_cnt++;
+ }
+ }
+ }
return r_in_c_cnt;
}
@@ -1104,7 +1126,7 @@ static size_t maat_compile_bool_matcher_match(struct compile_runtime *compile_rt
size_t ud_result_cnt = 0;
struct maat_compile *compile = NULL;
struct bool_expr_match *expr_match = compile_rt->expr_match_buff +
- (thread_id * MAX_SCANNER_HIT_COMPILE_NUM);
+ (thread_id * MAX_HIT_COMPILE_NUM);
assert(thread_id >= 0);
if (0 == compile_state->compile_rt_version) {
@@ -1128,7 +1150,7 @@ static size_t maat_compile_bool_matcher_match(struct compile_runtime *compile_rt
int bool_match_ret = bool_matcher_match(compile_rt->bm,
(unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0),
utarray_len(compile_state->all_hit_clauses),
- expr_match, MAX_SCANNER_HIT_COMPILE_NUM);
+ expr_match, MAX_HIT_COMPILE_NUM);
for (int i = 0; i < bool_match_ret && ud_result_cnt < ud_array_size; i++) {
compile = (struct maat_compile *)expr_match[i].user_tag;
assert(compile->magic_num == MAAT_COMPILE_MAGIC);
@@ -1214,7 +1236,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1226,7 +1248,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1254,7 +1276,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(copy_compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1267,7 +1289,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1294,7 +1316,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
compile = rcu_updating_hash_find(hash_tbl, (char *)&compile_id,
sizeof(long long));
if (NULL == compile) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld from compile_id:%lld failed, compile"
" is not existed.", __FUNCTION__, __LINE__, g2c_item->group_id,
compile_id);
@@ -1304,7 +1326,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_remove_literal(compile, &literal_id,
g2c_item->clause_index);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld vtable_id %d from clause %d of "
"compile_id:%lld failed, literal is not in compile.", __FUNCTION__,
__LINE__, g2c_item->group_id, g2c_item->vtable_id,
@@ -1337,7 +1359,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_remove_literal(copy_compile, &literal_id,
g2c_item->clause_index);
if (ret < 0) {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld vtable_id %d from clause %d of compile_id:"
"%lld failed, literal is not in compile.", __FUNCTION__, __LINE__,
g2c_item->group_id, g2c_item->vtable_id, g2c_item->clause_index,
@@ -1350,7 +1372,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), copy_compile);
}
} else {
- log_error(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld from compile_id:%lld failed, "
"compile is not existed.", __FUNCTION__, __LINE__,
g2c_item->group_id, compile_id);
@@ -1368,28 +1390,58 @@ struct compile_state *compile_state_new(void)
utarray_new(compile_state->internal_hit_paths, &ut_hit_path_icd);
utarray_new(compile_state->all_hit_clauses, &ut_clause_id_icd);
utarray_new(compile_state->this_scan_hit_clauses, &ut_clause_id_icd);
+ utarray_new(compile_state->this_scan_hit_not_clauses, &ut_clause_id_icd);
utarray_new(compile_state->direct_hit_groups, &ut_maat_hit_group_icd);
utarray_new(compile_state->indirect_hit_groups, &ut_maat_hit_group_icd);
utarray_new(compile_state->hit_compile_table_ids, &ut_hit_compile_table_id_icd);
+ compile_state->hit_not_groups = NULL;
return compile_state;
}
+static long long compile_state_hit_not_groups_free(struct compile_state *compile_state)
+{
+ if (NULL == compile_state) {
+ return 0;
+ }
+
+ long long free_bytes = 0;
+ struct table_group *tbl_group = NULL, *tmp_tbl_group = NULL;
+ HASH_ITER(hh, compile_state->hit_not_groups, tbl_group, tmp_tbl_group) {
+ free_bytes += (sizeof(tbl_group) + utarray_len(tbl_group->group_ids) * sizeof(long long));
+ HASH_DEL(compile_state->hit_not_groups, tbl_group);
+ if (tbl_group->group_ids != NULL) {
+ utarray_free(tbl_group->group_ids);
+ tbl_group->group_ids = NULL;
+ }
+ FREE(tbl_group);
+ }
+
+ return free_bytes;
+}
+
void compile_state_reset(struct compile_state *compile_state)
{
if (NULL == compile_state) {
return;
}
+ compile_state->this_scan_not_logic = 0;
compile_state->Nth_scan = 0;
compile_state->compile_rt_version = 0;
utarray_clear(compile_state->internal_hit_paths);
utarray_clear(compile_state->all_hit_clauses);
utarray_clear(compile_state->this_scan_hit_clauses);
+ utarray_clear(compile_state->this_scan_hit_not_clauses);
utarray_clear(compile_state->direct_hit_groups);
utarray_clear(compile_state->indirect_hit_groups);
utarray_clear(compile_state->hit_compile_table_ids);
+
+ struct table_group *tbl_group = NULL, *tmp_tbl_group = NULL;
+ HASH_ITER(hh, compile_state->hit_not_groups, tbl_group, tmp_tbl_group) {
+ utarray_clear(tbl_group->group_ids);
+ }
}
void compile_state_free(struct compile_state *compile_state,
@@ -1419,6 +1471,12 @@ void compile_state_free(struct compile_state *compile_state,
compile_state->this_scan_hit_clauses = NULL;
}
+ if (compile_state->this_scan_hit_not_clauses != NULL) {
+ free_bytes += utarray_size(compile_state->this_scan_hit_not_clauses) * sizeof(long long);
+ utarray_free(compile_state->this_scan_hit_not_clauses);
+ compile_state->this_scan_hit_not_clauses = NULL;
+ }
+
if (compile_state->direct_hit_groups != NULL) {
free_bytes += utarray_size(compile_state->direct_hit_groups) * sizeof(struct maat_hit_group);
utarray_free(compile_state->direct_hit_groups);
@@ -1437,6 +1495,8 @@ void compile_state_free(struct compile_state *compile_state,
compile_state->hit_compile_table_ids = NULL;
}
+ free_bytes += compile_state_hit_not_groups_free(compile_state);
+
FREE(compile_state);
free_bytes += sizeof(struct compile_state);
@@ -1444,14 +1504,14 @@ void compile_state_free(struct compile_state *compile_state,
thread_id, free_bytes);
}
-static void add_internal_hit_path(UT_array *hit_paths, long long item_id,
- long long group_id, int vtable_id, int NOT_flag,
- int Nth_scan)
+static void compile_state_add_internal_hit_path(struct compile_state *compile_state,
+ long long item_id, long long group_id,
+ int vtable_id, int NOT_flag, int Nth_scan)
{
- if (NULL == hit_paths || utarray_len(hit_paths) >= MAX_HIT_PATH_NUM) {
+ if (NULL == compile_state) {
return;
}
-
+
struct internal_hit_path new_path;
new_path.item_id = item_id;
new_path.Nth_scan = Nth_scan;
@@ -1459,7 +1519,7 @@ static void add_internal_hit_path(UT_array *hit_paths, long long item_id,
new_path.vtable_id = vtable_id;
new_path.NOT_flag = NOT_flag;
- utarray_push_back(hit_paths, &new_path);
+ utarray_push_back(compile_state->internal_hit_paths, &new_path);
}
static int maat_compile_has_literal(struct maat_compile *compile,
@@ -1508,7 +1568,7 @@ size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thr
struct maat_compile *compile = NULL;
struct literal_id literal_id = {0, 0};
struct bool_expr_match *expr_match = compile_rt->expr_match_buff +
- (thread_id * MAX_SCANNER_HIT_COMPILE_NUM);
+ (thread_id * MAX_HIT_COMPILE_NUM);
assert(thread_id >= 0);
if (compile_state->compile_rt_version != compile_rt->version) {
@@ -1517,8 +1577,8 @@ size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thr
int bool_match_ret = bool_matcher_match(compile_rt->bm,
(unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0),
- utarray_len(compile_state->all_hit_clauses), expr_match,
- MAX_SCANNER_HIT_COMPILE_NUM);
+ utarray_len(compile_state->all_hit_clauses), expr_match, MAX_HIT_COMPILE_NUM);
+
for (int idx = 0; idx < bool_match_ret; idx++) {
compile = (struct maat_compile *)expr_match[idx].user_tag;
assert(compile->magic_num == MAAT_COMPILE_MAGIC);
@@ -1620,6 +1680,33 @@ static void compile_state_add_hit_clauses(struct compile_state *compile_state,
}
}
+static void compile_state_add_hit_not_clauses(struct compile_state *compile_state,
+ UT_array *clause_id_array)
+{
+ size_t i = 0;
+ long long *clause_id = NULL;
+ size_t new_clause_idx = utarray_len(compile_state->this_scan_hit_not_clauses);
+
+ for (i = 0; i < utarray_len(clause_id_array); i++) {
+ clause_id = (long long *)utarray_eltptr(clause_id_array, i);
+ if (utarray_find(compile_state->all_hit_clauses, clause_id, compare_clause_id)) {
+ continue;
+ }
+ utarray_push_back(compile_state->this_scan_hit_not_clauses, clause_id);
+ }
+
+ if ((utarray_len(compile_state->this_scan_hit_not_clauses) - new_clause_idx) > 0) {
+ utarray_reserve(compile_state->all_hit_clauses,
+ utarray_len(compile_state->this_scan_hit_not_clauses) - new_clause_idx);
+
+ for (i = new_clause_idx; i < utarray_len(compile_state->this_scan_hit_not_clauses); i++) {
+ clause_id = (long long *)utarray_eltptr(compile_state->this_scan_hit_not_clauses, i);
+ utarray_push_back(compile_state->all_hit_clauses, clause_id);
+ }
+ utarray_sort(compile_state->all_hit_clauses, compare_clause_id);
+ }
+}
+
static void compile_state_update_hit_clauses(struct compile_state *compile_state,
struct compile_runtime *compile_rt,
long long group_id, int vtable_id)
@@ -1653,43 +1740,58 @@ static inline int compare_group_id(const void *a, const void *b)
}
}
-static size_t compile_state_update_hit_not_clauses(struct compile_state *compile_state,
- struct compile_runtime *compile_rt,
- long long *group_ids, size_t n_group_ids,
- int vtable_id, long long *NOT_group_ids_array,
- size_t NOT_group_ids_array_size)
+static void compile_state_cache_hit_not_groups(struct compile_state *compile_state,
+ struct compile_runtime *compile_rt,
+ long long *hit_group_ids,
+ size_t n_hit_group_id, int vtable_id)
{
if (NULL == compile_state || NULL == compile_rt) {
- return 0;
+ return;
}
- if (n_group_ids != 0) {
- qsort(group_ids, n_group_ids, sizeof(long long *), compare_group_id);
+ if (n_hit_group_id != 0) {
+ qsort(hit_group_ids, n_hit_group_id, sizeof(long long *), compare_group_id);
}
- size_t hit_NOT_group_cnt = 0;
- struct literal_clause *l2c_val = NULL, *tmp_l2c_val = NULL;
+ struct table_group *tbl_group = NULL;
+ HASH_FIND(hh, compile_state->hit_not_groups, &vtable_id, sizeof(int), tbl_group);
+ if (tbl_group != NULL) {
+ for (size_t i = 0; i < n_hit_group_id; i++) {
+ long long *group_id = (long long *)utarray_find(tbl_group->group_ids,
+ &hit_group_ids[i],
+ compare_group_id);
+ if (NULL == group_id) {
+ continue;
+ }
+ size_t remove_idx = utarray_eltidx(tbl_group->group_ids, group_id);
+ utarray_erase(tbl_group->group_ids, remove_idx, 1);
+ }
+ }
- //NOTE: Each virtual table can reference up to VTABLE_MAX_NOT_GROUP_NUM groups
+ struct literal_clause *l2c_val = NULL, *tmp_l2c_val = NULL;
HASH_ITER(hh, compile_rt->literal2not_clause_hash, l2c_val, tmp_l2c_val) {
if (l2c_val->key.vtable_id != vtable_id) {
continue;
}
- long long *tmp_group_id = bsearch(&(l2c_val->key.group_id), group_ids, n_group_ids,
- sizeof(long long), compare_group_id);
+ long long *tmp_group_id = bsearch(&(l2c_val->key.group_id), hit_group_ids,
+ n_hit_group_id, sizeof(long long), compare_group_id);
if (tmp_group_id != NULL) {
continue;
}
- if (hit_NOT_group_cnt < NOT_group_ids_array_size) {
- NOT_group_ids_array[hit_NOT_group_cnt++] = l2c_val->key.group_id;
+ if (NULL == tbl_group) {
+ tbl_group = ALLOC(struct table_group, 1);
+ tbl_group->vtable_id = vtable_id;
+ utarray_new(tbl_group->group_ids, &ut_compile_group_id_icd);
+ HASH_ADD_INT(compile_state->hit_not_groups, vtable_id, tbl_group);
}
- compile_state_add_hit_clauses(compile_state, l2c_val->clause_ids);
+ if (!utarray_find(tbl_group->group_ids, &(l2c_val->key.group_id), compare_group_id)) {
+ utarray_push_back(tbl_group->group_ids, &(l2c_val->key.group_id));
+ utarray_sort(tbl_group->group_ids, compare_group_id);
+ }
}
-
- return hit_NOT_group_cnt;
}
int compile_state_get_compile_table_id(struct compile_state *compile_state,
@@ -1853,7 +1955,7 @@ int compile_runtime_update(void *compile_runtime, void *compile_schema,
struct compile_runtime *compile_rt = (struct compile_runtime *)compile_runtime;
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] compile table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -1863,7 +1965,7 @@ int compile_runtime_update(void *compile_runtime, void *compile_schema,
long long compile_id = get_column_value(line, schema->compile_id_column);
if (compile_id < 0) {
- log_error(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] compile table:<%s> has no compile_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->compile_id_column, line);
@@ -1899,32 +2001,32 @@ static int validate_table_not_clause(struct group2compile_runtime *g2c_rt,
struct table_manager *tbl_mgr, int table_id,
int is_valid, struct log_handle *logger)
{
- struct table_not_clause *not_clause = NULL;
- HASH_FIND_INT(g2c_rt->not_clause_hash, &table_id, not_clause);
+ struct table_clause *not_clause = NULL;
+ HASH_FIND_INT(g2c_rt->tbl_not_clause_hash, &table_id, not_clause);
if (0 == is_valid) {
//delete
- if (NULL == not_clause || 0 == not_clause->not_clause_num) {
+ if (NULL == not_clause || 0 == not_clause->actual_clause_num) {
return 0;
} else {
- not_clause->not_clause_num--;
+ not_clause->actual_clause_num--;
}
} else {
//add
if (NULL == not_clause) {
- not_clause = ALLOC(struct table_not_clause, 1);
- not_clause->table_id = table_id;
- not_clause->not_clause_num++;
- HASH_ADD_INT(g2c_rt->not_clause_hash, table_id, not_clause);
+ not_clause = ALLOC(struct table_clause, 1);
+ not_clause->vtable_id = table_id;
+ not_clause->actual_clause_num++;
+ HASH_ADD_INT(g2c_rt->tbl_not_clause_hash, vtable_id, not_clause);
} else {
- if (not_clause->not_clause_num >= MAX_NOT_CLAUSE_NUM) {
+ if (not_clause->actual_clause_num >= MAX_NOT_CLAUSE_NUM) {
const char *table_name = table_manager_get_table_name(tbl_mgr, table_id);
log_fatal(logger, MODULE_COMPILE,
"[%s:%d]table:<%s> NOT clause num exceed maximum:%d",
__FUNCTION__, __LINE__, table_name, MAX_NOT_CLAUSE_NUM);
return -1;
}
- not_clause->not_clause_num++;
+ not_clause->actual_clause_num++;
}
}
@@ -1945,7 +2047,7 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -2061,7 +2163,7 @@ int compile_runtime_commit(void *compile_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_bool_matcher) {
- log_error(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] table[%s] rebuild compile bool_matcher failed, compile"
" rules count:%zu", __FUNCTION__, __LINE__, table_name, compile_cnt);
ret = -1;
@@ -2190,23 +2292,17 @@ int compile_runtime_match(struct compile_runtime *compile_rt, long long *compile
return MIN(bool_match_ret, compile_ids_size);
}
-int compile_state_update(int vtable_id, struct maat_item *hit_items,
- size_t n_hit_item, struct maat_state *state)
+int compile_state_update(struct compile_state *compile_state, struct maat *maat_inst,
+ int vtable_id, int custom_compile_tbl_id, int Nth_scan,
+ struct maat_item *hit_items, size_t n_hit_item)
{
size_t i = 0, j = 0;
size_t hit_cnt = n_hit_item;
- long long hit_group_ids[MAX_SCANNER_HIT_GROUP_NUM];
-
- struct maat *maat_inst = state->maat_inst;
- if (NULL == state->compile_state) {
- state->compile_state = compile_state_new();
- alignment_int64_array_add(maat_inst->stat->compile_state_cnt,
- state->thread_id, 1);
- }
+ long long hit_group_ids[MAX_HIT_GROUP_NUM];
- struct compile_state *compile_state = state->compile_state;
utarray_clear(compile_state->this_scan_hit_clauses);
- compile_state->Nth_scan = state->scan_cnt;
+ compile_state->this_scan_not_logic = 0;
+ compile_state->Nth_scan = Nth_scan;
for (i = 0; i < hit_cnt; i++) {
hit_group_ids[i] = hit_items[i].group_id;
@@ -2215,14 +2311,15 @@ int compile_state_update(int vtable_id, struct maat_item *hit_items,
int g2g_table_id = table_manager_get_group2group_table_id(maat_inst->tbl_mgr);
void *g2g_rt = table_manager_get_runtime(maat_inst->tbl_mgr, g2g_table_id);
- long long super_group_ids[MAX_SCANNER_HIT_GROUP_NUM];
+ long long super_group_ids[MAX_HIT_GROUP_NUM];
size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_rt, hit_group_ids,
hit_cnt, super_group_ids,
- MAX_SCANNER_HIT_GROUP_NUM);
+ MAX_HIT_GROUP_NUM);
if (1 == maat_inst->opts.hit_path_on && hit_cnt > 0) {
for (i = 0; i < hit_cnt; i++) {
- add_internal_hit_path(compile_state->internal_hit_paths, hit_items[i].item_id,
- hit_items[i].group_id, vtable_id, 0, state->scan_cnt);
+ compile_state_add_internal_hit_path(compile_state, hit_items[i].item_id,
+ hit_items[i].group_id, vtable_id,
+ 0, Nth_scan);
}
}
@@ -2234,8 +2331,8 @@ int compile_state_update(int vtable_id, struct maat_item *hit_items,
/* update hit clause */
int compile_table_id = table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
- if (state->compile_table_id > 0) {
- compile_table_id = state->compile_table_id;
+ if (custom_compile_tbl_id > 0) {
+ compile_table_id = custom_compile_tbl_id;
}
struct compile_runtime *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
@@ -2244,28 +2341,56 @@ int compile_state_update(int vtable_id, struct maat_item *hit_items,
return 0;
}
- for (j = 0; j < super_group_cnt && hit_cnt < MAX_SCANNER_HIT_GROUP_NUM; j++) {
+ for (j = 0; j < super_group_cnt && hit_cnt < MAX_HIT_GROUP_NUM; j++) {
hit_group_ids[hit_cnt++] = super_group_ids[j];
}
for (i = 0; i < hit_cnt; i++) {
- compile_state_update_hit_clauses(state->compile_state, compile_rt,
- hit_group_ids[i], vtable_id);
+ compile_state_update_hit_clauses(compile_state, compile_rt,
+ hit_group_ids[i], vtable_id);
}
- long long hit_NOT_group_ids[VTABLE_MAX_NOT_GROUP_NUM];
- size_t hit_not_cnt = compile_state_update_hit_not_clauses(state->compile_state, compile_rt,
- hit_group_ids, hit_cnt, vtable_id,
- hit_NOT_group_ids, VTABLE_MAX_NOT_GROUP_NUM);
-
- if (1 == maat_inst->opts.hit_path_on && hit_not_cnt > 0) {
- for (i = 0; i < hit_not_cnt; i++) {
- add_internal_hit_path(compile_state->internal_hit_paths, -1, hit_NOT_group_ids[i],
- vtable_id, 1, state->scan_cnt);
- }
+ compile_state_cache_hit_not_groups(compile_state, compile_rt, hit_group_ids,
+ hit_cnt, vtable_id);
+ return hit_cnt;
+}
+
+void compile_state_not_logic_update(struct compile_state *compile_state,
+ struct compile_runtime *compile_rt,
+ struct maat *maat_inst, int vtable_id,
+ int Nth_scan)
+{
+ if (NULL == compile_state || NULL == maat_inst) {
+ return;
}
- return (hit_cnt + hit_not_cnt);
+ compile_state->this_scan_not_logic = 1;
+ compile_state->Nth_scan = Nth_scan;
+ utarray_clear(compile_state->this_scan_hit_not_clauses);
+
+ struct table_group *tbl_group = NULL;
+ HASH_FIND(hh, compile_state->hit_not_groups, &vtable_id, sizeof(int), tbl_group);
+ if (NULL == tbl_group) {
+ return;
+ }
+
+ struct literal_clause *l2c_val = NULL;
+ for (size_t i = 0; i < utarray_len(tbl_group->group_ids); i++) {
+ long long *group_id = utarray_eltptr(tbl_group->group_ids, i);
+ struct literal_id literal_id = {*group_id, vtable_id, 1};
+
+ HASH_FIND(hh, compile_rt->literal2not_clause_hash, &literal_id,
+ sizeof(struct literal_id), l2c_val);
+ if (NULL == l2c_val) {
+ continue;
+ }
+
+ compile_state_add_hit_not_clauses(compile_state, l2c_val->clause_ids);
+ if (1 == maat_inst->opts.hit_path_on) {
+ compile_state_add_internal_hit_path(compile_state, -1, *group_id,
+ vtable_id, 1, Nth_scan);
+ }
+ }
}
size_t compile_state_get_indirect_hit_groups(struct compile_state *compile_state,
@@ -2332,7 +2457,6 @@ size_t compile_state_get_direct_hit_group_cnt(struct compile_state *compile_stat
return utarray_len(compile_state->direct_hit_groups);
}
-UT_icd ut_compile_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
struct compile_runtime *compile_rt,
struct group2group_runtime *g2g_rt,
@@ -2347,12 +2471,12 @@ size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
/*
NOTE: maybe one item has been deleted, but it's item_id still exist in internal_hit_paths
*/
- long long super_group_ids[MAX_SCANNER_HIT_GROUP_NUM];
+ long long super_group_ids[MAX_HIT_GROUP_NUM];
UT_array *valid_super_group_ids;
utarray_new(valid_super_group_ids, &ut_compile_group_id_icd);
size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_rt, &(internal_path->group_id), 1,
- super_group_ids, MAX_SCANNER_HIT_GROUP_NUM);
+ super_group_ids, MAX_HIT_GROUP_NUM);
for (size_t idx = 0; idx < super_group_cnt; idx++) {
utarray_push_back(valid_super_group_ids, &super_group_ids[idx]);
}
@@ -2394,4 +2518,4 @@ size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
}
return hit_path_cnt;
-} \ No newline at end of file
+}
diff --git a/src/maat_config_monitor.c b/src/maat_config_monitor.c
index 1ac467b..8e178c8 100644
--- a/src/maat_config_monitor.c
+++ b/src/maat_config_monitor.c
@@ -55,7 +55,7 @@ static int cm_read_cfg_index_file(const char *path, struct cm_table_info_t *idx,
ret = stat(idx[i].cfg_path, &file_info);
if (ret != 0) {
- log_error(logger, MODULE_CONFIG_MONITOR, "%s of %s not exist",
+ log_fatal(logger, MODULE_CONFIG_MONITOR, "%s of %s not exist",
idx[i].cfg_path, path);
fclose(fp);
return -1;
@@ -63,7 +63,7 @@ static int cm_read_cfg_index_file(const char *path, struct cm_table_info_t *idx,
i++;
if (i == size) {
- log_error(logger, MODULE_CONFIG_MONITOR, "Too much lines in %s", path);
+ log_fatal(logger, MODULE_CONFIG_MONITOR, "Too much lines in %s", path);
break;
}
}
@@ -123,7 +123,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
if (strlen(index->encrypt_algo) > 0) {
//JSON file has been encrypted
if (NULL == dec_key || 0 == strlen(dec_key)) {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"update error, no key to decrypt %s.",
index->cfg_path);
return -1;
@@ -133,7 +133,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
(unsigned char**)&file_buff, &file_sz, error_string,
sizeof(error_string));
if (ret < 0) {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"update error, decrypt %s failed: %s",
index->cfg_path, error_string);
return -1;
@@ -142,7 +142,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
// not encrypted
ret = load_file_to_memory(index->cfg_path, (unsigned char **)&file_buff, &file_sz);
if (ret < 0) {
- log_error(logger, MODULE_CONFIG_MONITOR, "[%s:%d] open %s failed.",
+ log_fatal(logger, MODULE_CONFIG_MONITOR, "[%s:%d] open %s failed.",
__FUNCTION__, __LINE__, index->cfg_path);
return -1;
}
@@ -156,7 +156,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
if(cfg_num != index->cfg_num) {
FREE(file_buff);
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] file %s config num not matched",
__FUNCTION__, __LINE__, index->cfg_path);
return -1;
@@ -168,14 +168,14 @@ static int cm_read_table_file(struct cm_table_info_t *index,
char *ret_str = read_nxt_line_from_buff(file_buff, file_sz, &file_offset,
line, sizeof(line));
if (ret_str == NULL) {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] file %s line_num %d less than claimed %d",
__FUNCTION__, __LINE__, index->cfg_path, i, cfg_num);
break;
}
if(line[sizeof(line) - 1] != '\0') {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] line size more than %u at of file %s:%d",
__FUNCTION__, __LINE__, sizeof(line), index->cfg_path, i);
continue;
@@ -266,7 +266,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
int n = my_scandir(file_dir, &namelist, filter_fn,
(int (*)(const void*, const void*))alphasort);
if (n < 0) {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] scan dir error", __FUNCTION__, __LINE__);
return update_type;
}
@@ -288,7 +288,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
}
if (strlen(namelist[i]->d_name) > 42) {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] config file %s filename too long, should like"
" full_config_index.000000000001",
__FUNCTION__, __LINE__, namelist[i]->d_name);
@@ -298,7 +298,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
int ret = sscanf(namelist[i]->d_name,"%[a-zA-Z]_config_index.%lld",
update_str, &config_seq);
if (ret != 2) {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] config file %s filename error, should like"
" full_config_index.000000000001",
__FUNCTION__, __LINE__, namelist[i]->d_name);
@@ -319,7 +319,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
}
}
} else {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] config file %s, not full or inc config",
__FUNCTION__, __LINE__, namelist[i]->d_name);
}
@@ -381,7 +381,7 @@ void config_monitor_traverse(long long current_version, const char *idx_dir,
log_info(logger, MODULE_CONFIG_MONITOR, "load %s", idx_path_array[i]);
int table_num = cm_read_cfg_index_file(idx_path_array[i], table_array, MAX_TABLE_NUM, logger);
if (table_num < 0) {
- log_error(logger, MODULE_CONFIG_MONITOR,
+ log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] load %s failed, abandon update",
__FUNCTION__, __LINE__, idx_path_array[i]);
break;
@@ -434,7 +434,7 @@ int load_maat_json_file(struct maat *maat_inst, const char *json_filename,
&decrypted_buff_sz,
err_str, err_str_sz);
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_CONFIG_MONITOR,
+ log_fatal(maat_inst->logger, MODULE_CONFIG_MONITOR,
"[%s:%d] Decrypt Maat JSON file %s failed",
__FUNCTION__, __LINE__, json_filename);
return -1;
@@ -449,7 +449,7 @@ int load_maat_json_file(struct maat *maat_inst, const char *json_filename,
&uncompressed_buff_sz);
FREE(json_buff);
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_CONFIG_MONITOR,
+ log_fatal(maat_inst->logger, MODULE_CONFIG_MONITOR,
"[%s:%d] Uncompress Maat JSON file %s failed",
__FUNCTION__, __LINE__, json_filename);
return -1;
@@ -463,7 +463,7 @@ int load_maat_json_file(struct maat *maat_inst, const char *json_filename,
if (NULL == json_buff) {
ret = load_file_to_memory(json_filename, &json_buff, &json_buff_sz);
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_CONFIG_MONITOR,
+ log_fatal(maat_inst->logger, MODULE_CONFIG_MONITOR,
"[%s:%d] Read Maat JSON file %s failed",
__FUNCTION__, __LINE__, json_filename);
return -1;
diff --git a/src/maat_expr.c b/src/maat_expr.c
index 5be2ecb..a381d10 100644
--- a/src/maat_expr.c
+++ b/src/maat_expr.c
@@ -187,7 +187,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
int ret = get_column_pos(line, expr_schema->item_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -197,7 +197,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->group_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -206,14 +206,14 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->keywords_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no keywords in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
if (column_len > MAX_KEYWORDS_STR_LEN) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> keywords length too long in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -222,7 +222,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->expr_type_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no expr_type in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -231,14 +231,14 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
expr_type = atoi(line + column_offset);
expr_item->expr_type = int_to_expr_type(expr_type);
if (expr_item->expr_type == EXPR_TYPE_INVALID) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has invalid expr_type in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
} else if (expr_item->expr_type == EXPR_TYPE_REGEX) {
ret = expr_matcher_verify_regex_expression(expr_item->keywords, expr_rt->logger);
if (0 == ret) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> regex expression(item_id:%lld):%s illegal,"
" will be dropped", __FUNCTION__, __LINE__, table_name,
expr_item->item_id, expr_item->keywords);
@@ -254,7 +254,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
}
if (column_len > MAX_DISTRICT_STR_LEN) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> district length exceed maximum:%d"
" in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_DISTRICT_STR_LEN, line);
@@ -272,7 +272,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->match_method_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no match_method in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -281,7 +281,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
match_method_type = atoi(line + column_offset);
expr_item->match_mode = int_to_match_mode(match_method_type);
if (expr_item->match_mode == EXPR_MATCH_MODE_INVALID) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has invalid match_method in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -289,7 +289,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->is_hexbin_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no is_hexbin in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -310,7 +310,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
expr_item->is_case_sensitive = TRUE;
break;
default:
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has invalid hexbin value:%d in line:%s",
__FUNCTION__, __LINE__, table_name, db_hexbin, line);
goto error;
@@ -333,7 +333,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
expr_schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -345,7 +345,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -355,7 +355,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -365,7 +365,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->group_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -375,7 +375,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->keywords_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no keywords column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -387,7 +387,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->district_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr_plus table:<%s> schema has no district column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -398,7 +398,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->expr_type_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no expr_type column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -408,7 +408,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->match_method_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no match_method column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -418,7 +418,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->is_hexbin_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no is_hexbin column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -553,7 +553,7 @@ static int expr_runtime_update_row(struct expr_runtime *expr_rt, char *key,
//add
ret = rcu_hash_add(expr_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr item(item_id:%lld) add to item_hash failed",
__FUNCTION__, __LINE__, item->item_id);
return -1;
@@ -637,7 +637,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
}
if (i >= MAAT_MAX_EXPR_ITEM_NUM) {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) "
"too many patterns", __FUNCTION__, __LINE__,
expr_item->item_id);
@@ -657,7 +657,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
}
if (i >= MAAT_MAX_EXPR_ITEM_NUM) {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) "
"too many patterns", __FUNCTION__, __LINE__,
expr_item->item_id);
@@ -669,7 +669,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
&(key_right_offset[i]));
if (!(key_left_offset[i] >= 0 && key_right_offset[i] > 0
&& key_left_offset[i] <= key_right_offset[i])) {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) "
"has invalid offset.", __FUNCTION__, __LINE__,
expr_item->item_id);
@@ -679,7 +679,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
sub_key_array[i] = (char *)memchr(sub_key_array[i], ':',
strlen(sub_key_array[i]));
if (NULL == sub_key_array[i]) {
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) "
"has invalid offset keyword format.",
__FUNCTION__, __LINE__, expr_item->item_id);
@@ -701,7 +701,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
sub_key_array[0] = expr_item->keywords;
break;
default:
- log_error(logger, MODULE_EXPR,
+ log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%lld) has "
"invalid expr type=%d", __FUNCTION__, __LINE__,
expr_item->item_id, expr_item->expr_type);
@@ -769,7 +769,7 @@ int expr_runtime_update(void *expr_runtime, void *expr_schema,
long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line);
@@ -779,7 +779,7 @@ int expr_runtime_update(void *expr_runtime, void *expr_schema,
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -887,7 +887,7 @@ int expr_runtime_commit(void *expr_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_matcher) {
- log_error(expr_rt->logger, MODULE_EXPR,
+ log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] table[%s] rebuild expr_matcher failed when update"
" %zu expr rules", __FUNCTION__, __LINE__, table_name, real_rule_cnt);
ret = -1;
@@ -969,9 +969,9 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
}
size_t n_hit_item = 0;
- struct expr_scan_result hit_results[MAX_SCANNER_HIT_ITEM_NUM];
+ struct expr_scan_result hit_results[MAX_HIT_ITEM_NUM];
int ret = expr_matcher_match(expr_rt->matcher, thread_id, data, data_len,
- hit_results, MAX_SCANNER_HIT_ITEM_NUM, &n_hit_item);
+ hit_results, MAX_HIT_ITEM_NUM, &n_hit_item);
if (ret < 0) {
return -1;
}
@@ -1003,7 +1003,15 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
}
next:
- return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state);
+ if (NULL == state->compile_state) {
+ state->compile_state = compile_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ state->thread_id, 1);
+ }
+
+ return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
+ state->compile_table_id, state->scan_cnt,
+ hit_maat_items, real_hit_item_cnt);
}
struct expr_matcher_stream *
@@ -1033,10 +1041,10 @@ int expr_runtime_stream_scan(struct expr_runtime *expr_rt,
}
size_t n_hit_item = 0;
- struct expr_scan_result hit_results[MAX_SCANNER_HIT_ITEM_NUM];
+ struct expr_scan_result hit_results[MAX_HIT_ITEM_NUM];
int ret = expr_matcher_stream_match(s_handle, data, data_len, hit_results,
- MAX_SCANNER_HIT_ITEM_NUM, &n_hit_item);
+ MAX_HIT_ITEM_NUM, &n_hit_item);
if (ret < 0) {
return -1;
}
@@ -1065,7 +1073,15 @@ int expr_runtime_stream_scan(struct expr_runtime *expr_rt,
}
next:
- return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state);
+ if (NULL == state->compile_state) {
+ state->compile_state = compile_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ state->thread_id, 1);
+ }
+
+ return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
+ state->compile_table_id, state->scan_cnt,
+ hit_maat_items, real_hit_item_cnt);
}
void expr_runtime_stream_close(struct expr_runtime *expr_rt, int thread_id,
diff --git a/src/maat_flag.c b/src/maat_flag.c
index 65b48d9..f5a1c4c 100644
--- a/src/maat_flag.c
+++ b/src/maat_flag.c
@@ -73,7 +73,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_FLAG,
+ log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -85,7 +85,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_error(logger, MODULE_FLAG,
+ log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -95,7 +95,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FLAG,
+ log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -105,7 +105,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->group_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FLAG,
+ log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -117,7 +117,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->district_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FLAG,
+ log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag_plus table:<%s> schema has no district column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -128,7 +128,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->flag_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FLAG,
+ log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no flag column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -138,7 +138,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->flag_mask_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FLAG,
+ log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no flag_mask column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -254,7 +254,7 @@ static int flag_runtime_update_row(struct flag_runtime *flag_rt, char *key,
//add
ret = rcu_hash_add(flag_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag item(item_id:%lld) add to item_hash failed",
__FUNCTION__, __LINE__, item->item_id);
return -1;
@@ -309,7 +309,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
int ret = get_column_pos(line, schema->item_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -319,7 +319,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->group_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -335,7 +335,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
}
if (column_len > MAX_DISTRICT_STR_LEN) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag_plus table:<%s> district length exceed "
"maximum:%d in line:%s", __FUNCTION__, __LINE__,
table_name, MAX_DISTRICT_STR_LEN, line);
@@ -353,7 +353,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->flag_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no flag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -363,7 +363,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->flag_mask_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no flag_mask in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -402,7 +402,7 @@ int flag_runtime_update(void *flag_runtime, void *flag_schema,
long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line);
@@ -411,7 +411,7 @@ int flag_runtime_update(void *flag_runtime, void *flag_schema,
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -499,7 +499,7 @@ int flag_runtime_commit(void *flag_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_flag_matcher) {
- log_error(flag_rt->logger, MODULE_FLAG,
+ log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] table[%s] rebuild flag_matcher engine failed "
"when update %zu flag rules", __FUNCTION__, __LINE__,
table_name, rule_cnt);
@@ -556,9 +556,8 @@ int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
return 0;
}
- struct flag_result hit_results[MAX_SCANNER_HIT_ITEM_NUM];
- int n_hit_item = flag_matcher_match(flag_rt->matcher, flag,
- hit_results, MAX_SCANNER_HIT_ITEM_NUM);
+ struct flag_result hit_results[MAX_HIT_ITEM_NUM];
+ int n_hit_item = flag_matcher_match(flag_rt->matcher, flag, hit_results, MAX_HIT_ITEM_NUM);
if (n_hit_item < 0) {
return -1;
}
@@ -589,7 +588,15 @@ int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
}
next:
- return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state);
+ if (NULL == state->compile_state) {
+ state->compile_state = compile_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ state->thread_id, 1);
+ }
+
+ return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
+ state->compile_table_id, state->scan_cnt,
+ hit_maat_items, real_hit_item_cnt);
}
void flag_runtime_hit_inc(struct flag_runtime *flag_rt, int thread_id)
diff --git a/src/maat_fqdn_plugin.c b/src/maat_fqdn_plugin.c
index 595e9f6..9100a46 100644
--- a/src/maat_fqdn_plugin.c
+++ b/src/maat_fqdn_plugin.c
@@ -54,7 +54,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -62,7 +62,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -72,7 +72,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -82,7 +82,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->suffix_match_method_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no suffix_match_method column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -93,7 +93,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->fqdn_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no fqdn column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -137,7 +137,7 @@ int fqdn_plugin_table_set_ex_container_schema(void *fqdn_plugin_schema, int tabl
struct fqdn_plugin_schema *schema = (struct fqdn_plugin_schema *)fqdn_plugin_schema;
if (1 == schema->container_schema.set_flag) {
- log_error(schema->logger, MODULE_FQDN_PLUGIN,
+ log_fatal(schema->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table(table_id:%d) ex_container_schema "
"has been set, can't set again", __FUNCTION__, __LINE__, table_id);
return -1;
@@ -240,7 +240,7 @@ static int fqdn_plugin_accept_tag_match(struct fqdn_plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
@@ -252,14 +252,14 @@ static int fqdn_plugin_accept_tag_match(struct fqdn_plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str);
if (TAG_MATCH_ERR == ret) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
}
if (TAG_MATCH_UNMATCHED == ret) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED;
@@ -287,7 +287,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -296,7 +296,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
ret = get_column_pos(line, schema->suffix_match_method_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no suffix_match_method in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -305,7 +305,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
fqdn_plugin_rule->is_suffix_match = atoi(line + column_offset);
if (fqdn_plugin_rule->is_suffix_match != 0 &&
fqdn_plugin_rule->is_suffix_match != 1) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> suffix_match_method:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, fqdn_plugin_rule->is_suffix_match, line);
goto error;
@@ -313,7 +313,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
ret = get_column_pos(line, schema->fqdn_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_FQDN_PLUGIN,
+ log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no fqdn in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -399,7 +399,7 @@ int fqdn_plugin_runtime_update(void *fqdn_plugin_runtime, void *fqdn_plugin_sche
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
+ log_fatal(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -409,7 +409,7 @@ int fqdn_plugin_runtime_update(void *fqdn_plugin_runtime, void *fqdn_plugin_sche
int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len);
if (ret < 0) {
- log_error(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
+ log_fatal(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line);
@@ -501,7 +501,7 @@ int fqdn_plugin_runtime_commit(void *fqdn_plugin_runtime, const char *table_name
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_fqdn_engine) {
- log_error(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
+ log_fatal(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] table[%s] rebuild FQDN engine failed when update"
" %zu fqdn_plugin rules", __FUNCTION__, __LINE__, table_name,
rule_cnt);
diff --git a/src/maat_group.c b/src/maat_group.c
index 0cc0d9e..02ad9a6 100644
--- a/src/maat_group.c
+++ b/src/maat_group.c
@@ -96,7 +96,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
g2g_schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -104,7 +104,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -114,7 +114,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2g_schema->group_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -124,7 +124,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2g_schema->super_group_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no super_group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -134,7 +134,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2g_schema->is_exclude_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no is_exclude column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -329,7 +329,7 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
int ret = get_column_pos(line, g2g_schema->group_id_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -339,7 +339,7 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
ret = get_column_pos(line, g2g_schema->super_group_id_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2 table:<%s> has no super_group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -349,7 +349,7 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
ret = get_column_pos(line, g2g_schema->is_exclude_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> has no is_exclude in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -357,14 +357,14 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
g2g_item->is_exclude = atoi(line + column_offset);
if (g2g_item->is_exclude != 0 && g2g_item->is_exclude != 1) {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> is_exclude:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, g2g_item->is_exclude, line);
goto error;
}
if (g2g_item->is_exclude != 0 && g2g_item->is_exclude != 1) {
- log_error(logger, MODULE_GROUP,
+ log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> is_exclude:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, g2g_item->is_exclude, line);
goto error;
@@ -433,7 +433,7 @@ static void group_topology_del_group(struct maat_group_topology *group_topo,
igraph_neighbors(&group_topo->group_graph, &v, group->vertex_id, IGRAPH_ALL);
if (igraph_vector_size(&v) > 0) {
print_igraph_vector(&v, buff, sizeof(buff));
- log_error(group_topo->logger, MODULE_GROUP,
+ log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Del group %d exception, still reached by %s.",
__FUNCTION__, __LINE__, group->vertex_id, buff);
assert(0);
@@ -595,7 +595,7 @@ static int group_topology_add_group_to_group(struct maat_group_topology *group_t
//No duplicated edges between two groups.
if (edge_id > 0) {
- log_error(group_topo->logger, MODULE_GROUP,
+ log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Add group %d to group %d failed, relation already existed.",
__FUNCTION__, __LINE__, group->group_id, super_group->group_id);
ret = -1;
@@ -621,7 +621,7 @@ static int group_topology_del_group_from_group(struct maat_group_topology *group
//No hash write operation, LOCK protection is unnecessary.
struct maat_group *group = group_topology_find_group(group_topo, group_id);
if (NULL == group) {
- log_error(group_topo->logger, MODULE_GROUP,
+ log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Del group %d from group %d failed, group %d not existed.",
__FUNCTION__, __LINE__, group_id, super_group_id, group_id);
return -1;
@@ -629,7 +629,7 @@ static int group_topology_del_group_from_group(struct maat_group_topology *group
struct maat_group *super_group = group_topology_find_group(group_topo, super_group_id);
if (NULL == super_group) {
- log_error(group_topo->logger, MODULE_GROUP,
+ log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Del group %d from group %d failed, superior group %d not existed.",
__FUNCTION__, __LINE__, group_id, super_group_id, super_group_id);
return -1;
@@ -677,7 +677,7 @@ static int group_topology_build_super_groups(struct maat_group_topology *group_t
igraph_bool_t is_dag;
igraph_is_dag(&(group_topo->group_graph), &is_dag);
if (!is_dag) {
- log_error(group_topo->logger, MODULE_GROUP,
+ log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Sub group cycle detected!", __FUNCTION__, __LINE__);
return -1;
}
@@ -709,7 +709,7 @@ int group2group_runtime_update(void *g2g_runtime, void *g2g_schema,
struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(g2g_rt->logger, MODULE_GROUP,
+ log_fatal(g2g_rt->logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -790,7 +790,7 @@ int group2group_runtime_commit(void *g2g_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000;
if (ret < 0) {
- log_error(g2g_rt->logger, MODULE_GROUP,
+ log_fatal(g2g_rt->logger, MODULE_GROUP,
"[%s:%d] table[%s] group2group runtime commit failed",
__FUNCTION__, __LINE__, table_name);
return -1;
@@ -1007,12 +1007,12 @@ static void get_super_group_ids(struct maat_group_topology *group_topo,
UT_array *kept_super_group_ids;
if (depth >= MAX_RECURSION_DEPTH) {
- log_error(group_topo->logger, MODULE_GROUP,
+ log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d]exceed max recursion depth(5)",
__FUNCTION__, __LINE__);
for (int i = 0; i < utarray_len(hit_group_ids); i++) {
long long *p = (long long *)utarray_eltptr(hit_group_ids, i);
- log_error(group_topo->logger, MODULE_GROUP,
+ log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d]group_id:%lld can't recursively get super group_id",
__FUNCTION__, __LINE__, *p);
}
diff --git a/src/maat_interval.c b/src/maat_interval.c
index 3dcb8cf..c0e7700 100644
--- a/src/maat_interval.c
+++ b/src/maat_interval.c
@@ -70,7 +70,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_INTERVAL,
+ log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -82,7 +82,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_error(logger, MODULE_INTERVAL,
+ log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -92,7 +92,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_INTERVAL,
+ log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -102,7 +102,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->group_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_INTERVAL,
+ log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -114,7 +114,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->district_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_INTERVAL,
+ log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval_plus table:<%s> schema has no district column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -125,7 +125,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->low_bound_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_INTERVAL,
+ log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no low_bound column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -135,7 +135,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->up_bound_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_INTERVAL,
+ log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no up_bound column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -283,7 +283,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
int ret = get_column_pos(line, schema->item_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -293,7 +293,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->group_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -309,7 +309,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
}
if (column_len > MAX_DISTRICT_STR_LEN) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval_plus table:<%s> district length exceed "
"maximum:%d in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_DISTRICT_STR_LEN, line);
@@ -327,7 +327,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->low_bound_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no low_bound in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -336,7 +336,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->up_bound_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no up_bound in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -375,7 +375,7 @@ static int interval_runtime_update_row(struct interval_runtime *interval_rt,
//add
ret = rcu_hash_add(interval_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval item(item_id:%lld) add to "
"interavl_item_hash failed", __FUNCTION__, __LINE__,
item->item_id);
@@ -400,7 +400,7 @@ int interval_runtime_update(void *interval_runtime, void *interval_schema,
long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line);
@@ -410,7 +410,7 @@ int interval_runtime_update(void *interval_runtime, void *interval_schema,
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -499,7 +499,7 @@ int interval_runtime_commit(void *interval_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_interval_matcher) {
- log_error(interval_rt->logger, MODULE_INTERVAL,
+ log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] table[%s]rebuild interval_matcher engine failed "
"when update %zu interval rules", __FUNCTION__, __LINE__,
table_name, rule_cnt);
@@ -556,9 +556,9 @@ int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
return 0;
}
- struct interval_result hit_results[MAX_SCANNER_HIT_ITEM_NUM];
+ struct interval_result hit_results[MAX_HIT_ITEM_NUM];
int n_hit_item = interval_matcher_match(interval_rt->matcher, integer,
- hit_results, MAX_SCANNER_HIT_ITEM_NUM);
+ hit_results, MAX_HIT_ITEM_NUM);
if (n_hit_item < 0) {
return -1;
}
@@ -589,7 +589,15 @@ int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
}
next:
- return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state);
+ if (NULL == state->compile_state) {
+ state->compile_state = compile_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ state->thread_id, 1);
+ }
+
+ return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
+ state->compile_table_id, state->scan_cnt,
+ hit_maat_items, real_hit_item_cnt);
}
void interval_runtime_hit_inc(struct interval_runtime *interval_rt, int thread_id)
diff --git a/src/maat_ip.c b/src/maat_ip.c
index 55bdd9f..cfa3c68 100644
--- a/src/maat_ip.c
+++ b/src/maat_ip.c
@@ -95,7 +95,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
ip_schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -103,7 +103,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -113,7 +113,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -123,7 +123,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->group_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -133,7 +133,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->addr_type_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no add_type column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -143,7 +143,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->addr_format_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no addr_format column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -153,7 +153,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->ip1_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no ip1 column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -163,7 +163,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->ip2_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no ip2 column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -173,7 +173,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->port_format_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no port_format column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -183,7 +183,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->port1_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no port1 column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -193,7 +193,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->port2_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no port2 column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -203,7 +203,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->protocol_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no protocol column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -232,11 +232,11 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
char ip1_str[40] = {0};
char ip2_str[40] = {0};
struct ip_item *ip_item = ALLOC(struct ip_item, 1);
-
+
int ret = get_column_pos(line, ip_schema->item_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -246,7 +246,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->group_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -256,7 +256,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->addr_type_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no addr_type in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -264,7 +264,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ip_item->addr_type = atoi(line + column_offset);
if (ip_item->addr_type != IPv4 && ip_item->addr_type != IPv6) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has invalid addr type:%d in line:%s",
__FUNCTION__, __LINE__, table_name, ip_item->addr_type, line);
goto error;
@@ -273,14 +273,14 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->addr_format_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no addr_format in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
memcpy(addr_format, (line + column_offset), column_len);
if (IP_FORMAT_UNKNOWN == ip_format_str2int(addr_format)) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has invalid addr_format, "
"should be single/range/CIDR/mask in line:%s",
__FUNCTION__, __LINE__, table_name, line);
@@ -290,7 +290,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->ip1_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no ip1 in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -300,7 +300,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->ip2_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no ip2 in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -311,7 +311,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = ip_format2range(ip_item->addr_type, ip_format_str2int(addr_format),
ip1_str, ip2_str, &ip_item->ipv4.min_ip, &ip_item->ipv4.max_ip);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> ip_format2range(ip4) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -321,7 +321,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = ip_format2range(ip_item->addr_type, ip_format_str2int(addr_format),
ip1_str, ip2_str, ip_item->ipv6.min_ip, ip_item->ipv6.max_ip);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> ip_format2range(ip6) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -331,7 +331,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->port_format_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no port_format in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -339,7 +339,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
memcpy(port_format, (line + column_offset), column_len);
if (PORT_FORMAT_UNKNOWN == port_format_str2int(port_format)) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has invalid port_format, "
"should be single/range in line:%s",
__FUNCTION__, __LINE__, table_name, line);
@@ -350,7 +350,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->port1_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s>) has no port1 in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -360,7 +360,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->port2_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no port2 in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -370,7 +370,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->protocol_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no protocol in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -379,7 +379,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ip_item->proto = atoi(line + column_offset);
if (ip_item->proto != IP_PROTO_ANY && ip_item->proto != IP_PROTO_ICMP &&
ip_item->proto != IP_PROTO_TCP && ip_item->proto != IP_PROTO_UDP) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> protocol:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, ip_item->proto, line);
goto error;
@@ -387,7 +387,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
if (ip_item->proto != IP_PROTO_ANY && ip_item->proto != IP_PROTO_ICMP &&
ip_item->proto != IP_PROTO_TCP && ip_item->proto != IP_PROTO_UDP) {
- log_error(logger, MODULE_IP,
+ log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> protocol:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, ip_item->proto, line);
goto error;
@@ -506,7 +506,7 @@ static int ip_runtime_update_row(struct ip_runtime *ip_rt, char *key, size_t key
// add
ret = rcu_hash_add(ip_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) {
- log_error(ip_rt->logger, MODULE_IP,
+ log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] ip item(item_id:%lld) add to ip runtime htable failed",
__FUNCTION__, __LINE__, item->item_id);
return -1;
@@ -529,7 +529,7 @@ int ip_runtime_update(void *ip_runtime, void *ip_schema,
long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) {
- log_error(ip_rt->logger, MODULE_IP,
+ log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line);
@@ -539,7 +539,7 @@ int ip_runtime_update(void *ip_runtime, void *ip_schema,
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(ip_rt->logger, MODULE_IP,
+ log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -625,7 +625,7 @@ int ip_runtime_commit(void *ip_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_ip_matcher) {
- log_error(ip_rt->logger, MODULE_IP,
+ log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] table[%s] rebuild ip_matcher engine failed "
"when update %zu ip rules", __FUNCTION__, __LINE__,
table_name, rule_cnt);
@@ -709,7 +709,7 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
}
struct ip_data scan_data;
- struct scan_result ip_results[MAX_SCANNER_HIT_ITEM_NUM];
+ struct scan_result ip_results[MAX_HIT_ITEM_NUM];
if (ip_type == IPv4) {
scan_data.type = IPv4;
@@ -724,14 +724,14 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
int ret = 0;
size_t real_hit_item_cnt = 0;
- struct maat_item hit_maat_items[MAX_SCANNER_HIT_ITEM_NUM];
+ struct maat_item hit_maat_items[MAX_HIT_ITEM_NUM];
if (NULL == ip_rt->ip_matcher) {
return 0;
}
int n_hit_ip_item = ip_matcher_match(ip_rt->ip_matcher, &scan_data,
- ip_results, MAX_SCANNER_HIT_ITEM_NUM);
+ ip_results, MAX_HIT_ITEM_NUM);
if (n_hit_ip_item < 0) {
return -1;
}
@@ -761,7 +761,15 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
}
next:
- return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state);
+ if (NULL == state->compile_state) {
+ state->compile_state = compile_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ state->thread_id, 1);
+ }
+
+ return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
+ state->compile_table_id, state->scan_cnt,
+ hit_maat_items, real_hit_item_cnt);
}
void ip_runtime_hit_inc(struct ip_runtime *ip_rt, int thread_id)
diff --git a/src/maat_ip_plugin.c b/src/maat_ip_plugin.c
index bc44592..34705e7 100644
--- a/src/maat_ip_plugin.c
+++ b/src/maat_ip_plugin.c
@@ -57,7 +57,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -65,7 +65,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -75,7 +75,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -85,7 +85,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->ip_type_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no ip_type column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -95,7 +95,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->start_ip_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no start_ip column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -105,7 +105,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->end_ip_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no end_ip column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -152,7 +152,7 @@ static int ip_plugin_accept_tag_match(struct ip_plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
@@ -164,14 +164,14 @@ static int ip_plugin_accept_tag_match(struct ip_plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str);
if (TAG_MATCH_ERR == ret) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
}
if (TAG_MATCH_UNMATCHED == ret) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED;
@@ -199,7 +199,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -208,14 +208,14 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->ip_type_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no ip_type in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
ip_plugin_rule->type = atoi(line + column_offset);
if (ip_plugin_rule->type != IPv4 && ip_plugin_rule->type != IPv6) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> ip_type[%d] invalid in line:%s",
__FUNCTION__, __LINE__, table_name, ip_plugin_rule->type, line);
goto error;
@@ -223,7 +223,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->start_ip_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no start_ip in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -232,7 +232,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->end_ip_column, &column_offset, &column_len);
if (ret < 0) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no end_ip in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -245,7 +245,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
&ip_plugin_rule->ipv4_rule.start_ip,
&ip_plugin_rule->ipv4_rule.end_ip);
if (ret < 0) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s>> ip_format2range(ip4) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -257,7 +257,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ip_plugin_rule->ipv6_rule.start_ip,
ip_plugin_rule->ipv6_rule.end_ip);
if (ret < 0) {
- log_error(logger, MODULE_IP_PLUGIN,
+ log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> ip_format2range(ip6) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -285,7 +285,7 @@ int ip_plugin_table_set_ex_container_schema(void *ip_plugin_schema, int table_id
struct ip_plugin_schema *schema = (struct ip_plugin_schema *)ip_plugin_schema;
if (1 == schema->container_schema.set_flag) {
- log_error(schema->logger, MODULE_IP_PLUGIN,
+ log_fatal(schema->logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table(table_id:%d) ex_container_schema has been set, can't set again",
__FUNCTION__, __LINE__, table_id);
return -1;
@@ -498,7 +498,7 @@ int ip_plugin_runtime_commit(void *ip_plugin_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_ip_matcher) {
- log_error(ip_plugin_rt->logger, MODULE_IP_PLUGIN,
+ log_fatal(ip_plugin_rt->logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table[%s] rebuild ip_matcher failed when "
"update %zu rules", __FUNCTION__, __LINE__, table_name, rule_cnt);
ret = -1;
diff --git a/src/maat_ipport_plugin.c b/src/maat_ipport_plugin.c
index d6fd44c..3bc6d50 100644
--- a/src/maat_ipport_plugin.c
+++ b/src/maat_ipport_plugin.c
@@ -79,7 +79,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -87,7 +87,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -97,7 +97,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -107,7 +107,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->ip_type_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no ip_type column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -117,7 +117,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->ip_addr_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no ip_addr column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -127,7 +127,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->port1_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no port1 column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -137,7 +137,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->port2_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no port2 column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -176,7 +176,7 @@ int ipport_plugin_table_set_ex_container_schema(void *ipport_plugin_schema, int
struct ipport_plugin_schema *schema = (struct ipport_plugin_schema *)ipport_plugin_schema;
if (1 == schema->container_schema.set_flag) {
- log_error(schema->logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(schema->logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table(table_id:%d) ex_container_schema has been set"
", can't set again", __FUNCTION__, __LINE__, table_id);
return -1;
@@ -265,7 +265,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
int ret = get_column_pos(line, schema->item_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -275,7 +275,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->ip_type_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no ip_type in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -283,7 +283,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ipport_item->ip_type = atoi(line + column_offset);
if (ipport_item->ip_type != IPV4 && ipport_item->ip_type != IPV6) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has invalid ip type:%d in line:%s",
__FUNCTION__, __LINE__, table_name, ipport_item->ip_type, line);
goto error;
@@ -292,7 +292,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->ip_addr_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no ip_addr in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -303,7 +303,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
uint32_t ipv4_addr = 0;
ret = inet_pton(AF_INET, ip_str, &ipv4_addr);
if (ret < 0) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> ip_format2range(ip4) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -315,7 +315,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
uint32_t ipv6_addr[4] = {0};
ret = inet_pton(AF_INET6, ip_str, ipv6_addr);
if (ret < 0) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> ip_format2range(ip6) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -326,7 +326,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->port1_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s>) has no port1 in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -336,7 +336,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->port2_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no port2 in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -514,7 +514,7 @@ int ipport_plugin_runtime_commit(void *ipport_plugin_runtime, const char *table_
long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 +
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_matcher) {
- log_error(ipport_plugin_rt->logger, MODULE_IPPORT_PLUGIN,
+ log_fatal(ipport_plugin_rt->logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table[%s] rebuild ipport_matcher failed when "
"update %zu rules", __FUNCTION__, __LINE__, table_name, rule_cnt);
ret = -1;
diff --git a/src/maat_plugin.c b/src/maat_plugin.c
index 95e61dd..c9cdb15 100644
--- a/src/maat_plugin.c
+++ b/src/maat_plugin.c
@@ -96,7 +96,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
cJSON *custom_item = NULL;
cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (NULL == item || item->type != cJSON_Number) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -108,7 +108,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Object) {
custom_item = cJSON_GetObjectItem(item, "key");
if (NULL == custom_item || custom_item->type != cJSON_Number) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema has no key column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -117,7 +117,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
custom_item = cJSON_GetObjectItem(item, "key_type");
if (NULL == custom_item || custom_item->type != cJSON_String) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema has no key_type column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -129,7 +129,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
schema->key_type = PLUGIN_KEY_TYPE_INTEGER;
custom_item = cJSON_GetObjectItem(item, "key_len");
if (NULL == custom_item || custom_item->type != cJSON_Number) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema integer key must"
" have key_len column", __FUNCTION__, __LINE__,
table_name);
@@ -140,7 +140,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
schema->key_type = PLUGIN_KEY_TYPE_IP_ADDR;
custom_item = cJSON_GetObjectItem(item, "addr_type");
if (NULL == custom_item || custom_item->type != cJSON_Number) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema ip_addr key must"
" have addr_type column", __FUNCTION__, __LINE__,
table_name);
@@ -148,7 +148,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
}
schema->addr_type_column = custom_item->valueint;
} else {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema key_type:%s is illegal, "
"just allow {pointer}, {integer}, {ip_addr}",
__FUNCTION__, __LINE__, table_name, custom_item->valuestring);
@@ -212,7 +212,7 @@ int plugin_table_add_callback(void *plugin_schema, int table_id,
size_t idx = schema->cb_cnt;
if (idx == MAX_PLUGIN_PER_TABLE) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] the plugin number of table_id: %d exceed maxium:%d",
__FUNCTION__, __LINE__, table_id, MAX_PLUGIN_PER_TABLE);
return -1;
@@ -271,7 +271,7 @@ int plugin_table_set_ex_container_schema(void *plugin_schema, int table_id,
struct plugin_schema *schema = (struct plugin_schema *)plugin_schema;
if (1 == schema->container_schema.set_flag) {
- log_error(schema->logger, MODULE_PLUGIN,
+ log_fatal(schema->logger, MODULE_PLUGIN,
"[%s:%d] plugin table(table_id:%d) ex_container_schema"
" has been set, can't set again", __FUNCTION__, __LINE__,
table_id);
@@ -405,7 +405,7 @@ static int plugin_accept_tag_match(struct plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column, &column_offset,
&column_len);
if (ret < 0) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] table: <%s> has no rule_tag(column_seq:%d) "
"in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->rule_tag_column, line);
@@ -418,14 +418,14 @@ static int plugin_accept_tag_match(struct plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str);
if (TAG_MATCH_ERR == ret) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] table: <%s> has invalid tag format in table_line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
}
if (TAG_MATCH_UNMATCHED == ret) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] table: <%s> has unmatched tag in table_line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED;
@@ -445,7 +445,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
int ret = get_column_pos(line, schema->key_column, &key_offset, &key_len);
if (ret < 0) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> has no key(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->key_column, line);
@@ -453,7 +453,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
}
if (key_len > MAX_KEYWORDS_STR_LEN) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> key(column seq:%d) length exceed maxium:%d"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->key_column, MAX_KEYWORDS_STR_LEN, line);
@@ -475,7 +475,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
*dst_key_len = schema->key_len;
} else if (schema->key_type == PLUGIN_KEY_TYPE_IP_ADDR) {
if (key_len >= INET6_ADDRSTRLEN) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> ip_key too long(illegal) in "
"table_line:%s", __FUNCTION__, __LINE__, table_name, line);
return -1;
@@ -486,7 +486,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
ret = get_column_pos(line, schema->addr_type_column, &addr_type_offset,
&addr_type_len);
if (ret < 0) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> has no addr_type(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->addr_type_column, line);
@@ -502,7 +502,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
uint32_t ipv4_addr;
ret = inet_pton(AF_INET, ip_key, &ipv4_addr);
if (ret <= 0) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> ipv4 key(column seq:%d)"
" illegal in table_line:%s", __FUNCTION__, __LINE__,
table_name, schema->key_column, line);
@@ -515,7 +515,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
uint8_t ipv6_addr[16];
ret = inet_pton(AF_INET6, ip_key, ipv6_addr);
if (ret <= 0) {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> ipv6 key(column seq:%d)"
" illegal in table_line:%s", __FUNCTION__, __LINE__,
table_name, schema->key_column, line);
@@ -525,7 +525,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
memcpy(dst_key, (char *)&ipv6_addr, sizeof(ipv6_addr));
*dst_key_len = sizeof(ipv6_addr);
} else {
- log_error(logger, MODULE_PLUGIN,
+ log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> addr_type:%d illegal, just"
" allow{4, 6}, table_line:%s", __FUNCTION__, __LINE__,
table_name, addr_type, line);
@@ -549,7 +549,7 @@ int plugin_runtime_update(void *plugin_runtime, void *plugin_schema,
struct plugin_runtime *plugin_rt = (struct plugin_runtime *)plugin_runtime;
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_error(plugin_rt->logger, MODULE_PLUGIN,
+ log_fatal(plugin_rt->logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
diff --git a/src/maat_redis_monitor.c b/src/maat_redis_monitor.c
index cdfde6d..590e096 100644
--- a/src/maat_redis_monitor.c
+++ b/src/maat_redis_monitor.c
@@ -110,7 +110,7 @@ static void _get_foregin_keys(struct serial_rule *p_rule, int *foreign_columns,
foreign_columns[i],
&foreign_key_size);
if (NULL == p_foreign) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign keys failed: No %dth column",
__FUNCTION__, __LINE__, p_rule->table_name, p_rule->rule_id,
foreign_columns[i]);
@@ -123,7 +123,7 @@ static void _get_foregin_keys(struct serial_rule *p_rule, int *foreign_columns,
}
if (0 != strncmp(p_foreign, foreign_source_prefix, strlen(foreign_source_prefix))) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign key failed: Invalid source prefix %s",
__FUNCTION__, __LINE__, p_rule->table_name, p_rule->rule_id, p_foreign);
continue;
@@ -245,7 +245,7 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
for (i = 0; i < rule_num; i++) {
ret = maat_wrap_redis_get_reply(c, &reply);
if (ret == REDIS_ERR) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis GET %s:%s,%lld failed, redis server error",
__FUNCTION__, __LINE__, mr_key_prefix[rule_list[i].op],
rule_list[i].table_name, rule_list[i].rule_id);
@@ -260,7 +260,7 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
retry_ids[failed_cnt] = i;
failed_cnt++;
} else {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis GET %s:%s,%lld failed",
__FUNCTION__, __LINE__, mr_key_prefix[rule_list[i].op],
rule_list[i].table_name, rule_list[i].rule_id);
@@ -291,7 +291,7 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
idx = retry_ids[i];
ret = maat_wrap_redis_get_reply(c, &reply);
if (ret == REDIS_ERR) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] redis command %s failed, redis server error",
__FUNCTION__, __LINE__, redis_cmd);
FREE(retry_ids);
@@ -302,12 +302,12 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
rule_list[idx].table_line = maat_strdup(reply->str);
} else if(reply->type==REDIS_REPLY_ERROR) {
//Deal with Redis response: "Loading Redis is loading the database in memory"
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] redis command %s error, reply type=%d, error str=%s",
__FUNCTION__, __LINE__, redis_cmd, reply->type, reply->str);
} else {
//Handle type "nil"
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] redis command %s failed, reply type=%d",
__FUNCTION__, __LINE__, redis_cmd, reply->type);
}
@@ -362,7 +362,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
mr_status_sset, instance_version,
target_version);
if (NULL == reply) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] GET %s failed with a NULL reply, error: %s",
__FUNCTION__, __LINE__, mr_status_sset, c->errstr);
return -1;
@@ -381,7 +381,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
mr_status_sset,
reply->element[0]->str);
if (tmp_reply->type != REDIS_REPLY_STRING) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] ZSCORE %s %s failed Version: %lld->%lld",
__FUNCTION__, __LINE__, mr_status_sset,
reply->element[0]->str, instance_version,
@@ -417,7 +417,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
int ret = sscanf(reply->element[i]->str, "%3s,%[^,],%lld",
op_str, s_rule[j].table_name, &(s_rule[j].rule_id));
if (ret != 3 || s_rule[i].rule_id < 0) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key: %s",
__FUNCTION__, __LINE__, reply->element[i]->str);
continue;
@@ -428,7 +428,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
} else if(strncmp(op_str, "DEL", strlen("DEL")) == 0) {
s_rule[j].op = MAAT_OP_DEL;
} else {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key: %s",
__FUNCTION__, __LINE__, reply->element[i]->str);
continue;
@@ -489,7 +489,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
redisReply *reply = (redisReply *)redisCommand(c, "GET MAAT_VERSION");
if (reply != NULL) {
if (reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] GET MAAT_VERSION failed, maybe Redis is busy",
__FUNCTION__, __LINE__);
freeReplyObject(reply);
@@ -497,7 +497,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
return -1;
}
} else {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] GET MAAT_VERSION failed with NULL reply, error: %s",
__FUNCTION__, __LINE__, c->errstr);
return -1;
@@ -506,7 +506,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
long long redis_version = maat_read_redis_integer(reply);
if (redis_version < 0) {
if (reply->type == REDIS_REPLY_ERROR) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis Communication error: %s",
__FUNCTION__, __LINE__, reply->str);
}
@@ -525,7 +525,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
}
if (redis_version < instance_version) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] VERSION roll back MAAT: %lld -> Redis: %lld",
__FUNCTION__, __LINE__, instance_version, redis_version);
goto FULL_UPDATE;
@@ -568,7 +568,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
return rule_num;
FULL_UPDATE:
- log_info(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"Initiate full update from instance_version %lld to %lld",
instance_version, redis_version);
size_t append_cmd_cnt = 0;
@@ -591,14 +591,14 @@ FULL_UPDATE:
reply = maat_wrap_redis_command(c, "EXEC");
if (NULL == reply) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis Communication error: %s",
__FUNCTION__, __LINE__, c->errstr);
return -1;
}
if (reply->type != REDIS_REPLY_ARRAY) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key List type %d",
__FUNCTION__, __LINE__, reply->type);
freeReplyObject(reply);
@@ -609,7 +609,7 @@ FULL_UPDATE:
*new_version = maat_read_redis_integer(reply->element[0]);
redisReply *sub_reply = reply->element[1];
if (sub_reply->type != REDIS_REPLY_ARRAY) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key List type %d",
__FUNCTION__, __LINE__, sub_reply->type);
freeReplyObject(reply);
@@ -621,7 +621,7 @@ FULL_UPDATE:
s_rule_array = ALLOC(struct serial_rule, sub_reply->elements);
for (i = 0, full_idx = 0; i < sub_reply->elements; i++) {
if (sub_reply->element[i]->type != REDIS_REPLY_STRING) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key Type: %d",
__FUNCTION__, __LINE__, sub_reply->element[i]->type);
continue;
@@ -634,7 +634,7 @@ FULL_UPDATE:
if (ret != 2 || s_rule_array[full_idx].rule_id < 0 ||
strlen(s_rule_array[full_idx].table_name) == 0) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key Format: %s",
__FUNCTION__, __LINE__, sub_reply->element[i]->str);
continue;
@@ -687,7 +687,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
ret = remove(rule_list[i].f_keys[j].filename);
if (ret == -1) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Foreign content file %s remove failed",
__FUNCTION__, __LINE__, rule_list[i].f_keys[j].filename);
}
@@ -719,7 +719,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
for (i = 0; i < key_num; i++) {
ret = maat_wrap_redis_get_reply(c, &reply);
if (ret == REDIS_ERR) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign key %s content failed, redis server error",
__FUNCTION__, __LINE__,
rule_list[track[i].rule_idx].table_name,
@@ -729,7 +729,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
}
if (reply->type != REDIS_REPLY_STRING) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign key %s content failed",
__FUNCTION__, __LINE__,
rule_list[track[i].rule_idx].table_name,
@@ -740,7 +740,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
s_rule = rule_list+track[i].rule_idx;
FILE *fp = fopen(s_rule->f_keys[track[i].foreign_idx].filename, "w");
if (NULL == fp) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Write foreign content failed: fopen %s error", __FUNCTION__,
__LINE__, s_rule->f_keys[track[i].foreign_idx].filename);
} else {
@@ -1134,7 +1134,7 @@ int maat_cmd_write_rule(redisContext *c, struct serial_rule *s_rule,
}
rule_seq = expected_reply[i].s_rule_seq;
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] %s %s %lld failed, rule id maybe conflict or not exist",
__FUNCTION__, __LINE__, mr_op_str[s_rule[rule_seq].op],
s_rule[rule_seq].table_name, s_rule[rule_seq].rule_id);
@@ -1159,7 +1159,7 @@ error_out:
if (renew_num > 0 && renew_allowed != 1) {
for (i = 0; i < (unsigned int)serial_rule_num; i++) {
if (s_rule[i].op == MAAT_OP_RENEW_TIMEOUT) {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] %s %s %lld is not allowed due to lock contention",
__FUNCTION__, __LINE__, mr_op_str[MAAT_OP_RENEW_TIMEOUT],
s_rule[i].table_name, s_rule[i].rule_id);
@@ -1278,13 +1278,13 @@ static void check_maat_expiration(redisContext *c, struct log_handle *logger)
int success_cnt = maat_cmd_write_rule(c, s_rule, s_rule_num, server_time, logger);
if (success_cnt < 0) {
- log_error(logger, MODULE_REDIS_MONITOR, "[%s:%d] maat_cmd_write_rule failed.",
+ log_fatal(logger, MODULE_REDIS_MONITOR, "[%s:%d] maat_cmd_write_rule failed.",
__FUNCTION__, __LINE__);
} else if (success_cnt == (int)s_rule_num) {
log_info(logger, MODULE_REDIS_MONITOR,
"Succesfully expired %zu rules in Redis", s_rule_num);
} else {
- log_error(logger, MODULE_REDIS_MONITOR,
+ log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Failed to expired %d of %zu rules in Redis, try later",
__FUNCTION__, __LINE__, s_rule_num - success_cnt, s_rule_num);
}
@@ -1369,7 +1369,7 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx *mr_ctx,
if (ret < 0) {
redisFree(mr_ctx->read_ctx);
mr_ctx->read_ctx = NULL;
- log_error(maat_inst->logger, MODULE_REDIS_MONITOR,
+ log_fatal(maat_inst->logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get Redis value failed, abandon update and close connection",
__FUNCTION__, __LINE__);
goto clean_up;
@@ -1417,7 +1417,7 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx *mr_ctx,
valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id);
ret = validate_line(rule_list[i].table_line, valid_column);
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_REDIS_MONITOR,
+ log_fatal(maat_inst->logger, MODULE_REDIS_MONITOR,
"[%s:%d] Validate line failed, invaid format %s",
__FUNCTION__, __LINE__, rule_list[i].table_line);
continue;
@@ -1435,7 +1435,7 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx *mr_ctx,
finish_fn(u_param);
if (call_update_num < rule_num) {
- log_error(maat_inst->logger, MODULE_REDIS_MONITOR,
+ log_fatal(maat_inst->logger, MODULE_REDIS_MONITOR,
"[%s:%d] Load %d entries to match engine, no table: %d, empty value: %d",
__FUNCTION__, __LINE__, call_update_num, no_table_num, empty_value_num);
}
diff --git a/src/maat_rule.c b/src/maat_rule.c
index 1ebbad7..16c3eab 100644
--- a/src/maat_rule.c
+++ b/src/maat_rule.c
@@ -131,7 +131,7 @@ static int maat_update_cb(const char *table_name, const char *line, void *u_para
struct maat *maat_inst =(struct maat *)u_param;
int table_id = table_manager_get_table_id(maat_inst->tbl_mgr, table_name);
if (table_id < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] update warning, unknown table name %s",
__FUNCTION__, __LINE__, table_name);
return -1;
@@ -151,7 +151,7 @@ static int maat_update_cb(const char *table_name, const char *line, void *u_para
int ret = table_manager_update_runtime(maat_inst->tbl_mgr, table_name,
(int)conj_parent_table_ids[i], line, update_type);
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] table<%s> update runtime error for rule:%s",
__FUNCTION__, __LINE__, table_name, line);
continue;
@@ -161,7 +161,7 @@ static int maat_update_cb(const char *table_name, const char *line, void *u_para
int ret = table_manager_update_runtime(maat_inst->tbl_mgr, table_name,
table_id, line, update_type);
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] table<%s> update runtime error for rules:%s",
__FUNCTION__, __LINE__, table_name, line);
return -1;
@@ -302,7 +302,7 @@ void maat_read_full_config(struct maat *maat_inst)
}
if (NULL == maat_inst->creating_maat_rt) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] At initiation: NO effective rule in redis %s:%hu db%d",
__FUNCTION__, __LINE__, redis_ctx->redis_ip, redis_ctx->redis_port,
redis_ctx->redis_db);
@@ -315,7 +315,7 @@ void maat_read_full_config(struct maat *maat_inst)
maat_inst, maat_inst->opts.decrypt_key,
maat_inst->logger);
if (NULL == maat_inst->creating_maat_rt) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] At initiation: NO effective rule in %s",
__FUNCTION__, __LINE__, maat_inst->opts.iris_ctx.full_idx_dir);
}
@@ -324,7 +324,7 @@ void maat_read_full_config(struct maat *maat_inst)
ret = load_maat_json_file(maat_inst, maat_inst->opts.json_ctx.json_file,
err_str, sizeof(err_str));
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] Maat re-initiate with JSON file %s failed: %s",
__FUNCTION__, __LINE__, maat_inst->opts.json_ctx.json_file, err_str);
}
@@ -335,7 +335,7 @@ void maat_read_full_config(struct maat *maat_inst)
maat_inst, maat_inst->opts.decrypt_key,
maat_inst->logger);
if (NULL == maat_inst->creating_maat_rt) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] At initiation: NO effective rule in %s",
__FUNCTION__, __LINE__, maat_inst->opts.json_ctx.iris_file);
}
@@ -449,7 +449,7 @@ void *rule_monitor_loop(void *arg)
ret = load_maat_json_file(maat_inst, maat_inst->opts.json_ctx.json_file,
err_str, sizeof(err_str));
if (ret < 0) {
- log_error(maat_inst->logger, MODULE_MAAT_RULE,
+ log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] Maat re-initiate with JSON file %s (md5=%s)failed: %s\n",
__FUNCTION__, __LINE__, maat_inst->opts.json_ctx.json_file,
md5_tmp, err_str);
diff --git a/src/maat_stat.c b/src/maat_stat.c
index 141da99..c0dbc36 100644
--- a/src/maat_stat.c
+++ b/src/maat_stat.c
@@ -114,7 +114,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
int ret = fieldstat_register_table_row(stat->fs_handle, table_id, "Sum", NULL, 0,
stat->total_stat_id);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table_row Sum failed.");
+ log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table_row Sum failed.");
return -1;
}
@@ -122,7 +122,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->total_stat_id[COLUMN_SCAN_BYTES],
stat->total_stat_id[COLUMN_CPU_TIME], 1000000000);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Bps for Sum failed.");
+ log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Bps for Sum failed.");
return -1;
}
@@ -130,7 +130,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->total_stat_id[COLUMN_SCAN_CNT],
stat->total_stat_id[COLUMN_CPU_TIME], 1000000000);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Tps for Sum failed.");
+ log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Tps for Sum failed.");
return -1;
}
@@ -138,7 +138,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->total_stat_id[COLUMN_HIT_CNT],
stat->total_stat_id[COLUMN_SCAN_CNT], 1);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set hit_rate for Sum failed.");
+ log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set hit_rate for Sum failed.");
return -1;
}
@@ -159,7 +159,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
ret = fieldstat_register_table_row(stat->fs_handle, table_id, table_name, NULL, 0,
stat->fs_column_id[i]);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT,
+ log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat_register_table_row %s failed.", table_name);
return -1;
}
@@ -168,7 +168,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->fs_column_id[i][COLUMN_SCAN_BYTES],
stat->fs_column_id[i][COLUMN_CPU_TIME], 1000000000);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT,
+ log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat set IN_Bps for %s failed.", table_name);
return -1;
}
@@ -177,7 +177,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->fs_column_id[i][COLUMN_SCAN_CNT],
stat->fs_column_id[i][COLUMN_CPU_TIME], 1000000000);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT,
+ log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat set IN_Tps for %s failed.", table_name);
return -1;
}
@@ -186,7 +186,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->fs_column_id[i][COLUMN_HIT_CNT],
stat->fs_column_id[i][COLUMN_SCAN_CNT], 1);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT,
+ log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat set hit_rate for %s failed.", table_name);
return -1;
}
@@ -275,19 +275,19 @@ int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
const char *instance_name = "maat_stat";
stat->fs_handle = fieldstat_instance_new(instance_name);
if (NULL == stat->fs_handle) {
- log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_instance_new failed.");
+ log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_instance_new failed.");
return -1;
}
int ret = fieldstat_set_local_output(stat->fs_handle, stat->stat_file, "default");
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_set_local_output failed.");
+ log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_set_local_output failed.");
return -1;
}
ret = fieldstat_disable_background_thread(stat->fs_handle);
if (ret < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT,
+ log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat_disable_background_thread failed.");
return -1;
}
@@ -301,7 +301,7 @@ int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
common_column_name, common_column_type,
n_column);
if (fs_table_id < 0) {
- log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table failed.");
+ log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table failed.");
return -1;
}
diff --git a/src/maat_table.c b/src/maat_table.c
index 213ced0..ea27b77 100644
--- a/src/maat_table.c
+++ b/src/maat_table.c
@@ -301,7 +301,7 @@ static size_t parse_accept_tag(const char *value, struct rule_tag **result,
cJSON *json = cJSON_Parse(value);
if (!json) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] parse accept tag Error before: %-200.200s",
__FUNCTION__, __LINE__, cJSON_GetErrorPtr());
return 0;
@@ -509,7 +509,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
}
if (item->valueint >= MAX_TABLE_NUM) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) exceed maxium %d",
__FUNCTION__, __LINE__, MAX_TABLE_NUM);
goto error;
@@ -529,7 +529,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
item = cJSON_GetObjectItem(json, "table_type");
if (NULL == item || item->type != cJSON_String) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:%s has no table_type column",
__FUNCTION__, __LINE__, ptable->table_name);
goto error;
@@ -538,7 +538,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
ret = maat_kv_read(reserved_word_map, item->valuestring,
(long long *)&(ptable->table_type), 1);
if (ret < 0) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:%s table_type %s is illegal",
__FUNCTION__, __LINE__, ptable->table_name,
item->valuestring);
@@ -548,7 +548,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
item = cJSON_GetObjectItem(json, "valid_column");
if (NULL == item || item->type != cJSON_Number) {
if (ptable->table_type != TABLE_TYPE_VIRTUAL) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:%s has no valid column",
__FUNCTION__, __LINE__, ptable->table_name);
goto error;
@@ -603,7 +603,7 @@ static int register_single_tbl_name2id(struct maat_kv_store *tbl_name2id_map,
struct log_handle *logger)
{
if (strlen(table_name) >= NAME_MAX) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:<%s> name length exceed maxium:%d",
__FUNCTION__, __LINE__, table_name, NAME_MAX);
return -1;
@@ -612,7 +612,7 @@ static int register_single_tbl_name2id(struct maat_kv_store *tbl_name2id_map,
long long tmp_table_id = -1;
int ret = maat_kv_read(tbl_name2id_map, table_name, &tmp_table_id, 1);
if (ret > 0 && tmp_table_id != table_id) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:<%s>(table_id:%lld) has already been registered"
", can't register again",
__FUNCTION__, __LINE__, table_name, tmp_table_id);
@@ -642,7 +642,7 @@ static int register_conjunction_tbl_name2id(struct maat_kv_store *conj_tbl_name2
for (int j = 0; j < n_table_name; j++) {
cJSON *tmp_item = cJSON_GetArrayItem(item, j);
if (NULL == tmp_item || tmp_item->type != cJSON_String) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) db_tables element format invalid"
", should be string", __FUNCTION__, __LINE__, table_id);
return -1;
@@ -668,7 +668,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
for (i = 0; i < json_array_size; i++) {
cJSON *json = cJSON_GetArrayItem(root, i);
if (NULL == json || json->type != cJSON_Object) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] %s has invalid json object",
__FUNCTION__, __LINE__, table_info_path);
return -1;
@@ -676,7 +676,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (NULL == item || item->type != cJSON_Number) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] %s has invalid json object, happened in table_id column ",
__FUNCTION__, __LINE__, table_info_path);
return -1;
@@ -685,7 +685,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
item = cJSON_GetObjectItem(json, "table_name");
if (NULL == item || item->type != cJSON_String) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] %s has invalid json object, happened in table_name column",
__FUNCTION__, __LINE__, table_info_path);
return -1;
@@ -713,7 +713,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
for (int j = 0; j < n_table_name; j++) {
cJSON *tmp_item = cJSON_GetArrayItem(item, j);
if (NULL == tmp_item || tmp_item->type != cJSON_String) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) db_tables element format invalid"
", should be string", __FUNCTION__, __LINE__, table_id);
return -1;
@@ -761,7 +761,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
size_t json_buff_sz = 0;
int ret = load_file_to_memory(table_info_path, &json_buff, &json_buff_sz);
if (ret < 0) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] Maat read table info %s error.",
__FUNCTION__, __LINE__, table_info_path);
return NULL;
@@ -771,7 +771,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
cJSON *json = NULL;
root = cJSON_Parse((const char *)json_buff);
if (!root) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] error message: %-200.200s",
__FUNCTION__, __LINE__, cJSON_GetErrorPtr());
FREE(json_buff);
@@ -780,7 +780,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
int json_array_size = cJSON_GetArraySize(root);
if (json_array_size <= 0) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] invalid json content in %s",
__FUNCTION__, __LINE__, table_info_path);
FREE(json_buff);
@@ -798,7 +798,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
ret = register_tbl_name2id(tbl_mgr->tbl_name2id_map, root, table_info_path, logger);
if (ret < 0) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] register_tbl_name2id failed.", __FUNCTION__, __LINE__);
FREE(json_buff);
cJSON_Delete(root);
@@ -808,7 +808,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
ret = register_conjunction_tbl_name2id(tbl_mgr->conj_tbl_name2id_map, root, logger);
if (ret < 0) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] register_conjunction_tbl_name2id failed.", __FUNCTION__, __LINE__);
FREE(json_buff);
cJSON_Delete(root);
@@ -840,7 +840,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
maat_tbl->schema = maat_table_schema_new(json, maat_tbl->table_name, maat_tbl->table_type,
tbl_mgr, logger);
if (NULL == maat_tbl->schema) {
- log_error(logger, MODULE_TABLE,
+ log_fatal(logger, MODULE_TABLE,
"[%s:%d] Maat table schema new failed, table_name:%s",
__FUNCTION__, __LINE__, maat_tbl->table_name);
ret = -1;
@@ -949,7 +949,7 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_threa
void *schema = table_manager_get_schema(tbl_mgr, i);
if (NULL == schema) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] group2compile table(table_id:%d) schema is null",
__FUNCTION__, __LINE__, i);
continue;
@@ -1208,7 +1208,7 @@ int table_manager_update_runtime(struct table_manager *tbl_mgr, const char *tabl
int valid_column = table_manager_get_valid_column(tbl_mgr, table_id);
if (valid_column < 0) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table:%s has no valid column, can't update runtime",
__FUNCTION__, __LINE__, table_name);
return -1;
@@ -1216,14 +1216,14 @@ int table_manager_update_runtime(struct table_manager *tbl_mgr, const char *tabl
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table:%s table_type is invalid, can't update runtime",
__FUNCTION__, __LINE__, table_name);
return -1;
}
if (NULL == table_ops[table_type].update_runtime) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table:%s has no update_runtime function, can't update runtime",
__FUNCTION__, __LINE__, table_name);
return -1;
@@ -1243,7 +1243,7 @@ void table_commit_updating_runtime(struct table_manager *tbl_mgr, int table_id,
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't commit runtime",
__FUNCTION__, __LINE__, table_id);
return;
@@ -1277,7 +1277,7 @@ void table_commit_runtime(struct table_manager *tbl_mgr, int table_id,
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't commit runtime",
__FUNCTION__, __LINE__, table_id);
return;
@@ -1312,7 +1312,7 @@ long long table_manager_runtime_rule_count(struct table_manager *tbl_mgr, int ta
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't update runtime",
__FUNCTION__, __LINE__, table_id);
return 0;
@@ -1334,7 +1334,7 @@ long long table_manager_runtime_scan_count(struct table_manager *tbl_mgr, int ta
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get scan count",
__FUNCTION__, __LINE__, table_id);
return 0;
@@ -1356,7 +1356,7 @@ long long table_manager_runtime_scan_cpu_time(struct table_manager *tbl_mgr, int
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get scan cpu time",
__FUNCTION__, __LINE__, table_id);
return 0;
@@ -1378,7 +1378,7 @@ long long table_manager_runtime_hit_count(struct table_manager *tbl_mgr, int tab
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get hit count",
__FUNCTION__, __LINE__, table_id);
return 0;
@@ -1400,7 +1400,7 @@ long long table_manager_runtime_update_err_count(struct table_manager *tbl_mgr,
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) {
- log_error(tbl_mgr->logger, MODULE_TABLE,
+ log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get hit count",
__FUNCTION__, __LINE__, table_id);
return 0;
diff --git a/src/maat_virtual.c b/src/maat_virtual.c
index 9e9494e..85f9ab8 100644
--- a/src/maat_virtual.c
+++ b/src/maat_virtual.c
@@ -32,7 +32,7 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (NULL == item || item->type != cJSON_Number) {
- log_error(logger, MODULE_VIRTUAL,
+ log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -41,7 +41,7 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "physical_table");
if (NULL == item || item->type != cJSON_String) {
- log_error(logger, MODULE_VIRTUAL,
+ log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s> schema has no physical_table column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -49,7 +49,7 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
schema->physical_table_id = table_manager_get_table_id(tbl_mgr, item->valuestring);
if (schema->physical_table_id < 0) {
- log_error(logger, MODULE_VIRTUAL,
+ log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s>'s physical table:<%s> unregistered.",
__FUNCTION__, __LINE__, table_name, item->valuestring);
goto error;
diff --git a/test/benchmark/benchmark_hs_gtest.cpp b/test/benchmark/benchmark_hs_gtest.cpp
index 9c2c400..150cda3 100644
--- a/test/benchmark/benchmark_hs_gtest.cpp
+++ b/test/benchmark/benchmark_hs_gtest.cpp
@@ -56,7 +56,7 @@ void generate_expr_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -76,7 +76,7 @@ void generate_ip_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -99,7 +99,7 @@ void generate_integer_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -117,7 +117,7 @@ void generate_flag_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -135,7 +135,7 @@ void generate_compile_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -152,7 +152,7 @@ void generate_group2compile_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -534,7 +534,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n");
@@ -619,7 +619,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n");
@@ -704,7 +704,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n");
@@ -789,7 +789,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_500\t500\t./regex_rules/REGEX_500\n");
@@ -874,7 +874,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_1K\t1000\t./regex_rules/REGEX_1K\n");
@@ -959,7 +959,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_2K\t2000\t./regex_rules/REGEX_2K\n");
@@ -1044,7 +1044,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_3K\t3000\t./regex_rules/REGEX_3K\n");
@@ -1129,7 +1129,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_5K\t5000\t./regex_rules/REGEX_5K\n");
@@ -1214,7 +1214,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_10K\t10000\t./regex_rules/REGEX_10K\n");
@@ -1299,7 +1299,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_15K\t15000\t./regex_rules/REGEX_15K\n");
@@ -1385,7 +1385,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n");
@@ -1471,7 +1471,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n");
@@ -1557,7 +1557,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n");
@@ -1643,7 +1643,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n");
@@ -1729,7 +1729,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n");
@@ -1815,7 +1815,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n");
@@ -1901,7 +1901,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n");
@@ -1987,7 +1987,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n");
@@ -2073,7 +2073,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n");
@@ -2156,7 +2156,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n");
@@ -2239,7 +2239,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n");
@@ -2322,7 +2322,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n");
@@ -2405,7 +2405,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n");
@@ -2488,7 +2488,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n");
@@ -2571,7 +2571,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n");
@@ -2654,7 +2654,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n");
@@ -2737,7 +2737,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_1K 1000 ./IP_1K\n");
@@ -2823,7 +2823,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_5K 5000 ./IP_5K\n");
@@ -2909,7 +2909,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_10K 10000 ./IP_10K\n");
@@ -2995,7 +2995,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_50K 50000 ./IP_50K\n");
@@ -3081,7 +3081,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_100K 100000 ./IP_100K\n");
@@ -3167,7 +3167,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_500K 500000 ./IP_500K\n");
@@ -3253,7 +3253,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_1M 1000000 ./IP_1M\n");
@@ -3339,7 +3339,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_5M 5000000 ./IP_5M\n");
@@ -3425,7 +3425,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_10M 10000000 ./IP_10M\n");
@@ -3511,7 +3511,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n");
@@ -3597,7 +3597,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n");
@@ -3683,7 +3683,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n");
@@ -3769,7 +3769,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n");
@@ -3855,7 +3855,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n");
@@ -3941,7 +3941,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n");
diff --git a/test/benchmark/benchmark_rs_gtest.cpp b/test/benchmark/benchmark_rs_gtest.cpp
index c36d441..c58d9a8 100644
--- a/test/benchmark/benchmark_rs_gtest.cpp
+++ b/test/benchmark/benchmark_rs_gtest.cpp
@@ -56,7 +56,7 @@ void generate_expr_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -76,7 +76,7 @@ void generate_ip_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -99,7 +99,7 @@ void generate_integer_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -117,7 +117,7 @@ void generate_flag_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -135,7 +135,7 @@ void generate_compile_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -152,7 +152,7 @@ void generate_group2compile_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", table_name);
+ log_fatal(g_logger, "open file %s failed", table_name);
return;
}
@@ -534,7 +534,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n");
@@ -620,7 +620,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n");
@@ -706,7 +706,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n");
@@ -793,7 +793,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n");
@@ -880,7 +880,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n");
@@ -967,7 +967,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n");
@@ -1054,7 +1054,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n");
@@ -1141,7 +1141,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n");
@@ -1228,7 +1228,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n");
@@ -1315,7 +1315,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n");
@@ -1402,7 +1402,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n");
@@ -1489,7 +1489,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n");
@@ -1573,7 +1573,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n");
@@ -1657,7 +1657,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n");
@@ -1741,7 +1741,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n");
@@ -1825,7 +1825,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n");
@@ -1909,7 +1909,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n");
@@ -1993,7 +1993,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n");
@@ -2077,7 +2077,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n");
@@ -2161,7 +2161,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_1K 1000 ./IP_1K\n");
@@ -2248,7 +2248,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_5K 5000 ./IP_5K\n");
@@ -2335,7 +2335,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_10K 10000 ./IP_10K\n");
@@ -2422,7 +2422,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_50K 50000 ./IP_50K\n");
@@ -2509,7 +2509,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_100K 100000 ./IP_100K\n");
@@ -2596,7 +2596,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_500K 500000 ./IP_500K\n");
@@ -2683,7 +2683,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_1M 1000000 ./IP_1M\n");
@@ -2770,7 +2770,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_5M 5000000 ./IP_5M\n");
@@ -2857,7 +2857,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "IP_10M 10000000 ./IP_10M\n");
@@ -2944,7 +2944,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n");
@@ -3031,7 +3031,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n");
@@ -3118,7 +3118,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n");
@@ -3205,7 +3205,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n");
@@ -3292,7 +3292,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n");
@@ -3379,7 +3379,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) {
- log_error(g_logger, "open file %s failed", "full_config_index.0000001");
+ log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return;
}
fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n");
diff --git a/test/group_exclude/group_exclude_gtest.cpp b/test/group_exclude/group_exclude_gtest.cpp
index db37199..4d01b69 100644
--- a/test/group_exclude/group_exclude_gtest.cpp
+++ b/test/group_exclude/group_exclude_gtest.cpp
@@ -122,13 +122,13 @@ protected:
int ret = load_file_to_memory(table_info_path, &json_buff, &json_buff_size);
if (ret < 0) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "load_file_to_memory failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "load_file_to_memory failed.");
assert(0);
}
cJSON *root = cJSON_Parse((const char *)json_buff);
if (!root) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "cJSON_Parse failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "cJSON_Parse failed.");
assert(0);
}
@@ -137,7 +137,7 @@ protected:
cJSON_Delete(root);
if (NULL == g2g_schema) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_schema_new failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_schema_new failed.");
assert(0);
}
}
@@ -164,7 +164,7 @@ TEST_F(MaatGroupExclude, level_3_function) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0);
}
@@ -228,7 +228,7 @@ TEST_F(MaatGroupExclude, level_3_perf) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0);
}
@@ -304,7 +304,7 @@ TEST_F(MaatGroupExclude, level_4_function) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0);
}
@@ -360,7 +360,7 @@ TEST_F(MaatGroupExclude, level_4_perf) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0);
}
@@ -419,7 +419,7 @@ TEST_F(MaatGroupExclude, level_exceed_function) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) {
- log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
+ log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0);
}
diff --git a/test/maat_framework_gtest.cpp b/test/maat_framework_gtest.cpp
index 8accf7d..0e1b797 100644
--- a/test/maat_framework_gtest.cpp
+++ b/test/maat_framework_gtest.cpp
@@ -374,7 +374,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in JsonUpdate failed.",
__FUNCTION__, __LINE__);
assert(0);
@@ -415,8 +415,12 @@ void scan_with_old_or_new_cfg(struct maat *maat_inst, int is_old)
} else {
EXPECT_EQ(ret, MAAT_SCAN_OK);
}
- maat_state_reset(state);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ maat_state_reset(state);
ret = maat_scan_string(maat_inst, table_id, hit_new_data,
strlen(hit_new_data), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -427,6 +431,10 @@ void scan_with_old_or_new_cfg(struct maat *maat_inst, int is_old)
EXPECT_EQ(ret, MAAT_SCAN_OK);
}
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
}
@@ -463,7 +471,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -477,7 +485,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in MaatFlagScan failed.",
__FUNCTION__, __LINE__);
}
@@ -515,6 +523,10 @@ TEST_F(MaatFlagScan, basic) {
EXPECT_EQ(results[0], 207);
EXPECT_EQ(results[1], 192);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = 0;
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
@@ -530,6 +542,10 @@ TEST_F(MaatFlagScan, basic) {
EXPECT_EQ(n_hit_result, 2);
EXPECT_EQ(results[0], 207);
EXPECT_EQ(results[1], 192);
+
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
maat_state_reset(state);
scan_data = 6;
@@ -539,6 +555,11 @@ TEST_F(MaatFlagScan, basic) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
EXPECT_EQ(n_hit_result, 0);
+
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -563,6 +584,10 @@ TEST_F(MaatFlagScan, withExprRegion) {
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = 0;
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
@@ -575,6 +600,11 @@ TEST_F(MaatFlagScan, withExprRegion) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 193);
+
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -601,11 +631,19 @@ TEST_F(MaatFlagScan, hitMultiCompile) {
EXPECT_EQ(results[1], 194);
EXPECT_EQ(results[2], 192);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
memset(results, 0, sizeof(results));
ret = maat_scan_flag(maat_inst, flag_table_id, flag_scan_data, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = 0;
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
@@ -635,6 +673,10 @@ TEST_F(MaatFlagScan, hitRepeatedCompile) {
EXPECT_EQ(results[0], 207);
EXPECT_EQ(results[1], 192);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
//compile_id:192 flag: 0000 0001 mask: 0000 0011
//compile_id:194 flag: 0001 0101 mask: 0001 1111
//scan_data: 0001 0101 should hit compile192 and compile194
@@ -646,11 +688,19 @@ TEST_F(MaatFlagScan, hitRepeatedCompile) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 194);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
memset(results, 0, sizeof(results));
ret = maat_scan_flag(maat_inst, flag_table_id, flag_scan_data2, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = 0;
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
@@ -678,6 +728,10 @@ TEST_F(MaatFlagScan, FlagPlus) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_ERR);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_state_set_scan_district(state, flag_table_id, district_str,
strlen(district_str));
ASSERT_EQ(ret, 0);
@@ -688,10 +742,18 @@ TEST_F(MaatFlagScan, FlagPlus) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 196);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_flag(maat_inst, flag_table_id, scan_data1, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, flag_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = 0;
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
@@ -714,7 +776,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -730,7 +792,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in MaatHsStringScan failed.",
__FUNCTION__, __LINE__);
}
@@ -765,6 +827,11 @@ TEST_F(MaatHsStringScan, ScanDataOnlyOneByte) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -788,6 +855,11 @@ TEST_F(MaatHsStringScan, Full) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 125);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -807,6 +879,11 @@ TEST_F(MaatHsStringScan, Regex) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 148);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -827,6 +904,10 @@ TEST_F(MaatHsStringScan, BackslashR_N_Escape) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 225);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -849,6 +930,10 @@ TEST_F(MaatHsStringScan, ExprPlus) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_ERR);//Should return error for district not setting.
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_state_set_scan_district(state, table_id, district_str1,
strlen(district_str1));
ASSERT_EQ(ret, 0);
@@ -858,6 +943,10 @@ TEST_F(MaatHsStringScan, ExprPlus) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 128);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = maat_state_set_scan_district(state, table_id, district_str2,
strlen(district_str2));
@@ -867,6 +956,10 @@ TEST_F(MaatHsStringScan, ExprPlus) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 190);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -918,12 +1011,20 @@ TEST_F(MaatHsStringScan, ExprPlusWithOffset)
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, table_id, (char*)udp_payload_hit,
sizeof(udp_payload_hit), results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 149);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -950,6 +1051,10 @@ TEST_F(MaatHsStringScan, ExprPlusWithHex) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 156);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_state_set_scan_district(state, table_id, district_str2,
strlen(district_str2));
ASSERT_EQ(ret, 0);
@@ -957,12 +1062,20 @@ TEST_F(MaatHsStringScan, ExprPlusWithHex) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK); //maat-v3 consider as half hit, it's unreasonable
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, "KEYWORDS_TABLE");
ret = maat_scan_string(maat_inst, table_id, scan_data2, strlen(scan_data2),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 132);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -986,6 +1099,10 @@ TEST_F(MaatHsStringScan, ExprAndExprPlus) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_ERR);
+ ret = maat_scan_not_logic(maat_inst, expr_plus_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_state_set_scan_district(state, expr_plus_table_id, district_str,
strlen(district_str));
ASSERT_EQ(ret, 0);
@@ -994,12 +1111,20 @@ TEST_F(MaatHsStringScan, ExprAndExprPlus) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, expr_plus_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, expr_table_id, scan_data,
strlen(scan_data), results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 195);
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1037,6 +1162,10 @@ TEST_F(MaatHsStringScan, ShouldNotHitExprPlus) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK); //maat-v3 consider as half hit, it's unreasonable
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1060,6 +1189,10 @@ TEST_F(MaatHsStringScan, Expr8) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 182);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = 0;
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
@@ -1084,7 +1217,12 @@ TEST_F(MaatHsStringScan, HexBinCaseSensitive) {
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int ret = maat_scan_string(maat_inst, table_id, scan_data1, strlen(scan_data1),
results, ARRAY_SIZE, &n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = maat_scan_string(maat_inst, table_id, scan_data2, strlen(scan_data2),
@@ -1094,6 +1232,10 @@ TEST_F(MaatHsStringScan, HexBinCaseSensitive) {
EXPECT_EQ(results[0], 206);
EXPECT_EQ(results[1], 191);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
}
@@ -1133,6 +1275,10 @@ TEST_F(MaatHsStringScan, BugReport20190325) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 150);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1158,6 +1304,10 @@ TEST_F(MaatHsStringScan, PrefixAndSuffix) {
int ret = maat_scan_integer(maat_inst, cont_sz_table_id, 2015, results,
ARRAY_SIZE, &n_hit_result, state);
+ ret = maat_scan_not_logic(maat_inst, cont_sz_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, mail_addr_table_id, hit_twice,
strlen(hit_twice), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1166,6 +1316,10 @@ TEST_F(MaatHsStringScan, PrefixAndSuffix) {
EXPECT_EQ(results[0], 151);
EXPECT_EQ(results[1], 152);
+ ret = maat_scan_not_logic(maat_inst, mail_addr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = maat_scan_string(maat_inst, mail_addr_table_id, hit_suffix,
strlen(hit_suffix), results, ARRAY_SIZE,
@@ -1174,9 +1328,17 @@ TEST_F(MaatHsStringScan, PrefixAndSuffix) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 151);
+ ret = maat_scan_not_logic(maat_inst, mail_addr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_integer(maat_inst, cont_sz_table_id, 2015, results,
ARRAY_SIZE, &n_hit_result, state);
+ ret = maat_scan_not_logic(maat_inst, cont_sz_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, mail_addr_table_id, hit_prefix,
strlen(hit_prefix), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1184,6 +1346,10 @@ TEST_F(MaatHsStringScan, PrefixAndSuffix) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 152);
+ ret = maat_scan_not_logic(maat_inst, mail_addr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1206,6 +1372,10 @@ TEST_F(MaatHsStringScan, MaatUnescape) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 132);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1240,6 +1410,13 @@ TEST_F(MaatHsStringScan, OffsetChunk64) {
pass_flag = 1;
break;
}
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results,
+ ARRAY_SIZE, &n_hit_result, state);
+ if (ret > 0) {
+ pass_flag = 1;
+ break;
+ }
}
EXPECT_EQ(pass_flag, 1);
EXPECT_EQ(results[0], 136);
@@ -1279,6 +1456,13 @@ TEST_F(MaatHsStringScan, OffsetChunk1460) {
pass_flag = 1;
break;
}
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ if (ret > 0) {
+ pass_flag = 1;
+ break;
+ }
}
EXPECT_EQ(pass_flag, 1);
EXPECT_EQ(results[0], 136);
@@ -1316,6 +1500,13 @@ TEST_F(MaatHsStringScan, StreamScanUTF8) {
pass_flag = 1;
break;
}
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ if (ret == MAAT_SCAN_HIT) {
+ pass_flag = 1;
+ break;
+ }
}
EXPECT_EQ(pass_flag, 1);
@@ -1349,12 +1540,21 @@ TEST_F(MaatHsStringScan, StreamInput) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
maat_stream_free(sp);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 125);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1376,6 +1576,10 @@ TEST_F(MaatHsStringScan, dynamic_config) {
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
const char *compile_table_name = "COMPILE_DEFAULT";
@@ -1409,6 +1613,11 @@ TEST_F(MaatHsStringScan, dynamic_config) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
@@ -1432,6 +1641,11 @@ TEST_F(MaatHsStringScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
EXPECT_EQ(n_hit_result, 0);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1449,7 +1663,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -1465,7 +1679,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in MaatRsStringScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1502,6 +1716,10 @@ TEST_F(MaatRsStringScan, ScanDataOnlyOneByte) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1526,6 +1744,10 @@ TEST_F(MaatRsStringScan, Full) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 125);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1547,6 +1769,10 @@ TEST_F(MaatRsStringScan, Regex) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 148);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1567,6 +1793,10 @@ TEST_F(MaatRsStringScan, BackslashR_N_Escape) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 225);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1592,6 +1822,10 @@ TEST_F(MaatRsStringScan, ExprPlus) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_ERR);//Should return error for district not setting.
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_state_set_scan_district(state, table_id, district_str1,
strlen(district_str1));
ASSERT_EQ(ret, 0);
@@ -1603,6 +1837,10 @@ TEST_F(MaatRsStringScan, ExprPlus) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 128);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = maat_state_set_scan_district(state, table_id, district_str2,
strlen(district_str2));
@@ -1614,6 +1852,10 @@ TEST_F(MaatRsStringScan, ExprPlus) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 190);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1665,6 +1907,10 @@ TEST_F(MaatRsStringScan, ExprPlusWithOffset)
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, table_id, (char*)udp_payload_hit,
sizeof(udp_payload_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1672,6 +1918,10 @@ TEST_F(MaatRsStringScan, ExprPlusWithOffset)
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 149);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1699,6 +1949,10 @@ TEST_F(MaatRsStringScan, ExprPlusWithHex) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 156);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_state_set_scan_district(state, table_id, district_str2,
strlen(district_str2));
ASSERT_EQ(ret, 0);
@@ -1706,6 +1960,10 @@ TEST_F(MaatRsStringScan, ExprPlusWithHex) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK); //maat-v3 consider as half hit, it's unreasonable
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, "KEYWORDS_TABLE");
ret = maat_scan_string(maat_inst, table_id, scan_data2, strlen(scan_data2),
results, ARRAY_SIZE, &n_hit_result, state);
@@ -1713,6 +1971,10 @@ TEST_F(MaatRsStringScan, ExprPlusWithHex) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 132);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1736,6 +1998,10 @@ TEST_F(MaatRsStringScan, ExprAndExprPlus) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_ERR);
+ ret = maat_scan_not_logic(maat_inst, expr_plus_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_state_set_scan_district(state, expr_plus_table_id, district_str,
strlen(district_str));
ASSERT_EQ(ret, 0);
@@ -1745,6 +2011,10 @@ TEST_F(MaatRsStringScan, ExprAndExprPlus) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, expr_plus_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, expr_table_id, scan_data,
strlen(scan_data), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1752,6 +2022,10 @@ TEST_F(MaatRsStringScan, ExprAndExprPlus) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 195);
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1789,6 +2063,10 @@ TEST_F(MaatRsStringScan, ShouldNotHitExprPlus) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK); //maat-v3 consider as half hit, it's unreasonable
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1810,6 +2088,10 @@ TEST_F(MaatRsStringScan, Expr8) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 182);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = 0;
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
@@ -1834,7 +2116,7 @@ TEST_F(MaatRsStringScan, HexBinCaseSensitive) {
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int ret = maat_scan_string(maat_inst, table_id, scan_data1, strlen(scan_data1),
results, ARRAY_SIZE, &n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
maat_state_reset(state);
ret = maat_scan_string(maat_inst, table_id, scan_data2, strlen(scan_data2),
@@ -1844,6 +2126,10 @@ TEST_F(MaatRsStringScan, HexBinCaseSensitive) {
EXPECT_EQ(results[0], 206);
EXPECT_EQ(results[1], 191);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1884,6 +2170,10 @@ TEST_F(MaatRsStringScan, BugReport20190325) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 150);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1909,6 +2199,10 @@ TEST_F(MaatRsStringScan, PrefixAndSuffix) {
int ret = maat_scan_integer(maat_inst, cont_sz_table_id, 2015, results,
ARRAY_SIZE, &n_hit_result, state);
+ ret = maat_scan_not_logic(maat_inst, cont_sz_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, mail_addr_table_id, hit_twice,
strlen(hit_twice), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1917,6 +2211,10 @@ TEST_F(MaatRsStringScan, PrefixAndSuffix) {
EXPECT_EQ(results[0], 151);
EXPECT_EQ(results[1], 152);
+ ret = maat_scan_not_logic(maat_inst, mail_addr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = maat_scan_string(maat_inst, mail_addr_table_id, hit_suffix,
strlen(hit_suffix), results, ARRAY_SIZE,
@@ -1925,8 +2223,17 @@ TEST_F(MaatRsStringScan, PrefixAndSuffix) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 151);
+ ret = maat_scan_not_logic(maat_inst, mail_addr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_integer(maat_inst, cont_sz_table_id, 2015, results,
ARRAY_SIZE, &n_hit_result, state);
+
+ ret = maat_scan_not_logic(maat_inst, cont_sz_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, mail_addr_table_id, hit_prefix,
strlen(hit_prefix), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1934,6 +2241,10 @@ TEST_F(MaatRsStringScan, PrefixAndSuffix) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 152);
+ ret = maat_scan_not_logic(maat_inst, mail_addr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1956,6 +2267,10 @@ TEST_F(MaatRsStringScan, MaatUnescape) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 132);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -1990,6 +2305,13 @@ TEST_F(MaatRsStringScan, OffsetChunk64) {
pass_flag = 1;
break;
}
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ if (ret > 0) {
+ pass_flag = 1;
+ break;
+ }
}
EXPECT_EQ(pass_flag, 1);
EXPECT_EQ(results[0], 136);
@@ -2030,6 +2352,13 @@ TEST_F(MaatRsStringScan, OffsetChunk1460) {
pass_flag = 1;
break;
}
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ if (ret > 0) {
+ pass_flag = 1;
+ break;
+ }
}
EXPECT_EQ(pass_flag, 1);
@@ -2070,6 +2399,13 @@ TEST_F(MaatRsStringScan, StreamScanUTF8) {
pass_flag = 1;
break;
}
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ if (ret > 0) {
+ pass_flag = 1;
+ break;
+ }
}
EXPECT_EQ(pass_flag, 1);
@@ -2102,6 +2438,10 @@ TEST_F(MaatRsStringScan, StreamInput) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
maat_stream_free(sp);
@@ -2110,6 +2450,10 @@ TEST_F(MaatRsStringScan, StreamInput) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 125);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2130,6 +2474,10 @@ TEST_F(MaatRsStringScan, dynamic_config) {
EXPECT_EQ(n_hit_result, 0);
maat_state_reset(state);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
const char *compile_table_name = "COMPILE_DEFAULT";
const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
@@ -2162,6 +2510,10 @@ TEST_F(MaatRsStringScan, dynamic_config) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* EXPR_TYPE_AND MATCH_METHOD_SUB*/
@@ -2186,6 +2538,10 @@ TEST_F(MaatRsStringScan, dynamic_config) {
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2255,12 +2611,20 @@ TEST_F(MaatHsStreamScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
// STEP 2: Inc config update, use same stream to scan and wait old expr_runtime invalid
@@ -2285,6 +2649,10 @@ TEST_F(MaatHsStreamScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_stream_free(sp);
maat_state_free(state);
sp = NULL;
@@ -2357,12 +2725,20 @@ TEST_F(MaatRsStreamScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
// STEP 2: Inc config update, use same stream to scan and wait old expr_runtime invalid
@@ -2377,6 +2753,11 @@ TEST_F(MaatRsStreamScan, dynamic_config) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -2386,6 +2767,10 @@ TEST_F(MaatRsStreamScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_stream_free(sp);
maat_state_free(state);
sp = NULL;
@@ -2405,7 +2790,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -2419,7 +2804,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in MaatIPScan failed.",
__FUNCTION__, __LINE__);
}
@@ -2460,6 +2845,10 @@ TEST_F(MaatIPScan, IPv4ScanDataFull_0) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2487,6 +2876,10 @@ TEST_F(MaatIPScan, IPv4ScanDataFull_1) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2512,6 +2905,11 @@ TEST_F(MaatIPScan, IPv4RuleFull_0) {
ret = maat_scan_ipv4(maat_inst, table_id, sip, port, proto,
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
port = htons(64999);
@@ -2521,6 +2919,10 @@ TEST_F(MaatIPScan, IPv4RuleFull_0) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 169);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2548,6 +2950,10 @@ TEST_F(MaatIPScan, IPv6ScanDataFull_0) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
}
@@ -2574,6 +2980,10 @@ TEST_F(MaatIPScan, IPv6ScanDataFull_1) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
}
@@ -2598,6 +3008,11 @@ TEST_F(MaatIPScan, IPv6RuleFull_0) {
ret = maat_scan_ipv6(maat_inst, table_id, sip, port, proto,
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
port = htons(64999);
@@ -2607,6 +3022,10 @@ TEST_F(MaatIPScan, IPv6RuleFull_0) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 210);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2635,6 +3054,11 @@ TEST_F(MaatIPScan, IPv4_IPPort) {
EXPECT_EQ(n_hit_result, 2);
EXPECT_EQ(results[0], 208);
EXPECT_EQ(results[1], 154);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2661,6 +3085,10 @@ TEST_F(MaatIPScan, IPv6_IPPort) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 155);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2685,6 +3113,10 @@ TEST_F(MaatIPScan, BugReport20210515) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2709,6 +3141,11 @@ TEST_F(MaatIPScan, dynamic_config) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
const char *compile_table_name = "COMPILE_DEFAULT";
@@ -2740,6 +3177,11 @@ TEST_F(MaatIPScan, dynamic_config) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* ip table del line */
@@ -2764,6 +3206,10 @@ TEST_F(MaatIPScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2781,7 +3227,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -2794,7 +3240,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in MaatIntervalScan failed.",
__FUNCTION__, __LINE__);
}
@@ -2826,6 +3272,11 @@ TEST_F(MaatIntervalScan, IntegerRange) {
int ret = maat_scan_integer(maat_inst, table_id, scan_data1, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
unsigned int scan_data2 = 300;
@@ -2834,6 +3285,10 @@ TEST_F(MaatIntervalScan, IntegerRange) {
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
EXPECT_EQ(n_hit_result, 0);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2855,6 +3310,10 @@ TEST_F(MaatIntervalScan, SingleInteger) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 218);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2882,10 +3341,108 @@ TEST_F(MaatIntervalScan, IntervalPlus) {
EXPECT_EQ(results[0], 209);
EXPECT_EQ(results[1], 179);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
+class MaatGroupScan : public testing::Test
+{
+protected:
+ static void SetUpTestCase() {
+ const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},"
+ "{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
+ char redis_ip[64] = "127.0.0.1";
+ int redis_port = 6379;
+ int redis_db = 0;
+
+ logger = log_handle_create("./maat_framework_gtest.log", 0);
+ int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
+ if (ret < 0) {
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
+ "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
+ }
+
+ struct maat_options *opts = maat_options_new();
+ maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
+ maat_options_set_stat_file(opts, "./stat.log");
+ maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
+ maat_options_set_accept_tags(opts, accept_tags);
+
+ _shared_maat_inst = maat_new(opts, table_info_path);
+ maat_options_free(opts);
+ if (NULL == _shared_maat_inst) {
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
+ "[%s:%d] create maat instance in MaatGroupScan failed.",
+ __FUNCTION__, __LINE__);
+ }
+ }
+
+ static void TearDownTestCase() {
+ maat_free(_shared_maat_inst);
+ log_handle_destroy(logger);
+ }
+
+ static struct log_handle *logger;
+ static struct maat *_shared_maat_inst;
+};
+
+struct maat *MaatGroupScan::_shared_maat_inst;
+struct log_handle *MaatGroupScan::logger;
+
+TEST_F(MaatGroupScan, basic) {
+ long long results[ARRAY_SIZE] = {0};
+ size_t n_hit_result = 0;
+ int thread_id = 0;
+ const char *table_name = "KEYWORDS_TABLE";
+ struct maat *maat_inst = MaatGroupScan::_shared_maat_inst;
+ struct maat_state *state = maat_state_new(maat_inst, thread_id);
+
+ int table_id = maat_get_table_id(maat_inst, table_name);
+ ASSERT_GE(table_id, 0);
+
+ long long group_id = 158;
+ int ret = maat_scan_group(maat_inst, table_id, &group_id, 1, results,
+ ARRAY_SIZE, &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(n_hit_result, 1);
+ EXPECT_EQ(results[0], 226);
+
+ maat_state_free(state);
+ state = NULL;
+}
+
+TEST_F(MaatGroupScan, SetScanCompileTable) {
+ long long results[ARRAY_SIZE] = {0};
+ size_t n_hit_result = 0;
+ int thread_id = 0;
+ const char *table_name = "KEYWORDS_TABLE";
+ struct maat *maat_inst = MaatGroupScan::_shared_maat_inst;
+ struct maat_state *state = maat_state_new(maat_inst, thread_id);
+
+ int table_id = maat_get_table_id(maat_inst, table_name);
+ ASSERT_GE(table_id, 0);
+
+ const char *compile_table_name = "COMPILE_FIREWALL_CONJUNCTION";
+ int compile_table_id = maat_get_table_id(maat_inst, compile_table_name);
+
+ int ret = maat_state_set_scan_compile_table(state, compile_table_id);
+ EXPECT_EQ(ret, 0);
+
+ long long group_id = 159;
+ ret = maat_scan_group(maat_inst, table_id, &group_id, 1, results,
+ ARRAY_SIZE, &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(n_hit_result, 1);
+ EXPECT_EQ(results[0], 227);
+
+ maat_state_free(state);
+ state = NULL;
+}
+
class NOTLogic : public testing::Test
{
protected:
@@ -2899,7 +3456,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -2913,7 +3470,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in NOTLogic failed.",
__FUNCTION__, __LINE__);
}
@@ -2949,9 +3506,14 @@ TEST_F(NOTLogic, OneRegion) {
strlen(string_should_hit), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HIT);
- EXPECT_EQ(n_hit_result, 1);
+ EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 143);
+
maat_state_reset(state);
ret = maat_scan_string(maat_inst, table_id, string_should_not_hit,
@@ -2959,6 +3521,10 @@ TEST_F(NOTLogic, OneRegion) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -2984,6 +3550,10 @@ TEST_F(NOTLogic, ScanNotAtLast) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int not_hit_table_id = maat_get_table_id(maat_inst, not_hit_table_name);
ASSERT_GT(not_hit_table_id, 0);
@@ -2992,10 +3562,18 @@ TEST_F(NOTLogic, ScanNotAtLast) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, not_hit_table_id, string_contain_nothing,
strlen(string_contain_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 144);
@@ -3022,12 +3600,20 @@ TEST_F(NOTLogic, ScanIrrelavantAtLast) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int not_hit_table_id = maat_get_table_id(maat_inst, not_hit_table_name);
ASSERT_GT(hit_table_id, 0);
ret = maat_scan_string(maat_inst, not_hit_table_id, string_irrelevant,
strlen(string_irrelevant), results, ARRAY_SIZE,
&n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 144);
@@ -3054,7 +3640,11 @@ TEST_F(NOTLogic, ScanHitAtLastEmptyExpr) {
int ret = maat_scan_string(maat_inst, not_hit_table_id, string_should_not_hit,
strlen(string_should_not_hit), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
uint32_t sip;
inet_pton(AF_INET, "10.0.8.186", &sip);
@@ -3070,6 +3660,10 @@ TEST_F(NOTLogic, ScanHitAtLastEmptyExpr) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 186);
+ ret = maat_scan_not_logic(maat_inst, hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int empty_table_id = maat_get_table_id(maat_inst, empty_table_name);
ASSERT_GT(empty_table_id, 0);
@@ -3078,6 +3672,10 @@ TEST_F(NOTLogic, ScanHitAtLastEmptyExpr) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, empty_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -3099,7 +3697,11 @@ TEST_F(NOTLogic, ScanHitAtLastEmptyInteger) {
int ret = maat_scan_string(maat_inst, not_hit_table_id, string_should_not_hit,
strlen(string_should_not_hit), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
uint32_t sip;
inet_pton(AF_INET, "10.0.8.187", &sip);
@@ -3115,6 +3717,10 @@ TEST_F(NOTLogic, ScanHitAtLastEmptyInteger) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 187);
+ ret = maat_scan_not_logic(maat_inst, hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int empty_table_id = maat_get_table_id(maat_inst, empty_table_name);
ASSERT_GT(empty_table_id, 0);
@@ -3122,6 +3728,10 @@ TEST_F(NOTLogic, ScanHitAtLastEmptyInteger) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, empty_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -3144,6 +3754,10 @@ TEST_F(NOTLogic, ScanNotIP) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
uint32_t sip;
inet_pton(AF_INET, "10.0.6.205", &sip);
uint16_t port = htons(50001);
@@ -3156,10 +3770,18 @@ TEST_F(NOTLogic, ScanNotIP) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
inet_pton(AF_INET, "10.1.0.0", &sip);
ret = maat_scan_ipv4(maat_inst, not_hit_table_id, sip, port, proto,
results, ARRAY_SIZE, &n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 145);
@@ -3188,6 +3810,10 @@ TEST_F(NOTLogic, ScanNotWithDistrict) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int virtual_table_id = maat_get_table_id(maat_inst, virtual_table_name);
ASSERT_GT(virtual_table_id, 0);
@@ -3199,8 +3825,16 @@ TEST_F(NOTLogic, ScanNotWithDistrict) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, virtual_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, virtual_table_id, string3, strlen(string3),
results, ARRAY_SIZE, &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, virtual_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 221);
@@ -3231,6 +3865,10 @@ TEST_F(NOTLogic, NotUrlAndNotIp) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
uint32_t sip;
inet_pton(AF_INET, "10.1.0.0", &sip);
uint16_t port = htons(50001);
@@ -3241,7 +3879,11 @@ TEST_F(NOTLogic, NotUrlAndNotIp) {
ret = maat_scan_ipv4(maat_inst, ip_table_id, sip, port, proto,
results, ARRAY_SIZE, &n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int http_table_id = maat_get_table_id(maat_inst, http_table_name);
ASSERT_GT(http_table_id, 0);
@@ -3251,10 +3893,18 @@ TEST_F(NOTLogic, NotUrlAndNotIp) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, http_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, http_table_id, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, http_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 146);
@@ -3285,12 +3935,24 @@ TEST_F(NOTLogic, NotPhysicalTable) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, phy_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, vtable_id, string2, strlen(string2),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, vtable_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, phy_table_id, string3, strlen(string3),
results, ARRAY_SIZE, &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, phy_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 224);
@@ -3321,7 +3983,11 @@ TEST_F(NOTLogic, EightNotClause) {
int ret = maat_scan_string(maat_inst, table_id1, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id1, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int table_id2 = maat_get_table_id(maat_inst, table_name2);
ASSERT_GT(table_id2, 0);
@@ -3329,7 +3995,11 @@ TEST_F(NOTLogic, EightNotClause) {
ret = maat_scan_string(maat_inst, table_id2, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id2, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int table_id3 = maat_get_table_id(maat_inst, table_name3);
ASSERT_GT(table_id3, 0);
@@ -3337,15 +4007,23 @@ TEST_F(NOTLogic, EightNotClause) {
ret = maat_scan_string(maat_inst, table_id3, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id3, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int table_id4 = maat_get_table_id(maat_inst, table_name4);
ASSERT_GT(table_id4, 0);
ret = maat_scan_string(maat_inst, table_id4, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id4, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int table_id5 = maat_get_table_id(maat_inst, table_name5);
ASSERT_GT(table_id5, 0);
@@ -3353,7 +4031,11 @@ TEST_F(NOTLogic, EightNotClause) {
ret = maat_scan_string(maat_inst, table_id5, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id5, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int table_id6 = maat_get_table_id(maat_inst, table_name6);
ASSERT_GT(table_id6, 0);
@@ -3361,7 +4043,11 @@ TEST_F(NOTLogic, EightNotClause) {
ret = maat_scan_string(maat_inst, table_id6, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id6, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int table_id7 = maat_get_table_id(maat_inst, table_name7);
ASSERT_GT(table_id7, 0);
@@ -3369,7 +4055,11 @@ TEST_F(NOTLogic, EightNotClause) {
ret = maat_scan_string(maat_inst, table_id7, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id7, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int table_id8 = maat_get_table_id(maat_inst, table_name8);
ASSERT_GT(table_id8, 0);
@@ -3377,7 +4067,11 @@ TEST_F(NOTLogic, EightNotClause) {
ret = maat_scan_string(maat_inst, table_id8, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id8, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 147);
@@ -3406,17 +4100,29 @@ TEST_F(NOTLogic, NotClauseAndExcludeGroup1) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, url_table_id, string_should_half_hit,
strlen(string_should_half_hit), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int http_table_id = maat_get_table_id(maat_inst, http_table_name);
ASSERT_GT(http_table_id, 0);
ret = maat_scan_string(maat_inst, http_table_id, string_nothing,
strlen(string_nothing), results, ARRAY_SIZE,
&n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, http_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 216);
@@ -3448,12 +4154,35 @@ TEST_F(NOTLogic, NotClauseAndExcludeGroup2) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, http_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, url_table_id, string1, strlen(string1),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ maat_state_reset(state);
+
+ ret = maat_scan_string(maat_inst, http_table_id, string_keywords,
+ strlen(string_keywords), results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, http_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, url_table_id, string2, strlen(string2),
results, ARRAY_SIZE, &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 217);
@@ -3482,11 +4211,16 @@ TEST_F(NOTLogic, SameClauseHasMultiNotGroups) {
ret = maat_scan_string(maat_inst, table_id, string3, strlen(string3),
results, ARRAY_SIZE, &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 222);
maat_state_reset(state);
+
ret = maat_scan_string(maat_inst, table_id, not_string1, strlen(not_string1),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
@@ -3497,6 +4231,10 @@ TEST_F(NOTLogic, SameClauseHasMultiNotGroups) {
ret = maat_scan_string(maat_inst, table_id, string3, strlen(string3),
results, ARRAY_SIZE, &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 222);
@@ -3518,7 +4256,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -3532,7 +4270,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in ExcludeLogic failed.",
__FUNCTION__, __LINE__);
}
@@ -3567,7 +4305,11 @@ TEST_F(ExcludeLogic, ScanExcludeAtFirst) {
int ret = maat_scan_string(maat_inst, not_hit_table_id, string_should_not_hit,
strlen(string_should_not_hit), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
int hit_table_id = maat_get_table_id(maat_inst, hit_table_name);
ASSERT_GT(hit_table_id, 0);
@@ -3579,6 +4321,10 @@ TEST_F(ExcludeLogic, ScanExcludeAtFirst) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 199);
+ ret = maat_scan_not_logic(maat_inst, hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -3602,7 +4348,12 @@ TEST_F(ExcludeLogic, ScanExcludeAtLast) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
+
ret = maat_scan_string(maat_inst, table_id, string_should_hit,
strlen(string_should_hit), results,
ARRAY_SIZE, &n_hit_result, state);
@@ -3611,6 +4362,10 @@ TEST_F(ExcludeLogic, ScanExcludeAtLast) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 200);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -3636,14 +4391,22 @@ TEST_F(ExcludeLogic, ScanIrrelavantAtLast) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 200);
+ ret = maat_scan_not_logic(maat_inst, hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int not_hit_table_id = maat_get_table_id(maat_inst, not_hit_table_name);
ASSERT_GT(hit_table_id, 0);
ret = maat_scan_string(maat_inst, not_hit_table_id, string_irrelevant,
strlen(string_irrelevant), results, ARRAY_SIZE,
&n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, not_hit_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -3672,25 +4435,42 @@ TEST_F(ExcludeLogic, ScanVirtualTable) {
EXPECT_EQ(results[0], 202);
maat_state_reset(state);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
inet_pton(AF_INET, "100.64.1.5", &should_hit_ip);
ret = maat_scan_ipv4(maat_inst, table_id, should_hit_ip, port, 6,
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 202);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
inet_pton(AF_INET, "100.64.1.6", &should_not_hit_ip);
ret = maat_scan_ipv4(maat_inst, table_id, should_not_hit_ip, port, 6,
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
inet_pton(AF_INET, "100.64.1.11", &should_not_hit_ip);
ret = maat_scan_ipv4(maat_inst, table_id, should_not_hit_ip, port, 6,
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
- maat_state_reset(state);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
maat_state_free(state);
}
@@ -3714,12 +4494,20 @@ TEST_F(ExcludeLogic, ScanWithMultiClause) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
inet_pton(AF_INET, "47.92.108.93", &ip_addr);
port = htons(443);
ret = maat_scan_ipv4(maat_inst, ip_table_id, ip_addr, port, 6,
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
const char *expr_table_name = "HTTP_RESPONSE_KEYWORDS";
int expr_table_id = maat_get_table_id(maat_inst, expr_table_name);
ASSERT_GT(expr_table_id, 0);
@@ -3730,6 +4518,10 @@ TEST_F(ExcludeLogic, ScanWithMultiClause) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
const char *should_hit_expr = "mail.jianshu.com";
ret = maat_scan_string(maat_inst, expr_table_id, should_hit_expr,
strlen(should_hit_expr), results, ARRAY_SIZE,
@@ -3738,6 +4530,10 @@ TEST_F(ExcludeLogic, ScanWithMultiClause) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 203);
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -3761,6 +4557,10 @@ TEST_F(ExcludeLogic, ExcludeInDifferentLevel) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
inet_pton(AF_INET, "100.64.2.6", &ip_addr);
port = htons(443);
@@ -3768,6 +4568,10 @@ TEST_F(ExcludeLogic, ExcludeInDifferentLevel) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
const char *expr_table_name = "HTTP_RESPONSE_KEYWORDS";
int expr_table_id = maat_get_table_id(maat_inst, expr_table_name);
ASSERT_GT(expr_table_id, 0);
@@ -3778,12 +4582,20 @@ TEST_F(ExcludeLogic, ExcludeInDifferentLevel) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
const char *should_not_hit_expr2 = "mail.baidu.com";
ret = maat_scan_string(maat_inst, expr_table_id, should_not_hit_expr2,
strlen(should_not_hit_expr2), results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
const char *should_hit_expr = "hit.baidu.com";
ret = maat_scan_string(maat_inst, expr_table_id, should_hit_expr,
strlen(should_hit_expr), results, ARRAY_SIZE,
@@ -3792,6 +4604,10 @@ TEST_F(ExcludeLogic, ExcludeInDifferentLevel) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 204);
+ ret = maat_scan_not_logic(maat_inst, expr_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
}
@@ -3832,7 +4648,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -3846,7 +4662,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in PluginTable failed.",
__FUNCTION__, __LINE__);
}
@@ -4095,7 +4911,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -4109,7 +4925,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in IPPluginTable failed.",
__FUNCTION__, __LINE__);
}
@@ -4234,7 +5050,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -4248,7 +5064,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in IPPortPluginTable failed.",
__FUNCTION__, __LINE__);
}
@@ -4373,7 +5189,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -4387,7 +5203,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in FQDNPluginTable failed.",
__FUNCTION__, __LINE__);
}
@@ -4543,7 +5359,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -4557,7 +5373,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in BoolPluginTable failed.",
__FUNCTION__, __LINE__);
}
@@ -4629,7 +5445,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -4643,7 +5459,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in VirtualTable failed.",
__FUNCTION__, __LINE__);
}
@@ -4694,7 +5510,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -4709,7 +5525,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in CompileTable failed.",
__FUNCTION__, __LINE__);
}
@@ -4808,6 +5624,10 @@ TEST_F(CompileTable, Conjunction1) {
EXPECT_EQ(results[0], 197);
EXPECT_EQ(results[1], 141);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
EXPECT_EQ(n_read, 2);
@@ -4836,6 +5656,10 @@ TEST_F(CompileTable, Conjunction2) {
EXPECT_EQ(results[0], 197);
EXPECT_EQ(results[1], 141);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[HIT_PATH_SIZE] = {0};
int n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
EXPECT_EQ(n_read, 2);
@@ -4844,6 +5668,10 @@ TEST_F(CompileTable, Conjunction2) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
memset(hit_path, 0, sizeof(hit_path));
n_read = maat_state_get_hit_paths(state, hit_path, HIT_PATH_SIZE);
EXPECT_EQ(n_read, 4);
@@ -4865,7 +5693,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -4879,7 +5707,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in Policy failed.",
__FUNCTION__, __LINE__);
}
@@ -4967,11 +5795,19 @@ TEST_F(Policy, CompileRuleTags) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_string(maat_inst, table_id, should_hit,
strlen(should_hit), results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5002,7 +5838,7 @@ TEST_F(Policy, CompileEXData) {
compile_ex_param_dup,
0, &ex_data_counter);
ASSERT_TRUE(ret == 0);
- EXPECT_EQ(ex_data_counter, 1);
+ EXPECT_EQ(ex_data_counter, 2);
ret = maat_state_set_scan_compile_table(state, conj_compile_table_id);
EXPECT_EQ(ret, 0);
@@ -5013,6 +5849,10 @@ TEST_F(Policy, CompileEXData) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 198);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int compile_table_ids[ARRAY_SIZE];
ret = maat_state_get_compile_table_ids(state, results, 1, compile_table_ids);
EXPECT_EQ(ret, 1);
@@ -5050,6 +5890,10 @@ TEST_F(Policy, SubGroup) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, "IP_CONFIG");
ASSERT_GT(table_id, 0);
@@ -5059,6 +5903,10 @@ TEST_F(Policy, SubGroup) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(results[0], 153);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
const char *compile_table_name = "COMPILE_DEFAULT";
int phy_compile_table_id = maat_get_table_id(maat_inst, compile_table_name);
@@ -5089,6 +5937,10 @@ TEST_F(Policy, EvaluationOrder) {
EXPECT_EQ(results[1], 167);
EXPECT_EQ(results[2], 166);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
uint32_t ip_addr;
inet_pton(AF_INET, "192.168.23.23", &ip_addr);
uint16_t port = htons(65530);
@@ -5102,6 +5954,11 @@ TEST_F(Policy, EvaluationOrder) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 165);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
}
@@ -5134,7 +5991,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -5148,7 +6005,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in TableInfo failed.",
__FUNCTION__, __LINE__);
}
@@ -5191,6 +6048,10 @@ TEST_F(TableInfo, Conjunction) {
EXPECT_EQ(results[0], 134);
EXPECT_EQ(results[1], 133);
+ ret = maat_scan_not_logic(maat_inst, conj_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5305,7 +6166,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.",
__FUNCTION__, __LINE__);
}
@@ -5319,7 +6180,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in HierarchyTest failed.",
__FUNCTION__, __LINE__);
}
@@ -5356,6 +6217,10 @@ TEST_F(HierarchyTest, VirtualOfOnePhysical)
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, keywords_table_name);
ASSERT_GT(table_id, 0);
@@ -5364,6 +6229,11 @@ TEST_F(HierarchyTest, VirtualOfOnePhysical)
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 160);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
const char *should_not_hit = "2018-10-05 is a keywords of table "
@@ -5372,6 +6242,11 @@ TEST_F(HierarchyTest, VirtualOfOnePhysical)
strlen(should_not_hit), results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5403,6 +6278,10 @@ TEST_F(HierarchyTest, VirtualWithVirtual) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, res_table_name);
ASSERT_GT(table_id, 0);
@@ -5417,6 +6296,10 @@ TEST_F(HierarchyTest, VirtualWithVirtual) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 162);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5444,6 +6327,10 @@ TEST_F(HierarchyTest, OneGroupInTwoVirtual) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, res_table_name);
ASSERT_GT(table_id, 0);
@@ -5458,6 +6345,10 @@ TEST_F(HierarchyTest, OneGroupInTwoVirtual) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 163);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5485,6 +6376,10 @@ TEST_F(HierarchyTest, TwoVirtualInOneClause) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, dst_asn_table_name);
ASSERT_GT(table_id, 0);
@@ -5494,6 +6389,10 @@ TEST_F(HierarchyTest, TwoVirtualInOneClause) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 178);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
//--------------------------------------
@@ -5510,6 +6409,10 @@ TEST_F(HierarchyTest, TwoVirtualInOneClause) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, dst_asn_table_name);
ASSERT_GT(table_id, 0);
@@ -5519,6 +6422,10 @@ TEST_F(HierarchyTest, TwoVirtualInOneClause) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 178);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
//--------------------------------------
@@ -5531,6 +6438,10 @@ TEST_F(HierarchyTest, TwoVirtualInOneClause) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, dst_asn_table_name);
ASSERT_GT(table_id, 0);
@@ -5540,6 +6451,10 @@ TEST_F(HierarchyTest, TwoVirtualInOneClause) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 178);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5634,6 +6549,10 @@ TEST_F(MaatCmdTest, SetIP) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5673,6 +6592,11 @@ TEST_F(MaatCmdTest, SetExpr) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_TRUE(results[0] == compile_id || results[0] == (compile_id - 1));
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL, compile_id-1,
@@ -5686,6 +6610,11 @@ TEST_F(MaatCmdTest, SetExpr) {
ret = maat_scan_string(maat_inst, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
int timeout = 1;
@@ -5695,6 +6624,11 @@ TEST_F(MaatCmdTest, SetExpr) {
ret = maat_scan_string(maat_inst, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5744,6 +6678,11 @@ TEST_F(MaatCmdTest, SetExpr8) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_DEL, item_id,
@@ -5762,6 +6701,47 @@ TEST_F(MaatCmdTest, SetExpr8) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ maat_state_free(state);
+ state = NULL;
+}
+
+TEST_F(MaatCmdTest, MaatGroupScan) {
+ long long results[ARRAY_SIZE] = {0};
+ size_t n_hit_result = 0;
+ int thread_id = 0;
+ const char *table_name = "HTTP_URL";
+ const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ struct maat *maat_inst = MaatCmdTest::_shared_maat_inst;
+ struct maat_state *state = maat_state_new(maat_inst, thread_id);
+
+ int table_id = maat_get_table_id(maat_inst, table_name);
+ ASSERT_GE(table_id, 0);
+
+ /* compile table add line */
+ long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
+ compile_id, "null", 1, 0);
+ EXPECT_EQ(ret, 1);
+
+ /* group2compile table add line */
+ long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, compile_id, 0, table_name, 1, 0);
+ EXPECT_EQ(ret, 1);
+
+ sleep(WAIT_FOR_EFFECTIVE_S);
+
+ ret = maat_scan_group(maat_inst, table_id, &group_id, 1, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_HIT);
+ EXPECT_EQ(n_hit_result, 1);
+ EXPECT_EQ(results[0], compile_id);
+
maat_state_free(state);
state = NULL;
}
@@ -5813,6 +6793,10 @@ TEST_F(MaatCmdTest, SameFilterRefByOneCompile) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -5837,31 +6821,45 @@ TEST_F(MaatCmdTest, RuleIDRecycle) {
int ret = maat_scan_string(maat_inst, table_id, scan_data,
strlen(scan_data), results, ARRAY_SIZE,
&n_hit_result, state);
- maat_state_reset(state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], rule_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ maat_state_reset(state);
+
del_command(maat_inst, rule_id);
sleep(WAIT_FOR_EFFECTIVE_S);
ret = maat_scan_string(maat_inst, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
- maat_state_reset(state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ maat_state_reset(state);
+
test_add_expr_command(maat_inst, table_name, rule_id, 0, keywords);
sleep(WAIT_FOR_EFFECTIVE_S);
memset(results, 0, sizeof(results));
ret = maat_scan_string(maat_inst, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
- maat_state_free(state);
- state = NULL;
-
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], rule_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ maat_state_free(state);
+ state = NULL;
}
TEST_F(MaatCmdTest, ReturnRuleIDWithDescendingOrder) {
@@ -5893,12 +6891,17 @@ TEST_F(MaatCmdTest, ReturnRuleIDWithDescendingOrder) {
memset(results, 0, sizeof(results));
int ret = maat_scan_string(maat_inst, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
- maat_state_free(state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, repeat_times);
for (i = 0; i < repeat_times; i++) {
EXPECT_EQ(results[i], expect_rule_id[repeat_times -i - 1]);
}
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ maat_state_free(state);
}
TEST_F(MaatCmdTest, SubGroup) {
@@ -5958,7 +6961,7 @@ TEST_F(MaatCmdTest, SubGroup) {
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
group2_id, keyword1, NULL, 1, 0, 0, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
- sleep(4);
+ sleep(WAIT_FOR_EFFECTIVE_S * 2);
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
@@ -5968,6 +6971,11 @@ TEST_F(MaatCmdTest, SubGroup) {
EXPECT_EQ(n_hit_result, 2);
EXPECT_EQ(results[0], compile2_id);
EXPECT_EQ(results[1], compile1_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* item1 -> group2 -> group1 -> compile1
@@ -5984,6 +6992,11 @@ TEST_F(MaatCmdTest, SubGroup) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* item1 -> group2 -> group1 -> X
@@ -6001,12 +7014,17 @@ TEST_F(MaatCmdTest, SubGroup) {
group2_id, compile2_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- sleep(2);
+ sleep(WAIT_FOR_EFFECTIVE_S);
ret = maat_scan_string(maat_inst, table_id, scan_data1, strlen(scan_data1),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile2_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* item1 -> group2 -> group1 -> X
@@ -6026,6 +7044,11 @@ TEST_F(MaatCmdTest, SubGroup) {
ret = maat_scan_string(maat_inst, table_id, scan_data2, strlen(scan_data2),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* item1 -> group2 -> group1 -> X
@@ -6047,12 +7070,17 @@ TEST_F(MaatCmdTest, SubGroup) {
group1_id, compile1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- sleep(2);
+ sleep(WAIT_FOR_EFFECTIVE_S);
ret = maat_scan_string(maat_inst, table_id, scan_data1, strlen(scan_data1),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile2_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -6089,9 +7117,7 @@ TEST_F(MaatCmdTest, RefGroup) {
group1_id, keyword1, NULL, 1, 0, 0, 0); /* EXPR_TYPE_AND MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
- //TODO: value=1 MAAT_OPT_ENABLE_UPDATE
- sleep(2);
- //TODO: value=0 MAAT_OPT_ENABLE_UPDATE
+ sleep(WAIT_FOR_EFFECTIVE_S);
/* item1 -> group1 -> X -> compile1
/
@@ -6121,9 +7147,7 @@ TEST_F(MaatCmdTest, RefGroup) {
group2_id, compile1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- //TODO value=1 MAAT_OPT_ENABLE_UPDATE
-
- sleep(2);
+ sleep(WAIT_FOR_EFFECTIVE_S);
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
@@ -6132,6 +7156,11 @@ TEST_F(MaatCmdTest, RefGroup) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -6181,7 +7210,7 @@ TEST_F(MaatCmdTest, VirtualTable) {
group2_id, "uid=12345678;", "Cookie", 0, 0, 0, 0);/*EXPR_TYPE_STRING MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
- sleep(2);
+ sleep(WAIT_FOR_EFFECTIVE_S);
const char* http_req_hdr_ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36";
@@ -6203,6 +7232,10 @@ TEST_F(MaatCmdTest, VirtualTable) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, "HTTP_RESPONSE_HEADER");
ASSERT_GT(table_id, 0);
@@ -6216,6 +7249,11 @@ TEST_F(MaatCmdTest, VirtualTable) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
//delete group1
@@ -6229,7 +7267,8 @@ TEST_F(MaatCmdTest, VirtualTable) {
ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
compile1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- sleep(2);
+
+ sleep(WAIT_FOR_EFFECTIVE_S);
table_id = maat_get_table_id(maat_inst, "HTTP_RESPONSE_HEADER");
ASSERT_GT(table_id, 0);
@@ -6245,6 +7284,10 @@ TEST_F(MaatCmdTest, VirtualTable) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -7004,21 +8047,39 @@ TEST_F(MaatCmdTest, GroupInMassCompiles) {
results, 4, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_integer(maat_inst, appid_table_id, 100, results, 4,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], target_compile_id);
+
+ ret = maat_scan_not_logic(maat_inst, appid_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
ret = maat_scan_string(maat_inst, url_table_id, http_url1, strlen(http_url1),
results, 4, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, url_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_integer(maat_inst, appid_table_id, 100, results, 4,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 4);
+
+ ret = maat_scan_not_logic(maat_inst, appid_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -7145,6 +8206,10 @@ TEST_F(MaatCmdTest, HitGroup) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, http_req_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
size_t scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 1);
@@ -7180,6 +8245,10 @@ TEST_F(MaatCmdTest, HitGroup) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, http_res_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 2);
@@ -7222,6 +8291,11 @@ TEST_F(MaatCmdTest, HitGroup) {
ret = maat_scan_ipv4(maat_inst, ip_table_id, ip_addr, port, 6, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 4);
@@ -7370,6 +8444,10 @@ TEST_F(MaatCmdTest, HitPath) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, http_req_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
size_t scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 1);
@@ -7409,6 +8487,10 @@ TEST_F(MaatCmdTest, HitPath) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, http_res_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 2);
@@ -7463,6 +8545,10 @@ that the edges be all directed in the same direction.";
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, keywords_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 3);
@@ -7488,6 +8574,11 @@ that the edges be all directed in the same direction.";
ret = maat_scan_ipv4(maat_inst, ip_table_id, ip_addr, port, 6, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 4);
@@ -7507,6 +8598,11 @@ that the edges be all directed in the same direction.";
ret = maat_stream_scan(stream, keywords2, strlen(keywords2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, keywords_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 5);
@@ -7634,7 +8730,11 @@ TEST_F(MaatCmdTest, HitPathHasNotGroup) {
size_t n_hit_result = 0;
ret = maat_scan_string(maat_inst, http_req_table_id, http_url, strlen(http_url),
results, ARRAY_SIZE, &n_hit_result, state);
- EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, http_req_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
size_t scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 1);
@@ -7677,6 +8777,10 @@ TEST_F(MaatCmdTest, HitPathHasNotGroup) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, http_res_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 2);
@@ -7731,6 +8835,11 @@ TEST_F(MaatCmdTest, HitPathHasNotGroup) {
ret = maat_stream_scan(stream, keywords1, strlen(keywords1), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, keywords_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 3);
@@ -7757,6 +8866,11 @@ TEST_F(MaatCmdTest, HitPathHasNotGroup) {
ret = maat_scan_ipv4(maat_inst, ip_table_id, ip_addr, port, 6, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, ip_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 4);
@@ -7777,6 +8891,11 @@ TEST_F(MaatCmdTest, HitPathHasNotGroup) {
ret = maat_stream_scan(stream, keywords2, strlen(keywords2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, keywords_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
scan_count = maat_state_get_scan_count(state);
EXPECT_EQ(scan_count, 5);
@@ -7866,6 +8985,10 @@ TEST_F(MaatCmdTest, SameSuperGroupRefByMultiCompile) {
EXPECT_EQ(results[0], compile3_id);
EXPECT_EQ(results[1], compile2_id);
+ ret = maat_scan_not_logic(maat_inst, http_res_table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
memset(hit_path, 0, sizeof(hit_path));
int n_read = maat_state_get_hit_paths(state, hit_path, sizeof(hit_path));
EXPECT_EQ(n_read, 3);
@@ -7946,12 +9069,20 @@ TEST_F(MaatCmdTest, SameScanStatusWhenClauseUpdate_TSG6419) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
int scan_app_id = 32;
table_id = maat_get_table_id(maat_inst, app_id_table_name);
ret = maat_scan_integer(maat_inst, table_id, scan_app_id, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
/* item11 -> group11 -> clause1 -> compile1
/
item21 -> group21 -> clause2 _/
@@ -7981,12 +9112,20 @@ TEST_F(MaatCmdTest, SameScanStatusWhenClauseUpdate_TSG6419) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = maat_scan_integer(maat_inst, table_id, scan_app_id, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -8045,6 +9184,10 @@ TEST_F(MaatCmdTest, GroupEdit) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, app_id_table_name);
ASSERT_GT(table_id, 0);
@@ -8052,6 +9195,11 @@ TEST_F(MaatCmdTest, GroupEdit) {
ret = maat_scan_integer(maat_inst, table_id, scan_app_id, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
/* item11 -> group11 -> clause1 -> compile1
@@ -8082,6 +9230,10 @@ TEST_F(MaatCmdTest, GroupEdit) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
struct maat_hit_path hit_path[128];
memset(hit_path, 0, sizeof(hit_path));
@@ -8105,11 +9257,19 @@ TEST_F(MaatCmdTest, GroupEdit) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
table_id = maat_get_table_id(maat_inst, app_id_table_name);
ret = maat_scan_integer(maat_inst, table_id, scan_app_id, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -8157,6 +9317,10 @@ TEST_F(MaatCmdTest, CompileDelete_TSG6548) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
compile1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
@@ -8229,6 +9393,10 @@ TEST_F(MaatCmdTest, UpdateDeadLockDetection) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
compile2_id, "null", 1, 0);
@@ -8259,6 +9427,11 @@ TEST_F(MaatCmdTest, UpdateDeadLockDetection) {
results, ARRAY_SIZE, &n_hit_result, state);
//After full update, clause ids are re-orgnized, therefore mid are not compatible to the new scanner (hierarchy).
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -8296,6 +9469,10 @@ TEST_F(MaatCmdTest, StreamScanWhenExprTableIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
//item1 -> group1 -> compile1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, scan_table_name, MAAT_OP_ADD,
@@ -8312,6 +9489,10 @@ TEST_F(MaatCmdTest, StreamScanWhenExprTableIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_stream_free(stream);
stream = maat_stream_new(maat_inst, table_id, state);
@@ -8321,6 +9502,10 @@ TEST_F(MaatCmdTest, StreamScanWhenExprTableIncUpdate) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_stream_free(stream);
maat_state_free(state);
state = NULL;
@@ -8367,6 +9552,10 @@ TEST_F(MaatCmdTest, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
//DON'T DO THIS!!!
//Roll back version, trigger full update.
//This operation generates FATAL logs in test_maat_redis.log.yyyy-mm-dd.
@@ -8380,6 +9569,10 @@ TEST_F(MaatCmdTest, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK); //Scan was interupted after full update.
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_stream_free(stream);
maat_state_free(state);
state = NULL;
@@ -8445,6 +9638,10 @@ TEST_F(MaatCmdTest, IPAndStreamScanWhenIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
//add compile2 for compile runtime inc update
long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
@@ -8464,6 +9661,10 @@ TEST_F(MaatCmdTest, IPAndStreamScanWhenIncUpdate) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
/*
becase compile1_id has been returned, maat_scan_xx will not return duplicate compile_id again
*/
@@ -8473,6 +9674,10 @@ TEST_F(MaatCmdTest, IPAndStreamScanWhenIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_stream_free(stream);
maat_state_free(state);
state = NULL;
@@ -8539,6 +9744,10 @@ TEST_F(MaatCmdTest, IPAndStreamScanWhenFullUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
//DON'T DO THIS!!!
//Roll back version, trigger full update.
maat_cmd_incrby(maat_inst, "MAAT_VERSION", -100);
@@ -8555,6 +9764,10 @@ TEST_F(MaatCmdTest, IPAndStreamScanWhenFullUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
/* maat_state keep the compile_rt version when maat_state_new().
After full updating, new compile_rt version is different from that of maat_state,
so MAAT_SCAN_HIT will never happen.
@@ -8565,6 +9778,10 @@ TEST_F(MaatCmdTest, IPAndStreamScanWhenFullUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_stream_free(stream);
maat_state_free(state);
state = NULL;
@@ -8631,6 +9848,10 @@ TEST_F(MaatCmdTest, IPAndStringScanWhenIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
//add compile2 for compile runtime inc update
long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
@@ -8649,6 +9870,10 @@ TEST_F(MaatCmdTest, IPAndStringScanWhenIncUpdate) {
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], compile1_id);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
/*
becase compile1_id has been returned, maat_scan_xx will not return duplicate compile_id again
*/
@@ -8658,6 +9883,10 @@ TEST_F(MaatCmdTest, IPAndStringScanWhenIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -8723,6 +9952,10 @@ TEST_F(MaatCmdTest, IPAndStringScanWhenFullupdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
//DON'T DO THIS!!!
//Roll back version, trigger full update.
maat_cmd_incrby(maat_inst, "MAAT_VERSION", -100);
@@ -8738,6 +9971,10 @@ TEST_F(MaatCmdTest, IPAndStringScanWhenFullupdate) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
/* maat_state keep the compile_rt version when maat_state_new().
After full updating, new compile_rt version is different from that of maat_state,
so MAAT_SCAN_HIT will never happen.
@@ -8749,6 +9986,10 @@ TEST_F(MaatCmdTest, IPAndStringScanWhenFullupdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HALF_HIT);
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -8766,7 +10007,7 @@ protected:
logger = log_handle_create("./maat_framework_gtest.log", 0);
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -8778,7 +10019,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] create maat instance in MaatRollbackTest failed.",
__FUNCTION__, __LINE__);
}
@@ -8801,7 +10042,7 @@ static int clear_config_in_redis(redisContext *c, struct log_handle *logger)
redisReply *reply = maat_wrap_redis_command(c, "GET MAAT_VERSION");
if (reply != NULL) {
if (reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] GET MAAT_VERSION failed, maybe Redis is busy",
__FUNCTION__, __LINE__);
freeReplyObject(reply);
@@ -8809,7 +10050,7 @@ static int clear_config_in_redis(redisContext *c, struct log_handle *logger)
return -1;
}
} else {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] GET MAAT_VERSION failed with NULL reply, error: %s",
__FUNCTION__, __LINE__, c->errstr);
return -1;
@@ -8818,7 +10059,7 @@ static int clear_config_in_redis(redisContext *c, struct log_handle *logger)
redis_version = maat_read_redis_integer(reply);
if (redis_version < 0) {
if (reply->type == REDIS_REPLY_ERROR) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] Redis Communication error: %s",
__FUNCTION__, __LINE__, reply->str);
}
@@ -8871,7 +10112,7 @@ static int rollback_redis_version(redisContext *c, struct log_handle *logger)
{
redisReply *reply = maat_wrap_redis_command(c, "SET MAAT_VERSION 0");
if (NULL == reply) {
- log_error(logger, MODULE_FRAMEWORK_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_GTEST,
"[%s:%d] set MAAT_VERSION failed, Redis Communication error: %s",
__FUNCTION__, __LINE__, c->errstr);
return -1;
@@ -8902,6 +10143,11 @@ TEST_F(MaatRollbackTest, FullConfigRollback) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 125);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
sleep(5);
@@ -8928,6 +10174,11 @@ TEST_F(MaatRollbackTest, FullConfigRollback) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 125);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
@@ -8952,6 +10203,11 @@ TEST_F(MaatRollbackTest, FullConfigRollbackWhenScanUnfinished) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 125);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_reset(state);
sleep(5);
@@ -8978,6 +10234,11 @@ TEST_F(MaatRollbackTest, FullConfigRollbackWhenScanUnfinished) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 125);
+
+ ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
+ &n_hit_result, state);
+ EXPECT_EQ(ret, MAAT_SCAN_OK);
+
maat_state_free(state);
state = NULL;
}
diff --git a/test/maat_framework_perf_gtest.cpp b/test/maat_framework_perf_gtest.cpp
index 9f11a28..7ba3750 100644
--- a/test/maat_framework_perf_gtest.cpp
+++ b/test/maat_framework_perf_gtest.cpp
@@ -384,7 +384,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -399,7 +399,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatStringScan failed.",
__FUNCTION__, __LINE__);
}
@@ -534,7 +534,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -549,7 +549,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatRegexScan failed.",
__FUNCTION__, __LINE__);
}
@@ -737,7 +737,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -752,7 +752,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatStreamScan failed.",
__FUNCTION__, __LINE__);
}
@@ -867,7 +867,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -882,7 +882,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatIPScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1034,7 +1034,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -1049,7 +1049,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatIntegerScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1129,7 +1129,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -1144,7 +1144,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatFlagScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1277,7 +1277,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -1292,7 +1292,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatFQDNPluginScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1505,7 +1505,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -1520,7 +1520,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in BoolPluginScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1716,7 +1716,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatPerfFileScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1852,7 +1852,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -1865,7 +1865,7 @@ protected:
_shared_maat_inst = maat_new(opts, tsg_table_info);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatTSGFqdnScan failed.",
__FUNCTION__, __LINE__);
}
@@ -1924,7 +1924,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
}
@@ -1939,7 +1939,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
- log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
+ log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatFlagScan failed.",
__FUNCTION__, __LINE__);
}
diff --git a/test/maat_json.json b/test/maat_json.json
index 19184a8..ee64e62 100644
--- a/test/maat_json.json
+++ b/test/maat_json.json
@@ -5,6 +5,7 @@
"groups": [
{
"group_name": "ASN1234",
+ "group_id": 1,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -20,6 +21,7 @@
},
{
"group_name": "ASN2345",
+ "group_id": 2,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -35,6 +37,7 @@
},
{
"group_name": "financial-department-ip",
+ "group_id": 3,
"regions": [
{
"table_name": "IP_CONFIG",
@@ -54,6 +57,7 @@
},
{
"group_name": "Country-Sparta-IP",
+ "group_id": 4,
"regions": [
{
"table_name": "GeoLocation",
@@ -69,6 +73,7 @@
},
{
"group_name": "IPv4-composition-source-only",
+ "group_id": 5,
"regions": [
{
"table_type": "ip_plus",
@@ -88,6 +93,7 @@
},
{
"group_name": "FQDN_OBJ1",
+ "group_id": 6,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -103,6 +109,7 @@
},
{
"group_name": "FQDN_CAT1",
+ "group_id": 7,
"regions": [
{
"table_name": "INTERGER_PLUS",
@@ -117,6 +124,7 @@
},
{
"group_name": "IPv4-composition-NOT-client-ip",
+ "group_id": 8,
"regions": [
{
"table_type": "ip_plus",
@@ -136,6 +144,7 @@
},
{
"group_name": "IPv4-composition-NOT-server-ip",
+ "group_id": 9,
"regions": [
{
"table_type": "ip_plus",
@@ -165,8 +174,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "123_IP_group",
"virtual_table": "IP_CONFIG",
+ "group_name": "123_IP_group",
+ "group_id": 10,
"regions": [
{
"table_name": "IP_CONFIG",
@@ -199,8 +209,9 @@
]
},
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "123_url_group",
+ "group_id": 11,
"regions": [
{
"table_name": "HTTP_URL",
@@ -226,12 +237,13 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "123_IP_group",
- "virtual_table":"IP_CONFIG"
+ "virtual_table":"IP_CONFIG",
+ "group_name": "123_IP_group"
},
{
- "group_name": "Untitled",
"virtual_table": "CONTENT_SIZE",
+ "group_name": "124_interval_group",
+ "group_id": 12,
"regions": [
{
"table_name": "CONTENT_SIZE",
@@ -256,6 +268,8 @@
"groups": [
{
"virtual_table":"HTTP_URL",
+ "group_name": "125_url_group",
+ "group_id": 13,
"regions": [
{
"table_name": "HTTP_URL",
@@ -281,8 +295,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "126_url_group",
+ "group_id": 14,
"regions": [
{
"table_name": "HTTP_URL",
@@ -297,8 +312,9 @@
]
},
{
- "group_name": "126_interval_group",
"virtual_table": "CONTENT_SIZE",
+ "group_name": "126_interval_group",
+ "group_id": 15,
"regions": [
{
"table_name": "CONTENT_SIZE",
@@ -322,8 +338,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_SIGNATURE",
+ "group_name": "128_expr_plus_group",
+ "group_id": 16,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -350,8 +367,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "129_url_group",
+ "group_id": 17,
"regions": [
{
"table_name": "HTTP_URL",
@@ -377,8 +395,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "130_keywords_group",
+ "group_id": 18,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -404,8 +423,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "131_keywords_group",
+ "group_id": 19,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -431,8 +451,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "TakeMeHome",
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "TakeMeHome",
+ "group_id": 20,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -458,8 +479,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_HOST",
+ "group_name": "133_host_group",
+ "group_id": 21,
"regions": [
{
"table_name": "HTTP_HOST",
@@ -485,8 +507,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "134_url_group",
+ "group_id": 22,
"regions": [
{
"table_name": "HTTP_URL",
@@ -512,8 +535,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "IMAGE_FP",
+ "group_name": "136_expr_group",
+ "group_id": 23,
"regions": [
{
"table_name": "IMAGE_FP",
@@ -539,8 +563,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "IMAGE_FP",
+ "group_name": "137_expr_group",
+ "group_id": 24,
"regions": [
{
"table_name": "IMAGE_FP",
@@ -569,6 +594,8 @@
"groups": [
{
"virtual_table": "HTTP_URL",
+ "group_name": "138_url_group",
+ "group_id": 25,
"regions": [
{
"table_name": "HTTP_URL",
@@ -597,6 +624,8 @@
"groups": [
{
"virtual_table": "HTTP_URL",
+ "group_name": "139_url_group",
+ "group_id": 26,
"regions": [
{
"table_name": "HTTP_URL",
@@ -622,8 +651,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "140_keywords_group",
+ "group_id": 27,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -650,9 +680,10 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"g2c_table_name": "GROUP2COMPILE_ALIAS",
"virtual_table": "HTTP_URL",
+ "group_name": "141_url_group",
+ "group_id": 28,
"regions": [
{
"table_name": "HTTP_URL",
@@ -679,6 +710,8 @@
"groups": [
{
"virtual_table": "HTTP_URL",
+ "group_name": "142_url_group",
+ "group_id": 29,
"regions": [
{
"table_name": "HTTP_URL",
@@ -705,6 +738,8 @@
"groups": [
{
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "143_url_group1",
+ "group_id": 30,
"not_flag": 0,
"regions": [
{
@@ -721,6 +756,8 @@
},
{
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "143_url_group2",
+ "group_id": 31,
"not_flag": 1,
"regions": [
{
@@ -748,6 +785,8 @@
"groups": [
{
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "144_url_group",
+ "group_id": 32,
"not_flag": 0,
"regions": [
{
@@ -764,6 +803,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
+ "group_name": "144_keywords_group",
+ "group_id": 33,
"not_flag": 1,
"regions": [
{
@@ -790,8 +831,10 @@
"is_valid": "yes",
"groups": [
{
- "not_flag": 0,
"virtual_table": "HTTP_URL",
+ "group_name": "145_url_group",
+ "group_id": 34,
+ "not_flag": 0,
"regions": [
{
"table_name": "HTTP_URL",
@@ -807,8 +850,8 @@
},
{
"virtual_table": "VIRTUAL_IP_CONFIG",
- "not_flag": 1,
- "group_name": "123_IP_group"
+ "group_name": "123_IP_group",
+ "not_flag": 1
}
]
},
@@ -823,6 +866,8 @@
"groups": [
{
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "146_url_group",
+ "group_id": 35,
"not_flag": 0,
"clause_index": 0,
"regions": [
@@ -840,6 +885,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
+ "group_name": "146_keywords_group",
+ "group_id": 36,
"not_flag": 1,
"clause_index": 1,
"regions": [
@@ -857,9 +904,9 @@
},
{
"virtual_table": "VIRTUAL_IP_CONFIG",
+ "group_name": "123_IP_group",
"not_flag": 1,
- "clause_index": 2,
- "group_name": "123_IP_group"
+ "clause_index": 2
}
]
},
@@ -874,6 +921,8 @@
"groups": [
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_1",
+ "group_name": "147_keywords_group1",
+ "group_id": 37,
"not_flag": 1,
"clause_index": 0,
"regions": [
@@ -891,6 +940,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_2",
+ "group_name": "147_keywords_group2",
+ "group_id": 38,
"not_flag": 1,
"clause_index": 1,
"regions": [
@@ -908,6 +959,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_3",
+ "group_name": "147_keywords_group3",
+ "group_id": 39,
"not_flag": 1,
"clause_index": 2,
"regions": [
@@ -925,6 +978,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_4",
+ "group_name": "147_keywords_group4",
+ "group_id": 40,
"not_flag": 1,
"clause_index": 3,
"regions": [
@@ -942,6 +997,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_5",
+ "group_name": "147_keywords_group5",
+ "group_id": 41,
"not_flag": 1,
"clause_index": 4,
"regions": [
@@ -959,6 +1016,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_6",
+ "group_name": "147_keywords_group6",
+ "group_id": 42,
"not_flag": 1,
"clause_index": 5,
"regions": [
@@ -976,6 +1035,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_7",
+ "group_name": "147_keywords_group7",
+ "group_id": 43,
"not_flag": 1,
"clause_index": 6,
"regions": [
@@ -993,6 +1054,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS_8",
+ "group_name": "147_keywords_group8",
+ "group_id": 44,
"not_flag": 1,
"clause_index": 7,
"regions": [
@@ -1021,6 +1084,8 @@
"groups": [
{
"virtual_table": "HTTP_URL",
+ "group_name": "148_url_group",
+ "group_id": 45,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1046,8 +1111,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "APP_PAYLOAD",
+ "group_name": "149_app_group",
+ "group_id": 46,
"regions": [
{
"table_name": "APP_PAYLOAD",
@@ -1075,6 +1141,8 @@
"groups": [
{
"virtual_table": "TROJAN_PAYLOAD",
+ "group_name": "billgates_regist1",
+ "group_id": 47,
"regions": [
{
"table_type": "expr",
@@ -1086,11 +1154,12 @@
"match_method": "sub"
}
}
- ],
- "group_name": "billgates_regist1"
+ ]
},
{
"virtual_table": "TROJAN_PAYLOAD",
+ "group_name": "billgates_regist2",
+ "group_id": 48,
"regions": [
{
"table_type": "expr",
@@ -1102,8 +1171,7 @@
"match_method": "sub"
}
}
- ],
- "group_name": "billgates_regist2"
+ ]
}
]
},
@@ -1118,6 +1186,8 @@
"groups": [
{
"virtual_table": "MAIL_ADDR",
+ "group_name": "151_expr_group",
+ "group_id": 49,
"regions": [
{
"table_type": "expr",
@@ -1129,8 +1199,7 @@
"match_method": "suffix"
}
}
- ],
- "group_name": "Untitled"
+ ]
}
]
},
@@ -1144,8 +1213,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "152_mail_addr",
"virtual_table": "MAIL_ADDR",
+ "group_name": "152_mail_addr",
+ "group_id": 50,
"regions": [
{
"table_type": "expr",
@@ -1170,8 +1240,9 @@
]
},
{
- "group_name": "interval_group_refered",
"virtual_table": "CONTENT_SIZE",
+ "group_name": "interval_group_refered",
+ "group_id": 51,
"sub_groups": [
{
"group_name": "126_interval_group"
@@ -1190,8 +1261,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "MAIL_ADDR",
+ "group_name": "153_expr_group",
+ "group_id": 52,
"not_flag": 0,
"regions": [
{
@@ -1207,14 +1279,15 @@
],
"sub_groups": [
{
- "group_name": "152_mail_addr",
- "virtual_table": "MAIL_ADDR"
+ "virtual_table": "MAIL_ADDR",
+ "group_name": "152_mail_addr"
}
]
},
{
- "group_name": "IP_group_refered",
"virtual_table": "IP_CONFIG",
+ "group_name": "IP_group_refered",
+ "group_id": 53,
"sub_groups": [
{
"group_name": "123_IP_group"
@@ -1234,6 +1307,8 @@
"groups": [
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "154_IP_group",
+ "group_id": 54,
"not_flag": 0,
"regions": [
{
@@ -1265,6 +1340,8 @@
"groups": [
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "155_IP_group",
+ "group_id": 55,
"regions": [
{
"table_type": "ip_plus",
@@ -1295,8 +1372,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_SIGNATURE",
+ "group_name": "156_expr_group",
+ "group_id": 56,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -1324,6 +1402,8 @@
"groups": [
{
"virtual_table": "TROJAN_PAYLOAD",
+ "group_name": "157_expr_group",
+ "group_id": 57,
"regions": [
{
"table_type": "expr",
@@ -1350,6 +1430,8 @@
"groups": [
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "158_IP_group",
+ "group_id": 58,
"regions": [
{
"table_type": "ip_plus",
@@ -1365,8 +1447,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1381,6 +1462,8 @@
"groups": [
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "159_IP_group",
+ "group_id": 59,
"regions": [
{
"table_type": "ip_plus",
@@ -1396,8 +1479,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1411,12 +1493,14 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "TakeMeHome",
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
+ "group_name": "TakeMeHome",
"not_flag": 0
},
{
"virtual_table": "HTTP_URL",
+ "group_name": "160_url_group",
+ "group_id": 60,
"not_flag": 0,
"regions": [
{
@@ -1443,8 +1527,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "vt_grp_http_sig1",
"virtual_table": "HTTP_SIGNATURE",
+ "group_name": "vt_grp_http_sig1",
+ "group_id": 61,
"not_flag": 0,
"regions": [
{
@@ -1461,8 +1546,9 @@
]
},
{
- "group_name": "vt_grp_http_sig2",
"virtual_table": "HTTP_SIGNATURE",
+ "group_name": "vt_grp_http_sig2",
+ "group_id": 62,
"not_flag": 0,
"regions": [
{
@@ -1501,13 +1587,13 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "vt_grp_http_sig1",
"virtual_table": "HTTP_REQUEST_HEADER",
+ "group_name": "vt_grp_http_sig1",
"not_flag": 0
},
{
- "group_name": "vt_grp_http_sig2",
"virtual_table": "HTTP_RESPONSE_HEADER",
+ "group_name": "vt_grp_http_sig2",
"not_flag": 0
}
]
@@ -1522,13 +1608,13 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "vt_grp_http_sig2",
"virtual_table": "HTTP_REQUEST_HEADER",
+ "group_name": "vt_grp_http_sig2",
"not_flag": 0
},
{
- "group_name": "vt_grp_http_sig2",
"virtual_table": "HTTP_RESPONSE_HEADER",
+ "group_name": "vt_grp_http_sig2",
"not_flag": 0
}
]
@@ -1543,8 +1629,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "164_keywords_group",
+ "group_id": 63,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -1571,8 +1658,9 @@
"evaluation_order": "2.111",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "165_url_group",
+ "group_id": 64,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1588,6 +1676,9 @@
},
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "165_IP_group",
+ "group_id": 65,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -1603,8 +1694,7 @@
"protocol": -1
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1619,8 +1709,9 @@
"evaluation_order": "100.233",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "166_url_group",
+ "group_id": 66,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1647,8 +1738,9 @@
"evaluation_order": "300.999",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "167_url_group",
+ "group_id": 67,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1675,8 +1767,9 @@
"evaluation_order": "0",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "168_url_group",
+ "group_id": 68,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1703,6 +1796,9 @@
"groups": [
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "169_IP_group",
+ "group_id": 69,
+ "not_flag" : 0,
"regions": [
{
"table_type": "ip_plus",
@@ -1718,8 +1814,7 @@
"protocol": 6
}
}
- ],
- "not_flag" : 0
+ ]
}
]
},
@@ -1733,8 +1828,10 @@
"is_valid": "no",
"groups": [
{
- "group_name": "ipv4_virtual.source",
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "ipv4_virtual.source",
+ "group_id": 70,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -1750,8 +1847,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1765,8 +1861,10 @@
"is_valid": "no",
"groups": [
{
- "group_name": "ipv4_virtual.destination",
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "ipv4_virtual.destination",
+ "group_id": 71,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -1782,8 +1880,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1797,13 +1894,13 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "ipv4_virtual.source",
"virtual_table": "VIRTUAL_IP_PLUS_SOURCE",
+ "group_name": "ipv4_virtual.source",
"not_flag": 0
},
{
- "group_name": "ipv4_virtual.destination",
"virtual_table": "VIRTUAL_IP_PLUS_DESTINATION",
+ "group_name": "ipv4_virtual.destination",
"not_flag": 0
}
]
@@ -1818,8 +1915,10 @@
"is_valid": "no",
"groups": [
{
- "group_name": "ipv4_composition.source",
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "ipv4_composition.source",
+ "group_id": 72,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -1835,8 +1934,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1850,8 +1948,10 @@
"is_valid": "no",
"groups": [
{
- "group_name": "ipv4_composition.destination",
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "ipv4_composition.destination",
+ "group_id": 73,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -1867,8 +1967,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1882,8 +1981,10 @@
"is_valid": "no",
"groups": [
{
- "group_name": "ipv4_composition.session",
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "ipv4_composition.session",
+ "group_id": 74,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -1899,8 +2000,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -1914,26 +2014,26 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "ASN1234",
"virtual_table": "SOURCE_IP_ASN",
+ "group_name": "ASN1234",
"not_flag": 0,
"clause_index": 0
},
{
- "group_name": "financial-department-ip",
"virtual_table": "IP_CONFIG",
+ "group_name": "financial-department-ip",
"not_flag": 0,
"clause_index": 0
},
{
- "group_name": "Country-Sparta-IP",
"virtual_table": "SOURCE_IP_GEO",
+ "group_name": "Country-Sparta-IP",
"not_flag": 0,
"clause_index": 0
},
{
- "group_name": "ASN2345",
"virtual_table": "DESTINATION_IP_ASN",
+ "group_name": "ASN2345",
"not_flag": 0,
"clause_index": 1
}
@@ -1949,8 +2049,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "INTERGER_PLUS",
+ "group_name": "179_interval_group",
+ "group_id": 75,
"regions": [
{
"table_name": "INTERGER_PLUS",
@@ -1976,6 +2077,8 @@
"groups": [
{
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "182_keywords_group",
+ "group_id": 76,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -2001,8 +2104,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "CORNER_CASE_TABLE",
+ "group_name": "183_expr_group",
+ "group_id": 77,
"regions": [
{
"table_name": "CORNER_CASE_TABLE",
@@ -2029,8 +2133,9 @@
"service": 0,
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "IP_CONFIG",
+ "group_name": "184_IP_group",
+ "group_id": 78,
"regions": [
{
"table_name": "IP_CONFIG",
@@ -2061,6 +2166,8 @@
"groups": [
{
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "186_expr_group",
+ "group_id": 79,
"not_flag": 1,
"regions": [
{
@@ -2076,8 +2183,10 @@
]
},
{
- "not_flag": 0,
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "186_IP_group",
+ "group_id": 80,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -2108,6 +2217,8 @@
"groups": [
{
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "187_url_group",
+ "group_id": 81,
"not_flag": 1,
"regions": [
{
@@ -2124,6 +2235,8 @@
},
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "187_IP_group",
+ "group_id": 82,
"not_flag": 0,
"regions": [
{
@@ -2155,6 +2268,8 @@
"groups": [
{
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "188_url_group",
+ "group_id": 83,
"not_flag": 1,
"regions": [
{
@@ -2171,6 +2286,8 @@
},
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "188_IP_group",
+ "group_id": 84,
"not_flag": 0,
"regions": [
{
@@ -2202,6 +2319,8 @@
"groups": [
{
"virtual_table": "APP_PAYLOAD",
+ "group_name": "189_app_group",
+ "group_id": 85,
"regions": [
{
"table_name": "APP_PAYLOAD",
@@ -2214,8 +2333,7 @@
},
"table_type": "expr_plus"
}
- ],
- "group_name": "Untitled"
+ ]
}
]
},
@@ -2229,8 +2347,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_SIGNATURE",
+ "group_name": "190_expr_group",
+ "group_id": 86,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -2258,6 +2377,8 @@
"groups": [
{
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "191_keywords_group",
+ "group_id": 87,
"regions": [
{
"table_type": "expr",
@@ -2269,8 +2390,7 @@
"match_method": "sub"
}
}
- ],
- "group_name": "Untitled"
+ ]
}
]
},
@@ -2285,6 +2405,8 @@
"groups": [
{
"virtual_table": "FLAG_CONFIG",
+ "group_name": "192_flag_group",
+ "group_id": 88,
"regions": [
{
"table_type": "flag",
@@ -2309,6 +2431,8 @@
"groups": [
{
"virtual_table": "FLAG_CONFIG",
+ "group_name": "193_flag_group",
+ "group_id": 89,
"regions": [
{
"table_type": "flag",
@@ -2322,6 +2446,8 @@
},
{
"virtual_table": "HTTP_URL",
+ "group_name": "193_url_group",
+ "group_id": 90,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2348,6 +2474,8 @@
"groups": [
{
"virtual_table": "FLAG_CONFIG",
+ "group_name": "194_flag_group",
+ "group_id": 91,
"regions": [
{
"table_type": "flag",
@@ -2372,6 +2500,8 @@
"groups": [
{
"virtual_table": "HTTP_SIGNATURE",
+ "group_name": "195_signature_group",
+ "group_id": 92,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -2388,6 +2518,8 @@
},
{
"virtual_table": "HTTP_URL",
+ "group_name": "195_url_group",
+ "group_id": 93,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2413,7 +2545,9 @@
"is_valid": "yes",
"groups": [
{
- "virtual_table": "FLAG_PLUS_CONFIG",
+ "virtual_table": "FLAG_PLUS_CONFIG",
+ "group_name": "196_flag_group",
+ "group_id": 94,
"regions": [
{
"table_type": "flag_plus",
@@ -2438,8 +2572,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "HTTP_URL",
+ "group_name": "197_url_group",
+ "group_id": 95,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2466,9 +2601,10 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
- "virtual_table": "HTTP_URL",
"g2c_table_name": "GROUP2COMPILE_FIREWALL",
+ "virtual_table": "HTTP_URL",
+ "group_name": "198_url_group",
+ "group_id": 96,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2494,11 +2630,13 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "ExcludeLogicGroup199",
"virtual_table": "HTTP_URL",
+ "group_name": "ExcludeLogicGroup199",
+ "group_id": 97,
"sub_groups":[
{
"group_name": "ExcludeLogicGroup199_1",
+ "group_id": 98,
"is_exclude": 0,
"clause_index": 0,
"regions": [
@@ -2516,6 +2654,7 @@
},
{
"group_name": "ExcludeLogicGroup199_2",
+ "group_id": 99,
"is_exclude": 1,
"clause_index": 0,
"regions": [
@@ -2545,12 +2684,14 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "ExcludeLogicGroup200",
"virtual_table": "HTTP_URL",
+ "group_name": "ExcludeLogicGroup200",
+ "group_id": 100,
"sub_groups":[
{
- "group_name": "ExcludeLogicGroup200_1",
"virtual_table": "HTTP_URL",
+ "group_name": "ExcludeLogicGroup200_1",
+ "group_id": 101,
"is_exclude": 0,
"clause_index": 0,
"regions": [
@@ -2567,8 +2708,9 @@
]
},
{
- "group_name": "ExcludeLogicGroup200_2",
"virtual_table": "HTTP_URL",
+ "group_name": "ExcludeLogicGroup200_2",
+ "group_id": 102,
"is_exclude": 1,
"clause_index": 0,
"regions": [
@@ -2598,12 +2740,14 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "ExcludeLogicGroup202",
"virtual_table": "VIRTUAL_IP_PLUS_TABLE",
+ "group_name": "ExcludeLogicGroup202",
+ "group_id": 103,
"clause_index": 0,
"sub_groups":[
{
"group_name": "ExcludeLogicGroup202_1",
+ "group_id": 104,
"is_exclude": 0,
"regions": [
{
@@ -2624,6 +2768,7 @@
},
{
"group_name": "ExcludeLogicGroup202_2",
+ "group_id": 105,
"is_exclude": 1,
"regions": [
{
@@ -2644,6 +2789,7 @@
},
{
"group_name": "ExcludeLogicGroup202_3",
+ "group_id": 106,
"is_exclude": 1,
"regions": [
{
@@ -2676,8 +2822,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "ExcludeLogicGroup203_1",
"virtual_table": "VIRTUAL_IP_PLUS_SOURCE",
+ "group_name": "ExcludeLogicGroup203_1",
+ "group_id": 107,
"clause_index": 0,
"regions": [
{
@@ -2699,8 +2846,9 @@
]
},
{
- "group_name": "ExcludeLogicGroup203_2",
"virtual_table": "VIRTUAL_IP_PLUS_DESTINATION",
+ "group_name": "ExcludeLogicGroup203_2",
+ "group_id": 108,
"clause_index": 1,
"regions": [
{
@@ -2721,12 +2869,14 @@
]
},
{
- "group_name": "ExcludeLogicGroup203_3",
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
+ "group_name": "ExcludeLogicGroup203_3",
+ "group_id": 109,
"clause_index": 2,
"sub_groups": [
{
"group_name": "ExcludeLogicGroup203_3_1",
+ "group_id": 110,
"is_exclude": 0,
"regions": [
{
@@ -2743,6 +2893,7 @@
},
{
"group_name": "ExcludeLogicGroup203_3_2",
+ "group_id": 111,
"is_exclude": 1,
"regions": [
{
@@ -2771,8 +2922,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "ExcludeLogicGroup204_1",
"virtual_table": "VIRTUAL_IP_PLUS_SOURCE",
+ "group_name": "ExcludeLogicGroup204_1",
+ "group_id": 112,
"clause_index": 0,
"regions": [
{
@@ -2794,8 +2946,9 @@
]
},
{
- "group_name": "ExcludeLogicGroup204_2",
"virtual_table": "VIRTUAL_IP_PLUS_DESTINATION",
+ "group_name": "ExcludeLogicGroup204_2",
+ "group_id": 113,
"clause_index": 1,
"regions": [
{
@@ -2816,16 +2969,19 @@
]
},
{
- "group_name": "ExcludeLogicGroup204_3",
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
+ "group_name": "ExcludeLogicGroup204_3",
+ "group_id": 114,
"clause_index": 2,
"sub_groups": [
{
"group_name": "ExcludeLogicGroup204_3_1",
+ "group_id": 115,
"is_exclude": 0,
"sub_groups" : [
{
"group_name": "ExcludeLogicGroup204_3_1_1",
+ "group_id": 116,
"is_exclude": 0,
"regions": [
{
@@ -2842,6 +2998,7 @@
},
{
"group_name": "ExcludeLogicGroup204_3_1_2",
+ "group_id": 117,
"is_exclude": 1,
"regions": [
{
@@ -2860,6 +3017,7 @@
},
{
"group_name": "ExcludeLogicGroup204_3_2",
+ "group_id": 118,
"is_exclude": 1,
"regions": [
{
@@ -2889,6 +3047,8 @@
"groups": [
{
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "205_keywords_group",
+ "group_id": 119,
"regions": [
{
"table_type": "expr",
@@ -2900,8 +3060,7 @@
"match_method": "sub"
}
}
- ],
- "group_name": "Untitled"
+ ]
}
]
},
@@ -2916,6 +3075,8 @@
"groups": [
{
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "206_keywords_group",
+ "group_id": 120,
"regions": [
{
"table_type": "expr",
@@ -2927,8 +3088,7 @@
"match_method": "sub"
}
}
- ],
- "group_name": "Untitled"
+ ]
}
]
},
@@ -2943,6 +3103,8 @@
"groups": [
{
"virtual_table": "FLAG_CONFIG",
+ "group_name": "207_flag_group",
+ "group_id": 121,
"regions": [
{
"table_type": "flag",
@@ -2967,6 +3129,9 @@
"groups": [
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "208_IP_group",
+ "group_id": 122,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -2982,8 +3147,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -2997,8 +3161,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "INTERGER_PLUS",
+ "group_name": "209_interval_group",
+ "group_id": 123,
"regions": [
{
"table_name": "INTERGER_PLUS",
@@ -3024,6 +3189,8 @@
"groups": [
{
"virtual_table": "IP_PLUS_CONFIG",
+ "group_name": "210_IP_group",
+ "group_id": 124,
"regions": [
{
"table_type": "ip_plus",
@@ -3039,8 +3206,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -3055,6 +3221,9 @@
"groups": [
{
"virtual_table": "IP_PERF_CONFIG",
+ "group_name": "211_IP_group",
+ "group_id": 125,
+ "not_flag": 0,
"regions": [
{
"table_type": "ip_plus",
@@ -3070,8 +3239,7 @@
"protocol": 6
}
}
- ],
- "not_flag": 0
+ ]
}
]
},
@@ -3085,8 +3253,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "INTEGER_PERF_CONFIG",
+ "group_name": "212_interval_group",
+ "group_id": 126,
"regions": [
{
"table_name": "INTEGER_PERF_CONFIG",
@@ -3111,6 +3280,8 @@
"groups": [
{
"virtual_table": "EXPR_LITERAL_PERF_CONFIG",
+ "group_name": "213_expr_group",
+ "group_id": 127,
"regions": [
{
"table_name": "EXPR_LITERAL_PERF_CONFIG",
@@ -3137,6 +3308,8 @@
"groups": [
{
"virtual_table": "FLAG_PERF_CONFIG",
+ "group_name": "214_flag_group",
+ "group_id": 128,
"regions": [
{
"table_type": "flag",
@@ -3161,6 +3334,8 @@
"groups": [
{
"virtual_table": "EXPR_REGEX_PERF_CONFIG",
+ "group_name": "215_expr_group",
+ "group_id": 129,
"regions": [
{
"table_name": "EXPR_REGEX_PERF_CONFIG",
@@ -3193,7 +3368,8 @@
},
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "NOTClauseAndExcludeGroup211",
+ "group_name": "NOTClauseAndExcludeGroup216",
+ "group_id": 130,
"not_flag": 1,
"clause_index": 1,
"regions": [
@@ -3223,11 +3399,13 @@
{
"virtual_table": "HTTP_URL_FILTER",
"group_name": "NOTClauseAndExcludeGroup217_1",
+ "group_id": 131,
"not_flag": 1,
"clause_index": 0,
"sub_groups": [
{
"group_name": "ExcludeLogicGroup217_1_1",
+ "group_id": 132,
"is_exclude": 0,
"regions": [
{
@@ -3244,6 +3422,7 @@
},
{
"group_name": "ExcludeLogicGroup217_1_2",
+ "group_id": 133,
"is_exclude": 1,
"regions": [
{
@@ -3263,6 +3442,7 @@
{
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
"group_name": "NOTClauseAndExcludeGroup217_2",
+ "group_id": 134,
"not_flag": 0,
"clause_index": 1,
"regions": [
@@ -3290,8 +3470,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "Untitled",
"virtual_table": "CONTENT_SIZE",
+ "group_name": "218_interval_group",
+ "group_id": 135,
"regions": [
{
"table_name": "CONTENT_SIZE",
@@ -3317,6 +3498,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_1",
+ "group_id": 136,
"not_flag": 0,
"clause_index": 0,
"regions": [
@@ -3335,6 +3517,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_2",
+ "group_id": 137,
"not_flag": 1,
"clause_index": 1,
"regions": [
@@ -3353,6 +3536,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_3",
+ "group_id": 138,
"not_flag": 1,
"clause_index": 2,
"regions": [
@@ -3371,6 +3555,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_4",
+ "group_id": 139,
"not_flag": 1,
"clause_index": 3,
"regions": [
@@ -3389,6 +3574,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_5",
+ "group_id": 140,
"not_flag": 1,
"clause_index": 4,
"regions": [
@@ -3407,6 +3593,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_6",
+ "group_id": 141,
"not_flag": 1,
"clause_index": 5,
"regions": [
@@ -3425,6 +3612,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_7",
+ "group_id": 142,
"not_flag": 1,
"clause_index": 6,
"regions": [
@@ -3443,6 +3631,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup219_8",
+ "group_id": 143,
"not_flag": 1,
"clause_index": 7,
"regions": [
@@ -3472,6 +3661,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup220_1",
+ "group_id": 144,
"not_flag": 0,
"clause_index": 0,
"regions": [
@@ -3490,6 +3680,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup220_2",
+ "group_id": 145,
"not_flag": 1,
"clause_index": 1,
"regions": [
@@ -3508,6 +3699,7 @@
{
"virtual_table": "HTTP_DUMMY",
"group_name": "NOTClauseAndExcludeGroup220_3",
+ "group_id": 146,
"not_flag": 1,
"clause_index": 2,
"regions": [
@@ -3535,8 +3727,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "NOTLogicGroup_221_1",
"virtual_table": "HTTP_REQUEST_HEADER",
+ "group_name": "NOTLogicGroup_221_1",
+ "group_id": 147,
"not_flag": 1,
"regions": [
{
@@ -3553,8 +3746,9 @@
]
},
{
- "group_name": "NOTLogicGroup_221_2",
"virtual_table": "HTTP_URL",
+ "group_name": "NOTLogicGroup_221_2",
+ "group_id": 148,
"not_flag": 0,
"regions": [
{
@@ -3581,8 +3775,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "NOTLogicGroup_222_1",
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "NOTLogicGroup_222_1",
+ "group_id": 149,
"clause_index": 0,
"not_flag": 1,
"regions": [
@@ -3599,8 +3794,9 @@
]
},
{
- "group_name": "NOTLogicGroup_222_2",
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "NOTLogicGroup_222_2",
+ "group_id": 150,
"clause_index": 0,
"not_flag": 1,
"regions": [
@@ -3617,8 +3813,9 @@
]
},
{
- "group_name": "NOTLogicGroup_222_3",
"virtual_table": "HTTP_URL_FILTER",
+ "group_name": "NOTLogicGroup_222_3",
+ "group_id": 151,
"clause_index": 1,
"not_flag": 0,
"regions": [
@@ -3646,8 +3843,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "NOTLogicGroup_223_1",
"virtual_table": "HTTP_NOT_LOGIC",
+ "group_name": "NOTLogicGroup_223_1",
+ "group_id": 152,
"not_flag": 1,
"clause_index": 0,
"regions": [
@@ -3664,8 +3862,9 @@
]
},
{
- "group_name": "NOTLogicGroup_223_2",
"virtual_table": "HTTP_NOT_LOGIC",
+ "group_name": "NOTLogicGroup_223_2",
+ "group_id": 153,
"not_flag": 1,
"clause_index": 1,
"regions": [
@@ -3682,8 +3881,9 @@
]
},
{
- "group_name": "NOTLogicGroup_223_1",
"virtual_table": "HTTP_NOT_LOGIC",
+ "group_name": "NOTLogicGroup_223_1",
+ "group_id": 154,
"not_flag": 1,
"clause_index": 2,
"regions": [
@@ -3711,8 +3911,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "NOTLogicGroup_224_1",
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "NOTLogicGroup_224_1",
+ "group_id": 155,
"not_flag": 1,
"clause_index": 0,
"regions": [
@@ -3729,8 +3930,9 @@
]
},
{
- "group_name": "NOTLogicGroup_224_2",
"virtual_table": "HTTP_RESPONSE_KEYWORDS",
+ "group_name": "NOTLogicGroup_224_2",
+ "group_id": 156,
"not_flag": 0,
"clause_index": 1,
"regions": [
@@ -3758,8 +3960,9 @@
"is_valid": "yes",
"groups": [
{
- "group_name": "EscapeGroup_225_1",
"virtual_table": "KEYWORDS_TABLE",
+ "group_name": "EscapeGroup_225_1",
+ "group_id": 157,
"not_flag": 0,
"clause_index": 0,
"regions": [
@@ -3776,6 +3979,40 @@
]
}
]
+ },
+ {
+ "compile_id": 226,
+ "service": 1,
+ "action": 1,
+ "do_blacklist": 1,
+ "do_log": 1,
+ "user_region": "maat_scan_group",
+ "is_valid": "yes",
+ "groups": [
+ {
+ "virtual_table": "KEYWORDS_TABLE",
+ "group_name": "226_url_group",
+ "group_id": 158
+ }
+ ]
+ },
+ {
+ "compile_id": 227,
+ "service": 1,
+ "action": 1,
+ "do_blacklist": 1,
+ "do_log": 1,
+ "user_region": "maat_scan_group",
+ "compile_table_name": "COMPILE_FIREWALL_DEFAULT",
+ "is_valid": "yes",
+ "groups": [
+ {
+ "virtual_table": "KEYWORDS_TABLE",
+ "group_name": "227_url_group",
+ "group_id": 159,
+ "g2c_table_name": "GROUP2COMPILE_FIREWALL"
+ }
+ ]
}
],
"plugin_table": [
diff --git a/tools/maat_redis_tool.cpp b/tools/maat_redis_tool.cpp
index 15a2bdf..b63245f 100644
--- a/tools/maat_redis_tool.cpp
+++ b/tools/maat_redis_tool.cpp
@@ -293,7 +293,7 @@ int rollback_redis_version(redisContext *c, struct log_handle *logger)
{
redisReply *reply = maat_wrap_redis_command(c, "SET MAAT_VERSION 0");
if (NULL == reply) {
- log_error(logger, MODULE_REDIS_TOOL,
+ log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] set MAAT_VERSION failed, Redis Communication error: %s",
__FUNCTION__, __LINE__, c->errstr);
return -1;
@@ -310,7 +310,7 @@ int clear_config_in_redis(redisContext *c, struct log_handle *logger)
redisReply *reply = maat_wrap_redis_command(c, "GET MAAT_VERSION");
if (reply != NULL) {
if (reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) {
- log_error(logger, MODULE_REDIS_TOOL,
+ log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] GET MAAT_VERSION failed, maybe Redis is busy",
__FUNCTION__, __LINE__);
freeReplyObject(reply);
@@ -318,7 +318,7 @@ int clear_config_in_redis(redisContext *c, struct log_handle *logger)
return -1;
}
} else {
- log_error(logger, MODULE_REDIS_TOOL,
+ log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] GET MAAT_VERSION failed with NULL reply, error: %s",
__FUNCTION__, __LINE__, c->errstr);
return -1;
@@ -327,7 +327,7 @@ int clear_config_in_redis(redisContext *c, struct log_handle *logger)
redis_version = maat_read_redis_integer(reply);
if (redis_version < 0) {
if (reply->type == REDIS_REPLY_ERROR) {
- log_error(logger, MODULE_REDIS_TOOL,
+ log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] Redis Communication error: %s",
__FUNCTION__, __LINE__, reply->str);
}
@@ -449,27 +449,27 @@ int main(int argc, char * argv[])
size_t json_buff_sz = 0;
int ret = load_file_to_memory(json_file, (unsigned char**)&json_buff, &json_buff_sz);
if (ret < 0) {
- log_error(logger, MODULE_REDIS_TOOL, "open file:%s failed.", json_file);
+ log_fatal(logger, MODULE_REDIS_TOOL, "open file:%s failed.", json_file);
return -1;
}
ret = json2iris(json_buff, json_file, c, tmp_iris_path, sizeof(tmp_iris_path), NULL, NULL, logger);
FREE(json_buff);
if (ret < 0) {
- log_error(logger, MODULE_REDIS_TOOL, "Invalid json format.");
+ log_fatal(logger, MODULE_REDIS_TOOL, "Invalid json format.");
return -1;
}
size_t total_line_cnt = 0;
config_monitor_traverse(0, tmp_iris_path, NULL, count_line_num_cb, NULL, &total_line_cnt, NULL, logger);
- log_error(logger, MODULE_REDIS_TOOL, "Serialize %s to %zu lines, write temp file to %s .",
+ log_fatal(logger, MODULE_REDIS_TOOL, "Serialize %s to %zu lines, write temp file to %s .",
json_file, total_line_cnt, tmp_iris_path);
struct serial_rule *s_rule = ALLOC(struct serial_rule, total_line_cnt);
s_rule->ref_ctx = c;
long long server_time = maat_redis_server_time_s(c);
if (!server_time) {
- log_error(logger, MODULE_REDIS_TOOL, "Get Redis Time failed.");
+ log_fatal(logger, MODULE_REDIS_TOOL, "Get Redis Time failed.");
FREE(s_rule);
return -1;
}
@@ -487,7 +487,7 @@ int main(int argc, char * argv[])
} while(success_cnt < 0);
if (success_cnt != (int)total_line_cnt) {
- log_error(logger, MODULE_REDIS_TOOL, "Only Add %d of %zu, rule id maybe conflicts.",
+ log_fatal(logger, MODULE_REDIS_TOOL, "Only Add %d of %zu, rule id maybe conflicts.",
success_cnt, total_line_cnt);
}
@@ -499,19 +499,19 @@ int main(int argc, char * argv[])
} else if (mode == WORK_MODE_UPLOAD) {
int ret = clear_config_in_redis(c, logger);
if (ret < 0) {
- log_error(logger, MODULE_REDIS_TOOL, "clear config in redis failed.");
+ log_fatal(logger, MODULE_REDIS_TOOL, "clear config in redis failed.");
return -1;
}
ret = write_config_to_redis(c, upload_file, logger);
if (ret < 0) {
- log_error(logger, MODULE_REDIS_TOOL, "write config to redis failed.");
+ log_fatal(logger, MODULE_REDIS_TOOL, "write config to redis failed.");
return -1;
}
ret = rollback_redis_version(c, logger);
if (ret < 0) {
- log_error(logger, MODULE_REDIS_TOOL, "rollback redis version failed.");
+ log_fatal(logger, MODULE_REDIS_TOOL, "rollback redis version failed.");
return -1;
}
redisFree(c);