From 83e921c683c91961382f60b80333f3bd5186cda0 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Mon, 19 Sep 2016 17:09:03 +0800 Subject: [PATCH] =?UTF-8?q?Maat=20Json=E6=94=AF=E6=8C=81=E6=9C=AA=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E5=88=86=E7=BB=84=E5=90=8D=EF=BC=8C=E5=8F=AF=E5=B0=86?= =?UTF-8?q?group=5Fname=E9=85=8D=E7=BD=AE=E4=B8=BA"Untitled"=E4=BB=A5?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E4=B8=8D=E9=9C=80=E8=A6=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E9=9D=9E=E5=88=86=E7=BB=84=E5=A4=8D=E7=94=A8=EF=BC=8C=E7=94=B1?= =?UTF-8?q?Maat=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90group=5Fid=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_rule.cpp | 2 +- src/entry/json2iris.cpp | 31 +++++++++++++++++++++---------- test/maat_json.json | 29 ++++++++++++++--------------- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 789e97c..55b8268 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -26,7 +26,7 @@ #include "mesa_fuzzy.h" #include "great_index_engine.h" -int MAAT_FRAME_VERSION_1_8_20160918_TABLE_CONJ=1; +int MAAT_FRAME_VERSION_1_8_20160919=1; const char *maat_module="MAAT Frame"; const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin", diff --git a/src/entry/json2iris.cpp b/src/entry/json2iris.cpp index d515995..4f745a4 100644 --- a/src/entry/json2iris.cpp +++ b/src/entry/json2iris.cpp @@ -12,7 +12,8 @@ #include "cJSON.h" #include "map_str2int.h" #include "Maat_rule_internal.h" -const char* maat_json="maat json"; +const char* maat_json="MAAT JSON"; +const char* untitled_group_name="Untitled"; const int json_version=1; #define MAX_PATH_LINE 256 #define MAX_COLUMN_NUM 32 @@ -758,6 +759,7 @@ int write_iris(cJSON *json,struct iris_description_t *p_iris,void* logger) cJSON *compile_rule=NULL,*group_rule=NULL,*region_rule=NULL,*each_plug_table=NULL; const char* group_name=NULL; struct group_info_t *group_info=NULL; + struct group_info_t untitled_group; plug_tables=cJSON_GetObjectItem(json,"plugin_table"); if(NULL!=plug_tables) { @@ -813,11 +815,14 @@ int write_iris(cJSON *json,struct iris_description_t *p_iris,void* logger) item=cJSON_GetObjectItem(group_rule,"group_name"); if(item==NULL||item->type!=cJSON_String) { - MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json, - "compile rule %d's group has no name.",compile_id); - return -1; + MESA_handle_runtime_log(logger,RLOG_LV_INFO,maat_json, + "compile rule %d's group has no name,regard as Untitled.",compile_id); + group_name=untitled_group_name; + } + else + { + group_name=item->valuestring; } - group_name=item->valuestring; group_info=(struct group_info_t*)MESA_htable_search(p_iris->group_name_map, (const unsigned char*)group_name, strlen(group_name)); if(group_info!=NULL)//exist group name ,region already read { @@ -837,11 +842,17 @@ int write_iris(cJSON *json,struct iris_description_t *p_iris,void* logger) } continue; } - - group_info=(struct group_info_t*)malloc(sizeof(struct group_info_t)); - group_info->group_id=p_iris->group_cnt++; - MESA_htable_add(p_iris->group_name_map,(const unsigned char*)group_name, strlen(group_name),group_info); - + if(0==strncasecmp(group_name,untitled_group_name,strlen(untitled_group_name))) + { + group_info=&untitled_group; + group_info->group_id=p_iris->group_cnt++; + } + else + { + group_info=(struct group_info_t*)malloc(sizeof(struct group_info_t)); + group_info->group_id=p_iris->group_cnt++; + MESA_htable_add(p_iris->group_name_map,(const unsigned char*)group_name, strlen(group_name),group_info); + } r_rules=cJSON_GetObjectItem(group_rule,"regions"); if(r_rules==NULL) { diff --git a/test/maat_json.json b/test/maat_json.json index 0804d84..3384247 100644 --- a/test/maat_json.json +++ b/test/maat_json.json @@ -13,7 +13,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_1", + "group_name": "IP_group", "regions": [ { "table_name": "IP_CONFIG", @@ -52,7 +52,7 @@ ] }, { - "group_name": "group_2", + "group_name": "Untitled", "regions": [ { "table_name": "HTTP_URL", @@ -79,10 +79,10 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_1" + "group_name": "IP_group" }, { - "group_name": "group_3", + "group_name": "Untitled", "regions": [ { "table_name": "CONTENT_SIZE", @@ -107,7 +107,6 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_4", "regions": [ { "table_name": "HTTP_URL", @@ -134,7 +133,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_5", + "group_name": "Untitled", "regions": [ { "table_name": "HTTP_URL", @@ -149,7 +148,7 @@ ] }, { - "group_name": "group_6", + "group_name": "Untitled", "regions": [ { "table_name": "CONTENT_SIZE", @@ -174,7 +173,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_7", + "group_name": "Untitled", "regions": [ { "table_name": "FILE_DIGEST", @@ -200,7 +199,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_8", + "group_name": "Untitled", "regions": [ { "table_name": "HTTP_REGION", @@ -228,7 +227,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_9", + "group_name": "Untitled", "regions": [ { "table_name": "HTTP_URL", @@ -255,7 +254,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_10", + "group_name": "Untitled", "regions": [ { "table_name": "KEYWORDS_TABLE", @@ -282,7 +281,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_11", + "group_name": "Untitled", "regions": [ { "table_name": "KEYWORDS_TABLE", @@ -309,7 +308,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_12", + "group_name": "Untitled", "regions": [ { "table_name": "KEYWORDS_TABLE", @@ -336,7 +335,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_13", + "group_name": "Untitled", "regions": [ { "table_name": "HTTP_HOST", @@ -364,7 +363,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "group_14", + "group_name": "Untitled", "regions": [ { "table_name": "HTTP_URL",