为刘梦岩2021-5-15提出的IPv6误命中bug,增加单元测试用例。该问题已在rulescan_VERSION_2020_12_20、MAAT_FRAME_VERSION_3_1_21_20210513重现。

This commit is contained in:
zhengchao
2021-05-17 20:07:51 +08:00
parent 85daf06a79
commit a58baa274f
2 changed files with 66 additions and 2 deletions

View File

@@ -1997,6 +1997,41 @@
] ]
} }
] ]
},
{
"compile_id": 184,
"user_region": "APP_ID=6006740;Liumengyan-Bugreport-20210515",
"description": "Hulu",
"is_valid": "yes",
"do_blacklist": 0,
"do_log": 0,
"action": 0,
"service": 0,
"groups": [
{
"group_name": "Untitled",
"regions": [
{
"table_name": "IP_CONFIG",
"table_type": "ip",
"table_content": {
"protocol": 0,
"addr_type": "ipv6",
"direction": "double",
"src_ip": "::",
"dst_ip": "2620:100:3000::",
"src_port": "0",
"dst_port": "0",
"mask_src_port": "65535",
"mask_src_ip": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
"mask_dst_port": "65535",
"mask_dst_ip": "ffff:ffff:ff00:0000:0000:0000:0000:0000"
}
}
]
}
]
} }
], ],
"plugin_table": [ "plugin_table": [
@@ -2040,7 +2075,8 @@
"101\t4\t192.168.30.99\t192.168.30.101\tSomething-like-json\t1", "101\t4\t192.168.30.99\t192.168.30.101\tSomething-like-json\t1",
"102\t4\t192.168.30.90\t192.168.30.128\tBigger-range-should-in-the-back\t1", "102\t4\t192.168.30.90\t192.168.30.128\tBigger-range-should-in-the-back\t1",
"103\t6\t2001:db8:1234::\t2001:db8:1235::\tBigger-range-should-in-the-back\t1", "103\t6\t2001:db8:1234::\t2001:db8:1235::\tBigger-range-should-in-the-back\t1",
"104\t6\t2001:db8:1234::1\t2001:db8:1234::5210\tSomething-like-json\t1" "104\t6\t2001:db8:1234::1\t2001:db8:1234::5210\tSomething-like-json\t1",
"105\t6\t2620:100:3000::\t2620:0100:30ff:ffff:ffff:ffff:ffff:ffff\tBugreport-liumengyan-20210517\t1"
] ]
}, },
{ {

View File

@@ -292,7 +292,7 @@ TEST(IP_Plugin_Table, EX_DATA)
ip_plugin_EX_dup_cb, ip_plugin_EX_dup_cb,
0, &ip_plugin_ex_data_counter); 0, &ip_plugin_ex_data_counter);
ASSERT_TRUE(ret>=0); ASSERT_TRUE(ret>=0);
EXPECT_EQ(ip_plugin_ex_data_counter, 4); EXPECT_EQ(ip_plugin_ex_data_counter, 5);
struct ip_address ipv4, ipv6; struct ip_address ipv4, ipv6;
struct ip_plugin_ud* result[4]; struct ip_plugin_ud* result[4];
ipv4.ip_type=4; ipv4.ip_type=4;
@@ -315,6 +315,10 @@ TEST(IP_Plugin_Table, EX_DATA)
{ {
ip_plugin_EX_free_cb(0, (void**)&(result[i]), 0, NULL); ip_plugin_EX_free_cb(0, (void**)&(result[i]), 0, NULL);
} }
//Reproduce BugReport-Liumengyan-20210515
inet_pton(AF_INET6,"240e:97c:4010:104::17",&(ipv6.ipv6));
ret=Maat_ip_plugin_get_EX_data(g_feather, table_id, &ipv6, (void**)result, 4);
ASSERT_EQ(ret, 0);
} }
@@ -970,6 +974,30 @@ TEST(IPScan, IPv4_composition)
Maat_clean_status(&mid); Maat_clean_status(&mid);
return; return;
} }
TEST(IPScan, BugReport20210515)
{
//By Liu Mengyan 2021-5-15
int table_id=0,ret=0;
struct Maat_rule_t result[4];
struct ipaddr ipv6_addr;
struct stream_tuple4_v6 v6_addr;
scan_status_t mid=NULL;
ipv6_addr.addrtype=ADDR_TYPE_IPV6;
inet_pton(AF_INET6,"2409:8915:3430:7e7:8c9b:ff2a:7aa1:e74",&(v6_addr.saddr));
v6_addr.source=htons(41159);
inet_pton(AF_INET6,"240e:97c:4010:104::17",&(v6_addr.daddr));
v6_addr.dest=htons(7706);
ipv6_addr.v6=&v6_addr;
const char* table_name="IP_CONFIG";
table_id=Maat_table_register(g_feather, table_name);
EXPECT_GT(table_id, 0);
ret=Maat_scan_proto_addr(g_feather, table_id, &ipv6_addr, 6, result, 4, &mid, 0);
EXPECT_EQ(ret, 0);
Maat_clean_status(&mid);
return;
}
#define TEST_NOTLogic 1 #define TEST_NOTLogic 1