Skip to content

Commit 7c174e9

Browse files
authored
Merge pull request #3161 from eduar-hte/others-update
Update libinjection & Mbed TLS
2 parents dc8af8f + a3f40ef commit 7c174e9

23 files changed

+101
-4808
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ jobs:
5757
sudo apt-get install -y libgeoip-dev:${{ matrix.platform.arch }} \
5858
libfuzzy-dev:${{ matrix.platform.arch }}
5959
- uses: actions/checkout@v4
60-
with:
61-
submodules: true
60+
- name: get submodules
61+
# get submodules manually for git describe to work during build
62+
run: |
63+
git submodule init
64+
git submodule update
6265
- name: build.sh
6366
run: ./build.sh
6467
- name: configure
@@ -105,8 +108,11 @@ jobs:
105108
bison \
106109
flex
107110
- uses: actions/checkout@v4
108-
with:
109-
submodules: true
111+
- name: get submodules
112+
# get submodules manually for git describe to work during build
113+
run: |
114+
git submodule init
115+
git submodule update
110116
- name: build.sh
111117
run: ./build.sh
112118
- name: configure
@@ -135,8 +141,11 @@ jobs:
135141
- {label: "wo libxml", opt: "-WITHOUT_LIBXML2=ON" }
136142
steps:
137143
- uses: actions/checkout@v4
138-
with:
139-
submodules: true
144+
- name: Get submodules
145+
# get submodules manually for git describe to work during build
146+
run: |
147+
git submodule init
148+
git submodule update
140149
- name: Install Conan
141150
run: |
142151
pip3 install conan --upgrade

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "bindings/python"]
88
path = bindings/python
99
url = https://github.com/owasp-modsecurity/ModSecurity-Python-bindings.git
10+
[submodule "others/mbedtls"]
11+
path = others/mbedtls
12+
url = https://github.com/Mbed-TLS/mbedtls.git

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cppcheck:
6363
--enable=warning,style,performance,portability,unusedFunction,missingInclude \
6464
--inconclusive \
6565
--template="warning: {file},{line},{severity},{id},{message}" \
66-
-I headers -I . -I others -I src -I others/mbedtls -I src/parser \
66+
-I headers -I . -I others -I src -I others/mbedtls/include -I src/parser \
6767
--error-exitcode=1 \
6868
-i "src/parser/seclang-parser.cc" -i "src/parser/seclang-scanner.cc" \
6969
--force --verbose .

build/win32/CMakeLists.txt

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ option(USE_ASAN "Build with Address Sanitizer" OFF)
1414

1515
# NOTE: MBEDTLS_CONFIG_FILE is not only required to compile the mbedtls subset in others, but also
1616
# when their headers are included while compiling libModSecurity
17-
add_compile_definitions(WIN32 _CRT_SECURE_NO_WARNINGS MBEDTLS_CONFIG_FILE="mbed-tls-config.h")
17+
add_compile_definitions(WIN32 _CRT_SECURE_NO_WARNINGS MBEDTLS_CONFIG_FILE="mbedtls/mbedtls_config.h")
1818

1919
# set standards conformance preprocessor & compiler to align with cross-compiled codebase
2020
# NOTE: otherwise visual c++'s default compiler/preprocessor behaviour generates C4067 warnings
@@ -30,15 +30,41 @@ endif()
3030

3131
project(libinjection C)
3232

33-
add_library(libinjection STATIC ${BASE_DIR}/others/libinjection/src/libinjection_sqli.c ${BASE_DIR}/others/libinjection/src/libinjection_xss.c ${BASE_DIR}/others/libinjection/src/libinjection_html5.c)
33+
set(LIBINJECTION_DIR ${BASE_DIR}/others/libinjection)
3434

35-
# mbedtls
35+
add_library(libinjection STATIC ${LIBINJECTION_DIR}/src/libinjection_sqli.c ${LIBINJECTION_DIR}/src/libinjection_xss.c ${LIBINJECTION_DIR}/src/libinjection_html5.c)
3636

37-
project(mbedtls C)
37+
# get libinjection version with git describe
38+
execute_process(
39+
COMMAND git describe
40+
WORKING_DIRECTORY ${LIBINJECTION_DIR}
41+
OUTPUT_VARIABLE LIBINJECTION_VERSION
42+
OUTPUT_STRIP_TRAILING_WHITESPACE
43+
)
44+
45+
message("-- Detecting libinjection version - ${LIBINJECTION_VERSION}")
46+
47+
target_compile_definitions(libinjection PRIVATE LIBINJECTION_VERSION="${LIBINJECTION_VERSION}")
48+
49+
# mbedtls (mbedcrypto)
50+
51+
project(mbedcrypto C)
3852

39-
add_library(mbedtls STATIC ${BASE_DIR}/others/mbedtls/base64.c ${BASE_DIR}/others/mbedtls/sha1.c ${BASE_DIR}/others/mbedtls/md5.c)
53+
set(MBEDTLS_DIR ${BASE_DIR}/others/mbedtls)
54+
55+
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)
56+
57+
target_include_directories(mbedcrypto PRIVATE ${MBEDTLS_DIR}/include)
58+
59+
# get mbedtls version with git describe
60+
execute_process(
61+
COMMAND git describe
62+
WORKING_DIRECTORY ${MBEDTLS_DIR}
63+
OUTPUT_VARIABLE MBEDTLS_VERSION
64+
OUTPUT_STRIP_TRAILING_WHITESPACE
65+
)
4066

