修复 TSG-7994 ,避免处理未知district时出现误命中。
This commit is contained in:
@@ -200,7 +200,7 @@ void scan_region_hit_wraper_build_with_rulescan(struct scan_region_hit_wraper* w
|
|||||||
for(i=0; i< n_rslt; i++)
|
for(i=0; i< n_rslt; i++)
|
||||||
{
|
{
|
||||||
region=(struct Maat_region_inner*)(rulescan_rslt[i].tag);
|
region=(struct Maat_region_inner*)(rulescan_rslt[i].tag);
|
||||||
if(region->district_id==district_id||district_id==-1)
|
if(region->district_id==district_id||district_id==DISTRICT_ANY)
|
||||||
{
|
{
|
||||||
wraper->hit_regions[wraper->n_hit_region]=region;
|
wraper->hit_regions[wraper->n_hit_region]=region;
|
||||||
wraper->n_hit_region++;
|
wraper->n_hit_region++;
|
||||||
@@ -422,7 +422,7 @@ struct _OUTER_scan_status_t* _make_outer_status(_Maat_feather_t *feather, int th
|
|||||||
struct _OUTER_scan_status_t* outer_mid=NULL;
|
struct _OUTER_scan_status_t* outer_mid=NULL;
|
||||||
outer_mid=(struct _OUTER_scan_status_t*)calloc(sizeof(struct _OUTER_scan_status_t),1);
|
outer_mid=(struct _OUTER_scan_status_t*)calloc(sizeof(struct _OUTER_scan_status_t),1);
|
||||||
outer_mid->feather=feather;
|
outer_mid->feather=feather;
|
||||||
outer_mid->district_id=-1;
|
outer_mid->district_id=DISTRICT_ANY;
|
||||||
outer_mid->thread_num=(unsigned short)thread_num;
|
outer_mid->thread_num=(unsigned short)thread_num;
|
||||||
alignment_int64_array_add(feather->outer_mid_cnt, thread_num,1);
|
alignment_int64_array_add(feather->outer_mid_cnt, thread_num,1);
|
||||||
return outer_mid;
|
return outer_mid;
|
||||||
@@ -2481,7 +2481,7 @@ int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCA
|
|||||||
if(map_ret<0)
|
if(map_ret<0)
|
||||||
{
|
{
|
||||||
//May be the district is not effected yet.
|
//May be the district is not effected yet.
|
||||||
_mid->district_id=-1;
|
_mid->district_id=DISTRICT_UNKNOWN;
|
||||||
}
|
}
|
||||||
_mid->is_set_district=1;
|
_mid->is_set_district=1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ extern "C"
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int MAAT_FRAME_VERSION_3_4_8_20210819=1;
|
int MAAT_FRAME_VERSION_3_4_9_20211011=1;
|
||||||
|
|
||||||
int is_valid_table_name(const char* str)
|
int is_valid_table_name(const char* str)
|
||||||
{
|
{
|
||||||
@@ -671,7 +671,7 @@ void destroy_rs_ip_rule(scan_rule_t* p)
|
|||||||
{
|
{
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
scan_rule_t* create_rs_intval_rule(unsigned int sub_type,struct db_intval_rule *intval_rule)
|
scan_rule_t* create_rs_intval_rule(unsigned int sub_type,struct db_interval_rule *intval_rule)
|
||||||
{
|
{
|
||||||
scan_rule_t *p_rule=(scan_rule_t*)calloc(sizeof(scan_rule_t),1);
|
scan_rule_t *p_rule=(scan_rule_t*)calloc(sizeof(scan_rule_t),1);
|
||||||
p_rule->rule_type=RULETYPE_INT;
|
p_rule->rule_type=RULETYPE_INT;
|
||||||
@@ -1358,14 +1358,14 @@ int add_ip_rule(struct Maat_table_schema* table, struct db_ip_rule_t* db_ip_rule
|
|||||||
MESA_lqueue_join_tail(scanner->region_update_q, &op_expr, sizeof(void*));
|
MESA_lqueue_join_tail(scanner->region_update_q, &op_expr, sizeof(void*));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int add_intval_rule(struct Maat_table_schema* table,struct db_intval_rule* intval_rule,struct Maat_scanner *scanner,void* logger)
|
int add_interval_rule(struct Maat_table_schema* table,struct db_interval_rule* intval_rule,struct Maat_scanner *scanner,void* logger)
|
||||||
{
|
{
|
||||||
scan_rule_t* p_rule=NULL;
|
scan_rule_t* p_rule=NULL;
|
||||||
struct op_expr_t* op_expr=NULL;
|
struct op_expr_t* op_expr=NULL;
|
||||||
struct Maat_region_inner* u_para=NULL;
|
struct Maat_region_inner* u_para=NULL;
|
||||||
int expr_id=0, ret=0,district_id=-1;
|
int expr_id=0, ret=0,district_id=-1;
|
||||||
|
|
||||||
if(table->table_type==TABLE_TYPE_EXPR_PLUS)
|
if(table->table_type==TABLE_TYPE_INTERVAL_PLUS)
|
||||||
{
|
{
|
||||||
assert(strlen(intval_rule->district)>0);
|
assert(strlen(intval_rule->district)>0);
|
||||||
str_unescape(intval_rule->district);
|
str_unescape(intval_rule->district);
|
||||||
@@ -1945,7 +1945,7 @@ error_out:
|
|||||||
|
|
||||||
void update_intval_rule(struct Maat_table_schema* table, const char* table_line, struct Maat_scanner *scanner, void* logger)
|
void update_intval_rule(struct Maat_table_schema* table, const char* table_line, struct Maat_scanner *scanner, void* logger)
|
||||||
{
|
{
|
||||||
struct db_intval_rule* intval_rule=ALLOC(struct db_intval_rule, 1);
|
struct db_interval_rule* intval_rule=ALLOC(struct db_interval_rule, 1);
|
||||||
struct Maat_table_runtime* table_rt=Maat_table_runtime_get(scanner->table_rt_mgr, table->table_id);
|
struct Maat_table_runtime* table_rt=Maat_table_runtime_get(scanner->table_rt_mgr, table->table_id);
|
||||||
int ret=0;
|
int ret=0;
|
||||||
switch(table->table_type)
|
switch(table->table_type)
|
||||||
@@ -2006,7 +2006,7 @@ void update_intval_rule(struct Maat_table_schema* table, const char* table_line,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret=add_intval_rule(table, intval_rule,scanner,logger);
|
ret=add_interval_rule(table, intval_rule,scanner,logger);
|
||||||
if(ret<0)
|
if(ret<0)
|
||||||
{
|
{
|
||||||
MESA_handle_runtime_log(logger,RLOG_LV_INFO,maat_module ,
|
MESA_handle_runtime_log(logger,RLOG_LV_INFO,maat_module ,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ struct db_ip_rule_t
|
|||||||
};
|
};
|
||||||
int is_valid;
|
int is_valid;
|
||||||
};
|
};
|
||||||
struct db_intval_rule
|
struct db_interval_rule
|
||||||
{
|
{
|
||||||
int region_id;
|
int region_id;
|
||||||
int group_id;
|
int group_id;
|
||||||
@@ -162,14 +162,15 @@ struct Maat_region_inner
|
|||||||
int expr_id_ub; //up boundary
|
int expr_id_ub; //up boundary
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define DISTRICT_ANY -1
|
||||||
|
#define DISTRICT_UNKNOWN -2
|
||||||
struct _OUTER_scan_status_t
|
struct _OUTER_scan_status_t
|
||||||
{
|
{
|
||||||
struct _Maat_feather_t* feather;
|
struct _Maat_feather_t* feather;
|
||||||
unsigned short thread_num;
|
unsigned short thread_num;
|
||||||
unsigned char is_set_district;
|
unsigned char is_set_district;
|
||||||
unsigned char is_last_region;
|
unsigned char is_last_region;
|
||||||
int district_id;
|
int district_id; //-1: Any District; -2: Unkonwn District;
|
||||||
int scan_cnt;
|
int scan_cnt;
|
||||||
struct Maat_hierarchy_compile_mid* compile_mid;
|
struct Maat_hierarchy_compile_mid* compile_mid;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
"regions": [
|
"regions": [
|
||||||
{
|
{
|
||||||
"table_name": "INTERGER_PLUS",
|
"table_name": "INTERGER_PLUS",
|
||||||
"table_type": "intval_plus",
|
"table_type": "interval_plus",
|
||||||
"table_content": {
|
"table_content": {
|
||||||
"district": "fqdn_cat_id",
|
"district": "fqdn_cat_id",
|
||||||
"low_boundary": 1724,
|
"low_boundary": 1724,
|
||||||
@@ -261,7 +261,7 @@
|
|||||||
"regions": [
|
"regions": [
|
||||||
{
|
{
|
||||||
"table_name": "CONTENT_SIZE",
|
"table_name": "CONTENT_SIZE",
|
||||||
"table_type": "intval",
|
"table_type": "interval",
|
||||||
"table_content": {
|
"table_content": {
|
||||||
"low_boundary": 100,
|
"low_boundary": 100,
|
||||||
"up_boundary": 500
|
"up_boundary": 500
|
||||||
@@ -325,7 +325,7 @@
|
|||||||
"regions": [
|
"regions": [
|
||||||
{
|
{
|
||||||
"table_name": "CONTENT_SIZE",
|
"table_name": "CONTENT_SIZE",
|
||||||
"table_type": "intval",
|
"table_type": "interval",
|
||||||
"table_content": {
|
"table_content": {
|
||||||
"low_boundary": 2014,
|
"low_boundary": 2014,
|
||||||
"up_boundary": 2016
|
"up_boundary": 2016
|
||||||
@@ -1947,9 +1947,9 @@
|
|||||||
"regions": [
|
"regions": [
|
||||||
{
|
{
|
||||||
"table_name": "INTERGER_PLUS",
|
"table_name": "INTERGER_PLUS",
|
||||||
"table_type": "intval_plus",
|
"table_type": "interval_plus",
|
||||||
"table_content": {
|
"table_content": {
|
||||||
"district": "intval.plus",
|
"district": "interval.plus",
|
||||||
"low_boundary": 2020,
|
"low_boundary": 2020,
|
||||||
"up_boundary": 2020
|
"up_boundary": 2020
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -540,8 +540,8 @@ TEST(StringScan, PrefixAndSuffix)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IntvalPlusTest 1
|
#define IntervalPlusTest 1
|
||||||
TEST(IntvalScan, IntvalPlusPlus)
|
TEST(IntervalScan, IntervalPlus)
|
||||||
{
|
{
|
||||||
int table_id=0,ret=0;
|
int table_id=0,ret=0;
|
||||||
int scan_val=2020;
|
int scan_val=2020;
|
||||||
@@ -551,7 +551,7 @@ TEST(IntvalScan, IntvalPlusPlus)
|
|||||||
table_id=Maat_table_register(g_feather, "INTERGER_PLUS");
|
table_id=Maat_table_register(g_feather, "INTERGER_PLUS");
|
||||||
ASSERT_GT(table_id, 0);
|
ASSERT_GT(table_id, 0);
|
||||||
|
|
||||||
ret=Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_DISTRICT, "intval.plus", strlen("intval.plus"));
|
ret=Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_DISTRICT, "interval.plus", strlen("interval.plus"));
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
|
|
||||||
ret=Maat_scan_intval(g_feather, table_id, scan_val, result,4, &mid, 0);
|
ret=Maat_scan_intval(g_feather, table_id, scan_val, result,4, &mid, 0);
|
||||||
@@ -675,7 +675,7 @@ TEST(StringScan, ShouldNotHitExprPlus)
|
|||||||
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, (char*)udp_payload_not_hit, sizeof(udp_payload_not_hit),
|
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, (char*)udp_payload_not_hit, sizeof(udp_payload_not_hit),
|
||||||
result, NULL, 4,
|
result, NULL, 4,
|
||||||
&mid, 0);
|
&mid, 0);
|
||||||
EXPECT_EQ(ret, 0);
|
EXPECT_EQ(ret, -2);
|
||||||
|
|
||||||
Maat_clean_status(&mid);
|
Maat_clean_status(&mid);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user