1、新增测试用例;2、json支持digest类型;

This commit is contained in:
zhengchao
2015-11-12 17:49:57 +08:00
parent ba937ab14c
commit 6bac9a6fc8
4 changed files with 86 additions and 7 deletions

View File

@@ -1039,13 +1039,14 @@ stream_para_t Maat_stream_scan_digest_start(Maat_feather_t feather,int table_id,
sp->table_id=table_id;
sp->thread_num=thread_num;
sp->total_len=total_len;
sp->fuzzy_hash_handle=fuzzy_create_handle();
sp->fuzzy_hash_handle=fuzzy_create_handle(total_len);
return sp;
}
#define QUERY_MIN_RATE (3) //30%
#define QUERY_MIN_LEN (1024*1024*4)
inline int REACH_QUERY_THRESH(unsigned long long total_len,unsigned long long acc_len,unsigned char* query_point,int point_size)
{
const int QUERY_MIN_RATE=(3); //30%
const int QUERY_MIN_LEN=(1024*1024*4);
//do query every 10 percent since 30%, e.g. 0.3/0.4/0.5/.../1.0
unsigned long long rate=(acc_len*10)/total_len;
// if(acc_len>QUERY_MIN_LEN)
@@ -1134,7 +1135,7 @@ void Maat_stream_scan_digest_end(stream_para_t* stream_para)
}
fuzzy_destroy_handle(sp->fuzzy_hash_handle);
assert(sp->last_cache==NULL);
assert(sp->scan_buff==NULL)
assert(sp->scan_buff==NULL);
free(sp);
*stream_para=NULL;
return;

View File

@@ -111,7 +111,8 @@ int set_iris_descriptor(const char* json_file,cJSON *json,struct iris_descriptio
map_register(iris_cfg->str2int_map, "ip",TABLE_TYPE_IP);
map_register(iris_cfg->str2int_map, "string",TABLE_TYPE_EXPR);
map_register(iris_cfg->str2int_map, "intval",TABLE_TYPE_INTVAL);
map_register(iris_cfg->str2int_map, "digest",TABLE_TYPE_DIGEST);
map_register(iris_cfg->str2int_map, "ipv4",4);
map_register(iris_cfg->str2int_map, "ipv6",6);
@@ -431,6 +432,39 @@ int write_intval_rule(cJSON *region_json,struct iris_description_t *p_iris,const
return direct_write_rule(region_json, p_iris->str2int_map,json_cmd, cmd_cnt,path,logger);
}
int write_digest_rule(cJSON *region_json,struct iris_description_t *p_iris,const char* path,void * logger)
{
struct traslate_command_t json_cmd[MAX_COLUMN_NUM];
int cmd_cnt=0;
memset(json_cmd,0,sizeof(json_cmd));
json_cmd[cmd_cnt].json_string="region_id";
json_cmd[cmd_cnt].json_type=cJSON_Number;
cmd_cnt++;
json_cmd[cmd_cnt].json_string="group_id";
json_cmd[cmd_cnt].json_type=cJSON_Number;
cmd_cnt++;
json_cmd[cmd_cnt].json_string="raw_len";
json_cmd[cmd_cnt].json_type=cJSON_String;
cmd_cnt++;
json_cmd[cmd_cnt].json_string="digest";
json_cmd[cmd_cnt].json_type=cJSON_String;
cmd_cnt++;
json_cmd[cmd_cnt].json_string="cfds_level";
json_cmd[cmd_cnt].json_type=cJSON_String;
cmd_cnt++;
json_cmd[cmd_cnt].json_string="is_valid";
json_cmd[cmd_cnt].json_type=cJSON_Number;
cmd_cnt++;
return direct_write_rule(region_json, p_iris->str2int_map,json_cmd, cmd_cnt,path,logger);
}
struct iris_table_t* query_table_info(iris_description_t* p_iris,const char* table_name)
{
@@ -572,6 +606,9 @@ int write_region_rule(cJSON* region_json,int compile_id,int group_id,iris_descri
case TABLE_TYPE_INTVAL:
ret=write_intval_rule(table_content, p_iris, table_info->table_path, logger);
break;
case TABLE_TYPE_DIGEST:
ret=write_digest_rule(table_content, p_iris, table_info->table_path, logger);
break;
default:
assert(0);
break;