diff options
| author | fengweihao <[email protected]> | 2019-12-11 15:28:36 +0800 |
|---|---|---|
| committer | fengweihao <[email protected]> | 2019-12-11 15:28:36 +0800 |
| commit | 5cdd28235d5ed4e1b2a505762b517e631eb5a299 (patch) | |
| tree | 05db351d3d147b674322ea810c9e5b3925effe35 | |
| parent | 7476f84fa1e4b806d5b3be71ed88cf91f39eb0bc (diff) | |
日志接口、扫描接口修复
1)日志发送接口:增加对非结构化日志判断
2)扫描接口:对客户端请求中HOST字段为空情况,扫描不在扫FQDN域
| -rw-r--r-- | plugin/business/pangu-http/src/pangu_http.cpp | 14 | ||||
| -rw-r--r-- | plugin/business/pangu-http/src/pangu_logger.cpp | 6 |
2 files changed, 11 insertions, 9 deletions
diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index 75516ab..d3c02f0 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -1937,13 +1937,15 @@ enum pangu_action http_scan(const struct tfe_http_session * session, enum tfe_ht if (events & EV_HTTP_REQ_HDR) { const char *str_host = session->req->req_spec.host; - int str_host_length = (int) (strlen(session->req->req_spec.host)); - - scan_ret = Maat_full_scan_string(g_pangu_rt->maat, g_pangu_rt->scan_table_id[PXY_CTRL_HTTP_FQDN], - CHARSET_UTF8, str_host, str_host_length, result, NULL, MAX_SCAN_RESULT, &(ctx->scan_mid), ctx->thread_id); - if (scan_ret > 0) + if (str_host != NULL) { - hit_cnt += scan_ret; + int str_host_length = (int) (strlen(session->req->req_spec.host)); + scan_ret = Maat_full_scan_string(g_pangu_rt->maat, g_pangu_rt->scan_table_id[PXY_CTRL_HTTP_FQDN], + CHARSET_UTF8, str_host, str_host_length, result, NULL, MAX_SCAN_RESULT, &(ctx->scan_mid), ctx->thread_id); + if (scan_ret > 0) + { + hit_cnt += scan_ret; + } } const char * str_url = session->req->req_spec.url; diff --git a/plugin/business/pangu-http/src/pangu_logger.cpp b/plugin/business/pangu-http/src/pangu_logger.cpp index 1759d95..78a430c 100644 --- a/plugin/business/pangu-http/src/pangu_logger.cpp +++ b/plugin/business/pangu-http/src/pangu_logger.cpp @@ -221,7 +221,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) int ret=tfe_cmsg_get_value(cmsg, TFE_CMSG_STREAM_TRACE_ID, (unsigned char *) opt_val, sizeof(opt_val), &opt_out_size); if (ret==0) { - cJSON_AddStringToObject(common_obj, "common_stream_trace_id", opt_val); + cJSON_AddNumberToObject(common_obj, "common_stream_trace_id", atoll(opt_val)); } } @@ -296,7 +296,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) struct tango_cache_meta_put meta; char* log_file_key=NULL;; const char* cont_type_val; - if(log_msg->req_body!=NULL) + 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); @@ -321,7 +321,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) } free(log_file_key); } - if(log_msg->resp_body!=NULL) + if(log_msg->resp_body!=NULL && log_msg->result[0].do_log==1) { memset(&meta, 0, sizeof(meta)); asprintf(&log_file_key, "%s.respbody", http->req->req_spec.url); |
