summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangyang <[email protected]>2024-04-24 06:35:56 -0400
committerzhangyang <[email protected]>2024-04-24 06:35:56 -0400
commit692770ddee810312f71de078b85406c66c78ccde (patch)
tree1af8803aec72e653892073fb8bb7473f4e0adee2
parent99e44515969e4fc9a0fa47a4772fc47e1e560911 (diff)
remove demo3
-rw-r--r--demo3/CMakeLists.txt8
-rw-r--r--demo3/maat_json.json34
-rw-r--r--demo3/main.c56
-rw-r--r--demo3/table_info.conf52
4 files changed, 0 insertions, 150 deletions
diff --git a/demo3/CMakeLists.txt b/demo3/CMakeLists.txt
deleted file mode 100644
index 62f21f6..0000000
--- a/demo3/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Set the minimum version of CMake that can be used
-cmake_minimum_required(VERSION 3.10)
-
-# Define a new project
-project(Demo1)
-
-# Add an executable
-add_executable(Demo1 main.c) \ No newline at end of file
diff --git a/demo3/maat_json.json b/demo3/maat_json.json
deleted file mode 100644
index b6f140c..0000000
--- a/demo3/maat_json.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "compile_table": "COMPILE_DEFAULT",
- "group2compile_table": "GROUP2COMPILE_DEFAULT",
- "group2group_table": "GROUP2GROUP",
- "rules": [
- {
- "compile_id": 123,
- "service": 1,
- "action": 1,
- "do_blacklist": 1,
- "do_log": 1,
- "user_region": "escaped\\bdata:have\\ba\\bspace\\band\\ba\\b\\&\\bsymbol.",
- "is_valid": "yes",
- "groups": [
- {
- "group_name": "ASN1234",
- "group_id": 1,
- "regions": [
- {
- "table_name": "AS_NUMBER",
- "table_type": "expr",
- "table_content": {
- "keywords": "AS1234",
- "expr_type": "none",
- "match_method": "exact",
- "format": "uncase plain"
- }
- }
- ]
- }
- ]
- }
- ]
-} \ No newline at end of file
diff --git a/demo3/main.c b/demo3/main.c
deleted file mode 100644
index 1cf9fe9..0000000
--- a/demo3/main.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "maat.h"
-#include "stdio.h"
-#include <assert.h>
-#include <stddef.h>
-#include <string.h>
-
-#define ARRAY_SIZE 16
-
-const char *json_filename = "/root/Git/demo/demo3/maat_json.json";
-const char *table_info_path = "/root/Git/demo/demo3/table_info.conf";
-
-int main()
-{
- // 输出 pwd
- // char pwd[1024] = {0};
- // getcwd(pwd, sizeof(pwd));
- // printf("pwd: %s\n", pwd);
-
- /* initialize maat options which will be used by maat_new() */
- struct maat_options *opts = maat_options_new();
- maat_options_set_json_file(opts, json_filename);
- maat_options_set_logger(opts, "/root/Git/demo/demo3/sample_test.log", LOG_LEVEL_TRACE);
-
- /* create maat instance, rules in table_info.conf will be loaded. */
- struct maat *maat_instance = maat_new(opts, table_info_path);
- assert(maat_instance != NULL);
- maat_options_free(opts);
-
- const char *table_name = "AS_NUMBER"; /* maat_json.json has HTTP_URL rule */
- int table_id = maat_get_table_id(maat_instance, table_name);
- assert(table_id == 3); /* defined in table_info.conf */
-
- int thread_id = 0;
- long long results[ARRAY_SIZE] = {0};
- size_t n_hit_result = 0;
-
- /* store scanning intermediate state */
- struct maat_state *state = maat_state_new(maat_instance, thread_id);
- assert(state != NULL);
-
- const char *src_asn1 = "AS1234";
-
- /**
- * Becase maat instance has loaded rule in table_info.conf which keywords is "Hello Maat",
- so maat_scan_string should return hit flag and rule's compile_id stored in results array.
- */
- int ret = maat_scan_string(maat_instance, table_id, src_asn1, strlen(src_asn1), results, ARRAY_SIZE,
- &n_hit_result, state);
- assert(ret == MAAT_SCAN_HIT);
- assert(n_hit_result == 1);
- assert(results[0] == 123);
-
- maat_state_free(state);
-
- return 0;
-}
diff --git a/demo3/table_info.conf b/demo3/table_info.conf
deleted file mode 100644
index 3eccb12..0000000
--- a/demo3/table_info.conf
+++ /dev/null
@@ -1,52 +0,0 @@
-[
- {
- "table_id":0,
- "table_name":"COMPILE_DEFAULT",
- "table_type":"compile",
- "valid_column":7,
- "custom": {
- "compile_id":1,
- "tags":6,
- "clause_num":8
- }
- },
- {
- "table_id":1,
- "table_name":"GROUP2COMPILE_DEFAULT",
- "table_type":"group2compile",
- "associated_compile_table_id":0,
- "valid_column":6,
- "custom": {
- "group_id":1,
- "compile_id":2,
- "not_flag":3,
- "virtual_table_name":4,
- "clause_index":5
- }
- },
- {
- "table_id":2,
- "table_name":"GROUP2GROUP",
- "table_type":"group2group",
- "valid_column":4,
- "custom": {
- "group_id":1,
- "included_sub_group_ids":2,
- "excluded_sub_group_ids":3
- }
- },
- {
- "table_id":3,
- "table_name":"AS_NUMBER",
- "table_type":"expr",
- "valid_column":7,
- "custom": {
- "item_id":1,
- "group_id":2,
- "keywords":3,
- "expr_type":4,
- "match_method":5,
- "is_hexbin":6
- }
- }
-] \ No newline at end of file