diff options
| author | Lu <[email protected]> | 2018-07-20 11:03:22 +0800 |
|---|---|---|
| committer | Lu <[email protected]> | 2018-07-20 11:03:22 +0800 |
| commit | 9664996f416a75bb9431218c98893f527f3af1a5 (patch) | |
| tree | e0eabe25922923f23f497ec7077ac0e0b6df071a | |
| parent | e8fb760d2103d7eea464dd37c006766507e7742d (diff) | |
#5 增加预置的内容类型白名单过滤列表,只针对text类型的内容执行应答侧处理。
| -rw-r--r-- | src/httpscan.cc | 28 | ||||
| -rw-r--r-- | src/httpscan.h | 1 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/httpscan.cc b/src/httpscan.cc index c8915ad..17a2f96 100644 --- a/src/httpscan.cc +++ b/src/httpscan.cc @@ -234,8 +234,16 @@ void HttpScanSession::ScanResponseHeader(HttpSession * http_session_ctx) { auto & response = http_session_ctx->response(); + /* 内容类型过滤列表 */ + auto scan_result = scan_bypass_content_type(response.cHeaders()); + if (scan_result == scan_result_t::kScanResultHit) + { + http_session_ctx->Bypass(); + return; + } + /* 扫描应答头部 */ - auto scan_result = scan_headers(response.cHeaders(), httpscan_module_ref_.table_id_ctrl_http_res_hdr); + scan_result = scan_headers(response.cHeaders(), httpscan_module_ref_.table_id_ctrl_http_res_hdr); /* Hit */ if (scan_result == scan_result_t::kScanResultHit) { @@ -339,6 +347,24 @@ HttpScanSession::scan_result_t HttpScanSession::scan_body(const char * data, siz return scan_result_t::kScanResultNotHit; } +HttpScanSession::scan_result_t HttpScanSession::scan_bypass_content_type(const HttpHeaders & c_headers) +{ + std::string content_type; + + c_headers.ForEachValueOfHeader("Content-Type", [&content_type] + (const std::string & field, const std::string & value) + { + content_type = value; return false; + }); + + if (content_type.find("text") != 0) + { + return scan_result_t::kScanResultHit; + } + + return scan_result_t::kScanResultNotHit; +} + void HttpScanSession::hit_config_and_do_action(HttpSession * session) { /* 判断命中数量,若为多命中,选择优先级最高的动作执行 */ diff --git a/src/httpscan.h b/src/httpscan.h index e3891ce..d235521 100644 --- a/src/httpscan.h +++ b/src/httpscan.h @@ -75,6 +75,7 @@ private: kScanResultError = -1 }; + scan_result_t scan_bypass_content_type(const HttpHeaders & c_headers); scan_result_t scan_headers(const HttpHeaders & c_headers, int table_id); scan_result_t scan_body(const char * data, size_t len, int table_id); |
