From 3b049f2f13d7aa54156248e497b5d6cfb5425d9a Mon Sep 17 00:00:00 2001 From: zhengchao Date: Wed, 19 Jun 2019 15:15:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8BExprPlusWithHex=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/maat_json.json | 27 +++++++++++++++++++++++++++ test/table_info.conf | 2 +- test/test_maatframe.cpp | 32 +++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/test/maat_json.json b/test/maat_json.json index aab8dce..75ef9c1 100644 --- a/test/maat_json.json +++ b/test/maat_json.json @@ -1013,6 +1013,33 @@ "not_flag" : 0 } ] + }, + { + "compile_id": 156, + "service": 1, + "action": 1, + "do_blacklist": 1, + "do_log": 1, + "user_region": "ExprPlusWithHex", + "is_valid": "yes", + "groups": [ + { + "group_name": "Untitled", + "regions": [ + { + "table_name": "HTTP_REGION", + "table_type": "expr_plus", + "table_content": { + "district": "Content-Type", + "keywords": "2f68746d6c", + "expr_type": "none", + "match_method": "sub", + "format": "hexbin" + } + } + ] + } + ] } ], "plugin_table": [ diff --git a/test/table_info.conf b/test/table_info.conf index 22c683e..5119ef6 100644 --- a/test/table_info.conf +++ b/test/table_info.conf @@ -24,7 +24,7 @@ 5 CONTENT_SIZE intval -- 6 QD_ENTRY_INFO plugin 4 -- 7 FILE_DIGEST digest -- -8 HTTP_REGION expr_plus GBK GBK no 0 +8 HTTP_REGION expr_plus GBK GBK yes 0 9 SIM_URL similar -- 10 IMAGE_FP expr UTF8 UTF8 yes 128 quickoff 11 TEST_EFFECTIVE_RANGE_TABLE plugin {"valid":4,"tag":5} -- diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index 9ef93f3..b89ceb6 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -347,7 +347,7 @@ TEST(StringScan, PrefixAndSuffix) Maat_clean_status(&mid); } - +#define ExprPlusTest 1 TEST(StringScan, ExprPlus) { int ret=0; @@ -371,6 +371,8 @@ TEST(StringScan, ExprPlus) &mid, 0); EXPECT_EQ(ret, 1); EXPECT_EQ(result[0].config_id, 128); + + Maat_clean_status(&mid); return; } @@ -422,8 +424,34 @@ TEST(StringScan, ExprPlusWithOffset) &mid, 0); EXPECT_EQ(ret, 1); EXPECT_EQ(result[0].config_id, 148); + + Maat_clean_status(&mid); return; } + +TEST(StringScan, ExprPlusWithHex) +{ + int table_id=0,ret=0; + struct Maat_rule_t result[4]; + const char* scan_data="text/html; charset=UTF-8"; + const char* region_name="Content-Type"; + int found_pos[4]; + table_id=Maat_table_register(g_feather, "HTTP_REGION"); + ASSERT_GT(table_id, 0); + scan_status_t mid=NULL; + ret=Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_DISTRICT, region_name, strlen(region_name)); + ASSERT_EQ(ret, 0); + ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, scan_data, strlen(scan_data), + result, found_pos, 4, + &mid, 0); + EXPECT_EQ(ret, 1); + EXPECT_EQ(result[0].config_id, 156); + Maat_clean_status(&mid); + + return; + +} + TEST(IPScan, IPv4_mask) { int table_id=0,ret=0; @@ -908,6 +936,8 @@ TEST(StringScan, StreamInput) Maat_clean_status(&mid); return; } + + TEST(SimilarScan, Pure) { int ret=0;