Skip to content

Commit a30e0da

Browse files
committed
remove yajl
1 parent 98fd8f7 commit a30e0da

42 files changed

Lines changed: 3532 additions & 1030 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/msc_find_lib.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ dnl Sets and AC_SUBSTs:
1010
dnl ${NAME}_CFLAGS, ${NAME}_LDADD, ${NAME}_LDFLAGS,
1111
dnl ${NAME}_VERSION, ${NAME}_DISPLAY, ${NAME}_FOUND (0/1/2)
1212
dnl
13-
dnl NAME - Variable prefix (e.g., YAJL, CURL, LIBXML2)
13+
dnl NAME - Variable prefix (e.g., CURL, LIBXML2, LMDB)
1414
dnl PKG_NAMES - Space-separated pkg-config names to try
15-
dnl HEADER - Header file to look for (e.g., yajl/yajl_parse.h)
15+
dnl HEADER - Header file to look for (e.g., libxml/parser.h)
1616
dnl LIB_NAMES - Space-separated library names for -l flags
17-
dnl EXTRA_CFLAGS - Additional CFLAGS when found (e.g., -DWITH_YAJL)
17+
dnl EXTRA_CFLAGS - Additional CFLAGS when found (e.g., -DWITH_LIBXML2)
1818
dnl MIN_VERSION - Optional minimum version for pkg-config check
1919
dnl WITH_NAME - Optional --with-X name if different from lowercased NAME
2020

@@ -208,7 +208,7 @@ if test "${_msc_header_dir}" = "."; then
208208
_msc_check_inc_path="$4"
209209
fi
210210
else
211-
# Header with subdirectory (e.g., "yajl/yajl_parse.h")
211+
# Header with subdirectory (e.g., "libxml/parser.h")
212212
if test -e "$4/include/$2"; then
213213
_msc_check_inc_path="$4/include"
214214
elif test -e "$4/$2"; then

build/win32/CMakeLists.txt

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ option(WITH_LUA "Include LUA support" ON)
77
option(WITH_LIBXML2 "Include LibXML2 support" ON)
88
option(WITH_MAXMIND "Include MaxMind support" ON)
99
option(WITH_CURL "Include CURL support" ON)
10+
set(JSON_BACKEND "simdjson" CACHE STRING "Select internal JSON backend (simdjson or jsoncons)")
11+
set_property(CACHE JSON_BACKEND PROPERTY STRINGS simdjson jsoncons)
1012

1113
option(USE_ASAN "Build with Address Sanitizer" OFF)
1214

