refactor hierarchy and maat_table

This commit is contained in:
liuwentan
2023-01-31 20:39:53 +08:00
parent 25f944a1d1
commit cca7d882e1
29 changed files with 1087 additions and 1107 deletions

View File

@@ -3,6 +3,7 @@
#include "maat_utils.h"
#include "maat_rule.h"
#include "json2iris.h"
#include "maat_table.h"
#include "maat_config_monitor.h"
#include <gtest/gtest.h>
@@ -37,7 +38,7 @@ TEST(json_mode, maat_scan_string) {
size_t n_hit_result = 0;
struct maat_state *state = NULL;
int ret = maat_scan_string(maat_instance, table_id, 0, scan_data, strlen(scan_data), results, sizeof(results), &n_hit_result, &state);
EXPECT_EQ(ret, 0);
EXPECT_EQ(ret, MAAT_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 191);
@@ -80,7 +81,7 @@ TEST(iris_mode, maat_scan_string) {
size_t n_hit_result = 0;
struct maat_state *state = NULL;
int ret = maat_scan_string(maat_instance, table_id, 0, scan_data, strlen(scan_data), results, sizeof(results), &n_hit_result, &state);
EXPECT_EQ(ret, 0);
EXPECT_EQ(ret, MAAT_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 191);
@@ -193,14 +194,14 @@ TEST(redis_mode, maat_scan_string) {
maat_options_set_logger(opts, logger);
struct maat *maat_instance = maat_new(opts, table_info_path);
int table_id = table_manager_get_table_id(maat_instance->tbl_mgr "HTTP_URL");
int table_id = table_manager_get_table_id(maat_instance->tbl_mgr, "HTTP_URL");
char scan_data[128] = "hello";
int results[5] = {0};
size_t n_hit_result = 0;
struct maat_state *state = NULL;
int ret = maat_scan_string(maat_instance, table_id, 0, scan_data, strlen(scan_data), results, sizeof(results), &n_hit_result, &state);
EXPECT_EQ(ret, 0);
EXPECT_EQ(ret, MAAT_HIT);
EXPECT_EQ(n_hit_result, 1);
EXPECT_EQ(results[0], 191);