Skip to content

Commit 878682f

Browse files
committed
Removed support to build without YAJL, which is a mandatory dependency.
1 parent 2fd45f8 commit 878682f

File tree

9 files changed

+56
-161
lines changed

9 files changed

+56
-161
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ jobs:
178178
- name: Setup Dependencies
179179
run: |
180180
sudo apt-get update -y -qq
181-
sudo apt-get install -y cppcheck
181+
sudo apt-get install -y cppcheck libyajl-dev
182182
- name: Get libModSecurity v3 source
183183
uses: actions/checkout@v4
184184
with:

Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11

2-
if TEST_UTILITIES
32
export MAYBE_TEST = test
4-
endif
53

64
if EXAMPLES
75
export MAYBE_EXAMPLES = examples

build/yajl.m4

Lines changed: 37 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl Check for YAJL Libraries
22
dnl CHECK_YAJL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
33

4-
AC_DEFUN([PROG_YAJL], [
4+
AC_DEFUN([CHECK_YAJL], [
55
66
# Possible names for the yajl library/package (pkg-config)
77
YAJL_POSSIBLE_LIB_NAMES="yajl2 yajl"
@@ -24,80 +24,52 @@ AC_ARG_WITH(
2424
[AS_HELP_STRING([--with-yajl=PATH],[Path to yajl prefix or config script])]
2525
)
2626
27-
if test "x${with_yajl}" == "xno"; then
28-
AC_DEFINE(HAVE_YAJL, 0, [Support for YAJL was disabled by the utilization of --without-yajl or --with-yajl=no])
29-
AC_MSG_NOTICE([Support for YAJL was disabled by the utilization of --without-yajl or --with-yajl=no])
30-
YAJL_DISABLED=yes
31-
else
32-
if test "x${with_yajl}" == "xyes"; then
33-
YAJL_MANDATORY=yes
34-
AC_MSG_NOTICE([YAJL support was marked as mandatory by the utilization of --with-yajl=yes])
35-
fi
36-
# for x in ${YAJL_POSSIBLE_LIB_NAMES}; do
37-
# CHECK_FOR_YAJL_AT(${x})
38-
# if test -n "${YAJL_VERSION}"; then
39-
# break
40-
# fi
41-
# done
42-
43-
# if test "x${with_yajl}" != "xyes" or test "x${with_yajl}" == "xyes"; then
44-
if test "x${with_yajl}" == "x" || test "x${with_yajl}" == "xyes"; then
45-
# Nothing about YAJL was informed, using the pkg-config to figure things out.
46-
if test -n "${PKG_CONFIG}"; then
47-
YAJL_PKG_NAME=""
48-
for x in ${YAJL_POSSIBLE_LIB_NAMES}; do
49-
if ${PKG_CONFIG} --exists ${x}; then
50-
YAJL_PKG_NAME="$x"
51-
break
52-
fi
53-
done
27+
YAJL_MANDATORY=yes
28+
AC_MSG_NOTICE([YAJL is mandatory])
29+
30+
31+
if test "x${with_yajl}" == "x" || test "x${with_yajl}" == "xyes"; then
32+
# Nothing about YAJL was informed, using the pkg-config to figure things out.
33+
if test -n "${PKG_CONFIG}"; then
34+
YAJL_PKG_NAME=""
35+
for x in ${YAJL_POSSIBLE_LIB_NAMES}; do
36+
if ${PKG_CONFIG} --exists ${x}; then
37+
YAJL_PKG_NAME="$x"
38+
break
5439
fi
55-
AC_MSG_NOTICE([Nothing about YAJL was informed during the configure phase. Trying to detect it on the platform...])
56-
if test -n "${YAJL_PKG_NAME}"; then
57-
# Package was found using the pkg-config scripts
58-
YAJL_VERSION="`${PKG_CONFIG} ${YAJL_PKG_NAME} --modversion`"
59-
YAJL_CFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --cflags`"
60-
YAJL_LDADD="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-l`"
61-
YAJL_LDFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-L --libs-only-other`"
62-
YAJL_DISPLAY="${YAJL_LDADD}, ${YAJL_CFLAGS}"
63-
else
64-
# If pkg-config did not find anything useful, go over file lookup.
65-
for x in ${YAJL_POSSIBLE_LIB_NAMES}; do
66-
CHECK_FOR_YAJL_AT(${x})
67-
if test -n "${YAJL_VERSION}"; then
68-
break
69-
fi
70-
done
40+
done
41+
fi
42+
AC_MSG_NOTICE([Nothing about YAJL was informed during the configure phase. Trying to detect it on the platform...])
43+
if test -n "${YAJL_PKG_NAME}"; then
44+
# Package was found using the pkg-config scripts
45+
YAJL_VERSION="`${PKG_CONFIG} ${YAJL_PKG_NAME} --modversion`"
46+
YAJL_CFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --cflags`"
47+
YAJL_LDADD="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-l`"
48+
YAJL_LDFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-L --libs-only-other`"
49+
else
50+
# If pkg-config did not find anything useful, go over file lookup.
51+
for x in ${YAJL_POSSIBLE_PATHS}; do
52+
CHECK_FOR_YAJL_AT(${x})
53+
if test -n "${YAJL_LDADD}"; then
54+
break
7155
fi
72-
fi
73-
if test "x${with_yajl}" != "x"; then
74-
# An specific path was informed, lets check.
75-
YAJL_MANDATORY=yes
76-
CHECK_FOR_YAJL_AT(${with_yajl})
77-
fi
78-
# fi
56+
done
57+
fi
58+
elif test "x${with_yajl}" != "x"; then
59+
# A specific path was informed, let's check.
60+
CHECK_FOR_YAJL_AT(${with_yajl})
7961
fi
8062
8163
if test -z "${YAJL_LDADD}"; then
82-
if test -z "${YAJL_MANDATORY}"; then
83-
if test -z "${YAJL_DISABLED}"; then
84-
AC_MSG_NOTICE([YAJL library was not found])
85-
YAJL_FOUND=0
86-
else
87-
YAJL_FOUND=2
88-
fi
89-
else
90-
AC_MSG_ERROR([YAJL was explicitly referenced but it was not found])
91-
YAJL_FOUND=-1
92-
fi
64+
AC_MSG_ERROR([YAJL is mandatory but it was not found])
65+
YAJL_FOUND=-1
9366
else
9467
YAJL_FOUND=1
9568
AC_MSG_NOTICE([using YAJL v${YAJL_VERSION}])
96-
YAJL_CFLAGS="-DWITH_YAJL ${YAJL_CFLAGS}"
69+
YAJL_CFLAGS="${YAJL_CFLAGS}"
9770
YAJL_DISPLAY="${YAJL_LDADD}, ${YAJL_CFLAGS}"
9871
AC_SUBST(YAJL_VERSION)
9972
AC_SUBST(YAJL_LDADD)
100-
AC_SUBST(YAJL_LIBS)
10173
AC_SUBST(YAJL_LDFLAGS)
10274
AC_SUBST(YAJL_CFLAGS)
10375
AC_SUBST(YAJL_DISPLAY)
@@ -107,7 +79,7 @@ fi
10779
10880
AC_SUBST(YAJL_FOUND)
10981
110-
]) # AC_DEFUN [PROG_YAJL]
82+
]) # AC_DEFUN [CHECK_YAJL]
11183

11284

11385
AC_DEFUN([CHECK_FOR_YAJL_AT], [
@@ -164,6 +136,5 @@ AC_DEFUN([CHECK_FOR_YAJL_AT], [
164136
YAJL_CFLAGS="-I${yajl_inc_path}"
165137
YAJL_LDADD="-l${yajl_lib_name}"
166138
YAJL_LDFLAGS="-L${yajl_lib_path}"
167-
YAJL_DISPLAY="${yajl_lib_file}, ${yajl_inc_path}"
168139
fi
169140
]) # AC_DEFUN [CHECK_FOR_YAJL_AT]

configure.ac

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ AC_DEFUN([SECLANG_TEST_VERSION], m4_esyscmd_s(cd "test/test-cases/secrules-langu
8181

8282

8383
# Check for yajl
84-
PROG_YAJL
85-
86-
AM_CONDITIONAL([YAJL_VERSION], [test "$YAJL_VERSION" != ""])
84+
CHECK_YAJL
8785

8886
# Check for LibGeoIP
8987
PROG_GEOIP
@@ -318,24 +316,9 @@ if test $buildParser = true; then
318316
fi
319317
fi
320318

321-
322-
# Decide if we want to build the tests or not.
323-
buildTestUtilities=false
324-
if test "x$YAJL_FOUND" = "x1"; then
325-
# Regression tests will not be able to run without the logging support.
326-
# But we still have the unit tests.
327-
# if test "$debugLogs" = "true"; then
328-
buildTestUtilities=true
329-
# fi
330-
fi
331-
332-
333-
AM_CONDITIONAL([TEST_UTILITIES], [test $buildTestUtilities = true])
334-
if test $buildTestUtilities = true; then
335-
if test $debugLogs = true; then
336-
if test -f ./test/test-list.sh; then
337-
TEST_CASES=`./test/test-list.sh`
338-
fi
319+
if test $debugLogs = true; then
320+
if test -f ./test/test-list.sh; then
321+
TEST_CASES=`./test/test-list.sh`
339322
fi
340323
fi
341324

@@ -374,8 +357,7 @@ AC_CONFIG_FILES([\
374357
tools/rules-check/Makefile
375358
])
376359

377-
AM_COND_IF([TEST_UTILITIES],
378-
[AC_CONFIG_FILES([test/Makefile test/benchmark/Makefile])])
360+
AC_CONFIG_FILES([test/Makefile test/benchmark/Makefile])
379361

380362
AM_COND_IF([EXAMPLES],
381363
[AC_CONFIG_FILES([ \
@@ -423,6 +405,16 @@ echo " "
423405
echo "ModSecurity - ${MSC_GIT_VERSION} for $PLATFORM"
424406
echo " "
425407
echo " Mandatory dependencies"
408+
409+
## YAJL
410+
AS_ECHO_N(" + YAJL ....")
411+
if ! test "x$YAJL_VERSION" = "x"; then
412+
echo "v${YAJL_VERSION}"
413+
else
414+
echo ""
415+
fi
416+
echo " ${YAJL_DISPLAY}"
417+
426418
AS_ECHO_N(" + libInjection ....")
427419
echo LIBINJECTION_VERSION
428420
AS_ECHO_N(" + SecLang tests ....")
@@ -472,24 +464,6 @@ if test "x$CURL_FOUND" = "x2"; then
472464
fi
473465

474466

475-
## YAJL
476-
if test "x$YAJL_FOUND" = "x0"; then
477-
echo " + YAJL ....not found"
478-
fi
479-
if test "x$YAJL_FOUND" = "x1"; then
480-
AS_ECHO_N(" + YAJL ....found ")
481-
if ! test "x$YAJL_VERSION" = "x"; then
482-
echo "v${YAJL_VERSION}"
483-
else
484-
echo ""
485-
fi
486-
echo " ${YAJL_DISPLAY}"
487-
fi
488-
if test "x$YAJL_FOUND" = "x2"; then
489-
echo " + YAJL ....disabled"
490-
fi
491-
492-
493467
## LMDB
494468
if test "x$LMDB_FOUND" = "x0"; then
495469
echo " + LMDB ....not found"
@@ -580,14 +554,10 @@ fi
580554

581555
echo " "
582556
echo " Other Options"
583-
if test $buildTestUtilities = true; then
584-
if test $debugLogs = true; then
585-
echo " + Test Utilities ....enabled"
586-
else
587-
echo " + Test Utilities ....partially"
588-
fi
557+
if test $debugLogs = true; then
558+
echo " + Test Utilities ....enabled"
589559
else
590-
echo " + Test Utilities ....disabled"
560+
echo " + Test Utilities ....partially"
591561
fi
592562
if test $debugLogs = true; then
593563
echo " + SecDebugLog ....enabled"

src/modsecurity.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
#include "modsecurity/modsecurity.h"
1818
#include "src/config.h"
1919

20-
#ifdef WITH_YAJL
2120
#include <yajl/yajl_tree.h>
2221
#include <yajl/yajl_gen.h>
23-
#endif
2422
#ifdef WITH_LIBXML2
2523
#include <libxml/xmlschemas.h>
2624
#include <libxml/xpath.h>
@@ -222,7 +220,6 @@ void ModSecurity::serverLog(void *data, std::shared_ptr<RuleMessage> rm) {
222220

223221
int ModSecurity::processContentOffset(const char *content, size_t len,
224222
const char *matchString, std::string *json, const char **err) {
225-
#ifdef WITH_YAJL
226223
Utils::Regex variables("v([0-9]+),([0-9]+)");
227224
Utils::Regex operators("o([0-9]+),([0-9]+)");
228225
Utils::Regex transformations("t:(?:(?!t:).)+");
@@ -389,10 +386,6 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
389386

390387
yajl_gen_free(g);
391388
return 0;
392-
#else
393-
*err = "Without YAJL support, we cannot generate JSON.";
394-
return -1;
395-
#endif
396389
}
397390

398391

src/request_body_processor/json.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515

1616

17-
#ifdef WITH_YAJL
18-
1917
#include "src/request_body_processor/json.h"
2018

2119
#include <list>
@@ -314,7 +312,3 @@ int JSON::yajl_end_map(void *ctx) {
314312

315313
} // namespace RequestBodyProcessor
316314
} // namespace modsecurity
317-
318-
319-
#endif // WITH_YAJL
320-

src/request_body_processor/json.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#define SRC_REQUEST_BODY_PROCESSOR_JSON_H_
1818

1919

20-
#ifdef WITH_YAJL
21-
2220
#include <yajl/yajl_parse.h>
2321

2422
#include <string>
@@ -122,7 +120,5 @@ class JSON {
122120
} // namespace RequestBodyProcessor
123121
} // namespace modsecurity
124122

125-
#endif // WITH_YAJL
126-
127123
#endif // SRC_REQUEST_BODY_PROCESSOR_JSON_H_
128124

0 commit comments

Comments
 (0)