Maat Json支持未命名分组名,可将group_name配置为"Untitled"以表示不需要进行非分组复用,由Maat自动生成group_id。

This commit is contained in:
zhengchao
2016-09-19 17:09:03 +08:00
parent bdca633bbd
commit 83e921c683
3 changed files with 36 additions and 26 deletions

View File

@@ -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",

View File

@@ -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_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;
}
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)
{

View File

@@ -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",