diff --git a/test/maat_json.json b/test/maat_json.json index ee03144..47da2f5 100644 --- a/test/maat_json.json +++ b/test/maat_json.json @@ -298,7 +298,7 @@ "is_valid": "yes", "groups": [ { - "group_name": "Untitled", + "group_name": "TakeMeHome", "regions": [ { "table_name": "KEYWORDS_TABLE", @@ -1141,8 +1141,40 @@ ], "not_flag" : 0 } - ] - } + ] + }, + { + "compile_id": 160, + "service": 0, + "action": 0, + "do_blacklist": 0, + "do_log": 0, + "effective_rage": 0, + "user_region": "Virtual", + "is_valid": "yes", + "groups": [ + { + "group_name":"TakeMeHome", + "virtual_table":"HTTP_RESPONSE_KEYWORDS", + "not_flag" : 0 + }, + { + "not_flag":0, + "regions": [ + { + "table_name": "HTTP_URL", + "table_type": "string", + "table_content": { + "keywords": "https://blog.csdn.net/littlefang/article/details/8213058", + "expr_type": "none", + "match_method": "sub", + "format": "uncase plain" + } + } + ] + } + ] + } ], "plugin_table": [ { diff --git a/test/table_info.conf b/test/table_info.conf index 5119ef6..e960a64 100644 --- a/test/table_info.conf +++ b/test/table_info.conf @@ -13,6 +13,9 @@ #For plugin table. The first column's id is 1. 0 as not speicified. #id name type column_define # +#For virtual Table +#id name type real_table_name +# #For expr/expr_plus Table #id name type src_charset dst_charset do_merge cross_cache quick_mode 0 COMPILE compile escape -- @@ -35,4 +38,5 @@ 16 APP_PAYLOAD expr_plus UTF8 UTF8 yes 0 quickoff 17 TROJAN_PAYLOAD expr UTF8 UTF8 yes 0 quickoff 18 MAIL_ADDR expr UTF8 UTF8 yes 0 quickoff -19 IP_PLUS_CONFIG ip_plus -- \ No newline at end of file +19 IP_PLUS_CONFIG ip_plus -- +20 HTTP_RESPONSE_KEYWORDS virtual KEYWORDS_TABLE -- \ No newline at end of file diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index 64f062e..15b3edc 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -1462,6 +1462,40 @@ TEST(ScanResult, LongerServiceDefine) free(buff); return; } +TEST(VirtualTable, Test1) +{ +#define TestVirtualTable + int ret=0, table_id=0; + const char* http_content="Batman\\:Take me Home.Superman/:Fine,stay with me."; + const char* http_url="https://blog.csdn.net/littlefang/article/details/8213058"; + + struct Maat_rule_t result[4]; + memset(result, 0, sizeof(result)); + + scan_status_t mid=NULL; + + table_id=Maat_table_register(g_feather, "HTTP_URL"); + ASSERT_GT(table_id, 0); + + ret=Maat_full_scan_string(g_feather, table_id, CHARSET_GBK, http_url, strlen(http_url), + result, NULL, 4, &mid, 0); + + EXPECT_EQ(ret, -2); + + + table_id=Maat_table_register(g_feather, "HTTP_RESPONSE_KEYWORDS"); + ASSERT_GT(table_id, 0); + + ret=Maat_full_scan_string(g_feather, table_id, CHARSET_GBK, http_content, strlen(http_content), + result, NULL, 4, &mid, 0); + + EXPECT_EQ(ret, 1); + EXPECT_EQ(result[0].config_id, 160); + + Maat_clean_status(&mid); + return; +} + class MaatFileTest : public testing::Test {