Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(CAPTCHA): verify CAPTCHA responses using subrequests instead of libcurl #140

Draft
wants to merge 2 commits into
base: current-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 0 additions & 226 deletions include/ngx_http_waf_module_action.h

This file was deleted.

1 change: 0 additions & 1 deletion include/ngx_http_waf_module_captcha.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <ngx_http_waf_module_macro.h>
#include <ngx_http_waf_module_type.h>
#include <ngx_http_waf_module_util.h>
#include <ngx_http_waf_module_action.h>
#include <ngx_http_waf_module_check.h>
#include <cJSON.h>

Expand Down
24 changes: 12 additions & 12 deletions include/ngx_http_waf_module_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void ngx_http_waf_handler_cleanup(void *data);
* @retval MATCHED IP 地址在白名单中。
* @retval NOT_MATCHED IP 地址不在白名单中。
*/
ngx_int_t ngx_http_waf_handler_check_white_ip(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_white_ip(ngx_http_request_t* r);


/**
Expand All @@ -51,7 +51,7 @@ ngx_int_t ngx_http_waf_handler_check_white_ip(ngx_http_request_t* r);
* @retval MATCHED IP 地址在黑名单中。
* @retval NOT_MATCHED IP 地址不在黑名单中。
*/
ngx_int_t ngx_http_waf_handler_check_black_ip(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_black_ip(ngx_http_request_t* r);


/**
Expand All @@ -60,7 +60,7 @@ ngx_int_t ngx_http_waf_handler_check_black_ip(ngx_http_request_t* r);
* @retval MATCHED 超出限制。
* @retval NOT_MATCHED 未超出限制。
*/
ngx_int_t ngx_http_waf_handler_check_cc(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_cc(ngx_http_request_t* r);


/**
Expand All @@ -69,7 +69,7 @@ ngx_int_t ngx_http_waf_handler_check_cc(ngx_http_request_t* r);
* @retval MATCHED 在白名单中。
* @retval NOT_MATCHED 不在白名单中
*/
ngx_int_t ngx_http_waf_handler_check_white_url(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_white_url(ngx_http_request_t* r);


/**
Expand All @@ -78,7 +78,7 @@ ngx_int_t ngx_http_waf_handler_check_white_url(ngx_http_request_t* r);
* @retval MATCHED 在黑名单中。
* @retval NOT_MATCHED 不在黑名单中
*/
ngx_int_t ngx_http_waf_handler_check_black_url(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_black_url(ngx_http_request_t* r);


/**
Expand All @@ -87,7 +87,7 @@ ngx_int_t ngx_http_waf_handler_check_black_url(ngx_http_request_t* r);
* @retval MATCHED 在黑名单中。
* @retval NOT_MATCHED 不在黑名单中
*/
ngx_int_t ngx_http_waf_handler_check_black_args(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_black_args(ngx_http_request_t* r);


/**
Expand All @@ -96,7 +96,7 @@ ngx_int_t ngx_http_waf_handler_check_black_args(ngx_http_request_t* r);
* @retval MATCHED 在黑名单中。
* @retval NOT_MATCHED 不在黑名单中
*/
ngx_int_t ngx_http_waf_handler_check_black_user_agent(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_black_user_agent(ngx_http_request_t* r);


/**
Expand All @@ -105,7 +105,7 @@ ngx_int_t ngx_http_waf_handler_check_black_user_agent(ngx_http_request_t* r);
* @retval MATCHED 在白名单中。
* @retval NOT_MATCHED 不在白黑名单中
*/
ngx_int_t ngx_http_waf_handler_check_white_referer(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_white_referer(ngx_http_request_t* r);


/**
Expand All @@ -114,7 +114,7 @@ ngx_int_t ngx_http_waf_handler_check_white_referer(ngx_http_request_t* r);
* @retval MATCHED 在黑名单中。
* @retval NOT_MATCHED 不在黑名单中
*/
ngx_int_t ngx_http_waf_handler_check_black_referer(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_black_referer(ngx_http_request_t* r);


/**
Expand All @@ -123,13 +123,13 @@ ngx_int_t ngx_http_waf_handler_check_black_referer(ngx_http_request_t* r);
* @retval MATCHED 在黑名单中。
* @retval NOT_MATCHED 不在黑名单中
*/
ngx_int_t ngx_http_waf_handler_check_black_cookie(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_black_cookie(ngx_http_request_t* r);


/**
* @brief 检查请求体内容是否存在于黑名单中,存在则拦截,反之放行。
*/
ngx_int_t ngx_http_waf_handler_check_black_post(ngx_http_request_t* r);
ngx_http_waf_check_result_t ngx_http_waf_handler_check_black_post(ngx_http_request_t* r);


/**
Expand All @@ -140,7 +140,7 @@ ngx_int_t ngx_http_waf_handler_check_black_post(ngx_http_request_t* r);
* @param[in] cache 检测时所使用的缓存管理器
* @return 如果匹配到返回 NGX_HTTP_WAF_MATCHED,反之则为 NGX_HTTP_WAF_NOT_MATCHED。
*/
ngx_int_t ngx_http_waf_regex_exec_arrray(ngx_http_request_t* r,
ngx_http_waf_check_result_t ngx_http_waf_regex_exec_arrray(ngx_http_request_t* r,
ngx_str_t* str,
ngx_array_t* array,
const u_char* rule_type,
Expand Down
4 changes: 0 additions & 4 deletions include/ngx_http_waf_module_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@
#include <ngx_http_waf_module_shm.h>
#include <ngx_http_waf_module_modsecurity.h>
#include <ngx_http_waf_module_data.h>
#include <ngx_http_waf_module_action.h>


extern ngx_int_t ngx_http_waf_handler_access_phase(ngx_http_request_t* r);


extern ngx_int_t ngx_http_waf_handler_precontent_phase(ngx_http_request_t* r);


extern ngx_int_t ngx_http_waf_handler_log_phase(ngx_http_request_t* r);


Expand Down
6 changes: 0 additions & 6 deletions include/ngx_http_waf_module_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ ngx_int_t ngx_http_waf_init_process(ngx_cycle_t *cycle);
ngx_int_t ngx_http_waf_handler_access_phase(ngx_http_request_t* r);


/**
* @brief NGX_HTTP_CONTENT_PHASE 阶段的处理函数
*/
ngx_int_t ngx_http_waf_handler_precontent_phase(ngx_http_request_t* r);


/**
* @brief NGX_HTTP_LOG_PHASE 阶段的处理函数
*/
Expand Down
8 changes: 6 additions & 2 deletions include/ngx_http_waf_module_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#define NGX_HTTP_WAF_VERSION "v10.1.1"

#define NGX_HTTP_WAF_ASYNC_MODSECURITY (0)

/* 对应配置文件的文件名 */
#define NGX_HTTP_WAF_IPV4_FILE ("ipv4")
#define NGX_HTTP_WAF_IPV6_FILE ("ipv6")
Expand Down Expand Up @@ -335,6 +333,12 @@
#define ngx_http_waf_check_bit(origin, bit_index) (ngx_http_waf_check_flag((origin), 1 << (bit_index)))


#define ngx_http_waf_is_subrequest(r) ((r)->main != (r))


#define ngx_http_waf_is_internal_request(r) ((r)->internal)


#define ngx_http_waf_is_unset_or_disable_value(x) (((x) == NGX_CONF_UNSET) || ((x) == 0))


Expand Down
Loading
Loading