allow maat_json.json has no compile/g2c/g2c table

This commit is contained in:
liuwentan
2023-04-07 11:28:34 +08:00
parent 4430c8e696
commit 0c4acf224a
2 changed files with 5 additions and 19 deletions

View File

@@ -339,7 +339,7 @@ int direct_write_rule(cJSON *json, struct maat_kv_store *str2int,
int i = 0;
int ret = -1;
cJSON dummy;
for (i = 0; i < cmd_cnt; i++) {
cJSON *item = cJSON_GetObjectItem(json, cmd[i].json_string);
if (NULL == item && (1 == cmd[i].empty_allowed)) {
@@ -1088,32 +1088,17 @@ int json2iris(const char *json_buff, const char *json_filename,
tmp_obj = cJSON_GetObjectItem(json, "compile_table");
if (tmp_obj) {
compile_tbl_name = tmp_obj->valuestring;
} else {
log_error(logger, MODULE_JSON2IRIS,
"[%s:%d] json file:%s has no [compile_table] field",
__FUNCTION__, __LINE__, json_filename);
goto error_out;
}
}
tmp_obj = cJSON_GetObjectItem(json, "group2compile_table");
if (tmp_obj) {
group2compile_tbl_name = tmp_obj->valuestring;
} else {
log_error(logger, MODULE_JSON2IRIS,
"[%s:%d] json file:%s has no [group2compile_table] field",
__FUNCTION__, __LINE__, json_filename);
goto error_out;
}
}
tmp_obj = cJSON_GetObjectItem(json, "group2group_table");
if (tmp_obj) {
group2group_tbl_name = tmp_obj->valuestring;
} else {
log_error(logger, MODULE_JSON2IRIS,
"[%s:%d] json file:%s has no [group2group_table] field",
__FUNCTION__, __LINE__, json_filename);
goto error_out;
}
}
ret = set_iris_descriptor(json_filename, json, encrypt_key, encrypt_algo,
compile_tbl_name, group2compile_tbl_name,

View File

@@ -26,6 +26,7 @@ void maat_tool_print_usage(void)
printf("\t-p [port], redis port, 6379 as default.\n");
printf("\t-n [db], redis db, 0 as default.\n");
printf("\t-d [dir], dump rules from redis to [dir], %s as default.\n", redis_dump_dir);
printf("\t-u [dir], flush redis and upload full rules to redis, confirm the risk before proceeding\n");
printf("\t-v [version], dump specific [version] from redis, dump latest version as default.\n");
printf("\t-j [payload.json], add or delete rules as maat json. Must have field compile_table field, and plugin table's valid flag must be in the last column.\n");
printf("\t-t [timeout], timeout config after t seconds, default is 0 which means never timeout.\n");