修复加载8个字符串与表达式报错的bug TSG-4717;增加Hierarchy日志中输出去重后Clause的数量。
This commit is contained in:
@@ -913,7 +913,10 @@ static struct bool_matcher* Maat_hierarchy_build_bool_matcher(struct Maat_hierar
|
|||||||
if(bm!=NULL)
|
if(bm!=NULL)
|
||||||
{
|
{
|
||||||
MESA_handle_runtime_log(hier->logger, RLOG_LV_INFO, module_maat_hierarchy,
|
MESA_handle_runtime_log(hier->logger, RLOG_LV_INFO, module_maat_hierarchy,
|
||||||
"Build bool matcher with %zu expression use %zu bytes memory", expr_cnt, mem_size);
|
"Build bool matcher of %zu expressions and %llu clauses, use %zu bytes memory.",
|
||||||
|
expr_cnt,
|
||||||
|
HASH_COUNT(clause_dedup_hash),
|
||||||
|
mem_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1056,6 +1059,10 @@ struct Maat_hierarchy_literal* Maat_hierarchy_build_literal_hash(struct Maat_hie
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
MESA_handle_runtime_log(hier->logger, RLOG_LV_INFO, module_maat_hierarchy,
|
||||||
|
"Build literal hash with %llu literals.",
|
||||||
|
HASH_COUNT(literal_hash));
|
||||||
|
|
||||||
return literal_hash;
|
return literal_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ extern "C"
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int MAAT_FRAME_VERSION_3_1_5_20201205=1;
|
int MAAT_FRAME_VERSION_3_1_5_20201216=1;
|
||||||
|
|
||||||
int is_valid_table_name(const char* str)
|
int is_valid_table_name(const char* str)
|
||||||
{
|
{
|
||||||
@@ -1089,7 +1089,7 @@ int add_expr_rule(struct Maat_table_schema* table,struct db_str_rule_t* db_rule,
|
|||||||
scan_rule_t*p_rule=NULL;
|
scan_rule_t*p_rule=NULL;
|
||||||
|
|
||||||
enum MAAT_CHARSET dst_charset=CHARSET_NONE;
|
enum MAAT_CHARSET dst_charset=CHARSET_NONE;
|
||||||
char *sub_key_array[MAAT_MAX_EXPR_ITEM_NUM];
|
char *sub_key_array[MAAT_MAX_EXPR_ITEM_NUM], *tmp=NULL;
|
||||||
int key_left_offset[MAAT_MAX_EXPR_ITEM_NUM]={-1},key_right_offset[MAAT_MAX_EXPR_ITEM_NUM]={-1};
|
int key_left_offset[MAAT_MAX_EXPR_ITEM_NUM]={-1},key_right_offset[MAAT_MAX_EXPR_ITEM_NUM]={-1};
|
||||||
for(i=0;i<MAAT_MAX_EXPR_ITEM_NUM;i++)
|
for(i=0;i<MAAT_MAX_EXPR_ITEM_NUM;i++)
|
||||||
{
|
{
|
||||||
@@ -1115,20 +1115,21 @@ int add_expr_rule(struct Maat_table_schema* table,struct db_str_rule_t* db_rule,
|
|||||||
case EXPR_TYPE_REGEX:
|
case EXPR_TYPE_REGEX:
|
||||||
for(i=0,p=db_rule->keywords;;i++,p=NULL)
|
for(i=0,p=db_rule->keywords;;i++,p=NULL)
|
||||||
{
|
{
|
||||||
if(i>=MAAT_MAX_EXPR_ITEM_NUM)
|
tmp=strtok_r_esc(p, '&', &saveptr);
|
||||||
{
|
if(tmp==NULL)
|
||||||
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
|
||||||
"Table %s region cfg %d too many expr.",table->table_name[table->updating_name],db_rule->region_id);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
sub_key_array[i]=strtok_r_esc(p,'&',&saveptr);
|
|
||||||
if(sub_key_array[i]==NULL)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(i>=MAAT_MAX_EXPR_ITEM_NUM)
|
||||||
|
{
|
||||||
|
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
||||||
|
"Table %s region cfg %d too many expr.", table->table_name[table->updating_name], db_rule->region_id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sub_key_array[i]=tmp;
|
||||||
if(db_rule->expr_type==EXPR_TYPE_REGEX)
|
if(db_rule->expr_type==EXPR_TYPE_REGEX)
|
||||||
{
|
{
|
||||||
sub_key_array[i]=str_unescape_and(sub_key_array[i]);//regex remain use str_unescape_and
|
sub_key_array[i]=str_unescape_and(sub_key_array[i]);//regex should use str_unescape_and
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1140,29 +1141,30 @@ int add_expr_rule(struct Maat_table_schema* table,struct db_str_rule_t* db_rule,
|
|||||||
case EXPR_TYPE_OFFSET:
|
case EXPR_TYPE_OFFSET:
|
||||||
for(i=0,p=db_rule->keywords;;i++,p=NULL)
|
for(i=0,p=db_rule->keywords;;i++,p=NULL)
|
||||||
{
|
{
|
||||||
if(i>=MAAT_MAX_EXPR_ITEM_NUM)
|
tmp=strtok_r_esc(p, '&', &saveptr);
|
||||||
{
|
if(tmp==NULL)
|
||||||
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
|
||||||
"Table %s region cfg %d too many expr.",table->table_name[table->updating_name],db_rule->region_id);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
sub_key_array[i]=strtok_r_esc(p,'&',&saveptr);
|
|
||||||
if(sub_key_array[i]==NULL)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sscanf(sub_key_array[i],"%d-%d:",&(key_left_offset[i]),&(key_right_offset[i]));
|
if(i>=MAAT_MAX_EXPR_ITEM_NUM)
|
||||||
|
{
|
||||||
|
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
||||||
|
"Table %s region cfg %d too many expr.", table->table_name[table->updating_name], db_rule->region_id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sub_key_array[i]=tmp;
|
||||||
|
sscanf(sub_key_array[i], "%d-%d:", &(key_left_offset[i]),&(key_right_offset[i]));
|
||||||
if(!(key_left_offset[i]>=0&&key_right_offset[i]>0&&key_left_offset[i]<=key_right_offset[i]))
|
if(!(key_left_offset[i]>=0&&key_right_offset[i]>0&&key_left_offset[i]<=key_right_offset[i]))
|
||||||
{
|
{
|
||||||
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
||||||
"Table %s region cfg %d invalid offset.",table->table_name[table->updating_name],db_rule->region_id);
|
"Table %s region cfg %d invalid offset.", table->table_name[table->updating_name], db_rule->region_id);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sub_key_array[i]=(char*)memchr(sub_key_array[i],':',strlen(sub_key_array[i]));
|
sub_key_array[i]=(char*)memchr(sub_key_array[i], ':', strlen(sub_key_array[i]));
|
||||||
if(sub_key_array[i]==NULL)
|
if(sub_key_array[i]==NULL)
|
||||||
{
|
{
|
||||||
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module ,
|
||||||
"Table %s region cfg %d invalid offset keyword format.",table->table_name[table->updating_name],db_rule->region_id);
|
"Table %s region cfg %d invalid offset keyword format.", table->table_name[table->updating_name], db_rule->region_id);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sub_key_array[i]++;//jump over ':'
|
sub_key_array[i]++;//jump over ':'
|
||||||
|
|||||||
@@ -1946,6 +1946,31 @@
|
|||||||
"not_flag":0
|
"not_flag":0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"compile_id": 182,
|
||||||
|
"service": 1,
|
||||||
|
"action": 1,
|
||||||
|
"do_blacklist": 1,
|
||||||
|
"do_log": 1,
|
||||||
|
"user_region": "8-expr",
|
||||||
|
"is_valid": "yes",
|
||||||
|
"groups": [
|
||||||
|
{
|
||||||
|
"regions": [
|
||||||
|
{
|
||||||
|
"table_name": "KEYWORDS_TABLE",
|
||||||
|
"table_type": "string",
|
||||||
|
"table_content": {
|
||||||
|
"keywords": "string1&string2&string3&string4&string5&string6&string7&string8",
|
||||||
|
"expr_type": "and",
|
||||||
|
"match_method": "expr",
|
||||||
|
"format": "uncase plain"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"plugin_table": [
|
"plugin_table": [
|
||||||
|
|||||||
@@ -1305,6 +1305,28 @@ TEST(StringScan, MaatUnescape)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TEST(StringScan, Expr8)
|
||||||
|
{
|
||||||
|
int ret=0;
|
||||||
|
int table_id=0;
|
||||||
|
struct Maat_rule_t result[4];
|
||||||
|
const char* scan_data="string1, string2, string3, string4, string5, string6, string7, string8";
|
||||||
|
const char* table_name="KEYWORDS_TABLE";
|
||||||
|
scan_status_t mid=NULL;
|
||||||
|
|
||||||
|
table_id=Maat_table_register(g_feather,table_name);
|
||||||
|
ASSERT_GT(table_id, 0);
|
||||||
|
|
||||||
|
ret=Maat_full_scan_string(g_feather, table_id, CHARSET_GBK, scan_data, strlen(scan_data),
|
||||||
|
result, NULL, 4,
|
||||||
|
&mid, 0);
|
||||||
|
EXPECT_EQ(ret, 1);
|
||||||
|
EXPECT_EQ(result[0].config_id, 182);
|
||||||
|
Maat_clean_status(&mid);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TEST(StringScan, StreamInput)
|
TEST(StringScan, StreamInput)
|
||||||
{
|
{
|
||||||
int table_id=0,ret=0;
|
int table_id=0,ret=0;
|
||||||
|
|||||||
Reference in New Issue
Block a user