1)通过转义字符支持关键词中包含空格;
2)修复tableinfo中一个表设置Quick标志位后,由于未清零,导致其它表也被设置的bug。
This commit is contained in:
@@ -59,7 +59,7 @@ void print_maat_ret(int ret)
|
||||
}
|
||||
return;
|
||||
}
|
||||
const char* print_maat_rule(struct Maat_rule_t* result,int ret)
|
||||
const char* print_maat_result(struct Maat_rule_t* result,int ret)
|
||||
{
|
||||
static char buff[1024]={0};
|
||||
int i=0,j=0;
|
||||
@@ -101,7 +101,28 @@ int test_string_full_scan(Maat_feather_t feather,const char* table_name,scan_sta
|
||||
ret=Maat_full_scan_string(feather, table_id,CHARSET_GBK, scan_data, strlen(scan_data),
|
||||
result,found_pos, 4,
|
||||
mid, 0);
|
||||
print_maat_ret(ret);
|
||||
printf("Full String Scan:%s\n",print_maat_result(result,ret));
|
||||
return ret;
|
||||
}
|
||||
int test_unescape_string_scan(Maat_feather_t feather,const char* table_name,scan_status_t* mid)
|
||||
{
|
||||
int ret=0;
|
||||
int table_id=0;
|
||||
struct Maat_rule_t result[4];
|
||||
int found_pos[4];
|
||||
const char* scan_data="Batman\\:Take me Home&Batman";
|
||||
table_id=Maat_table_register(feather,table_name);
|
||||
if(table_id==-1)
|
||||
{
|
||||
printf("Database table %s register failed.\n",table_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret=Maat_full_scan_string(feather, table_id,CHARSET_GBK, scan_data, strlen(scan_data),
|
||||
result,found_pos, 4,
|
||||
mid, 0);
|
||||
printf("Unescape String Scan:%s\n",print_maat_result(result,ret));
|
||||
|
||||
return ret;
|
||||
}
|
||||
int test_intval_scan(Maat_feather_t feather,const char* table_name,scan_status_t* mid)
|
||||
@@ -118,7 +139,7 @@ int test_intval_scan(Maat_feather_t feather,const char* table_name,scan_status_t
|
||||
else
|
||||
{
|
||||
ret=Maat_scan_intval(feather, table_id, scan_val, result,4,mid, 0);
|
||||
print_maat_ret(ret);
|
||||
printf("Intval Scan:%s\n",print_maat_result(result,ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -149,7 +170,7 @@ int test_str_stream_scan(Maat_feather_t feather,const char* table_name,scan_stat
|
||||
,&detail_ret,mid);
|
||||
Maat_stream_scan_string_end(&sp);
|
||||
free(hit_detail);
|
||||
print_maat_ret(ret);
|
||||
printf("Stream String Scan:%s\n",print_maat_result(result,ret));
|
||||
return ret;
|
||||
}
|
||||
int test_ipv4_scan(Maat_feather_t feather,const char* table_name,scan_status_t* mid)
|
||||
@@ -174,10 +195,7 @@ int test_ipv4_scan(Maat_feather_t feather,const char* table_name,scan_status_t*
|
||||
else
|
||||
{
|
||||
ret=Maat_scan_proto_addr(feather,table_id,&ipv4_addr,6,result,4, mid,0);
|
||||
if(ret>0)
|
||||
{
|
||||
printf("ipv4 scan hit compile rule id %d.\n",result[0].config_id);
|
||||
}
|
||||
printf("IPv4 addr Scan:%s\n",print_maat_result(result,ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -204,11 +222,9 @@ int test_ipv6_scan(Maat_feather_t feather,const char* table_name,scan_status_t*
|
||||
else
|
||||
{
|
||||
ret=Maat_scan_proto_addr(feather,table_id,&ipv6_addr,6,result,4, mid,0);
|
||||
if(ret==-2)
|
||||
{
|
||||
printf("ipv6 scan hit region.\n");
|
||||
}
|
||||
else
|
||||
printf("IPv6 addr Scan:%s\n",print_maat_result(result,ret));
|
||||
|
||||
if(ret!=-2)
|
||||
{
|
||||
printf("ipv6 scan result:%d ,shoulde be -2.\n",ret);
|
||||
|
||||
@@ -249,7 +265,7 @@ int test_digest_scan(Maat_feather_t feather,const char* table_name,scan_status_t
|
||||
scan_offset+=read_size;
|
||||
if(ret>0)
|
||||
{
|
||||
printf("digest scan hit %d.\n",result[0].config_id);
|
||||
printf("Digest Scan:%s\n",print_maat_result(result,ret));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -300,12 +316,12 @@ int test_url_encode(Maat_feather_t feather,const char* table_name,scan_status_t*
|
||||
ret=Maat_full_scan_string(feather, table_id,CHARSET_GBK, url_utf8, strlen(url_utf8),
|
||||
result,found_pos, 4,
|
||||
mid, 0);
|
||||
printf("URL encode scan utf8 url %s\n",print_maat_rule(result,ret));
|
||||
printf("URL encode scan utf8 url: %s\n",print_maat_result(result,ret));
|
||||
|
||||
ret=Maat_full_scan_string(feather, table_id,CHARSET_GBK, url_gb2312, strlen(url_gb2312),
|
||||
result,found_pos, 4,
|
||||
mid, 0);
|
||||
printf("URL encode scan gb2312 url %s\n",print_maat_rule(result,ret));
|
||||
printf("URL encode scan gb2312 url: %s\n",print_maat_result(result,ret));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -363,7 +379,7 @@ int test_unicode_esc(Maat_feather_t feather,const char* table_name,scan_status_t
|
||||
read_len=fread(buff,1,sizeof(buff),fp);
|
||||
if(ret>0)
|
||||
{
|
||||
printf("UNI2ASCII file %s,%s\n",file_path,print_maat_rule(result,ret));
|
||||
printf("UNI2ASCII file %s,%s\n",file_path,print_maat_result(result,ret));
|
||||
}
|
||||
}
|
||||
Maat_stream_scan_string_end(&sp);
|
||||
@@ -468,7 +484,10 @@ int main(int argc,char* argv[])
|
||||
|
||||
test_unicode_esc(feather,"KEYWORDS_TABLE",&mid);
|
||||
Maat_clean_status(&mid);
|
||||
|
||||
|
||||
test_unescape_string_scan(feather,"KEYWORDS_TABLE",&mid);
|
||||
Maat_clean_status(&mid);
|
||||
|
||||
sleep(4);
|
||||
|
||||
Maat_burn_feather(feather);
|
||||
|
||||
Reference in New Issue
Block a user