summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2021-05-10 10:21:31 +0800
committerfengweihao <[email protected]>2021-05-10 10:21:31 +0800
commit91facad80ad88ca81970246f3550efb677dd16ff (patch)
tree845728c5d1988ef14eb7f6e6b374e361bd8ff6ed
parentc184cf6ad6f35da222371a9cc47d4446868a9724 (diff)
TSG-6072 Deny动作和Redirect动作日志中存在非格式化日志HTTP.Request Bodyv4.5.01-202105
TSG-6095 代理策略monitor动作产生的非格式化下载日志与策略配置不相符
-rw-r--r--cache/include/tango_cache_client.h1
-rw-r--r--cache/src/tango_cache_client.cpp11
-rw-r--r--plugin/business/doh/src/doh.cpp2
-rw-r--r--plugin/business/pangu-http/src/pangu_http.cpp2
-rw-r--r--plugin/business/pangu-http/src/pangu_logger.cpp103
5 files changed, 70 insertions, 49 deletions
diff --git a/cache/include/tango_cache_client.h b/cache/include/tango_cache_client.h
index 1ed9695..eac19bf 100644
--- a/cache/include/tango_cache_client.h
+++ b/cache/include/tango_cache_client.h
@@ -144,6 +144,7 @@ struct tango_cache_meta_put
const char* std_hdr[HDR_CONTENT_NUM]; //����ͷ������"Content-Type: text/html"����Ҫ�������У�NULL��ʾû�и�ͷ����
const char* usertag; //�������������ݣ�GETʱ��ԭ������
size_t usertag_len; //��󳤶�USER_TAG_MAX_LEN��0��ʾû�и�ͷ��
+ size_t user_log_name;
struct response_freshness put;
};
diff --git a/cache/src/tango_cache_client.cpp b/cache/src/tango_cache_client.cpp
index 520ba53..cdfb1bc 100644
--- a/cache/src/tango_cache_client.cpp
+++ b/cache/src/tango_cache_client.cpp
@@ -414,7 +414,16 @@ struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *
if(instance->param->hash_object_key)
{
caculate_sha256(meta->url, strlen(meta->url), buffer, 72);
- snprintf(ctx->object_key, 256, "%s/%c%c_%c%c_%s", instance->param->bucketname, buffer[0], buffer[1], buffer[2], buffer[3], buffer+4);
+ if(meta->user_log_name)
+ {
+ struct timespec start_time;
+ clock_gettime(CLOCK_REALTIME,&start_time);
+ snprintf(ctx->object_key, 256, "%s/%lu_%c%c_%c%c_%s", instance->param->bucketname, start_time.tv_nsec, buffer[0], buffer[1], buffer[2], buffer[3], buffer+4);
+ }
+ else
+ {
+ snprintf(ctx->object_key, 256, "%s/%c%c_%c%c_%s", instance->param->bucketname, buffer[0], buffer[1], buffer[2], buffer[3], buffer+4);
+ }
//����ԭʼURL
snprintf(buffer, 2064, "x-amz-meta-url: %s", meta->url);
ctx->headers = curl_slist_append(ctx->headers, buffer);
diff --git a/plugin/business/doh/src/doh.cpp b/plugin/business/doh/src/doh.cpp
index a4c0d97..59cf502 100644
--- a/plugin/business/doh/src/doh.cpp
+++ b/plugin/business/doh/src/doh.cpp
@@ -205,7 +205,7 @@ static void doh_maat_scan(const struct tfe_stream *stream, const struct tfe_http
{
int hit_cnt = 0;
int scan_ret = 0;
- int app_id = 135;
+ int app_id = 8006;
struct ipaddr sapp_addr;
struct Maat_rule_t *p_result = NULL;
struct Maat_rule_t result[MAX_SCAN_RESULT];
diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp
index 41dff1c..8d47e4e 100644
--- a/plugin/business/pangu-http/src/pangu_http.cpp
+++ b/plugin/business/pangu-http/src/pangu_http.cpp
@@ -2374,7 +2374,7 @@ void pangu_on_http_begin(const struct tfe_stream * stream,
{
hit_cnt+=scan_ret;
}
- int scan_val=106;
+ int scan_val=67;
scan_ret=Maat_scan_intval(g_pangu_rt->maat, g_pangu_rt->scan_table_id[PXY_CTRL_APP_ID], scan_val, result+hit_cnt, MAX_SCAN_RESULT-hit_cnt, &(ctx->scan_mid), (int) thread_id);
if(scan_ret>0)
{
diff --git a/plugin/business/pangu-http/src/pangu_logger.cpp b/plugin/business/pangu-http/src/pangu_logger.cpp
index 70d2dd5..a27364e 100644
--- a/plugin/business/pangu-http/src/pangu_logger.cpp
+++ b/plugin/business/pangu-http/src/pangu_logger.cpp
@@ -219,60 +219,71 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
cJSON_AddStringToObject(common_obj,resp_fields[i].log_filed_name, tmp_val);
}
}
- char log_file_upload_path[TFE_STRING_MAX]={0}, cont_type_whole[TFE_STRING_MAX]={0};
- struct tango_cache_meta_put meta;
- char* log_file_key=NULL;;
- const char* cont_type_val;
- if(log_msg->req_body!=NULL && log_msg->result[0].do_log==1)
- {
- memset(&meta, 0, sizeof(meta));
- asprintf(&log_file_key, "%s.reqbody", http->req->req_spec.url);
- meta.url=log_file_key;
- cont_type_val=tfe_http_std_field_read(http->req, TFE_HTTP_CONT_TYPE);
- if(cont_type_val!=NULL)
- {
- snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val);
- meta.std_hdr[0]=cont_type_whole;
- }
- tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL,
- log_msg->req_body,
- &meta,
- log_file_upload_path, sizeof(log_file_upload_path));
- if(tmp==0)
- {
- cJSON_AddStringToObject(common_obj, "http_request_body", log_file_upload_path);
- }
- else
- {
- TFE_LOG_ERROR(handle->local_logger, "Upload req_body failed.");
- }
- free(log_file_key);
- }
- if(log_msg->resp_body!=NULL && log_msg->result[0].do_log==1)
+
+ for(size_t i=0; i<log_msg->result_num; i++)
{
- memset(&meta, 0, sizeof(meta));
- asprintf(&log_file_key, "%s.respbody", http->req->req_spec.url);
- meta.url=log_file_key;
- cont_type_val=tfe_http_std_field_read(http->resp, TFE_HTTP_CONT_TYPE);
- if(cont_type_val!=NULL)
+ if(log_msg->result[i].do_log!=1)
{
- snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val);
- meta.std_hdr[0]=cont_type_whole;
+ continue;
}
- tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL,
- log_msg->resp_body,
- &meta,
- log_file_upload_path, sizeof(log_file_upload_path));
- if(tmp==0)
+ char log_file_upload_path[TFE_STRING_MAX]={0}, cont_type_whole[TFE_STRING_MAX]={0};
+ struct tango_cache_meta_put meta;
+ char* log_file_key=NULL;;
+ const char* cont_type_val;
+ if(log_msg->req_body!=NULL)
{
- cJSON_AddStringToObject(common_obj, "http_response_body", log_file_upload_path);
+ memset(&meta, 0, sizeof(meta));
+ asprintf(&log_file_key, "%s.reqbody", http->req->req_spec.url);
+ meta.url=log_file_key;
+ cont_type_val=tfe_http_std_field_read(http->req, TFE_HTTP_CONT_TYPE);
+ if(cont_type_val!=NULL)
+ {
+ snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val);
+ meta.std_hdr[0]=cont_type_whole;
+ }
+ meta.user_log_name=1;
+ tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL,
+ log_msg->req_body,
+ &meta,
+ log_file_upload_path, sizeof(log_file_upload_path));
+ if(tmp==0)
+ {
+ cJSON_AddStringToObject(common_obj, "http_request_body", log_file_upload_path);
+ }
+ else
+ {
+ TFE_LOG_ERROR(handle->local_logger, "Upload req_body failed.");
+ }
+ free(log_file_key);
}
- else
+ if(log_msg->resp_body!=NULL)
{
- TFE_LOG_ERROR(handle->local_logger, "Upload resp_body failed.");
+ memset(&meta, 0, sizeof(meta));
+ asprintf(&log_file_key, "%s.respbody", http->req->req_spec.url);
+ meta.url=log_file_key;
+ cont_type_val=tfe_http_std_field_read(http->resp, TFE_HTTP_CONT_TYPE);
+ if(cont_type_val!=NULL)
+ {
+ snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val);
+ meta.std_hdr[0]=cont_type_whole;
+ }
+ meta.user_log_name=1;
+ tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL,
+ log_msg->resp_body,
+ &meta,
+ log_file_upload_path, sizeof(log_file_upload_path));
+
+ if(tmp==0)
+ {
+ cJSON_AddStringToObject(common_obj, "http_response_body", log_file_upload_path);
+ }
+ else
+ {
+ TFE_LOG_ERROR(handle->local_logger, "Upload resp_body failed.");
+ }
+ free(log_file_key);
}
- free(log_file_key);
}
for(size_t i=0; i<log_msg->result_num; i++)