From a58baa274f52677e1679863202b918b837fe914c Mon Sep 17 00:00:00 2001 From: zhengchao Date: Mon, 17 May 2021 20:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=88=98=E6=A2=A6=E5=B2=A92021-5-15?= =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=9A=84IPv6=E8=AF=AF=E5=91=BD=E4=B8=ADbug?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E3=80=82=E8=AF=A5=E9=97=AE=E9=A2=98=E5=B7=B2?= =?UTF-8?q?=E5=9C=A8rulescan=5FVERSION=5F2020=5F12=5F20=E3=80=81MAAT=5FFRA?= =?UTF-8?q?ME=5FVERSION=5F3=5F1=5F21=5F20210513=E9=87=8D=E7=8E=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/maat_json.json | 38 +++++++++++++++++++++++++++++++++++++- test/test_maatframe.cpp | 30 +++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/test/maat_json.json b/test/maat_json.json index 29495f8..7880ede 100644 --- a/test/maat_json.json +++ b/test/maat_json.json @@ -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": [ @@ -2040,7 +2075,8 @@ "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", "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" ] }, { diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index 745ee26..4755d6f 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -292,7 +292,7 @@ TEST(IP_Plugin_Table, EX_DATA) ip_plugin_EX_dup_cb, 0, &ip_plugin_ex_data_counter); 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_plugin_ud* result[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); } + //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); 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