From ecc646e4d8ed5f39cb60128490f9b32b1658fc5d Mon Sep 17 00:00:00 2001 From: zhengchao Date: Tue, 22 Jan 2019 19:44:10 +0600 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0regex=20\s=E8=BD=AC=E4=B9=89?= =?UTF-8?q?=E7=9A=84=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/maat_json.json | 25 +++++++++++++++++++++++++ test/test_maatframe.cpp | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/test/maat_json.json b/test/maat_json.json index a13ec5f..c53863a 100644 --- a/test/maat_json.json +++ b/test/maat_json.json @@ -685,6 +685,31 @@ "group_name": "IP_group" } ] + }, + { + "compile_id": 146, + "service": 1, + "action": 1, + "do_blacklist": 1, + "do_log": 1, + "user_region": "anything", + "is_valid": "yes", + "groups": [ + { + "regions": [ + { + "table_name": "HTTP_URL", + "table_type": "string", + "table_content": { + "keywords": "Cookie:\\s&head", + "expr_type": "regex", + "match_method": "sub", + "format": "uncase plain" + } + } + ] + } + ] } ], "plugin_table": [ diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index 1e13b58..cd09862 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -212,6 +212,7 @@ TEST(PluginTable, Callback) g_logger); } + TEST(StringScan, Full) { int ret=0; @@ -230,6 +231,25 @@ TEST(StringScan, Full) EXPECT_GE(ret, 1); Maat_clean_status(&mid); } +TEST(StringScan, Regex) +{ + int ret=0; + int table_id=0; + struct Maat_rule_t result[4]; + int found_pos[4]; + const char* table_name="HTTP_URL"; + scan_status_t mid=NULL; + const char* scan_data="Cookie: Txa123aheadBCAxd"; + table_id=Maat_table_register(g_feather,table_name); + ASSERT_GT(table_id, 0); + + ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, scan_data, strlen(scan_data), + result,found_pos, 4, &mid, 0); + + EXPECT_GE(ret, 1); + EXPECT_EQ(result[0].config_id, 146); + Maat_clean_status(&mid); +} TEST(IPScan, IPv4) {