增加非表达式测试用例:对于compile {url!=a&ip=b}, 先扫非条件(url不命中),后扫命中条件(ip命中)
This commit is contained in:
@@ -762,8 +762,7 @@ TEST(IPScan, IPv6_mask)
|
||||
table_id=Maat_table_register(g_feather,table_name);
|
||||
EXPECT_GT(table_id, 0);
|
||||
|
||||
//for improving performance.
|
||||
Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_LAST_REGION,NULL, 0);
|
||||
Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_LAST_REGION, NULL, 0);
|
||||
ret=Maat_scan_proto_addr(g_feather,table_id,&ipv6_addr,6,result,4, &mid,0);
|
||||
EXPECT_EQ(ret, -2);
|
||||
Maat_clean_status(&mid);
|
||||
@@ -1111,9 +1110,48 @@ TEST(NOTLogic, ScanIrrelavantAtLast)
|
||||
result,found_pos, 4, &mid, 0);
|
||||
|
||||
EXPECT_EQ(ret, 1);
|
||||
EXPECT_EQ(result[0].config_id, 144);
|
||||
Maat_clean_status(&mid);
|
||||
|
||||
}
|
||||
TEST(NOTLogic, ScanHitAtLast)
|
||||
{
|
||||
const char* string_should_not_hit="This string should not hit.";
|
||||
int ret=0;
|
||||
int table_id=0;
|
||||
struct Maat_rule_t result[4];
|
||||
int found_pos[4];
|
||||
const char* not_hit_table_name="HTTP_URL", *hit_table_name="IP_PLUS_CONFIG";
|
||||
scan_status_t mid=NULL;
|
||||
table_id=Maat_table_register(g_feather, not_hit_table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
ret=Maat_full_scan_string(g_feather, table_id, CHARSET_GBK, string_should_not_hit, strlen(string_should_not_hit),
|
||||
result, found_pos, 4, &mid, 0);
|
||||
EXPECT_GE(ret, 0);
|
||||
|
||||
struct ipaddr ipv4_addr;
|
||||
struct stream_tuple4_v4 v4_addr;
|
||||
ipv4_addr.addrtype=ADDR_TYPE_IPV4;
|
||||
inet_pton(AF_INET,"10.0.8.18",&(v4_addr.saddr));
|
||||
v4_addr.source=htons(18611);
|
||||
inet_pton(AF_INET,"10.0.8.20",&(v4_addr.daddr));
|
||||
v4_addr.dest=htons(80);
|
||||
ipv4_addr.v4=&v4_addr;
|
||||
|
||||
table_id=Maat_table_register(g_feather, hit_table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_LAST_REGION, NULL, 0);
|
||||
ret=Maat_scan_proto_addr(g_feather, table_id, &ipv4_addr, 6, result, 4, &mid,0);
|
||||
|
||||
|
||||
EXPECT_EQ(ret, 1);
|
||||
EXPECT_EQ(result[0].config_id, 186);
|
||||
Maat_clean_status(&mid);
|
||||
|
||||
}
|
||||
|
||||
TEST(NOTLogic, ScanNotIP)
|
||||
{
|
||||
const char* string_should_hit="This string ONLY contains must-contained-string-of-rule-145.";
|
||||
|
||||
Reference in New Issue
Block a user