Skip to content

Commit

Permalink
fix(config): fix config script to make it work with newer libinjection
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP committed Jan 25, 2025
1 parent f97a439 commit 87c2c11
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ srcs="$ngx_addon_dir/src/ngx_http_waf_module_core.c \
$ngx_addon_dir/src/ngx_http_waf_module_util.c \
$ngx_addon_dir/src/ngx_http_waf_module_vm.c \
$ngx_addon_dir/src/ngx_http_waf_module_lexer.c \
$ngx_addon_dir/src/ngx_http_waf_module_parser.tab.c \
$ngx_addon_dir/inc/libinjection/src/libinjection_html5.c \
$ngx_addon_dir/inc/libinjection/src/libinjection_sqli.c \
$ngx_addon_dir/inc/libinjection/src/libinjection_xss.c"

$ngx_addon_dir/src/ngx_http_waf_module_parser.tab.c"

ngx_http_waf_module_libs=""

Expand All @@ -45,7 +41,7 @@ if [ $? -ne 0 ] ; then
$0: error: the $ngx_addon_name module requires the flex.

Please run:
On Ubuntu or Debian:
On Ubuntu or Debian:
apt-get update && apt-get install --yes flex
On CentOS 7:
yum -y install flex
Expand Down Expand Up @@ -73,7 +69,7 @@ if [ $? -ne 0 ] ; then
$0: error: the $ngx_addon_name module requires the bison.

Please run:
On Ubuntu or Debian:
On Ubuntu or Debian:
apt-get update && apt-get install --yes bison
On CentOS 7:
yum -y install bison
Expand Down Expand Up @@ -129,7 +125,7 @@ ngx_feature_incs="#include <utstack.h>"
ngx_feature_libs=$ngx_http_waf_module_libs
ngx_feature_test=
. auto/feature
if [ $ngx_found = no ] ; then
if [ $ngx_found = no ] ; then
PWD=$(pwd)
cat << END
$0: error: the $ngx_addon_name module requires the $ngx_feature.
Expand Down Expand Up @@ -173,7 +169,7 @@ if (j == 1) { return 1; }
END
)
. auto/feature
if [ $ngx_found = no ] ; then
if [ $ngx_found = no ] ; then
cat << END
$0: error: the $ngx_addon_name module requires the $ngx_feature, make sure your C compiler supports and enables the C99 standard.

Expand All @@ -183,8 +179,12 @@ END
exit 1
fi


ngx_http_waf_module_inc_path="${ngx_http_waf_module_inc_path} ${ngx_addon_dir}/inc/libinjection/src"
if [ -n "$LIB_INJECTION" ] ; then
ngx_http_waf_module_inc_path="${ngx_http_waf_module_inc_path} ${LIB_INJECTION}/include"
ngx_http_waf_module_libs=" ${ngx_http_waf_module_libs} -L ${LIB_INJECTION}/lib -Wl,-Bstatic -l injection -Wl,-Bdynamic "
else
ngx_http_waf_module_libs=" ${ngx_http_waf_module_libs} -l injection "
fi


# Check if libinjection exists.
Expand All @@ -197,20 +197,28 @@ ngx_feature_incs=$(cat << END
#include <libinjection.h>
#include <libinjection_sqli.h>
#include <libinjection_xss.h>
#include <libinjection_html5.h>

END
)

ngx_feature_libs=$ngx_http_waf_module_libs
ngx_feature_test=
. auto/feature
if [ $ngx_found = no ] ; then
if [ $ngx_found = no ] ; then
PWD=$(pwd)
cat << END
$0: error: the $ngx_addon_name module requires the $ngx_feature.

Please run cd $ngx_addon_dir && git clone https://github.com/libinjection/libinjection.git inc/libinjection && cd $PWD

Please run
# You can remove directories libinjection-src and libinjection after installing the ngx_http_waf_module.
git clone https://github.com/libinjection/libinjection.git libinjection-src \\
&& cd libinjection-src \\
&& ./autogen.sh \\
&& ./configure --prefix=$PWD/libinjection \\
&& make -j\$(nproc) && make install \\
&& export LIB_INJECTION=$PWD/libinjection \\
&& cd $PWD
END
PWD=''
exit 1
Expand All @@ -232,15 +240,15 @@ ngx_feature_incs='#include <sodium.h>'
ngx_feature_libs=$ngx_http_waf_module_libs
ngx_feature_test=
. auto/feature
if [ $ngx_found = no ] ; then
if [ $ngx_found = no ] ; then
PWD=$(pwd)
cat << END
$0: error: the $ngx_addon_name module requires the $ngx_feature.

Please run:
On Ubuntu or Debian:
On Ubuntu or Debian:
apt-get update && apt-get install --yes libsodium23 libsodium-dev
On Alpine:
On Alpine:
apk update && apk add libsodium libsodium-dev
On other OS:
# You can remove directories libsodium-src and libsodium after installing the ngx_http_waf_module.
Expand Down Expand Up @@ -275,7 +283,7 @@ if test -n "$ngx_module_link"; then
ngx_module_incs=$ngx_http_waf_module_inc_path
ngx_module_srcs=$srcs
ngx_module_libs=$ngx_http_waf_module_libs

# Let ngx_http_access_module initialize before this module,
# so that this module can take effect after ngx_http_access_module,
# because the initialization order and the effective order are reversed.
Expand Down

0 comments on commit 87c2c11

Please sign in to comment.