TSG-23303 Negate hit path fix

TSG-23330 Statistics strategy complile table name changed
TSG-23363 Using incorrect judgment results in duplicate objects
This commit is contained in:
fengweihao
2024-11-05 11:57:39 +08:00
parent cb35a2b92b
commit ef4658d38d
5 changed files with 23 additions and 24 deletions

View File

@@ -296,7 +296,7 @@ void attribute_dict_free(struct attribute_dict_ctx *dict_ctx);
const char *get_conjunction_table_name(enum policy_rule_type rule_type) const char *get_conjunction_table_name(enum policy_rule_type rule_type)
{ {
const char *conjunction_table_name_map[] = {"SECURITY_RULE_CONJUNCTION", "PXY_CTRL_RULE_CONJUNCTION", "TRAFFIC_SHAPING_RULE_CONJUNCTION", const char *conjunction_table_name_map[] = {"SECURITY_RULE_CONJUNCTION", "PXY_CTRL_RULE_CONJUNCTION", "TRAFFIC_SHAPING_RULE_CONJUNCTION",
"SERVICE_CHAINING_RULE_CONJUNCTION", "PXY_INTERCEPT_RULE_CONJUNCTION","STATISTICS_COMPILE_CONJUNCTION", "SERVICE_CHAINING_RULE_CONJUNCTION", "PXY_INTERCEPT_RULE_CONJUNCTION","STATISTICS_RULE_CONJUNCTION",
"MONITOR_RULE_CONJUNCTION", "DOS_PROTECTION_RULE_CONJUNCTION", "TUNNEL_RULE_CONJUNCTION"}; "MONITOR_RULE_CONJUNCTION", "DOS_PROTECTION_RULE_CONJUNCTION", "TUNNEL_RULE_CONJUNCTION"};
size_t table_name_map_len = sizeof(conjunction_table_name_map)/sizeof(conjunction_table_name_map[0]); size_t table_name_map_len = sizeof(conjunction_table_name_map)/sizeof(conjunction_table_name_map[0]);
@@ -311,7 +311,7 @@ const char *get_conjunction_table_name(enum policy_rule_type rule_type)
const char *get_plugin_table_name(enum policy_rule_type rule_type) const char *get_plugin_table_name(enum policy_rule_type rule_type)
{ {
const char *plugin_table_name_map[] = {"SECURITY_RULE_PLUGIN", "PXY_CTRL_RULE_PLUGIN", "TRAFFIC_SHAPING_RULE_PLUGIN", const char *plugin_table_name_map[] = {"SECURITY_RULE_PLUGIN", "PXY_CTRL_RULE_PLUGIN", "TRAFFIC_SHAPING_RULE_PLUGIN",
"SERVICE_CHAINING_RULE_PLUGIN", "PXY_INTERCEPT_RULE_PLUGIN", "STATISTICS_COMPILE_PLUGIN", "SERVICE_CHAINING_RULE_PLUGIN", "PXY_INTERCEPT_RULE_PLUGIN", "STATISTICS_RULE_PLUGIN",
"MONITOR_RULE_PLUGIN", "DOS_PROTECTION_RULE_PLUGIN", "TUNNEL_RULE_PLUGIN"}; "MONITOR_RULE_PLUGIN", "DOS_PROTECTION_RULE_PLUGIN", "TUNNEL_RULE_PLUGIN"};
size_t table_name_map_len = sizeof(plugin_table_name_map)/sizeof(plugin_table_name_map[0]); size_t table_name_map_len = sizeof(plugin_table_name_map)/sizeof(plugin_table_name_map[0]);
@@ -1160,7 +1160,7 @@ int hit_rule_match_is_duplicate(struct maat_hit_path *src, struct maat_hit_path
{ {
for(int i = 0; i < result_cnt; i++) for(int i = 0; i < result_cnt; i++)
{ {
if(src[i].top_object_uuid == dest.top_object_uuid) if(uuid_compare(src[i].top_object_uuid, dest.top_object_uuid) == 0)
{ {
return 1; return 1;
} }
@@ -1262,11 +1262,11 @@ void http_get_scan_status(struct request_object_list *request_object, int compil
break; break;
} }
if(ctx->hit_path[i].item_uuid < 0) if( ctx->hit_path[i].negate_option == 1)
{ {
continue; continue;
} }
histObj=cJSON_CreateObject(); histObj=cJSON_CreateObject();
cJSON_AddItemToArray(hitPaths, histObj); cJSON_AddItemToArray(hitPaths, histObj);
cJSON_AddUuidToObject(histObj, "item_uuid", ctx->hit_path[i].item_uuid); cJSON_AddUuidToObject(histObj, "item_uuid", ctx->hit_path[i].item_uuid);
@@ -2490,10 +2490,10 @@ int tsg_policy_type_str2idx(const char *action_str)
{ {
const char * policy_name[__SCAN_POLICY_MAX]; const char * policy_name[__SCAN_POLICY_MAX];
policy_name[TSG_TABLE_SECURITY] = "security"; policy_name[TSG_TABLE_SECURITY] = "security";
policy_name[PXY_TABLE_MANIPULATION] = "pxy_manipulation"; policy_name[PXY_TABLE_MANIPULATION] = "proxy_manipulation";
policy_name[TSG_TRAFFIC_SHAPING] = "traffic_shaping"; policy_name[TSG_TRAFFIC_SHAPING] = "traffic_shaping";
policy_name[TSG_SERVICE_CHAINGNG] = "service_chaining"; policy_name[TSG_SERVICE_CHAINGNG] = "service_chaining";
policy_name[PXY_TABLE_INTERCEPT] = "pxy_intercept"; policy_name[PXY_TABLE_INTERCEPT] = "proxy_intercept";
policy_name[TSG_STATISTICS] = "statistics"; policy_name[TSG_STATISTICS] = "statistics";
policy_name[TSG_MONITOR] = "monitor"; policy_name[TSG_MONITOR] = "monitor";
policy_name[DOS_PROTECTION] = "dos_protection"; policy_name[DOS_PROTECTION] = "dos_protection";
@@ -3048,7 +3048,7 @@ int maat_complie_plugin_table_init(int vsys_id)
{ {
int ret=0; int ret=0;
const char *plugin_table_name_map[] = {"SECURITY_RULE_PLUGIN", "PXY_CTRL_RULE_PLUGIN", "TRAFFIC_SHAPING_RULE_PLUGIN", const char *plugin_table_name_map[] = {"SECURITY_RULE_PLUGIN", "PXY_CTRL_RULE_PLUGIN", "TRAFFIC_SHAPING_RULE_PLUGIN",
"SERVICE_CHAINING_RULE_PLUGIN", "PXY_INTERCEPT_RULE_PLUGIN", "STATISTICS_COMPILE_PLUGIN", "SERVICE_CHAINING_RULE_PLUGIN", "PXY_INTERCEPT_RULE_PLUGIN", "STATISTICS_RULE_PLUGIN",
"MONITOR_RULE_PLUGIN", "DOS_PROTECTION_RULE_PLUGIN", "TUNNEL_RULE_PLUGIN"}; "MONITOR_RULE_PLUGIN", "DOS_PROTECTION_RULE_PLUGIN", "TUNNEL_RULE_PLUGIN"};
for(int i = 0; i < PXY_TABLE_DEFENCE; i++) for(int i = 0; i < PXY_TABLE_DEFENCE; i++)
{ {

View File

@@ -111,20 +111,20 @@
}, },
{ {
"table_id":15, "table_id":15,
"table_name":"STATISTICS_COMPILE", "table_name":"STATISTICS_RULE",
"table_type":"rule" "table_type":"rule"
}, },
{ {
"table_id":16, "table_id":16,
"table_name":"STATISTICS_COMPILE_CONJUNCTION", "table_name":"STATISTICS_RULE_CONJUNCTION",
"db_tables":["STATISTICS_COMPILE"], "db_tables":["STATISTICS_RULE"],
"default_rule_table":1, "default_rule_table":1,
"table_type":"rule" "table_type":"rule"
}, },
{ {
"table_id":17, "table_id":17,
"table_name":"STATISTICS_COMPILE_PLUGIN", "table_name":"STATISTICS_RULE_PLUGIN",
"db_tables":["STATISTICS_COMPILE"], "db_tables":["STATISTICS_RULE"],
"table_type":"plugin", "table_type":"plugin",
"custom": { "custom": {
"key_name":"uuid", "key_name":"uuid",

View File

@@ -5,7 +5,7 @@
"vsys": 1, "vsys": 1,
"verify_list": [ "verify_list": [
{ {
"type": "pxy_manipulation", "type": "proxy_manipulation",
"verify_session": { "verify_session": {
"attributes": [ "attributes": [
{ {
@@ -28,7 +28,7 @@
"vsys": 1, "vsys": 1,
"verify_list": [ "verify_list": [
{ {
"type": "pxy_manipulation", "type": "proxy_manipulation",
"verify_session": { "verify_session": {
"attributes": [ "attributes": [
{ {
@@ -147,7 +147,7 @@
"vsys": 1, "vsys": 1,
"verify_list": [ "verify_list": [
{ {
"type": "pxy_manipulation", "type": "proxy_manipulation",
"verify_session": { "verify_session": {
"attributes": [ "attributes": [
{ {
@@ -193,7 +193,7 @@
"vsys": 1, "vsys": 1,
"verify_list": [ "verify_list": [
{ {
"type": "pxy_manipulation", "type": "proxy_manipulation",
"verify_session": { "verify_session": {
"attributes": [ "attributes": [
{ {
@@ -242,7 +242,7 @@
"vsys": 1, "vsys": 1,
"verify_list": [ "verify_list": [
{ {
"type": "pxy_manipulation", "type": "proxy_manipulation",
"verify_session": { "verify_session": {
"attributes": [ "attributes": [
{ {
@@ -282,7 +282,7 @@
"vsys": 1, "vsys": 1,
"verify_list": [ "verify_list": [
{ {
"type": "pxy_manipulation", "type": "proxy_manipulation",
"verify_session": { "verify_session": {
"attributes": [ "attributes": [
{ {
@@ -356,7 +356,7 @@
"vsys": 1, "vsys": 1,
"verify_list": [ "verify_list": [
{ {
"type": "pxy_manipulation", "type": "proxy_manipulation",
"vsys": 1, "vsys": 1,
"verify_session": { "verify_session": {
"attributes": [ "attributes": [

View File

@@ -476,10 +476,6 @@
{ {
"item_uuid": "00000000-0000-0000-0000-000000000000", "item_uuid": "00000000-0000-0000-0000-000000000000",
"superior_object_uuid": "00003021-0000-0000-0000-000000000000" "superior_object_uuid": "00003021-0000-0000-0000-000000000000"
},
{
"item_uuid": "00000000-0000-0000-0000-000000000000",
"superior_object_uuid": "00003022-0000-0000-0000-000000000000"
} }
] ]
} }

View File

@@ -397,6 +397,9 @@ TEST(VerifyPolicy, HitTunnelEndpointaPolicy_1027)
char *hit_policy_query = cJSON_PrintUnformatted(result_json); char *hit_policy_query = cJSON_PrintUnformatted(result_json);
ASSERT_TRUE(hit_policy_query != NULL); ASSERT_TRUE(hit_policy_query != NULL);
printf("hit_policy_query = %s\n", hit_policy_query);
printf("hit_policy_result = %s\n", hit_policy_result);
int equal = strncasecmp(hit_policy_query+2, hit_policy_result+16, strlen(hit_policy_result)); int equal = strncasecmp(hit_policy_query+2, hit_policy_result+16, strlen(hit_policy_result));
EXPECT_EQ(equal, 0); EXPECT_EQ(equal, 0);