diff --git a/inc/Maat_command.h b/inc/Maat_command.h index 3102222..d35a4d3 100644 --- a/inc/Maat_command.h +++ b/inc/Maat_command.h @@ -128,8 +128,9 @@ void Maat_add_region2cmd(struct Maat_cmd_t* cmd,int which_group,const struct Maa void Maat_free_cmd(struct Maat_cmd_t* cmd); int Maat_format_cmd(struct Maat_cmd_t* cmd, char* buffer, int size); +char* Maat_str_escape(char* dst,int size,const char*src); -// The below command functions are NOT thread safe. +// The following functions are NOT thread safe. int Maat_cmd(Maat_feather_t feather,struct Maat_cmd_t* cmd,enum MAAT_OPERATION op); //pipeline model diff --git a/src/entry/Maat_command.cpp b/src/entry/Maat_command.cpp index 1f86503..b33f491 100644 --- a/src/entry/Maat_command.cpp +++ b/src/entry/Maat_command.cpp @@ -855,7 +855,7 @@ void _maat_copy_region(struct Maat_region_t* dst,const struct Maat_region_t* src case REGION_DIGEST: dst->digest_rule.digest_string=_maat_strdup(src->digest_rule.digest_string); break; - case REGION_SIMILARITY: + case REGION_SIMILARITY: dst->similarity_rule.target=_maat_strdup(src->similarity_rule.target); break; default: diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 02dd5a2..68d3694 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -414,6 +414,39 @@ char* str_unescape(char* s) s[j]='\0'; return s; } +char* Maat_str_escape(char* dst,int size,const char*src) +{ + int i=0,j=0; + int len=strlen(src); + for(i=0,j=0;istat_handle, CREATE_THREAD, &value, sizeof(value)); feather->fs_status_id[STATUS_VERSION]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"version"); - feather->fs_status_id[STATUS_THRED_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"active_thread"); + feather->fs_status_id[STATUS_THRED_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"thread"); feather->fs_status_id[STATUS_TABLE_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"table_num"); feather->fs_status_id[STATUS_PLUGIN_CACHE_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"plug_cache"); @@ -61,20 +61,21 @@ void maat_stat_init(struct _Maat_feather_t* feather) feather->fs_status_id[STATUS_GROUP_RULE_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"grp_num"); feather->fs_status_id[STATUS_COMPILE_RULE_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"compile_num"); - feather->fs_status_id[STATUS_POSTPONE_QSIZE]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"postpone_num"); + feather->fs_status_id[STATUS_POSTPONE_QSIZE]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"postponed"); feather->fs_status_id[STATUS_GARBAGE_QSIZE]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"garbage_num"); feather->fs_status_id[STATUS_OUTER_MID_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"outer_mid"); feather->fs_status_id[STATUS_INNER_MID_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"inner_mid"); - feather->fs_status_id[STATUS_ORPHAN_GROUP_SAVING]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"orphan_grp_sv"); + feather->fs_status_id[STATUS_ZOMBIE_RS_STREAM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"z_stream"); + + feather->fs_status_id[STATUS_ORPHAN_GROUP_SAVING]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"only_grp_sv"); feather->fs_status_id[STATUS_LAST_REGION_SAVING]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"last_rgn_sv"); feather->fs_status_id[STATUS_TOTAL_SCAN_LEN]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"scan_bytes"); feather->fs_status_id[STATUS_TOTAL_SCAN_CNT]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"scan_times"); - feather->fs_status_id[STATUS_UPDATE_ERR_CNT]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"update_error"); - feather->fs_status_id[STATUS_ICONV_ERR_CNT]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"iconv_error"); + feather->fs_status_id[STATUS_UPDATE_ERR_CNT]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"update_err"); + feather->fs_status_id[STATUS_ICONV_ERR_CNT]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"iconv_err"); feather->fs_status_id[STATUS_SCAN_ERR_CNT]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"scan_error"); - feather->fs_status_id[STATUS_ZOMBIE_RS_STREAM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"zombie_stream"); feather->fs_status_id[STATUS_CMD_NUM]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"cmd_commit"); feather->fs_status_id[STATUS_CMD_Q_SIZE]=FS_register(feather->stat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT,"cmd_in_q"); diff --git a/test/maat_test.cpp b/test/maat_test.cpp index bbfc139..3591b45 100644 --- a/test/maat_test.cpp +++ b/test/maat_test.cpp @@ -565,7 +565,11 @@ void test_command(Maat_feather_t feather) { const char* scan_data="Hiredis is a minimalistic C client library for the Redis database.\r\n"; const char* table_name="HTTP_URL"; - const char* keywords="Hiredis&C\\bClient"; + + const char* keywords1="Hiredis"; + const char* keywords2="C Client"; + char escape_buff1[256],escape_buff2[256]; + char keywords[256]; scan_status_t mid=NULL; int config_id=-1, table_id=0, ret=0; int output_ids[4]; @@ -573,6 +577,9 @@ void test_command(Maat_feather_t feather) struct Maat_rule_t result; int timeout=0;//seconds int label_id=5210; + Maat_str_escape(escape_buff1, sizeof(escape_buff1),keywords1); + Maat_str_escape(escape_buff2, sizeof(escape_buff2),keywords2); + snprintf(keywords,sizeof(keywords),"%s&%s",escape_buff1,escape_buff2); config_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", 1); test_add_command(feather,table_name,config_id, 0, label_id, keywords); sleep(1);//waiting for commands go into effect @@ -628,6 +635,7 @@ void test_command(Maat_feather_t feather) { printf("Test Maat command timeout success.\n"); } + Maat_clean_status(&mid); } int main(int argc,char* argv[]) {