@@ -51,6 +53,8 @@ target_compile_definitions(libinjection PRIVATE LIBINJECTION_VERSION="${LIBINJEC
5153
project(mbedcrypto C)
5254

5355
set(MBEDTLS_DIR ${BASE_DIR}/others/mbedtls)
56+
set(SIMDJSON_DIR ${BASE_DIR}/others/simdjson/singleheader)
57+
set(JSONCONS_DIR ${BASE_DIR}/others/jsoncons/include)
5458

5559
add_library(mbedcrypto STATIC ${MBEDTLS_DIR}/library/base64.c ${MBEDTLS_DIR}/library/sha1.c ${MBEDTLS_DIR}/library/md5.c ${MBEDTLS_DIR}/library/platform_util.c ${MBEDTLS_DIR}/library/constant_time.c)
5660

@@ -87,7 +91,25 @@ set(PACKAGE_VERSION "${PROJECT_VERSION}")
8791
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
8892
set(PACKAGE_TARNAME "${PACKAGE_NAME}")
8993

90-
set(HAVE_YAJL 1) # should always be one, mandatory dependency
94+
if(NOT JSON_BACKEND STREQUAL "simdjson" AND NOT JSON_BACKEND STREQUAL "jsoncons")
95+
message(FATAL_ERROR "Unsupported JSON_BACKEND '${JSON_BACKEND}'. Use simdjson or jsoncons.")
96+
endif()
97+
98+
unset(MSC_JSON_BACKEND_SIMDJSON)
99+
unset(MSC_JSON_BACKEND_JSONCONS)
100+
set(JSON_BACKEND_SIMDJSON_SOURCE ${BASE_DIR}/src/request_body_processor/json_backend_simdjson.cc)
101+
set(JSON_BACKEND_JSONCONS_SOURCE ${BASE_DIR}/src/request_body_processor/json_backend_jsoncons.cc)
102+
103+
if(JSON_BACKEND STREQUAL "simdjson")
104+
set(MSC_JSON_BACKEND_SIMDJSON 1)
105+
set(JSON_BACKEND_SOURCES ${JSON_BACKEND_SIMDJSON_SOURCE} ${SIMDJSON_DIR}/simdjson.cpp)
106+
set(JSON_BACKEND_INCLUDE_DIR ${SIMDJSON_DIR})
107+
else()
108+
set(MSC_JSON_BACKEND_JSONCONS 1)
109+
set(JSON_BACKEND_SOURCES ${JSON_BACKEND_JSONCONS_SOURCE})
110+
set(JSON_BACKEND_INCLUDE_DIR ${JSONCONS_DIR})
111+
endif()
112+
91113
set(HAVE_GEOIP 0) # should always be zero, no conan package available
92114
set(HAVE_SSDEEP 0) # should always be zero, no conan package available
93115

@@ -119,7 +141,6 @@ macro(include_package package flag)
119141
endif()
120142
endmacro()
121143

122-
include_package(yajl HAVE_YAJL)
123144
include_package(libxml2 HAVE_LIBXML2)
124145
include_package(lua HAVE_LUA)
125146
include_package(CURL HAVE_CURL)
@@ -133,11 +154,13 @@ include_package(maxminddb HAVE_MAXMIND)
133154
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
134155

135156
file(GLOB_RECURSE libModSecuritySources ${BASE_DIR}/src/*.cc)
157+
list(REMOVE_ITEM libModSecuritySources ${JSON_BACKEND_SIMDJSON_SOURCE} ${JSON_BACKEND_JSONCONS_SOURCE})
158+
list(APPEND libModSecuritySources ${JSON_BACKEND_SOURCES})
136159

137160
add_library(libModSecurity SHARED ${libModSecuritySources})
138161

139162
target_compile_definitions(libModSecurity PRIVATE WITH_PCRE2)
140-
target_include_directories(libModSecurity PRIVATE ${BASE_DIR} ${BASE_DIR}/headers ${BASE_DIR}/others ${MBEDTLS_DIR}/include)
163+
target_include_directories(libModSecurity PRIVATE ${BASE_DIR} ${BASE_DIR}/headers ${BASE_DIR}/others ${MBEDTLS_DIR}/include ${JSON_BACKEND_INCLUDE_DIR})
141164
target_link_libraries(libModSecurity PRIVATE pcre2::pcre2 libinjection mbedcrypto Poco::Poco Iphlpapi.lib)
142165

143166
macro(add_package_dependency project compile_definition link_library flag)
@@ -147,7 +170,6 @@ macro(add_package_dependency project compile_definition link_library flag)
147170
endif()
148171
endmacro()
149172

150-
add_package_dependency(libModSecurity WITH_YAJL yajl::yajl HAVE_YAJL)
151173
add_package_dependency(libModSecurity WITH_LIBXML2 LibXml2::LibXml2 HAVE_LIBXML2)
152174
add_package_dependency(libModSecurity WITH_LUA lua::lua HAVE_LUA)
153175
if(HAVE_LUA)
@@ -164,9 +186,8 @@ project(libModSecurityTests)
164186

165187
function(setTestTargetProperties executable)
166188
target_compile_definitions(${executable} PRIVATE WITH_PCRE2)
167-
target_include_directories(${executable} PRIVATE ${BASE_DIR} ${BASE_DIR}/headers)
189+
target_include_directories(${executable} PRIVATE ${BASE_DIR} ${BASE_DIR}/headers ${JSONCONS_DIR})
168190
target_link_libraries(${executable} PRIVATE libModSecurity pcre2::pcre2 dirent::dirent)
169-
add_package_dependency(${executable} WITH_YAJL yajl::yajl HAVE_YAJL)
170191
endfunction()
171192

172193
# unit tests

build/win32/conanfile.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[requires]
2-
yajl/2.1.0
32
pcre2/10.42
43
libxml2/2.12.6
54
lua/5.4.6

build/win32/config.h.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@
5757
/* Define if SSDEEP is available */
5858
#cmakedefine HAVE_SSDEEP
5959

60-
/* Define if YAJL is available */
61-
#cmakedefine HAVE_YAJL
62-
6360
/* Define if libcurl is available */
6461
#cmakedefine HAVE_CURL
6562

63+
/* Define if jsoncons is the selected internal JSON backend */
64+
#cmakedefine MSC_JSON_BACKEND_JSONCONS
65+
66+
/* Define if simdjson is the selected internal JSON backend */
67+
#cmakedefine MSC_JSON_BACKEND_SIMDJSON
68+
6669
/* Name of package */
6770
#define PACKAGE "@PACKAGE_NAME@"
6871

@@ -89,4 +92,4 @@
8992
#cmakedefine STDC_HEADERS
9093
#endif
9194

92-
#endif // ndef MODSECURITY_CONFIG_H
95+
#endif // ndef MODSECURITY_CONFIG_H

build/yajl.m4

Lines changed: 0 additions & 33 deletions
This file was deleted.

configure.ac

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ m4_define([msc_version_with_patchlevel],
2727
[msc_version_major.msc_version_minor.msc_version_patchlevel])
2828

2929
m4_define([msc_version_git],
30-
[m4_esyscmd_s(git describe)])
30+
[m4_esyscmd_s(git describe --tags --always 2>/dev/null || echo unknown)])
3131

3232
m4_define([msc_version_info],
3333
[msc_version_c_plus_a:msc_version_patchlevel:msc_version_minor])
@@ -62,6 +62,23 @@ PKG_PROG_PKG_CONFIG
6262
# Set C++ standard version and check if compiler supports it.
6363
AX_CXX_COMPILE_STDCXX(17, noext, mandatory)
6464

65+
AC_ARG_WITH([json-backend],
66+
[AS_HELP_STRING([--with-json-backend=BACKEND],
67+
[Select internal JSON backend: simdjson or jsoncons [default=simdjson]])],
68+
[json_backend="$withval"],
69+
[json_backend="simdjson"])
70+
71+
case "$json_backend" in
72+
simdjson|jsoncons)
73+
;;
74+
*)
75+
AC_MSG_ERROR([Unsupported JSON backend '$json_backend'. Use simdjson or jsoncons.])
76+
;;
77+
esac
78+
79+
JSON_BACKEND="$json_backend"
80+
AC_SUBST([JSON_BACKEND])
81+
6582
# Check for libinjection
6683
if ! test -f "${srcdir}/others/libinjection/src/libinjection_html5.c"; then
6784
AC_MSG_ERROR([\
@@ -80,7 +97,7 @@ AC_MSG_ERROR([\
8097
])
8198
fi
8299
# Libinjection version
83-
AC_DEFUN([LIBINJECTION_VERSION], m4_esyscmd_s(cd "others/libinjection" && git describe && cd ../..))
100+
AC_DEFUN([LIBINJECTION_VERSION], m4_esyscmd_s(cd "others/libinjection" && (git describe --tags --always 2>/dev/null || echo unknown) && cd ../..))
84101
AC_SUBST([LIBINJECTION_VERSION])
85102

86103
# Check for Mbed TLS
@@ -101,16 +118,56 @@ AC_MSG_ERROR([\
101118
])
102119
fi
103120
# Mbed TLS version
104-
AC_DEFUN([MBEDTLS_VERSION], m4_esyscmd_s(cd "others/mbedtls" && git describe && cd ../..))
121+
AC_DEFUN([MBEDTLS_VERSION], m4_esyscmd_s(cd "others/mbedtls" && (git describe --tags --always 2>/dev/null || echo unknown) && cd ../..))
105122

106-
# SecLang test version
107-
AC_DEFUN([SECLANG_TEST_VERSION], m4_esyscmd_s(cd "test/test-cases/secrules-language-tests" && git log -1 --format="%h" --abbrev-commit && cd ../../..))
123+
# Check for selected JSON backend
124+
if test "x$json_backend" = "xsimdjson"; then
125+
if ! test -f "${srcdir}/others/simdjson/singleheader/simdjson.h" || \
126+
! test -f "${srcdir}/others/simdjson/singleheader/simdjson.cpp"; then
127+
AC_MSG_ERROR([\
128+
129+
130+
simdjson was not found within ModSecurity source directory.
131+
132+
simdjson code is available as part of ModSecurity source code in a format
133+
of a git-submodule. git-submodule allow us to specify the correct version of
134+
simdjson and still uses the simdjson repository to download it.
135+
136+
You can download simdjson using git:
137+
138+
$ git submodule update --init --recursive
139+
140+
])
141+
fi
142+
JSON_BACKEND_VERSION=`cd "${srcdir}/others/simdjson" && git describe --tags --always 2>/dev/null || echo unknown`
143+
AC_DEFINE([MSC_JSON_BACKEND_SIMDJSON], [1],
144+
[Define if simdjson is the selected internal JSON backend])
145+
elif test "x$json_backend" = "xjsoncons"; then
146+
if ! test -d "${srcdir}/others/jsoncons/include" || \
147+
! test -f "${srcdir}/others/jsoncons/include/jsoncons/json.hpp"; then
148+
AC_MSG_ERROR([\
149+
150+
151+
jsoncons was not found within ModSecurity source directory.
108152
153+
jsoncons code is available as part of ModSecurity source code in a format
154+
of a git-submodule. git-submodule allow us to specify the correct version of
155+
jsoncons and still uses the jsoncons repository to download it.
109156
110-
# Check for yajl
111-
PROG_YAJL
157+
You can download jsoncons using git:
112158
113-
AM_CONDITIONAL([YAJL_VERSION], [test "$YAJL_VERSION" != ""])
159+
$ git submodule update --init --recursive
160+
161+
])
162+
fi
163+
JSON_BACKEND_VERSION=`cd "${srcdir}/others/jsoncons" && git describe --tags --always 2>/dev/null || echo unknown`
164+
AC_DEFINE([MSC_JSON_BACKEND_JSONCONS], [1],
165+
[Define if jsoncons is the selected internal JSON backend])
166+
fi
167+
AC_SUBST([JSON_BACKEND_VERSION])
168+
169+
# SecLang test version
170+
AC_DEFUN([SECLANG_TEST_VERSION], m4_esyscmd_s(cd "test/test-cases/secrules-language-tests" && git log -1 --format="%h" --abbrev-commit && cd ../../..))
114171

115172
# Check for LibGeoIP
116173
PROG_GEOIP
@@ -306,14 +363,7 @@ fi
306363

307364

308365
# Decide if we want to build the tests or not.
309-
buildTestUtilities=false
310-
if test "x$YAJL_FOUND" = "x1"; then
311-
# Regression tests will not be able to run without the logging support.
312-
# But we still have the unit tests.
313-
# if test "$debugLogs" = "true"; then
314-
buildTestUtilities=true
315-
# fi
316-
fi
366+
buildTestUtilities=true
317367

318368

319369
AM_CONDITIONAL([TEST_UTILITIES], [test $buildTestUtilities = true])
@@ -328,6 +378,8 @@ fi
328378
AM_CONDITIONAL([EXAMPLES], [test $buildExamples = true])
329379
AM_CONDITIONAL([BUILD_PARSER], [test $buildParser = true])
330380
AM_CONDITIONAL([USE_MUTEX_ON_PM], [test $mutexPm = true])
381+
AM_CONDITIONAL([JSON_BACKEND_SIMDJSON], [test "x$json_backend" = "xsimdjson"])
382+
AM_CONDITIONAL([JSON_BACKEND_JSONCONS], [test "x$json_backend" = "xjsoncons"])
331383

332384

333385
# General link options
@@ -422,6 +474,8 @@ AS_ECHO_N(" + libInjection ....")
422474
echo LIBINJECTION_VERSION
423475
AS_ECHO_N(" + Mbed TLS ....")
424476
echo MBEDTLS_VERSION
477+
AS_ECHO_N(" + JSON backend ....")
478+
echo "$JSON_BACKEND ($JSON_BACKEND_VERSION)"
425479
AS_ECHO_N(" + SecLang tests ....")
426480
echo SECLANG_TEST_VERSION
427481

@@ -451,7 +505,6 @@ if test "x$GEOIP_FOUND" = "x2" && test "x$MAXMIND_FOUND" = "x2"; then
451505
fi
452506

453507
MSC_STATUS_LIB([LibCURL ], [CURL])
454-
MSC_STATUS_LIB([YAJL ], [YAJL])
455508
MSC_STATUS_LIB([LMDB ], [LMDB])
456509
MSC_STATUS_LIB([LibXML2 ], [LIBXML2])
457510
MSC_STATUS_LIB([SSDEEP ], [SSDEEP])
@@ -532,4 +585,3 @@ if test "$aflFuzzer" = "true"; then
532585
echo " $ export CC=afl-clang-fast "
533586
echo " "
534587
fi
535-

examples/multiprocess_c/Makefile.am

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ multi_LDFLAGS = \
1919
-lstdc++ \
2020
$(LUA_LDFLAGS) \
2121
$(SSDEEP_LDFLAGS) \
22-
$(MAXMIND_LDFLAGS) \
23-
$(YAJL_LDFLAGS)
22+
$(MAXMIND_LDFLAGS)
2423

2524
multi_CFLAGS = \
26-
-I$(top_builddir)/headers \
25+
-I$(top_srcdir)/headers \
2726
-I$(top_builddir) \
2827
$(GLOBAL_CFLAGS)
2928

3029
MAINTAINERCLEANFILES = \
3130
Makefile.in
32-
33-

examples/multithread/Makefile.am

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ multithread_LDADD = \
1515
$(LUA_LDADD) \
1616
$(PCRE_LDADD) \
1717
$(PCRE2_LDADD) \
18-
$(SSDEEP_LDADD) \
19-
$(YAJL_LDADD)
18+
$(SSDEEP_LDADD)
2019

2120
multithread_LDFLAGS = \
2221
-L$(top_builddir)/src/.libs/ \
@@ -28,12 +27,11 @@ multithread_LDFLAGS = \
2827
$(LMDB_LDFLAGS) \
2928
$(LUA_LDFLAGS) \
3029
$(MAXMIND_LDFLAGS) \
31-
$(SSDEEP_LDFLAGS) \
32-
$(YAJL_LDFLAGS)
30+
$(SSDEEP_LDFLAGS)
3331

3432
multithread_CPPFLAGS = \
3533
$(GLOBAL_CFLAGS) \
36-
-I$(top_builddir)/headers \
34+
-I$(top_srcdir)/headers \
3735
-I$(top_builddir) \
3836
-g \
3937
-I../others \
@@ -43,7 +41,6 @@ multithread_CPPFLAGS = \
4341
$(GEOIP_CFLAGS) \
4442
$(GLOBAL_CPPFLAGS) \
4543
$(MODSEC_NO_LOGS) \
46-
$(YAJL_CFLAGS) \
4744
$(LMDB_CFLAGS) \
4845
$(LUA_CFLAGS) \
4946
$(PCRE_CFLAGS) \
@@ -53,5 +50,3 @@ multithread_CPPFLAGS = \
5350

5451
MAINTAINERCLEANFILES = \
5552
Makefile.in
56-
57-

0 commit comments

Comments
 (0)