Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb304ab1

Browse files
author
Felipe Zimmerle
committed
Improves SecRemoteRules messages on IIS
IIS was not displaying correctly the error messages and the amount ofloaded rules while the operator SecRemoteRules was used.
1 parentf7c7a30 commitb304ab1

File tree

5 files changed

+46
-13
lines changed

5 files changed

+46
-13
lines changed

‎apache2/mod_security2.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static int hook_post_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_t
752752
real_server_signature);
753753
}
754754

755-
#ifndefWIN32
755+
#ifndefVERSION_IIS
756756
if (status_engine_state!=STATUS_ENGINE_DISABLED) {
757757
msc_status_engine_call();
758758
}
@@ -767,18 +767,12 @@ static int hook_post_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_t
767767
/**
768768
* Checking if it is not the first time that we are in this very function.
769769
* We want to show the messages below during the start and the reload.
770-
*
771-
* Turns out that IIS version does not hit it twice, thus, we have to show
772-
* the message in the first (and unique) opportunity.
773770
*/
774-
#ifdefVERSION_IIS
775-
if (first_time==1)
776-
{
777-
#else
771+
#ifndefVERSION_IIS
778772
if (first_time!=1)
779773
{
780-
#endif
781774
#ifdefWITH_REMOTE_RULES
775+
782776
if (remote_rules_server!=NULL)
783777
{
784778
if (remote_rules_server->amount_of_rules==1)
@@ -804,6 +798,7 @@ static int hook_post_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_t
804798
remote_rules_fail_message);
805799
}
806800
}
801+
#endif
807802

808803
srand((unsignedint)(time(NULL)*getpid()));
809804

‎iis/mymodule.cpp‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,12 @@ CMyHttpModule::OnBeginRequest(
797797
goto Finished;
798798
}
799799

800-
modsecStatusEngineCall();
801-
800+
modsecReportRemoteLoadedRules();
801+
if (this->status_call_already_sent ==false)
802+
{
803+
this->status_call_already_sent =true;
804+
modsecStatusEngineCall();
805+
}
802806
}
803807
delete apppath;
804808
}
@@ -1254,6 +1258,8 @@ CMyHttpModule::CMyHttpModule()
12541258
GetSystemInfo(&sysInfo);
12551259
m_dwPageSize = sysInfo.dwPageSize;
12561260

1261+
this->status_call_already_sent =false;
1262+
12571263
InitializeCriticalSection(&m_csLock);
12581264

12591265
modsecSetLogHook(this, Log);

‎iis/mymodule.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class CMyHttpModule : public CHttpModule
5252
voidDispose();
5353

5454
BOOLWriteEventViewerLog(LPCSTR szNotification, WORD category = EVENTLOG_INFORMATION_TYPE);
55+
BOOL status_call_already_sent;
5556
};
5657

5758
#endif

‎standalone/api.c‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ const char *modsecIsServerSignatureAvailale(void) {
705705
returnnew_server_signature;
706706
}
707707

708-
#ifdefWIN32
708+
#ifdefVERSION_IIS
709709
voidmodsecStatusEngineCall()
710710
{
711711
if (status_engine_state!=STATUS_ENGINE_DISABLED) {
@@ -717,4 +717,34 @@ void modsecStatusEngineCall()
717717
"SecStatusEngine to On.\n");
718718
}
719719
}
720+
721+
voidmodsecReportRemoteLoadedRules()
722+
{
723+
#ifdefWITH_REMOTE_RULES
724+
if (remote_rules_server!=NULL)
725+
{
726+
if (remote_rules_server->amount_of_rules==1)
727+
{
728+
ap_log_error(APLOG_MARK,APLOG_NOTICE,0,NULL,
729+
"ModSecurity: Loaded %d rule from: '%s'.",
730+
remote_rules_server->amount_of_rules,
731+
remote_rules_server->uri);
732+
}
733+
else
734+
{
735+
ap_log_error(APLOG_MARK,APLOG_NOTICE,0,NULL,
736+
"ModSecurity: Loaded %d rules from: '%s'.",
737+
remote_rules_server->amount_of_rules,
738+
remote_rules_server->uri);
739+
}
740+
}
741+
#endif
742+
if (remote_rules_fail_message!=NULL)
743+
{
744+
ap_log_error(APLOG_MARK,APLOG_NOTICE,0,NULL,"ModSecurity: " \
745+
"Problems loading external resources: %s",
746+
remote_rules_fail_message);
747+
}
748+
749+
}
720750
#endif

‎standalone/api.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ void modsecSetConfigForIISRequestBody(request_rec *r);
119119

120120
constchar*modsecIsServerSignatureAvailale(void);
121121

122-
#ifdefWIN32
122+
#ifdefVERSION_IIS
123123
voidmodsecStatusEngineCall(void);
124+
voidmodsecReportRemoteLoadedRules(void);
124125
#endif
125126

126127
#ifdef__cplusplus

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp