Skip to content

Commit b4e245e

Browse files
committed
build: Enable ssdeep and revert Version
1 parent c85d399 commit b4e245e

File tree

5 files changed

+106
-147
lines changed

5 files changed

+106
-147
lines changed

.github/workflows/test-ci-windows.yml

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ name: CI/CD for IIS Module
22

33
on:
44
push:
5-
branches:
6-
- v2/test-ci-windows
75
pull_request:
8-
branches:
9-
- v2/test-ci-windows
106

117
jobs:
128
build:
@@ -39,48 +35,42 @@ jobs:
3935
shell: pwsh
4036
run: |
4137
echo "APACHE_ROOT=C:\tools\Apache24" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
42-
43-
# Original Make file contain comment build script for ssdeep,
44-
# which is rely on MSYS2, so we need to install MSYS2.
45-
# If it's enabled, it need msys2 library for ssdeep.
4638
47-
# - name: Setup MSYS2
48-
# uses: msys2/setup-msys2@v2
49-
# with:
50-
# msystem: ${{ matrix.arch == 'x86' && 'MINGW32' || 'UCRT64' }}
51-
# update: true
52-
# install: >
53-
# git
54-
# make
55-
# autoconf
56-
# automake
57-
# libtool
58-
# ${{ matrix.arch == 'x86' && 'mingw-w64-i686-gcc' || 'mingw-w64-ucrt-x86_64-gcc' }}
59-
# ${{ matrix.arch == 'x86' && 'mingw-w64-i686-pkg-config' || 'mingw-w64-ucrt-x86_64-pkg-config' }}
60-
61-
# - name: Clone and build ssdeep
62-
# shell: msys2 {0}
63-
# run: |
64-
# MSYS2_WORKSPACE=$(cygpath -u '${{ github.workspace }}')
65-
# echo "Converted workspace path: $MSYS2_WORKSPACE"
66-
67-
# git clone https://github.com/ssdeep-project/ssdeep.git --depth 1
68-
# cd ssdeep
69-
# autoreconf -i
39+
- name: Setup MSYS2
40+
uses: msys2/setup-msys2@v2
41+
with:
42+
msystem: ${{ matrix.arch == 'x86' && 'MINGW32' || 'UCRT64' }}
43+
update: true
44+
install: >
45+
git
46+
make
47+
autoconf
48+
automake
49+
libtool
50+
${{ matrix.arch == 'x86' && 'mingw-w64-i686-gcc' || 'mingw-w64-ucrt-x86_64-gcc' }}
51+
${{ matrix.arch == 'x86' && 'mingw-w64-i686-pkg-config' || 'mingw-w64-ucrt-x86_64-pkg-config' }}
52+
53+
- name: Clone and build ssdeep
54+
shell: msys2 {0}
55+
run: |
56+
MSYS2_WORKSPACE=$(cygpath -u '${{ github.workspace }}')
57+
58+
git clone https://github.com/ssdeep-project/ssdeep.git --depth 1
59+
cd ssdeep
60+
autoreconf -i
7061
71-
# if [ "${{ matrix.arch }}" = "x86" ]; then
72-
# ./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3" --build=i686-pc-mingw32
73-
# else
74-
# ./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3"
75-
# fi
62+
if [ "${{ matrix.arch }}" = "x86" ]; then
63+
./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3" --build=i686-pc-mingw32
64+
else
65+
./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3"
66+
fi
7667
77-
# make dll
68+
make dll
7869
79-
# mkdir -p "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/bin"
80-
# mkdir -p "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/include"
81-
# cp -v fuzzy.dll "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/bin/"
82-
# cp -v fuzzy.h "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/include/"
83-
# cp -v fuzzy.def "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/"
70+
mkdir -p "${MSYS2_WORKSPACE}/ssdeep-install/"
71+
cp -v fuzzy.dll "${MSYS2_WORKSPACE}/ssdeep-install/"
72+
cp -v fuzzy.h "${MSYS2_WORKSPACE}/ssdeep-install/"
73+
cp -v fuzzy.def "${MSYS2_WORKSPACE}/ssdeep-install/"
8474
8575
- name: Restore vcpkg cache
8676
id: vcpkg-cache
@@ -105,14 +95,13 @@ jobs:
10595
-DAPACHE_ROOT="$env:APACHE_ROOT" `
10696
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}\iis\release\$installDir" `
10797
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" `
98+
-DSSDEEP_ROOT="${{ github.workspace }}\ssdeep-install" `
99+
-DWITH_SSDEEP=ON `
108100
-A $cmakeArch `
109101
-DWITH_LUA=ON `
110102
-DWITH_YAJL=ON `
111103
-S IIS -B "iis\build"
112104
113-
# -DSSDEEP_ROOT="${{ github.workspace }}\ssdeep-install-${{ matrix.arch }}" `
114-
# -DWITH_SSDEEP=ON `
115-
116105
- name: Build IIS Module
117106
shell: pwsh
118107
run: |
@@ -316,6 +305,9 @@ jobs:
316305
run: |
317306
go install github.com/coreruleset/go-ftw@latest
318307
308+
# Certain rules are disabled due to specific IIS behavior patterns.
309+
# Using go-ftw in cloud mode as the IIS connector does not generate logs in file format.
310+
# Technically, Event logs can be streamed to files, but this requires implementing rate limits to avoid log overflow.
319311
- name: Test ModSecurity Rules
320312
shell: pwsh
321313
run: |

iis/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

iis/CMakeLists.txt

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ find_package(PCRE2 CONFIG REQUIRED)
77
find_package(CURL CONFIG REQUIRED)
88
find_package(APR CONFIG REQUIRED)
99

10-
# iis/CMakeLists.txt
11-
set(IIS_MODULE_NAME "modsecurityiis") # Name should match the original output
10+
set(IIS_MODULE_NAME "modsecurityiis")
1211

13-
# Source files for IIS module (reusing Apache sources)
1412
set(IIS_APACHE_SOURCES
1513
../apache2/mod_security2.c
1614
../apache2/apache2_config.c
@@ -46,7 +44,6 @@ set(IIS_APACHE_SOURCES
4644
../apache2/libinjection/libinjection_xss.c
4745
)
4846

49-
# Source files for standalone components (if they exist in the project)
5047
set(IIS_STANDALONE_SOURCES
5148
../standalone/api.c
5249
../standalone/buckets.c
@@ -57,18 +54,12 @@ set(IIS_STANDALONE_SOURCES
5754
../standalone/server.c
5855
)
5956

60-
# Determine architecture
6157
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
6258
set(ARCHITECTURE "x64")
6359
else()
6460
set(ARCHITECTURE "x86")
6561
endif()
6662

67-
# Check if standalone directory exists, if not, exclude those sources
68-
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../standalone)
69-
set(IIS_STANDALONE_SOURCES "")
70-
endif()
71-
7263
set(IIS_RESOURCE_MC "${CMAKE_CURRENT_SOURCE_DIR}/ModSecurityIISMessage.mc")
7364

7465
set(MC_GENERATED_RC "${CMAKE_CURRENT_BINARY_DIR}/ModSecurityIISMessage.rc")
@@ -110,27 +101,19 @@ set_target_properties(${IIS_MODULE_NAME} PROPERTIES
110101
SUFFIX ".dll"
111102
)
112103

113-
# Include directories
114104
target_include_directories(${IIS_MODULE_NAME} PRIVATE
115105
${CMAKE_CURRENT_SOURCE_DIR}
116106
${CMAKE_CURRENT_SOURCE_DIR}/..
117107
${CMAKE_CURRENT_SOURCE_DIR}/../apache2
118108
${CMAKE_CURRENT_SOURCE_DIR}/../apache2/libinjection
119109
${LIBXML2_INCLUDE_DIR}/libxml
110+
${CMAKE_CURRENT_SOURCE_DIR}/../standalone
120111
${PCRE2_INCLUDE_DIRS}
121112
${CURL_INCLUDE_DIRS}
122113
${APR_INCLUDE_DIRS}
123114
${CMAKE_CURRENT_BINARY_DIR}
124115
)
125116

126-
# Include standalone directory if it exists
127-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../standalone)
128-
target_include_directories(${IIS_MODULE_NAME} PRIVATE
129-
${CMAKE_CURRENT_SOURCE_DIR}/../standalone
130-
)
131-
endif()
132-
133-
# Apache-specific includes
134117
if(APACHE_ROOT)
135118
if(NOT EXISTS "${APACHE_ROOT}")
136119
message(FATAL_ERROR "APACHE_ROOT is defined but the directory '${APACHE_ROOT}' does not exist. Please set APACHE_ROOT to a valid Apache installation directory.")
@@ -172,7 +155,6 @@ if(APACHE_ROOT)
172155
)
173156
endif()
174157

