diff --git a/tools/maat_debug_tool.cpp b/tools/maat_debug_tool.cpp index 5b8d3be..5697bab 100644 --- a/tools/maat_debug_tool.cpp +++ b/tools/maat_debug_tool.cpp @@ -2,16 +2,42 @@ #include "Maat_command.h" #include +#include #include /* for printf */ #include /* for exit */ #include #include +#include +void debug_maat_result_print(const char* table_name, int scan_ret, struct Maat_rule_t* result) +{ + printf("Scan table %s ", table_name); + if(scan_ret==-1) + { + printf("error.\n"); + } + else if(scan_ret==-2) + { + printf("hits group, but not compile.\n"); + } + else if(scan_ret==0) + { + printf("not hit."); + } + else + { + printf("hits "); + for(int i=0; i0) { - printf("Read %s failed, invalid maat json.\n", arg_value[ARG_INPUT_JSON]); + ret=Maat_set_feather_opt(feather, MAAT_OPT_JSON_FILE_PATH, arg_value[ARG_INPUT_JSON], strlen(arg_value[ARG_INPUT_JSON])+1); + if(ret!=0) + { + printf("Read %s failed, invalid maat json.\n", arg_value[ARG_INPUT_JSON]); + ret=-1; + goto clean_up; + } + } + else if(strlen(arg_value[ARG_INPUT_FULL_INDEX])) + { + ret=Maat_set_feather_opt(feather, MAAT_OPT_FULL_CFG_DIR, arg_value[ARG_INPUT_FULL_INDEX], strlen(arg_value[ARG_INPUT_FULL_INDEX])+1); + if(ret!=0) + { + printf("Set %s failed, invalid maat json.\n", arg_value[ARG_INPUT_FULL_INDEX]); + ret=-1; + goto clean_up; + } + } + else + { + printf("Error: One of --%s and --%s should be specified.\n", long_options[ARG_INPUT_JSON].name, long_options[ARG_INPUT_FULL_INDEX].name); ret=-1; goto clean_up; } @@ -165,6 +221,10 @@ int main(int argc, char ** argv) debug_maat_str_scan(feather, arg_value[ARG_TABLE_NAME], arg_value[ARG_SCAN_DISTRICT], file_buff, file_size); free(file_buff); } + if(strlen(arg_value[ARG_SCAN_IPv4])>0) + { + debug_maat_ip_scan(feather, arg_value[ARG_TABLE_NAME], arg_value[ARG_SCAN_IPv4]); + } clean_up: Maat_burn_feather(feather); MESA_destroy_runtime_log_handle(g_logger);