TSG-23072 Change the Policies-Manipulation log field from proxy_rule_list to proxy_rule_uuid_list
TSG-23090 Change the action field in the Metric structure proxy_rule_hits to the string type
This commit is contained in:
@@ -461,57 +461,9 @@ unsigned char log_option_type_str2idx(const char *log_option)
|
||||
return i;
|
||||
}
|
||||
|
||||
void policy_action_param_new(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||
void policy_set_param_by_action(struct policy_action_param* param, cJSON *action_parameter)
|
||||
{
|
||||
cJSON* pxy_ctrl_rule = cJSON_Parse(table_line);
|
||||
if(pxy_ctrl_rule == NULL)
|
||||
{
|
||||
TFE_LOG_ERROR(g_proxy_rt->local_logger, "PXY_CTRL_RULE parse table_line failed. table_line:%s", table_line);
|
||||
return;
|
||||
}
|
||||
|
||||
struct policy_action_param* param=ALLOC(struct policy_action_param, 1);
|
||||
|
||||
cJSON *uuid = cJSON_GetObjectItem(pxy_ctrl_rule, "uuid");
|
||||
if(uuid && uuid->type==cJSON_String)
|
||||
{
|
||||
param->hit_rule.config_uuid_string = strdup(uuid->valuestring);
|
||||
uuid_parse(uuid->valuestring, param->hit_rule.config_uuid);
|
||||
}
|
||||
|
||||
cJSON *action = cJSON_GetObjectItem(pxy_ctrl_rule, "action");
|
||||
if(action && action->type==cJSON_String)
|
||||
{
|
||||
param->hit_rule.action=action_type_str2idx(action->valuestring);
|
||||
}
|
||||
|
||||
cJSON *blacklist_option = cJSON_GetObjectItem(pxy_ctrl_rule, "blacklist_option");
|
||||
if(blacklist_option && blacklist_option->type==cJSON_Number)
|
||||
{
|
||||
param->hit_rule.do_blacklist=blacklist_option->valueint;
|
||||
}
|
||||
|
||||
cJSON *log_option = cJSON_GetObjectItem(pxy_ctrl_rule, "log_option");
|
||||
if(log_option && log_option->type==cJSON_String)
|
||||
{
|
||||
param->hit_rule.do_log=log_option_type_str2idx(log_option->valuestring);
|
||||
}
|
||||
|
||||
cJSON *action_parameter = cJSON_GetObjectItem(pxy_ctrl_rule, "action_parameter");
|
||||
if(action_parameter == NULL || action_parameter->type!=cJSON_Object)
|
||||
{
|
||||
FREE(¶m);
|
||||
TFE_LOG_ERROR(g_proxy_rt->local_logger, "invalid policy parameter: id = %s", param->hit_rule.config_uuid_string);
|
||||
return;
|
||||
}
|
||||
|
||||
param->ref_cnt=1;
|
||||
pthread_mutex_init(&(param->lock), NULL);
|
||||
param->hit_rule.action_parameter = cJSON_PrintUnformatted(action_parameter);
|
||||
|
||||
int rule_id=0;
|
||||
cJSON *rules=NULL, *item=NULL, *sub_item=NULL;
|
||||
|
||||
cJSON *item=NULL;
|
||||
switch(param->hit_rule.action)
|
||||
{
|
||||
case PX_ACTION_REDIRECT:
|
||||
@@ -586,13 +538,13 @@ void policy_action_param_new(const char *table_name, const char* key, const char
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *method=cJSON_GetObjectItem(action_parameter, "sub_action");
|
||||
if(method && method->type==cJSON_String)
|
||||
{
|
||||
param->action=manipulate_action_str2idx(method->valuestring);
|
||||
}
|
||||
|
||||
void policy_set_param_by_sub_action(struct policy_action_param* param, cJSON *action_parameter)
|
||||
{
|
||||
int rule_id=0;
|
||||
cJSON *rules=NULL, *item=NULL, *sub_item=NULL;
|
||||
switch(param->action)
|
||||
{
|
||||
case MA_ACTION_REPLACE_TEXT:
|
||||
@@ -748,6 +700,66 @@ void policy_action_param_new(const char *table_name, const char* key, const char
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void policy_action_param_new(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||
{
|
||||
cJSON* pxy_ctrl_rule = cJSON_Parse(table_line);
|
||||
if(pxy_ctrl_rule == NULL)
|
||||
{
|
||||
TFE_LOG_ERROR(g_proxy_rt->local_logger, "PXY_CTRL_RULE parse table_line failed. table_line:%s", table_line);
|
||||
return;
|
||||
}
|
||||
|
||||
struct policy_action_param* param=ALLOC(struct policy_action_param, 1);
|
||||
|
||||
cJSON *uuid = cJSON_GetObjectItem(pxy_ctrl_rule, "uuid");
|
||||
if(uuid && uuid->type==cJSON_String)
|
||||
{
|
||||
param->hit_rule.config_uuid_string = strdup(uuid->valuestring);
|
||||
uuid_parse(uuid->valuestring, param->hit_rule.config_uuid);
|
||||
}
|
||||
|
||||
cJSON *action = cJSON_GetObjectItem(pxy_ctrl_rule, "action");
|
||||
if(action && action->type==cJSON_String)
|
||||
{
|
||||
param->hit_rule.action=action_type_str2idx(action->valuestring);
|
||||
}
|
||||
|
||||
cJSON *blacklist_option = cJSON_GetObjectItem(pxy_ctrl_rule, "blacklist_option");
|
||||
if(blacklist_option && blacklist_option->type==cJSON_Number)
|
||||
{
|
||||
param->hit_rule.do_blacklist=blacklist_option->valueint;
|
||||
}
|
||||
|
||||
cJSON *log_option = cJSON_GetObjectItem(pxy_ctrl_rule, "log_option");
|
||||
if(log_option && log_option->type==cJSON_String)
|
||||
{
|
||||
param->hit_rule.do_log=log_option_type_str2idx(log_option->valuestring);
|
||||
}
|
||||
|
||||
cJSON *action_parameter = cJSON_GetObjectItem(pxy_ctrl_rule, "action_parameter");
|
||||
if(action_parameter == NULL || action_parameter->type!=cJSON_Object)
|
||||
{
|
||||
FREE(¶m);
|
||||
TFE_LOG_ERROR(g_proxy_rt->local_logger, "invalid policy parameter: id = %s", param->hit_rule.config_uuid_string);
|
||||
return;
|
||||
}
|
||||
|
||||
param->ref_cnt=1;
|
||||
pthread_mutex_init(&(param->lock), NULL);
|
||||
param->hit_rule.action_parameter = cJSON_PrintUnformatted(action_parameter);
|
||||
policy_set_param_by_action(param, action_parameter);
|
||||
|
||||
cJSON *method=cJSON_GetObjectItem(action_parameter, "sub_action");
|
||||
if(method && method->type==cJSON_String)
|
||||
{
|
||||
param->action=manipulate_action_str2idx(method->valuestring);
|
||||
}
|
||||
policy_set_param_by_sub_action(param, action_parameter);
|
||||
|
||||
*ad=param;
|
||||
TFE_LOG_INFO(g_proxy_rt->local_logger, "Add ctrl policy: %s", param->hit_rule.config_uuid_string);
|
||||
cJSON_Delete(pxy_ctrl_rule);
|
||||
@@ -1519,7 +1531,7 @@ void proxy_send_metric_log(const struct tfe_stream * stream, struct proxy_http_c
|
||||
{
|
||||
fieldstat->tags[thread_id][TAG_VSYS_ID].value_longlong = ctx->enforce_rules[i].vsys_id;
|
||||
fieldstat->tags[thread_id][TAG_RULE_ID].value_str = ctx->enforce_rules[i].config_uuid_string;
|
||||
fieldstat->tags[thread_id][TAG_ACTION].value_longlong = PX_ACTION_MANIPULATE;
|
||||
fieldstat->tags[thread_id][TAG_ACTION].value_str = "manipulate";
|
||||
if(ctx->enforce_rules[i].action == PX_ACTION_MANIPULATE)
|
||||
{
|
||||
fieldstat->tags[thread_id][TAG_SUB_ACTION].value_str = manipulate_action_map[ctx->param->action];
|
||||
|
||||
Reference in New Issue
Block a user