增加配置更新的测试用例。
This commit is contained in:
@@ -60,6 +60,32 @@ int hex2bin(char *hex,int hex_len,char *binary,int size)
|
|||||||
binary[resultlen]='\0';
|
binary[resultlen]='\0';
|
||||||
return resultlen;
|
return resultlen;
|
||||||
}
|
}
|
||||||
|
int is_valid_expr_type(enum MAAT_EXPR_TYPE expr_type)
|
||||||
|
{
|
||||||
|
switch(expr_type)
|
||||||
|
{
|
||||||
|
case EXPR_TYPE_STRING:
|
||||||
|
case EXPR_TYPE_AND:
|
||||||
|
case EXPR_TYPE_REGEX:
|
||||||
|
case EXPR_TYPE_OFFSET:
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int is_valid_match_method(enum MAAT_MATCH_METHOD match_method)
|
||||||
|
{
|
||||||
|
switch(match_method)
|
||||||
|
{
|
||||||
|
case MATCH_METHOD_SUB:
|
||||||
|
case MATCH_METHOD_RIGHT:
|
||||||
|
case MATCH_METHOD_LEFT:
|
||||||
|
case MATCH_METHOD_FULL:
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
iconv_t maat_iconv_open(struct _Maat_scanner_t* scanner,enum MAAT_CHARSET to,enum MAAT_CHARSET from)
|
iconv_t maat_iconv_open(struct _Maat_scanner_t* scanner,enum MAAT_CHARSET to,enum MAAT_CHARSET from)
|
||||||
{
|
{
|
||||||
const char *from_s=CHARSET_STRING[from];
|
const char *from_s=CHARSET_STRING[from];
|
||||||
@@ -1959,7 +1985,6 @@ void compatible_group_udpate(struct _Maat_table_info_t* table,int region_id,int
|
|||||||
update_group_rule(table, virtual_group_line,scanner,logger);
|
update_group_rule(table, virtual_group_line,scanner,logger);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_expr_rule(struct _Maat_table_info_t* table,const char* table_line,struct _Maat_scanner_t *scanner,void* logger,int group_mode_on)
|
void update_expr_rule(struct _Maat_table_info_t* table,const char* table_line,struct _Maat_scanner_t *scanner,void* logger,int group_mode_on)
|
||||||
{
|
{
|
||||||
struct db_str_rule_t* maat_str_rule=(struct db_str_rule_t*)malloc(sizeof(struct db_str_rule_t));
|
struct db_str_rule_t* maat_str_rule=(struct db_str_rule_t*)malloc(sizeof(struct db_str_rule_t));
|
||||||
@@ -2029,7 +2054,7 @@ void update_expr_rule(struct _Maat_table_info_t* table,const char* table_line,st
|
|||||||
table->udpate_err_cnt++;
|
table->udpate_err_cnt++;
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
if(maat_str_rule->match_method<MATCH_METHOD_SUB||maat_str_rule->match_method>MATCH_METHOD_FULL)
|
if(!is_valid_match_method(maat_str_rule->match_method))
|
||||||
{
|
{
|
||||||
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
||||||
"abandon config %d:update error,invalid match method=%d in expr table %s:%s"
|
"abandon config %d:update error,invalid match method=%d in expr table %s:%s"
|
||||||
@@ -2039,7 +2064,7 @@ void update_expr_rule(struct _Maat_table_info_t* table,const char* table_line,st
|
|||||||
table->udpate_err_cnt++;
|
table->udpate_err_cnt++;
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
if(maat_str_rule->expr_type<EXPR_TYPE_STRING||maat_str_rule->match_method>EXPR_TYPE_OFFSET)
|
if(!is_valid_expr_type(maat_str_rule->expr_type))
|
||||||
{
|
{
|
||||||
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
||||||
"abandon config %d:update error,invalid expr type=%d in expr table %s:%s"
|
"abandon config %d:update error,invalid expr type=%d in expr table %s:%s"
|
||||||
@@ -2682,7 +2707,7 @@ void maat_start_cb(unsigned int new_version,int update_type,void*u_para)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p_table->cfg_num=0;
|
p_table->cfg_num=0;
|
||||||
p_table->expr_rule_cn=0;
|
p_table->expr_rule_cnt=0;
|
||||||
p_table->regex_rule_cnt=0;
|
p_table->regex_rule_cnt=0;
|
||||||
if(p_table->table_type==TABLE_TYPE_PLUGIN)
|
if(p_table->table_type==TABLE_TYPE_PLUGIN)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -462,16 +462,26 @@ int main(int argc,char* argv[])
|
|||||||
int g_iThreadNum=4;
|
int g_iThreadNum=4;
|
||||||
const char* table_info_path="./table_info.conf";
|
const char* table_info_path="./table_info.conf";
|
||||||
const char* json_path="./maat_json.json";
|
const char* json_path="./maat_json.json";
|
||||||
// const char* ful_cfg_dir="./maat_json.json_iris_tmp/index";
|
const char* ful_cfg_dir="./rule/full/index";
|
||||||
// const char* inc_cfg_dir="./rules/inc/index";
|
const char* inc_cfg_dir="./rule/inc/index";
|
||||||
const char* log_file="./test.log";
|
const char* log_file="./test.log";
|
||||||
const char* stat_file="./scan_staus.log";
|
const char* stat_file="./scan_staus.log";
|
||||||
int scan_detail=0;
|
int scan_detail=0;
|
||||||
scan_status_t mid=NULL;
|
scan_status_t mid=NULL;
|
||||||
|
int wait_second=4;
|
||||||
void *logger=MESA_create_runtime_log_handle(log_file,0);
|
void *logger=MESA_create_runtime_log_handle(log_file,0);
|
||||||
|
|
||||||
feather=Maat_feather(g_iThreadNum, table_info_path, logger);
|
feather=Maat_feather(g_iThreadNum, table_info_path, logger);
|
||||||
Maat_set_feather_opt(feather, MAAT_OPT_JSON_FILE_PATH, json_path, strlen(json_path)+1);
|
if(argc>1&&0==strcmp(argv[1],"update"))
|
||||||
|
{
|
||||||
|
Maat_set_feather_opt(feather, MAAT_OPT_FULL_CFG_DIR, ful_cfg_dir, strlen(ful_cfg_dir)+1);
|
||||||
|
Maat_set_feather_opt(feather, MAAT_OPT_INC_CFG_DIR, inc_cfg_dir, strlen(inc_cfg_dir)+1);
|
||||||
|
wait_second=14;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Maat_set_feather_opt(feather, MAAT_OPT_JSON_FILE_PATH, json_path, strlen(json_path)+1);
|
||||||
|
}
|
||||||
Maat_set_feather_opt(feather, MAAT_OPT_STAT_FILE_PATH, stat_file, strlen(stat_file)+1);
|
Maat_set_feather_opt(feather, MAAT_OPT_STAT_FILE_PATH, stat_file, strlen(stat_file)+1);
|
||||||
Maat_set_feather_opt(feather, MAAT_OPT_STAT_ON, NULL, 0);
|
Maat_set_feather_opt(feather, MAAT_OPT_STAT_ON, NULL, 0);
|
||||||
Maat_set_feather_opt(feather, MAAT_OPT_PERF_ON, NULL, 0);
|
Maat_set_feather_opt(feather, MAAT_OPT_PERF_ON, NULL, 0);
|
||||||
@@ -519,7 +529,7 @@ int main(int argc,char* argv[])
|
|||||||
test_table_conjunction(feather, "HTTP_URL", "HTTP_HOST", &mid);
|
test_table_conjunction(feather, "HTTP_URL", "HTTP_HOST", &mid);
|
||||||
Maat_clean_status(&mid);
|
Maat_clean_status(&mid);
|
||||||
|
|
||||||
sleep(4);
|
sleep(wait_second);
|
||||||
|
|
||||||
Maat_burn_feather(feather);
|
Maat_burn_feather(feather);
|
||||||
|
|
||||||
|
|||||||
13
test/rule/full/COMPILE.local
Normal file
13
test/rule/full/COMPILE.local
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
0000000012
|
||||||
|
123 1 1 1 1 0 anything 1
|
||||||
|
124 1 1 1 1 0 anything 1
|
||||||
|
125 1 1 1 1 0 anything 1
|
||||||
|
126 1 1 1 1 0 anything 1
|
||||||
|
127 1 1 1 1 0 anything 1
|
||||||
|
128 1 1 1 1 0 anything 1
|
||||||
|
129 1 1 1 1 0 utf8_中文 1
|
||||||
|
130 1 1 1 1 0 utf8_维语 1
|
||||||
|
131 1 1 1 1 0 utf8_维语2 1
|
||||||
|
132 1 1 1 1 0 string\bunescape 1
|
||||||
|
133 1 1 1 1 0 table_conjunction_test_part1 1
|
||||||
|
134 1 1 1 1 0 table_conjunction_test_part2 1
|
||||||
3
test/rule/full/CONTENT_SIZE.local
Normal file
3
test/rule/full/CONTENT_SIZE.local
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
0000000002
|
||||||
|
3 2 100 500 1
|
||||||
|
6 5 2014 2016 1
|
||||||
2
test/rule/full/FILE_DIGEST.local
Normal file
2
test/rule/full/FILE_DIGEST.local
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0000000001
|
||||||
|
7 6 1160164 12288:UChtbFS6pypdTy4m2[0:1160163] 3 1
|
||||||
16
test/rule/full/GROUP.local
Normal file
16
test/rule/full/GROUP.local
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
0000000015
|
||||||
|
0 123 1
|
||||||
|
1 123 1
|
||||||
|
0 124 1
|
||||||
|
2 124 1
|
||||||
|
3 125 1
|
||||||
|
4 126 1
|
||||||
|
5 126 1
|
||||||
|
6 127 1
|
||||||
|
7 128 1
|
||||||
|
8 129 1
|
||||||
|
9 130 1
|
||||||
|
10 131 1
|
||||||
|
11 132 1
|
||||||
|
12 133 1
|
||||||
|
13 134 1
|
||||||
2
test/rule/full/HTTP_HOST.local
Normal file
2
test/rule/full/HTTP_HOST.local
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0000000001
|
||||||
|
13 12 www.3300av.com 0 0 0 1
|
||||||
2
test/rule/full/HTTP_REGION.local
Normal file
2
test/rule/full/HTTP_REGION.local
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0000000001
|
||||||
|
8 7 URL abckkk&123 1 0 0 1
|
||||||
6
test/rule/full/HTTP_URL.local
Normal file
6
test/rule/full/HTTP_URL.local
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
0000000005
|
||||||
|
2 1 abckkk&123 1 0 0 1
|
||||||
|
4 3 action=search\&query=(.*) 2 0 0 1
|
||||||
|
5 4 should_not_hit_any_rule 0 0 0 1
|
||||||
|
9 8 C#中国 0 0 0 1
|
||||||
|
14 13 novel&27122.txt 1 0 0 1
|
||||||
3
test/rule/full/IP_CONFIG.local
Normal file
3
test/rule/full/IP_CONFIG.local
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
0000000002
|
||||||
|
0 0 4 10.0.6.201 255.255.0.0 0 65535 0.0.0.0 255.255.255.255 0 65535 6 0 1
|
||||||
|
1 0 6 2001:da8:205:1::101 ffff:ffff:ffff:ffff:ffff:ffff:ffff:0000 0 65535 0::0 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 0 65535 6 0 1
|
||||||
4
test/rule/full/KEYWORDS_TABLE.local
Normal file
4
test/rule/full/KEYWORDS_TABLE.local
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0000000003
|
||||||
|
10 9 2010&يىلىدىكى 1 0 0 1
|
||||||
|
11 10 سىياسىي 1 0 0 1
|
||||||
|
12 11 Take\bme\bHome&Batman\ 1 0 0 1
|
||||||
4
test/rule/full/QD_ENTRY_INFO.local
Normal file
4
test/rule/full/QD_ENTRY_INFO.local
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0000000003
|
||||||
|
1 192.168.0.1 101
|
||||||
|
2 192.168.0.2 101
|
||||||
|
3 192.168.1.1 102
|
||||||
4
test/rule/full/TEST_PLUGIN_TABLE.local
Normal file
4
test/rule/full/TEST_PLUGIN_TABLE.local
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0000000003
|
||||||
|
1 3388 99 1
|
||||||
|
2 3355 66 1
|
||||||
|
3 cccc 11 1
|
||||||
4
test/rule/full/TEST_PLUGIN_TABLE_NO1.local
Normal file
4
test/rule/full/TEST_PLUGIN_TABLE_NO1.local
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0000000003
|
||||||
|
1 plugname1 1
|
||||||
|
2 plugname2 1
|
||||||
|
3 plugname3 1
|
||||||
1
test/rule/full/TEST_PLUGIN_TABLE_NO2.local
Normal file
1
test/rule/full/TEST_PLUGIN_TABLE_NO2.local
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0000000000
|
||||||
11
test/rule/full/index/full_config_index.0000000001
Normal file
11
test/rule/full/index/full_config_index.0000000001
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
COMPILE 12 ./rule/full/COMPILE.local
|
||||||
|
GROUP 15 ./rule/full/GROUP.local
|
||||||
|
TEST_PLUGIN_TABLE 3 ./rule/full/TEST_PLUGIN_TABLE.local
|
||||||
|
HTTP_REGION 1 ./rule/full/HTTP_REGION.local
|
||||||
|
IP_CONFIG 2 ./rule/full/IP_CONFIG.local
|
||||||
|
CONTENT_SIZE 2 ./rule/full/CONTENT_SIZE.local
|
||||||
|
HTTP_URL 5 ./rule/full/HTTP_URL.local
|
||||||
|
HTTP_HOST 1 ./rule/full/HTTP_HOST.local
|
||||||
|
QD_ENTRY_INFO 3 ./rule/full/QD_ENTRY_INFO.local
|
||||||
|
FILE_DIGEST 1 ./rule/full/FILE_DIGEST.local
|
||||||
|
KEYWORDS_TABLE 3 ./rule/full/KEYWORDS_TABLE.local
|
||||||
13
test/rule/inc/COMPILE.local
Normal file
13
test/rule/inc/COMPILE.local
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
0000000012
|
||||||
|
123 1 1 1 1 0 anything 1
|
||||||
|
124 1 1 1 1 0 anything 1
|
||||||
|
125 1 1 1 1 0 anything 1
|
||||||
|
126 1 1 1 1 0 anything 1
|
||||||
|
127 1 1 1 1 0 anything 1
|
||||||
|
128 1 1 1 1 0 anything 1
|
||||||
|
129 1 1 1 1 0 utf8_中文 1
|
||||||
|
130 1 1 1 1 0 utf8_维语 1
|
||||||
|
131 1 1 1 1 0 utf8_维语2 1
|
||||||
|
132 1 1 1 1 0 string\bunescape 1
|
||||||
|
133 1 1 1 1 0 table_conjunction_test_part1 1
|
||||||
|
134 1 1 1 1 0 table_conjunction_test_part2 1
|
||||||
3
test/rule/inc/CONTENT_SIZE.local
Normal file
3
test/rule/inc/CONTENT_SIZE.local
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
0000000002
|
||||||
|
3 2 100 500 1
|
||||||
|
6 5 2014 2016 1
|
||||||
2
test/rule/inc/FILE_DIGEST.local
Normal file
2
test/rule/inc/FILE_DIGEST.local
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0000000001
|
||||||
|
7 6 1160164 12288:UChtbFS6pypdTy4m2[0:1160163] 3 1
|
||||||
16
test/rule/inc/GROUP.local
Normal file
16
test/rule/inc/GROUP.local
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
0000000015
|
||||||
|
0 123 1
|
||||||
|
1 123 1
|
||||||
|
0 124 1
|
||||||
|
2 124 1
|
||||||
|
3 125 1
|
||||||
|
4 126 1
|
||||||
|
5 126 1
|
||||||
|
6 127 1
|
||||||
|
7 128 1
|
||||||
|
8 129 1
|
||||||
|
9 130 1
|
||||||
|
10 131 1
|
||||||
|
11 132 1
|
||||||
|
12 133 1
|
||||||
|
13 134 1
|
||||||
2
test/rule/inc/HTTP_HOST.local
Normal file
2
test/rule/inc/HTTP_HOST.local
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0000000001
|
||||||
|
13 12 www.3300av.com 0 0 0 1
|
||||||
2
test/rule/inc/HTTP_REGION.local
Normal file
2
test/rule/inc/HTTP_REGION.local
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0000000001
|
||||||
|
8 7 URL abckkk&123 1 0 0 1
|
||||||
6
test/rule/inc/HTTP_URL.local
Normal file
6
test/rule/inc/HTTP_URL.local
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
0000000005
|
||||||
|
2 1 abckkk&123 1 0 0 1
|
||||||
|
4 3 action=search\&query=(.*) 2 0 0 1
|
||||||
|
5 4 should_not_hit_any_rule 0 0 0 1
|
||||||
|
9 8 C#中国 0 0 0 1
|
||||||
|
14 13 novel&27122.txt 1 0 0 1
|
||||||
3
test/rule/inc/IP_CONFIG.local
Normal file
3
test/rule/inc/IP_CONFIG.local
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
0000000002
|
||||||
|
0 0 4 10.0.6.201 255.255.0.0 0 65535 0.0.0.0 255.255.255.255 0 65535 6 0 1
|
||||||
|
1 0 6 2001:da8:205:1::101 ffff:ffff:ffff:ffff:ffff:ffff:ffff:0000 0 65535 0::0 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 0 65535 6 0 1
|
||||||
3
test/rule/inc/KEYWORDS_TABLE.local
Normal file
3
test/rule/inc/KEYWORDS_TABLE.local
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
0000000003
|
||||||
|
10 9 2010&يىلىدىكى 1 0 0 1
|
||||||
|
11 10 سىياسىي 1 0 0 1
|
||||||
4
test/rule/inc/QD_ENTRY_INFO.local
Normal file
4
test/rule/inc/QD_ENTRY_INFO.local
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0000000003
|
||||||
|
1 192.168.0.1 101
|
||||||
|
2 192.168.0.2 101
|
||||||
|
3 192.168.1.1 102
|
||||||
4
test/rule/inc/TEST_PLUGIN_TABLE.local
Normal file
4
test/rule/inc/TEST_PLUGIN_TABLE.local
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0000000003
|
||||||
|
1 3388 99 1
|
||||||
|
2 3355 66 1
|
||||||
|
3 cccc 11 1
|
||||||
4
test/rule/inc/TEST_PLUGIN_TABLE_NO1.local
Normal file
4
test/rule/inc/TEST_PLUGIN_TABLE_NO1.local
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0000000003
|
||||||
|
1 plugname1 1
|
||||||
|
2 plugname2 1
|
||||||
|
3 plugname3 1
|
||||||
1
test/rule/inc/TEST_PLUGIN_TABLE_NO2.local
Normal file
1
test/rule/inc/TEST_PLUGIN_TABLE_NO2.local
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0000000000
|
||||||
10
test/rule/inc/index/full_config_index.0000000002
Normal file
10
test/rule/inc/index/full_config_index.0000000002
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
COMPILE 12 ./rule/inc/COMPILE.local
|
||||||
|
GROUP 15 ./rule/inc/GROUP.local
|
||||||
|
HTTP_REGION 1 ./rule/inc/HTTP_REGION.local
|
||||||
|
IP_CONFIG 2 ./rule/inc/IP_CONFIG.local
|
||||||
|
CONTENT_SIZE 2 ./rule/inc/CONTENT_SIZE.local
|
||||||
|
HTTP_URL 5 ./rule/inc/HTTP_URL.local
|
||||||
|
HTTP_HOST 1 ./rule/inc/HTTP_HOST.local
|
||||||
|
QD_ENTRY_INFO 3 ./rule/inc/QD_ENTRY_INFO.local
|
||||||
|
FILE_DIGEST 1 ./rule/inc/FILE_DIGEST.local
|
||||||
|
KEYWORDS_TABLE 2 ./rule/inc/KEYWORDS_TABLE.local
|
||||||
Reference in New Issue
Block a user