175-
# Compile definitions to match the original Makefile.win
176158
set(MODSECURITY_VERSION_FLAG "VERSION_IIS") # Define the version flag string
177159
target_compile_definitions(${IIS_MODULE_NAME} PRIVATE
178160
inline=APR_INLINE
@@ -181,11 +163,10 @@ target_compile_definitions(${IIS_MODULE_NAME} PRIVATE
181163
WITH_REMOTE_RULES
182164
MSC_LARGE_STREAM_INPUT
183165
WITH_YAJL
184-
${MODSECURITY_VERSION_FLAG} # Use the defined version flag
166+
${MODSECURITY_VERSION_FLAG}
185167
)
186168

187169
option(WITH_LUA "Enable Lua support" OFF)
188-
# Optional compile definitions
189170
if(WITH_LUA)
190171
find_package(Lua CONFIG REQUIRED)
191172
target_compile_definitions(${IIS_MODULE_NAME} PRIVATE WITH_LUA)
@@ -211,30 +192,26 @@ if(WITH_YAJL)
211192
target_include_directories(${IIS_MODULE_NAME} PRIVATE ${YAJL_INCLUDE_DIRS})
212193
else()
213194
message(WARNING "YAJL not found. YAJL_INCLUDE_DIR: '${YAJL_INCLUDE_DIR}', YAJL_LIBRARY: '${YAJL_LIBRARY}'. Please ensure yajl is installed via vcpkg in the vcpkg_installed directory. Disabling YAJL support.")
214-
option(WITH_YAJL "Enable YAJL support" OFF) # Disable if not found
195+
option(WITH_YAJL "Enable YAJL support" OFF)
215196
endif()
216197
endif()
217198

218199
option(WITH_SSDEEP "Enable SSDEEP support" OFF)
219200
if(WITH_SSDEEP)
220201

221-
set(SSDEEP_ROOT "" CACHE PATH "Path to manually built ssdeep")
222-
if(NOT SSDEEP_ROOT OR NOT EXISTS "${SSDEEP_ROOT}")
202+
if(NOT EXISTS "${SSDEEP_ROOT}")
223203
message(WARNING "SSDEEP_ROOT is not defined or path does not exist. Current SSDEEP_ROOT: '${SSDEEP_ROOT}'. Please set SSDEEP_ROOT to the ssdeep installation directory. Disabling SSDEEP support.")
224204
set(WITH_SSDEEP OFF CACHE BOOL "Enable SSDEEP support" FORCE)
225205
else()
226206

227207
file(TO_CMAKE_PATH "${SSDEEP_ROOT}" SSDEEP_ROOT)
228208

229-
message(STATUS "SSDEEP_ROOT: ${SSDEEP_ROOT}")
230-
231209
find_path(SSDEEP_INCLUDE_DIR fuzzy.h
232-
PATHS "${SSDEEP_ROOT}/include"
210+
PATHS "${SSDEEP_ROOT}"
233211
NO_DEFAULT_PATH
234212
)
235213

236214
if(SSDEEP_INCLUDE_DIR)
237-
message(STATUS "Found manually built ssdeep include: ${SSDEEP_INCLUDE_DIR}")
238215
target_compile_definitions(${IIS_MODULE_NAME} PRIVATE WITH_SSDEEP)
239216
target_include_directories(${IIS_MODULE_NAME} PRIVATE ${SSDEEP_INCLUDE_DIR})
240217

@@ -244,7 +221,7 @@ if(WITH_SSDEEP)
244221
set(WITH_SSDEEP OFF CACHE BOOL "Enable SSDEEP support" FORCE)
245222
else()
246223
set(SSDEEP_GENERATED_LIB "${CMAKE_CURRENT_BINARY_DIR}/fuzzy.lib")
247-
set(SSDEEP_GENERATED_dll "${CMAKE_CURRENT_BINARY_DIR}/bin/fuzzy.dll")
224+
set(SSDEEP_GENERATED_dll "${CMAKE_CURRENT_BINARY_DIR}/fuzzy.dll")
248225

249226
add_custom_command(
250227
OUTPUT ${SSDEEP_GENERATED_LIB}
@@ -271,43 +248,30 @@ if(WITH_SSDEEP)
271248
)
272249

273250
endif()
251+
else()
252+
message(WARNING "fuzzy.h not found at ${SSDEEP_INCLUDE_DIR}. Disabling SSDEEP support.")
253+
set(WITH_SSDEEP OFF CACHE BOOL "Enable SSDEEP support" FORCE)
274254
endif()
275255
endif()
276256
endif()
277257

278-
# Compiler-specific options for MSVC to match the original Makefile.win
279258
if(MSVC)
280259
target_compile_options(${IIS_MODULE_NAME} PRIVATE
281260
/nologo
282261
/W3
283262
/wd4244
284263
/wd4018
285-
286264
)
287265
endif()
288266

289-
# Link libraries to match the original Makefile.win
290267
target_link_libraries(${IIS_MODULE_NAME} PRIVATE
291268
LibXml2::LibXml2
292269
PCRE2::8BIT
293270
CURL::libcurl
294-
kernel32
295-
user32
296-
gdi32
297-
winspool
298-
comdlg32
299-
advapi32
300-
shell32
301-
ole32
302-
oleaut32
303-
uuid
304-
odbc32
305-
odbccp32
306271
ws2_32
307272
iphlpapi
308273
)
309274

310-
# Apache-specific libraries
311275
if(APACHE_ROOT)
312276
target_link_libraries(${IIS_MODULE_NAME} PRIVATE
313277
Apache::httpd
@@ -319,7 +283,6 @@ else()
319283
message(WARNING "APACHE_ROOT is not defined or path does not exist. Current APACHE_ROOT: '${APACHE_ROOT}'. Please set APACHE_ROOT to the Apache installation directory.")
320284
endif()
321285

322-
# Optional link libraries
323286
if(WITH_LUA)
324287
target_link_libraries(${IIS_MODULE_NAME} PRIVATE ${LUA_LIBRARIES})
325288
endif()
@@ -349,10 +312,10 @@ else()
349312
message(WARNING "APACHE_ROOT is not defined or path does not exist. Current APACHE_ROOT: '${APACHE_ROOT}'. Please set APACHE_ROOT to the Apache installation directory.")
350313
endif()
351314

352-
if(WITH_SSDEEP AND SSDEEP_ROOT AND EXISTS "${SSDEEP_ROOT}/bin/fuzzy.dll")
315+
if(WITH_SSDEEP AND SSDEEP_ROOT AND EXISTS "${SSDEEP_ROOT}/fuzzy.dll")
353316
add_custom_command(TARGET ${IIS_MODULE_NAME} POST_BUILD
354317
COMMAND ${CMAKE_COMMAND} -E copy_if_different
355-
"${SSDEEP_ROOT}/bin/fuzzy.dll"
318+
"${SSDEEP_ROOT}/fuzzy.dll"
356319
$<TARGET_FILE_DIR:${IIS_MODULE_NAME}>
357320
COMMENT "Copying SSDEEP DLL to output directory"
358321
)
@@ -374,9 +337,9 @@ if(APACHE_ROOT AND EXISTS "${APACHE_ROOT}/bin")
374337
)
375338
endif()
376339

377-
if(WITH_SSDEEP AND SSDEEP_ROOT AND EXISTS "${SSDEEP_ROOT}/bin/fuzzy.dll")
340+
if(WITH_SSDEEP AND SSDEEP_ROOT AND EXISTS "${SSDEEP_ROOT}/fuzzy.dll")
378341
install(FILES
379-
"${SSDEEP_ROOT}/bin/fuzzy.dll"
342+
"${SSDEEP_ROOT}/fuzzy.dll"
380343
DESTINATION .
381344
)
382345
endif()

iis/installer.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
lightArgs:
88
-->
99
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
10-
<Product Id="22B04FDB-9BAB-46B0-87B8-A39544ECECD3" Name="ModSecurity IIS" Language="1033" Version="2.9.13" Manufacturer="ModSecurity" UpgradeCode="82F09489-1678-4C38-ADCB-08C3757653DB">
10+
<Product Id="22B04FDB-9BAB-46B0-87B8-A39544ECECD3" Name="ModSecurity IIS" Language="1033" Version="2.9.12" Manufacturer="ModSecurity" UpgradeCode="82F09489-1678-4C38-ADCB-08C3757653DB">
1111
<Package Description="ModSecurityISS" Comments="none" InstallerVersion="405" Compressed="yes" InstallPrivileges="elevated" InstallScope="perMachine" />
1212
<?define ProductName = "ModSecurity IIS" ?>
1313
<?if $(sys.BUILDARCH) = x64 ?>

0 commit comments

Comments
 (0)