Skip to content

Commit db46478

Browse files
committed
fix: address Copilot review feedback on Windows build
- Fix "installion" typo in Makefile.win usage comments - Fix "mlocg.exe" typo in README_WINDOWS.md - Fix SecAuditLogRelevantStatus regex to use negative lookahead - Check PCRE2 archive existence in build_pcre.bat instead of Apache - Wire up WITH_PCRE_JIT option in iis/CMakeLists.txt - Quote %log_file% paths in list_dependencies.bat for spaces - Use explicit PowerShell path via [SystemFolder] in installer.wxs - Change CreateModSecurityDirs to Return="check" to surface errors - Restore Action="createAndRemoveOnUninstall" on RegistryKey - Only print verbose MSI log on installation failure in CI
1 parent 76323ea commit db46478

File tree

8 files changed

+63
-55
lines changed

8 files changed

+63
-55
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,20 @@ jobs:
257257
$logSize = (Get-Item $installLog).Length
258258
Write-Host "Install log created: $installLog ($logSize bytes)"
259259
260-
Write-Host "`n=== Installation Log Contents ==="
261-
if ($logSize -gt 0) {
262-
Get-Content $installLog -Raw | Write-Host
263-
} else {
264-
Write-Host "WARNING: Log file is empty!"
265-
}
266260
} else {
267261
Write-Host "WARNING: Install log was not created at $installLog"
268262
}
269263
270264
if ($installResult.ExitCode -ne 0) {
265+
Write-Host "`n=== Full Installation Log (installation failed) ==="
266+
if (Test-Path $installLog) {
267+
$logSize = (Get-Item $installLog).Length
268+
if ($logSize -gt 0) {
269+
Get-Content $installLog -Raw | Write-Host
270+
} else {
271+
Write-Host "WARNING: Log file is empty!"
272+
}
273+
}
271274
Write-Host "`n=== Installation Failed ==="
272275
Write-Host "Exit code: $($installResult.ExitCode)"
273276
Write-Host "Common MSI error codes:"

README_WINDOWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Add configuration directives to your Apache conf\httpd.conf:
142142
Include conf/owasp_crs/crs-setup.conf
143143
Include conf/owasp_crs/rules/*.conf
144144
SecAuditEngine RelevantOnly
145-
SecAuditLogRelevantStatus "^(?:5|4\d[^4])"
145+
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
146146
SecAuditLogType Serial
147147
SecAuditLogParts ABCDEFGHZ
148148
SecAuditLog logs/modsecurity.log
@@ -171,7 +171,7 @@ Build the ``mlogc.exe`` program:
171171
CD C:\work\mod_security_trunk\mlogc
172172
NMAKE -f Makefile.win
173173

174-
Copy ``mlocg.exe`` to ``C:\Apache2466\bin\``
174+
Copy ``mlogc.exe`` to ``C:\Apache2466\bin\``
175175

176176
Create a new command file ``C:\Apache2466\bin\mlogc.bat`` with one line:
177177

apache2/Makefile.win

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###########################################################################
22
#
3-
# Usage: NMAKE -f Makefile.win APACHE={httpd installion dir} PCRE={pcre2 dir} LIBXML2={LibXML2 dir} [ LUA={Lua dir} ]
3+
# Usage: NMAKE -f Makefile.win APACHE={httpd installation dir} PCRE={pcre2 dir} LIBXML2={LibXML2 dir} [ LUA={Lua dir} ]
44
# Note: ModSecurity v2 uses PCRE2 by default (not legacy PCRE). Set PCRE to your pcre2 build directory.
55
#
66
!IF "$(APACHE)" == "" || "$(PCRE)" == "" || "$(LIBXML2)" == "" || "$(CURL)" == ""

iis/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ target_compile_definitions(${IIS_MODULE_NAME} PRIVATE
166166
${MODSECURITY_VERSION_FLAG}
167167
)
168168

169+
option(WITH_PCRE_JIT "Enable PCRE2 JIT support" OFF)
170+
if(WITH_PCRE_JIT)
171+
target_compile_definitions(${IIS_MODULE_NAME} PRIVATE WITH_PCRE_JIT)
172+
endif()
173+
169174
option(WITH_LUA "Enable Lua support" OFF)
170175
if(WITH_LUA)
171176
find_package(Lua CONFIG REQUIRED)

iis/Makefile.win

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###########################################################################
22
#
3-
# Usage: NMAKE -f Makefile.win APACHE={httpd installion dir} PCRE={pcre2 dir} LIBXML2={LibXML2 dir} [ LUA={Lua dir} ]
3+
# Usage: NMAKE -f Makefile.win APACHE={httpd installation dir} PCRE={pcre2 dir} LIBXML2={LibXML2 dir} [ LUA={Lua dir} ]
44
# Note: ModSecurity v2 uses PCRE2 by default (not legacy PCRE). Set PCRE to your pcre2 build directory.
55
#
66
!IF "$(APACHE)" == "" || "$(PCRE)" == "" || "$(LIBXML2)" == "" || "$(CURL)" == ""

iis/dependencies/build_pcre.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd "%WORK_DIR%"
44

5-
@if NOT EXIST "%SOURCE_DIR%\%APACHE_BIN%" goto file_not_found_bin
5+
@if NOT EXIST "%SOURCE_DIR%\%PCRE%" goto file_not_found_bin
66

77
7z.exe x "%SOURCE_DIR%\%PCRE%"
88
set PCRE_DIR=%PCRE:~0,-4%

iis/installer.wxs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
<util:XmlConfig Id="appHostEntryAllowDefinition" File="$(var.ConfigFile)" ElementPath="appHostEntry" Name="allowDefinition" Value="Everywhere" Sequence="4" />
202202
<util:XmlConfig Id="removeAppHostEntry" File="$(var.ConfigFile)" Action="delete" ElementPath="/configuration/configSections/sectionGroup[\[]@name='system.webServer'[\]]" Node="element" VerifyPath="section[\[]@name='ModSecurity'[\]]" On="uninstall" Sequence="1" />
203203
<util:XmlConfig Id="removeAppHostEntry2" File="$(var.ConfigFile)" Action="delete" ElementPath="/configuration/system.webServer" Node="element" VerifyPath="/configuration/system.webServer/ModSecurity" Name="section" On="uninstall" Sequence="2" />
204-
<RegistryKey Root="HKLM" Key="SOFTWARE\ModSecurity\ModSecurity">
204+
<RegistryKey Root="HKLM" Key="SOFTWARE\ModSecurity\ModSecurity" Action="createAndRemoveOnUninstall">
205205
<RegistryValue Type="string" Name="ModSecurityConfigureIIS" Value="[IIS_SETUP]" KeyPath="yes" />
206206
</RegistryKey>
207207
</Component>
@@ -412,7 +412,7 @@
412412
<CustomAction Id="Cleanup5" Execute="deferred" Impersonate="no" Return="ignore" Directory="INSTALLFOLDER" ExeCommand="&quot;[SystemFolder]inetsrv\appcmd.exe&quot; uninstall module /module.name:&quot;ModSecurityIIS&quot;" />
413413
<?endif?>
414414
<!-- Create required directories for ModSecurity with proper permissions for IIS -->
415-
<CustomAction Id="CreateModSecurityDirs" Execute="deferred" Impersonate="no" Return="ignore" Directory="INSTALLFOLDER" ExeCommand="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command &quot;New-Item -ItemType Directory -Path 'c:\inetpub\temp', 'c:\inetpub\logs' -Force | Out-Null; icacls 'c:\inetpub\temp' /grant 'IIS_IUSRS:(OI)(CI)M' /T /Q | Out-Null; icacls 'c:\inetpub\logs' /grant 'IIS_IUSRS:(OI)(CI)M' /T /Q | Out-Null&quot;" />
415+
<CustomAction Id="CreateModSecurityDirs" Execute="deferred" Impersonate="no" Return="check" Directory="INSTALLFOLDER" ExeCommand="&quot;[SystemFolder]WindowsPowerShell\v1.0\powershell.exe&quot; -NoProfile -ExecutionPolicy Bypass -Command &quot;New-Item -ItemType Directory -Path 'c:\inetpub\temp', 'c:\inetpub\logs' -Force | Out-Null; icacls 'c:\inetpub\temp' /grant 'IIS_IUSRS:(OI)(CI)M' /T /Q | Out-Null; icacls 'c:\inetpub\logs' /grant 'IIS_IUSRS:(OI)(CI)M' /T /Q | Out-Null&quot;" />
416416
<?if $(var.Win64) = "yes" ?>
417417
<CustomAction Id="InstallModule32" Execute="deferred" Impersonate="no" Return="check" Directory="INSTALLFOLDER" ExeCommand="&quot;[System64Folder]inetsrv\appcmd.exe&quot; install module /name:&quot;ModSecurity IIS (64bits)&quot; /image:&quot;%SystemRoot%\System32\inetsrv\ModSecurityIIS.dll&quot; /preCondition:&quot;bitness64&quot;" />
418418
<CustomAction Id="InstallModule64" Execute="deferred" Impersonate="no" Return="check" Directory="INSTALLFOLDER" ExeCommand="&quot;[System64Folder]inetsrv\appcmd.exe&quot; install module /name:&quot;ModSecurity IIS (32bits)&quot; /image:&quot;%SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll&quot; /preCondition:&quot;bitness32&quot;" />

iis/wix/list_dependencies.bat

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ if %errorlevel% equ 0 (
7171
echo [MISSING] Visual C++ 2019 Redistributable (x86) is NOT installed >> "%log_file%"
7272
echo Download from: https://aka.ms/vs/17/release/vc_redist.x86.exe >> "%log_file%"
7373
)
74-
echo. >> %log_file%
74+
echo. >> "%log_file%"
7575

7676
REM Updated paths to include Visual Studio 2019 and 2022
7777
set POSSIBLE_PATHS_X86="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\*\bin\Hostx86\x86\dumpbin.exe" "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\*\bin\Hostx86\x86\dumpbin.exe" "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\*\bin\Hostx86\x86\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\*\bin\Hostx86\x86\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\*\bin\Hostx86\x86\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx86\x86\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\dumpbin.exe"
7878
set POSSIBLE_PATHS_X64="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\dumpbin.exe"
7979

8080
for %%i in (%POSSIBLE_PATHS_X86%) do (
8181
echo Checking for dumpbin x86... %%i
82-
echo Checking for dumpbin x86... %%i >> %log_file%
82+
echo Checking for dumpbin x86... %%i >> "%log_file%"
8383
if exist %%i (
8484
SET DUMPBIN_X86=%%i
8585
goto found_x86
@@ -89,87 +89,87 @@ for %%i in (%POSSIBLE_PATHS_X86%) do (
8989

9090
for %%i in (%POSSIBLE_PATHS_X64%) do (
9191
echo Checking for dumpbin x64... %%i
92-
echo Checking for dumpbin x64... %%i >> %log_file%
92+
echo Checking for dumpbin x64... %%i >> "%log_file%"
9393
if exist %%i (
9494
SET DUMPBIN_X64=%%i
9595
goto found_x64
9696
)
9797
)
9898
:found_x64
9999

100-
echo ================================================ >> %log_file%
101-
echo ModSecurity IIS Dependency Analysis >> %log_file%
102-
echo ================================================ >> %log_file%
103-
echo. >> %log_file%
100+
echo ================================================ >> "%log_file%"
101+
echo ModSecurity IIS Dependency Analysis >> "%log_file%"
102+
echo ================================================ >> "%log_file%"
103+
echo. >> "%log_file%"
104104

105105
REM Check ModSecurity DLL locations
106-
echo Checking ModSecurity DLL locations... >> %log_file%
106+
echo Checking ModSecurity DLL locations... >> "%log_file%"
107107
if exist "%SystemRoot%\System32\inetsrv\ModSecurityIIS.dll" (
108-
echo [FOUND] %SystemRoot%\System32\inetsrv\ModSecurityIIS.dll >> %log_file%
108+
echo [FOUND] %SystemRoot%\System32\inetsrv\ModSecurityIIS.dll >> "%log_file%"
109109
) else (
110-
echo [MISSING] %SystemRoot%\System32\inetsrv\ModSecurityIIS.dll >> %log_file%
110+
echo [MISSING] %SystemRoot%\System32\inetsrv\ModSecurityIIS.dll >> "%log_file%"
111111
)
112112

113113
if exist "%SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll" (
114-
echo [FOUND] %SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll >> %log_file%
114+
echo [FOUND] %SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll >> "%log_file%"
115115
) else (
116-
echo [MISSING] %SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll >> %log_file%
116+
echo [MISSING] %SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll >> "%log_file%"
117117
)
118-
echo. >> %log_file%
118+
echo. >> "%log_file%"
119119

120120
if "%DUMPBIN_X86:~1,-1%" == "" (
121121
echo Dumpbin x86 not found.
122-
echo Dumpbin x86 not found. >> %log_file%
123-
echo NOTE: Install Visual Studio 2019/2022 with C++ tools to use dumpbin. >> %log_file%
122+
echo Dumpbin x86 not found. >> "%log_file%"
123+
echo NOTE: Install Visual Studio 2019/2022 with C++ tools to use dumpbin. >> "%log_file%"
124124
) else (
125125
echo Using dumpbin x86: %DUMPBIN_X86%
126-
echo Using dumpbin x86: %DUMPBIN_X86% >> %log_file%
127-
echo. >> %log_file%
126+
echo Using dumpbin x86: %DUMPBIN_X86% >> "%log_file%"
127+
echo. >> "%log_file%"
128128
if exist "%SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll" (
129-
echo ================================================ >> %log_file%
130-
echo 32-bit ModSecurityIIS.dll dependencies: >> %log_file%
131-
echo ================================================ >> %log_file%
132-
%DUMPBIN_X86% /imports /dependents "%SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll" >> %log_file% 2>&1
129+
echo ================================================ >> "%log_file%"
130+
echo 32-bit ModSecurityIIS.dll dependencies: >> "%log_file%"
131+
echo ================================================ >> "%log_file%"
132+
%DUMPBIN_X86% /imports /dependents "%SystemRoot%\SysWOW64\inetsrv\ModSecurityIIS.dll" >> "%log_file%" 2>&1
133133
)
134134
if not "%*" == "" (
135-
echo. >> %log_file%
136-
echo ================================================ >> %log_file%
137-
echo Additional files specified: >> %log_file%
138-
echo ================================================ >> %log_file%
139-
%DUMPBIN_X86% /imports /dependents %* >> %log_file% 2>&1
135+
echo. >> "%log_file%"
136+
echo ================================================ >> "%log_file%"
137+
echo Additional files specified: >> "%log_file%"
138+
echo ================================================ >> "%log_file%"
139+
%DUMPBIN_X86% /imports /dependents %* >> "%log_file%" 2>&1
140140
)
141141
)
142142

143-
echo. >> %log_file%
143+
echo. >> "%log_file%"
144144

145145
if "%DUMPBIN_X64:~1,-1%" == "" (
146146
echo Dumpbin x64 not found.
147-
echo Dumpbin x64 not found. >> %log_file%
148-
echo NOTE: Install Visual Studio 2019/2022 with C++ tools to use dumpbin. >> %log_file%
147+
echo Dumpbin x64 not found. >> "%log_file%"
148+
echo NOTE: Install Visual Studio 2019/2022 with C++ tools to use dumpbin. >> "%log_file%"
149149
) else (
150150
echo Using dumpbin x64: %DUMPBIN_X64%
151-
echo Using dumpbin x64: %DUMPBIN_X64% >> %log_file%
152-
echo. >> %log_file%
151+
echo Using dumpbin x64: %DUMPBIN_X64% >> "%log_file%"
152+
echo. >> "%log_file%"
153153
if exist "%SystemRoot%\System32\inetsrv\ModSecurityIIS.dll" (
154-
echo ================================================ >> %log_file%
155-
echo 64-bit ModSecurityIIS.dll dependencies: >> %log_file%
156-
echo ================================================ >> %log_file%
157-
%DUMPBIN_X64% /imports /dependents "%SystemRoot%\System32\inetsrv\ModSecurityIIS.dll" >> %log_file% 2>&1
154+
echo ================================================ >> "%log_file%"
155+
echo 64-bit ModSecurityIIS.dll dependencies: >> "%log_file%"
156+
echo ================================================ >> "%log_file%"
157+
%DUMPBIN_X64% /imports /dependents "%SystemRoot%\System32\inetsrv\ModSecurityIIS.dll" >> "%log_file%" 2>&1
158158
)
159159
if not "%*" == "" (
160-
echo. >> %log_file%
161-
echo ================================================ >> %log_file%
162-
echo Additional files specified: >> %log_file%
163-
echo ================================================ >> %log_file%
164-
%DUMPBIN_X64% /imports /dependents %* >> %log_file% 2>&1
160+
echo. >> "%log_file%"
161+
echo ================================================ >> "%log_file%"
162+
echo Additional files specified: >> "%log_file%"
163+
echo ================================================ >> "%log_file%"
164+
%DUMPBIN_X64% /imports /dependents %* >> "%log_file%" 2>&1
165165
)
166166
)
167167

168168
goto exit
169169

170170
:exit
171-
echo Logs were saved at: %log_file%.
171+
echo Logs were saved at: "%log_file%".
172172
echo Trying to open it with explorer...
173-
explorer %log_file%
173+
explorer "%log_file%"
174174
echo Done.
175175
pause

0 commit comments

Comments
 (0)