nbs-system / naxsi

NAXSI is an open-source, high performance, low rules maintenance WAF for NGINX
GNU General Public License v3.0
4.8k stars 606 forks source link

Fix: use pcre2 when building with nginx >= 1.21.5 #585

Closed laluigino closed 2 years ago

laluigino commented 2 years ago

I've tried to compile naxsi 1.3 as module for nginx 1.21.6, and got the error:

error: invalid use of incomplete typedef 'ngx_regex_t' {aka 'struct pcre2_real_code_8'} 205 | (tmp_idx < len && (match = pcre_exec(rl->br->rx->regex->code,

I found this issue report: Ref: https://github.com/nbs-system/naxsi/issues/580 then i tried to solve the pcre2 compatibility issue.

I've included an helper function that is 'copied' from: https://github.com/nginx/nginx/blob/master/src/core/ngx_regex.c#L393 that it is called in place of 'pcre_exec' when nginx_version >= 1021005

Not sure if this is the best solution, but I managed to build naxsi 1.3 as module for nginx 1.21.6 succesfully, and it seems to work well.

I'm not used to develop in C anymore (since 25 years ago, at least!), but I hope that this patch I made can help anybody else.

AarbozT commented 2 years ago

Hi! My report of successful build on CentOS 7.8: I recently compiled Naxsi v1.3 with Nginx v1.21.6 as a dynamic module with no compile issues.

Previously I used Naxsi v1.0 with Nginx v1.18.0 also as a dynamic module without compilation problems.

And once deployed and tested I don't see execution and operation problems either.