虚拟表功能单元测试通过。

This commit is contained in:
zhengchao
2019-07-28 15:00:24 +06:00
parent 4c4222a302
commit 484637060d
3 changed files with 74 additions and 4 deletions

View File

@@ -298,7 +298,7 @@
"is_valid": "yes", "is_valid": "yes",
"groups": [ "groups": [
{ {
"group_name": "Untitled", "group_name": "TakeMeHome",
"regions": [ "regions": [
{ {
"table_name": "KEYWORDS_TABLE", "table_name": "KEYWORDS_TABLE",
@@ -1141,8 +1141,40 @@
], ],
"not_flag" : 0 "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": [ "plugin_table": [
{ {

View File

@@ -13,6 +13,9 @@
#For plugin table. The first column's id is 1. 0 as not speicified. #For plugin table. The first column's id is 1. 0 as not speicified.
#id name type column_define #id name type column_define
# #
#For virtual Table
#id name type real_table_name
#
#For expr/expr_plus Table #For expr/expr_plus Table
#id name type src_charset dst_charset do_merge cross_cache quick_mode #id name type src_charset dst_charset do_merge cross_cache quick_mode
0 COMPILE compile escape -- 0 COMPILE compile escape --
@@ -35,4 +38,5 @@
16 APP_PAYLOAD expr_plus UTF8 UTF8 yes 0 quickoff 16 APP_PAYLOAD expr_plus UTF8 UTF8 yes 0 quickoff
17 TROJAN_PAYLOAD expr UTF8 UTF8 yes 0 quickoff 17 TROJAN_PAYLOAD expr UTF8 UTF8 yes 0 quickoff
18 MAIL_ADDR expr UTF8 UTF8 yes 0 quickoff 18 MAIL_ADDR expr UTF8 UTF8 yes 0 quickoff
19 IP_PLUS_CONFIG ip_plus -- 19 IP_PLUS_CONFIG ip_plus --
20 HTTP_RESPONSE_KEYWORDS virtual KEYWORDS_TABLE --

View File

@@ -1462,6 +1462,40 @@ TEST(ScanResult, LongerServiceDefine)
free(buff); free(buff);
return; 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 class MaatFileTest : public testing::Test
{ {