41-
target_include_directories(mbedtls PRIVATE ${BASE_DIR}/others)
67+
message("-- Detecting Mbed TLS version - ${MBEDTLS_VERSION}")
4268

4369
#
4470
# libModSecurity
@@ -112,8 +138,8 @@ file(GLOB_RECURSE libModSecuritySources ${BASE_DIR}/src/*.cc)
112138
add_library(libModSecurity SHARED ${libModSecuritySources})
113139

114140
target_compile_definitions(libModSecurity PRIVATE WITH_PCRE2)
115-
target_include_directories(libModSecurity PRIVATE ${BASE_DIR} ${BASE_DIR}/headers ${BASE_DIR}/others)
116-
target_link_libraries(libModSecurity PRIVATE pcre2::pcre2 pthreads4w::pthreads4w libinjection mbedtls Poco::Poco Iphlpapi.lib)
141+
target_include_directories(libModSecurity PRIVATE ${BASE_DIR} ${BASE_DIR}/headers ${BASE_DIR}/others ${MBEDTLS_DIR}/include)
142+
target_link_libraries(libModSecurity PRIVATE pcre2::pcre2 pthreads4w::pthreads4w libinjection mbedcrypto Poco::Poco Iphlpapi.lib)
117143

118144
macro(add_package_dependency project compile_definition link_library flag)
119145
if(${flag})

configure.ac

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ AC_MSG_ERROR([\
7575
fi
7676
# Libinjection version
7777
AC_DEFUN([LIBINJECTION_VERSION], m4_esyscmd_s(cd "others/libinjection" && git describe && cd ../..))
78+
AC_SUBST([LIBINJECTION_VERSION])
79+
80+
# Check for Mbed TLS
81+
if ! test -f "${srcdir}/others/mbedtls/library/base64.c"; then
82+
AC_MSG_ERROR([\
83+
84+
85+
Mbed TLS was not found within ModSecurity source directory.
86+
87+
Mbed TLS code is available as part of ModSecurity source code in a format
88+
of a git-submodule. git-submodule allow us to specify the correct version of
89+
Mbed TLS and still uses the Mbed TLS repository to download it.
90+
91+
You can download Mbed TLS using git:
92+
93+
$ git submodule init
94+
$ git submodule update
95+
96+
])
97+
fi
98+
# Mbed TLS version
99+
AC_DEFUN([MBEDTLS_VERSION], m4_esyscmd_s(cd "others/mbedtls" && git describe && cd ../..))
78100

79101
# SecLang test version
80102
AC_DEFUN([SECLANG_TEST_VERSION], m4_esyscmd_s(cd "test/test-cases/secrules-language-tests" && git log -1 --format="%h" --abbrev-commit && cd ../../..))
@@ -425,6 +447,8 @@ echo " "
425447
echo " Mandatory dependencies"
426448
AS_ECHO_N(" + libInjection ....")
427449
echo LIBINJECTION_VERSION
450+
AS_ECHO_N(" + Mbed TLS ....")
451+
echo MBEDTLS_VERSION
428452
AS_ECHO_N(" + SecLang tests ....")
429453
echo SECLANG_TEST_VERSION
430454

others/Makefile.am

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11

22
noinst_LTLIBRARIES = libinjection.la libmbedtls.la
3+
34
libinjection_la_SOURCES = \
45
libinjection/src/libinjection_html5.c \
56
libinjection/src/libinjection_sqli.c \
67
libinjection/src/libinjection_xss.c
78

9+
libinjection_la_CFLAGS = -D LIBINJECTION_VERSION=\"${LIBINJECTION_VERSION}\"
10+
libinjection_la_LIBADD =
11+
812
noinst_HEADERS = \
913
libinjection/src/libinjection.h \
1014
libinjection/src/libinjection_html5.h \
1115
libinjection/src/libinjection_sqli.h \
1216
libinjection/src/libinjection_sqli_data.h \
1317
libinjection/src/libinjection_xss.h \
14-
mbedtls/base64.h \
15-
mbedtls/check_config.h \
16-
mbedtls/mbed-tls-config.h \
17-
mbedtls/md5.h \
18-
mbedtls/platform.h \
19-
mbedtls/sha1.h
18+
mbedtls/include/mbedtls/base64.h \
19+
mbedtls/include/mbedtls/check_config.h \
20+
mbedtls/include/mbedtls/mbedtls_config.h \
21+
mbedtls/include/mbedtls/md5.h \
22+
mbedtls/include/mbedtls/platform.h \
23+
mbedtls/include/mbedtls/sha1.h
2024

2125
libmbedtls_la_SOURCES = \
22-
mbedtls/base64.c \
23-
mbedtls/md5.c \
24-
mbedtls/sha1.c
26+
mbedtls/library/base64.c \
27+
mbedtls/library/md5.c \
28+
mbedtls/library/sha1.c \
29+
mbedtls/library/platform_util.c
2530

26-
libmbedtls_la_CFLAGS = -D MBEDTLS_CONFIG_FILE=\"mbed-tls-config.h\" -Iothers
31+
libmbedtls_la_CFLAGS = -DMBEDTLS_CONFIG_FILE=\"mbedtls/mbedtls_config.h\" -Imbedtls/include
2732
libmbedtls_la_CPPFLAGS =
2833
libmbedtls_la_LIBADD =

others/mbedtls

Submodule mbedtls added at 2ca6c28

0 commit comments

Comments
 (0)