summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2020-04-03 16:16:07 +0800
committerfengweihao <[email protected]>2020-04-03 16:16:07 +0800
commitab492252a91f77bee363377358dbb57928a741ff (patch)
tree97f9153c12e00c5b88024cfc1335136727b19664
parentc94eab176be2dd6fb374e74461137b5b6f2feecb (diff)
TSG-1167 proxy-event-log增加注入文件大小
-rw-r--r--plugin/business/pangu-http/src/pangu_http.cpp6
-rw-r--r--plugin/business/pangu-http/src/pangu_logger.cpp1
-rw-r--r--plugin/business/pangu-http/src/pangu_logger.h1
-rw-r--r--plugin/business/pangu-http/src/pattern_replace.h1
4 files changed, 8 insertions, 1 deletions
diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp
index ec744ae..4066d77 100644
--- a/plugin/business/pangu-http/src/pangu_http.cpp
+++ b/plugin/business/pangu-http/src/pangu_http.cpp
@@ -1041,6 +1041,7 @@ struct pangu_http_ctx
struct policy_action_param *param;
struct evbuffer* log_req_body, *log_resp_body;
+ size_t inject_sz;
struct replace_ctx * rep_ctx;
struct insert_ctx * ins_ctx;
@@ -1696,6 +1697,7 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
ctx->action = PG_ACTION_NONE;
return;
}
+ ctx->inject_sz = hijack_size;
char cont_len_str[16];
@@ -1748,6 +1750,7 @@ static int format_insert_rule(int profile_id, struct insert_rule *rule)
rule->script = tfe_strdup(insert_profile->profile_msg);
rule->type = tfe_strdup(insert_profile->profile_type);
rule->position = tfe_strdup(insert_profile->profile_position);
+ rule->inject_sz = insert_profile->msg_len;
ma_profile_table_free(insert_profile);
insert_profile = NULL;
@@ -1787,6 +1790,7 @@ static void http_insert(const struct tfe_stream * stream, const struct tfe_http_
ctx->action = PG_ACTION_NONE;
return;
}
+ ctx->inject_sz = ins_ctx->rule->inject_sz;
}
else
{
@@ -2474,7 +2478,7 @@ void pangu_on_http_end(const struct tfe_stream * stream,
}
}
struct pangu_log log_msg = {.stream=stream, .http=session, .result=ctx->enforce_rules, .result_num=ctx->n_enforce,
- .req_body= ctx->log_req_body, .resp_body=ctx->log_resp_body, .action=0};
+ .req_body=ctx->log_req_body, .resp_body=ctx->log_resp_body, .action=0, .inject_sz=ctx->inject_sz};
if(ctx->action == PG_ACTION_MANIPULATE)
{
diff --git a/plugin/business/pangu-http/src/pangu_logger.cpp b/plugin/business/pangu-http/src/pangu_logger.cpp
index df36e55..3a66b19 100644
--- a/plugin/business/pangu-http/src/pangu_logger.cpp
+++ b/plugin/business/pangu-http/src/pangu_logger.cpp
@@ -303,6 +303,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
if(log_msg->result[i].action == LG_ACTION_MANIPULATE)
{
cJSON_AddStringToObject(per_hit_obj, "common_sub_action", manipulate_action_map[log_msg->action]);
+ cJSON_AddNumberToObject(per_hit_obj, "http_action_file_sz", log_msg->inject_sz);
}
else
{
diff --git a/plugin/business/pangu-http/src/pangu_logger.h b/plugin/business/pangu-http/src/pangu_logger.h
index 2da32fb..91ca8cb 100644
--- a/plugin/business/pangu-http/src/pangu_logger.h
+++ b/plugin/business/pangu-http/src/pangu_logger.h
@@ -12,6 +12,7 @@ struct pangu_log
size_t result_num;
struct evbuffer* req_body, *resp_body;
unsigned char action;
+ size_t inject_sz;
};
struct pangu_logger;
struct pangu_logger* pangu_log_handle_create(const char* profile, const char* section, void* local_logger);
diff --git a/plugin/business/pangu-http/src/pattern_replace.h b/plugin/business/pangu-http/src/pattern_replace.h
index 4160b5c..2e85b67 100644
--- a/plugin/business/pangu-http/src/pattern_replace.h
+++ b/plugin/business/pangu-http/src/pattern_replace.h
@@ -23,6 +23,7 @@ struct replace_rule
struct insert_rule
{
+ int inject_sz;
char * script;
char * type;
char * position;