bugfix: 适配编译表和分组表结构变更,修改本地JSON配置
This commit is contained in:
@@ -435,7 +435,7 @@ char* str_unescape(char* s)
|
||||
|
||||
void policy_action_param_new(const char *table_name, int table_id, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||
{
|
||||
int ret=0;
|
||||
int ret=0, group_num=0;
|
||||
long long config_id=0;
|
||||
int service_id=0, action=0;
|
||||
int do_log=0,do_blacklist=0,is_valid=0;
|
||||
@@ -443,8 +443,8 @@ void policy_action_param_new(const char *table_name, int table_id, const char* k
|
||||
char srv_def_large[8192]={0};
|
||||
struct policy_action_param* param=NULL;
|
||||
|
||||
ret=sscanf(table_line, "%lld\t%d\t%d\t%d\t%d\t%s\t%s\t%d", &config_id, &service_id, &action, &do_blacklist, &do_log,effective_range, srv_def_large, &is_valid);
|
||||
if(ret!=8)
|
||||
ret=sscanf(table_line, "%lld\t%d\t%d\t%d\t%d\t%s\t%s\t%d\t%d", &config_id, &service_id, &action, &do_blacklist, &do_log, effective_range, srv_def_large, &group_num, &is_valid);
|
||||
if(ret!=9)
|
||||
{
|
||||
TFE_LOG_ERROR(g_proxy_rt->local_logger, "ctrl policy table parse failed, ret:%d, %s", ret, table_line);
|
||||
return;
|
||||
@@ -1100,8 +1100,8 @@ int proxy_policy_init(const char* profile_path, const char* static_section, cons
|
||||
table_name[PXY_CTRL_SOURCE_ADDR] = "ATTR_SOURCE_ADDR";
|
||||
table_name[PXY_CTRL_DESTINATION_ADDR]="ATTR_DESTINATION_ADDR";
|
||||
table_name[PXY_CTRL_HTTP_URL] = "ATTR_HTTP_URL";
|
||||
table_name[PXY_CTRL_HTTP_FQDN] = "ATTR_HTTP_HOST";
|
||||
table_name[PXY_CTRL_HTTP_FQDN_CAT] = "ATTR_HTTP_HOST_CAT";
|
||||
table_name[PXY_CTRL_HTTP_FQDN] = "ATTR_HTTP_HOST_VIRTUAL";
|
||||
table_name[PXY_CTRL_HTTP_FQDN_CAT] = "ATTR_HTTP_HOST_CAT_VIRTUAL";
|
||||
table_name[PXY_CTRL_HTTP_REQ_HDR] = "ATTR_HTTP_REQ_HDR";
|
||||
table_name[PXY_CTRL_HTTP_REQ_BODY] = "ATTR_HTTP_REQ_BODY";
|
||||
table_name[PXY_CTRL_HTTP_RES_HDR] = "ATTR_HTTP_RES_HDR";
|
||||
|
||||
@@ -10,16 +10,19 @@
|
||||
"do_blacklist": 1,
|
||||
"do_log": 1,
|
||||
"effective_range": 0,
|
||||
"tags":"{\"tag_sets\":[[{\"tag\":\"device_id\",\"value\":[\"device_3\",\"device_4\"]}]]}",
|
||||
"user_region": "{\"protocol\":\"http\",\"method\":\"redirect\",\"code\":302,\"to\":\"https://www.jd.com\"}",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name":"http_url",
|
||||
"virtual_table":"ATTR_HTTP_URL",
|
||||
"group_name":"http_url",
|
||||
"group_id":101,
|
||||
"not_flag":0,
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "TSG_OBJ_URL",
|
||||
"table_type": "string",
|
||||
"table_type": "expr",
|
||||
"table_content": {
|
||||
"keywords": "baidu.com",
|
||||
"expr_type": "regex",
|
||||
@@ -28,6 +31,12 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"virtual_table":"ATTR_APP_ID",
|
||||
"group_name":"app_id",
|
||||
"group_id":201,
|
||||
"not_flag":0
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -44,8 +53,7 @@
|
||||
"groups": [
|
||||
{
|
||||
"group_name":"http_url",
|
||||
"virtual_table":"TSG_FIELD_HTTP_URL",
|
||||
"not_flag":0
|
||||
"virtual_table":"ATTR_HTTP_URL"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -60,12 +68,14 @@
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"virtual_table":"ATTR_HTTP_HOST_VIRTUAL",
|
||||
"group_name":"http_fqdn",
|
||||
"group_id":102,
|
||||
"not_flag":0,
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "TSG_OBJ_FQDN",
|
||||
"table_type": "string",
|
||||
"table_type": "expr",
|
||||
"table_content": {
|
||||
"keywords": "www.126.com",
|
||||
"expr_type": "regex",
|
||||
@@ -82,14 +92,14 @@
|
||||
"service": 1,
|
||||
"action": 48,
|
||||
"do_blacklist": 1,
|
||||
"do_log": 1,
|
||||
"do_log": 1,
|
||||
"effective_range": 0,
|
||||
"user_region":"{\"protocol\":\"http\",\"method\":\"replace\",\"rules\":[{\"search_in\":\"http_resp_body\",\"find\":\"大师\",\"replace_with\":\"小小\"}]}",
|
||||
"user_region":"{\"protocol\":\"http\",\"method\":\"replace\",\"rules\":[{\"search_in\":\"http_resp_body\",\"find\":\"账号登录\",\"replace_with\":\"Login\"}]}",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name":"http_fqdn",
|
||||
"virtual_table":"TSG_FIELD_HTTP_HOST",
|
||||
"virtual_table":"ATTR_HTTP_HOST",
|
||||
"not_flag":0
|
||||
}
|
||||
]
|
||||
@@ -99,14 +109,14 @@
|
||||
"service": 1,
|
||||
"action": 48,
|
||||
"do_blacklist": 1,
|
||||
"do_log": 1,
|
||||
"do_log": 1,
|
||||
"effective_range": 0,
|
||||
"user_region": "{\"protocol\":\"http\",\"method\":\"replace\",\"rules\":[{\"search_in\":\"http_resp_body\",\"find\":\"会员\",\"replace_with\":\"用户\"}]}",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name":"http_fqdn",
|
||||
"virtual_table":"TSG_FIELD_DOH_QNAME",
|
||||
"virtual_table":"ATTR_DOH_QNAME",
|
||||
"not_flag":0
|
||||
}
|
||||
]
|
||||
@@ -122,7 +132,9 @@
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name":"http_signature_ua",
|
||||
"virtual_table":"ATTR_HTTP_REQ_HDR",
|
||||
"group_name":"http_signature_ua",
|
||||
"group_id":103,
|
||||
"not_flag":0,
|
||||
"regions": [
|
||||
{
|
||||
@@ -140,7 +152,9 @@
|
||||
},
|
||||
{
|
||||
|
||||
"virtual_table":"ATTR_HTTP_REQ_HDR",
|
||||
"group_name":"http_signature_cookie",
|
||||
"group_id":104,
|
||||
"not_flag":0,
|
||||
"regions": [
|
||||
{
|
||||
@@ -169,12 +183,14 @@
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"virtual_table":"ATTR_HTTP_URL",
|
||||
"group_name":"http_url_bing",
|
||||
"group_id": 105,
|
||||
"not_flag":0,
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "TSG_OBJ_URL",
|
||||
"table_type": "string",
|
||||
"table_type": "expr",
|
||||
"table_content": {
|
||||
"keywords": "bing.com",
|
||||
"expr_type": "regex",
|
||||
@@ -196,31 +212,9 @@
|
||||
"user_region": "{\"protocol\":\"http\",\"method\":\"block\",\"code\":403,\"message\":\"error\"}",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name":"http_signature_ua",
|
||||
"virtual_table":"TSG_FIELD_HTTP_REQ_HDR",
|
||||
"not_flag":0
|
||||
},
|
||||
{
|
||||
"group_name":"http_url_bing",
|
||||
"virtual_table":"TSG_FIELD_HTTP_URL",
|
||||
"not_flag":0
|
||||
},
|
||||
{
|
||||
"group_name":"app_id",
|
||||
"not_flag":0,
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "TSG_OBJ_APP_ID",
|
||||
"table_type": "string",
|
||||
"table_content": {
|
||||
"keywords": "http.",
|
||||
"expr_type": "regex",
|
||||
"match_method": "sub",
|
||||
"format": "uncase plain"
|
||||
}
|
||||
}
|
||||
]
|
||||
"virtual_table":"ATTR_HTTP_URL"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -261,8 +255,8 @@
|
||||
{
|
||||
"table_name": "PXY_INTERCEPT_COMPILE",
|
||||
"table_content": [
|
||||
"0\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"protocol\":\"SSL\",\"keyring_for_trusted\":765,\"keyring_for_untrusted\":10,\"decryption\":0,\"tcp_option_profile\":1,\"traffic_mirror\":{\"enable\":0}}\t1\t2",
|
||||
"4\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"protocol\":\"SSL\",\"keyring_for_trusted\":1,\"keyring_for_untrusted\":10,\"decryption\":0,\"tcp_option_profile\":1,\"traffic_mirror\":{\"enable\":1,\"mirror_profile\":1234}}\t1\t2"
|
||||
"0\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"protocol\":\"SSL\",\"keyring_for_trusted\":765,\"keyring_for_untrusted\":10,\"decryption\":0,\"tcp_option_profile\":1,\"traffic_mirror\":{\"enable\":0}}\t1\t1\t2",
|
||||
"255119\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"protocol\":\"SSL\",\"keyring_for_trusted\":1,\"keyring_for_untrusted\":10,\"decryption\":0,\"tcp_option_profile\":1,\"traffic_mirror\":{\"enable\":1,\"mirror_profile\":1234}}\t1\t1\t2"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -285,6 +279,13 @@
|
||||
"2\teb149984fc9c44d85ed7f12c90d818be\t1\t0",
|
||||
"3\te6573e91e6eb777c0933c5b8f97f10cd\t1\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "APP_ID_DICT",
|
||||
"table_content": [
|
||||
"67\thttp\t0\tnull\tnetworking\tinfrastructure\tnetwork-protocol\t3\tused-by-malware,vulnerability,widely-used\tnull\tnull\t{\"method\":\"drop\",\"after_n_packets\":0,\"send_icmp_unreachable\":1,\"send_tcp_reset\":1}\t0\t60\t120\t30\t30\t201\t1",
|
||||
"68\thttps\t0\tnull\tnetworking\tinfrastructure\tnetwork-protocol\t3\tused-by-malware,vulnerability,widely-used\tnull\tnull\t{\"method\":\"rate_limit\",\"bps\":1000}\t0\t0\t0\t0\t0\t68000\t1"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
"table_name":"PXY_CTRL_COMPILE",
|
||||
"table_type":"compile",
|
||||
"user_region_encoded":"escape",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom": {
|
||||
"compile_id":1,
|
||||
"tags":6,
|
||||
"clause_num":9
|
||||
"clause_num":8
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -18,11 +18,11 @@
|
||||
"default_compile_table":1,
|
||||
"table_type":"compile",
|
||||
"user_region_encoded":"escape",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom": {
|
||||
"compile_id":1,
|
||||
"tags":6,
|
||||
"clause_num":9
|
||||
"clause_num":8
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -30,7 +30,7 @@
|
||||
"table_name":"PXY_CTRL_COMPILE_PLUGIN",
|
||||
"db_tables":["PXY_CTRL_COMPILE"],
|
||||
"table_type":"plugin",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom": {
|
||||
"key":1,
|
||||
"key_type":"integer",
|
||||
@@ -42,13 +42,13 @@
|
||||
"table_name":"GROUP_PXY_CTRL_COMPILE_RELATION",
|
||||
"table_type":"group2compile",
|
||||
"associated_compile_table_id":1,
|
||||
"valid_column":3,
|
||||
"valid_column":6,
|
||||
"custom": {
|
||||
"group_id":1,
|
||||
"compile_id":2,
|
||||
"not_flag":4,
|
||||
"virtual_table_name":5,
|
||||
"clause_index":6
|
||||
"not_flag":3,
|
||||
"virtual_table_name":4,
|
||||
"clause_index":5
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -127,16 +127,18 @@
|
||||
"up_bound":4
|
||||
}
|
||||
},
|
||||
{
|
||||
"table_id":10,
|
||||
"table_name":"ATTR_HTTP_HOST",
|
||||
"table_type":"virtual",
|
||||
{
|
||||
"table_id": 10,
|
||||
"table_name": "ATTR_HTTP_HOST_VIRTUAL",
|
||||
"db_tables": ["ATTR_HTTP_HOST", "ATTR_DESTINATION_SERVER_FQDN"],
|
||||
"table_type": "virtual",
|
||||
"physical_table": "TSG_OBJ_FQDN"
|
||||
},
|
||||
{
|
||||
"table_id":11,
|
||||
"table_name":"ATTR_HTTP_HOST_CAT",
|
||||
"table_type":"virtual",
|
||||
{
|
||||
"table_id": 11,
|
||||
"table_name": "ATTR_HTTP_HOST_CAT_VIRTUAL",
|
||||
"db_tables": ["ATTR_HTTP_HOST_CAT", "ATTR_DESTINATION_SERVER_FQDN_CAT"],
|
||||
"table_type": "virtual",
|
||||
"physical_table": "TSG_OBJ_FQDN_CAT"
|
||||
},
|
||||
{
|
||||
@@ -235,11 +237,11 @@
|
||||
"table_name":"PXY_CACHE_COMPILE",
|
||||
"table_type":"compile",
|
||||
"user_region_encoded":"escape",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom": {
|
||||
"compile_id":1,
|
||||
"tags":6,
|
||||
"clause_num":9
|
||||
"clause_num":8
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -249,11 +251,11 @@
|
||||
"default_compile_table":1,
|
||||
"table_type":"compile",
|
||||
"user_region_encoded":"escape",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom": {
|
||||
"compile_id":1,
|
||||
"tags":6,
|
||||
"clause_num":9
|
||||
"clause_num":8
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -273,13 +275,13 @@
|
||||
"table_name":"PXY_CACHE_GROUP",
|
||||
"table_type":"group2compile",
|
||||
"associated_compile_table_id":0,
|
||||
"valid_column":3,
|
||||
"valid_column":6,
|
||||
"custom": {
|
||||
"group_id":1,
|
||||
"compile_id":2,
|
||||
"not_flag":4,
|
||||
"virtual_table_name":5,
|
||||
"clause_index":6
|
||||
"not_flag":3,
|
||||
"virtual_table_name":4,
|
||||
"clause_index":5
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -369,7 +371,7 @@
|
||||
"table_id":33,
|
||||
"table_name":"PXY_INTERCEPT_COMPILE",
|
||||
"table_type":"plugin",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom": {
|
||||
"key":1,
|
||||
"key_type":"pointer"
|
||||
@@ -500,7 +502,7 @@
|
||||
"table_id":48,
|
||||
"table_name":"SERVICE_CHAINING_COMPILE",
|
||||
"table_type":"plugin",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom":{
|
||||
"key":1,
|
||||
"key_type":"pointer"
|
||||
@@ -510,7 +512,7 @@
|
||||
"table_id": 49,
|
||||
"table_name": "APP_ID_DICT",
|
||||
"table_type": "plugin",
|
||||
"valid_column": 18,
|
||||
"valid_column": 19,
|
||||
"custom": {
|
||||
"key": 1,
|
||||
"key_type": "integer",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"table_id":0,
|
||||
"table_name":"PXY_INTERCEPT_COMPILE",
|
||||
"table_type":"plugin",
|
||||
"valid_column":8,
|
||||
"valid_column":9,
|
||||
"custom": {
|
||||
"key":1,
|
||||
"key_type":"pointer"
|
||||
|
||||
Reference in New Issue
Block a user