Skip to content

Commit b35e818

Browse files
author
Felipe Zimmerle
committed
Merge branch 'modsec_status' into iis_installer
2 parents d54105e + c1a216e commit b35e818

15 files changed

+604
-7
lines changed

apache2/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod_security2_la_SOURCES = acmp.c \
88
libinjection/libinjection_sqli.c \
99
mod_security2.c \
1010
modsecurity.c \
11+
msc_status_engine.c \
1112
msc_crypt.c \
1213
msc_geo.c \
1314
msc_gsb.c \

apache2/Makefile.win

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ LIBS = $(APACHE)\lib\libhttpd.lib \
1212
$(APACHE)\lib\libaprutil-1.lib \
1313
$(PCRE)\pcre.lib \
1414
$(LIBXML2)\win32\bin.msvc\libxml2.lib \
15-
Ws2_32.lib
15+
Ws2_32.lib \
16+
"iphlpapi.lib"
1617

1718
###########################################################################
1819
###########################################################################
@@ -46,7 +47,8 @@ OBJS = mod_security2.obj apache2_config.obj apache2_io.obj apache2_util.obj \
4647
msc_logging.obj msc_xml.obj msc_multipart.obj modsecurity.obj \
4748
msc_parsers.obj msc_util.obj msc_pcre.obj persist_dbm.obj \
4849
msc_reqbody.obj msc_geo.obj msc_gsb.obj msc_crypt.obj msc_tree.obj msc_unicode.obj acmp.obj msc_lua.obj \
49-
msc_release.obj libinjection\libinjection_sqli.obj
50+
msc_release.obj libinjection\libinjection_sqli.obj \
51+
msc_status_engine.obj
5052

5153
all: $(DLL)
5254

apache2/apache2_config.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,23 @@ static const char *cmd_rule_engine(cmd_parms *cmd, void *_dcfg, const char *p1)
20622062
return NULL;
20632063
}
20642064

2065+
static const char *cmd_status_engine(cmd_parms *cmd, void *_dcfg, const char *p1)
2066+
{
2067+
if (strcasecmp(p1, "on") == 0) {
2068+
status_engine_state = STATUS_ENGINE_ENABLED;
2069+
}
2070+
else if (strcasecmp(p1, "off") == 0) {
2071+
status_engine_state = STATUS_ENGINE_DISABLED;
2072+
}
2073+
else {
2074+
return apr_psprintf(cmd->pool, "ModSecurity: Invalid value for " \
2075+
"SecStatusEngine: %s", p1);
2076+
}
2077+
2078+
return NULL;
2079+
}
2080+
2081+
20652082
static const char *cmd_rule_inheritance(cmd_parms *cmd, void *_dcfg, int flag)
20662083
{
20672084
directory_config *dcfg = (directory_config *)_dcfg;
@@ -3276,6 +3293,14 @@ const command_rec module_directives[] = {
32763293
"On or Off"
32773294
),
32783295

3296+
AP_INIT_TAKE1 (
3297+
"SecStatusEngine",
3298+
cmd_status_engine,
3299+
NULL,
3300+
CMD_SCOPE_ANY,
3301+
"On or Off"
3302+
),
3303+
32793304
AP_INIT_TAKE1 (
32803305
"SecXmlExternalEntity",
32813306
cmd_xml_external_entity,

apache2/mod_security2.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "msc_lua.h"
3838
#endif
3939

40+
#include "msc_status_engine.h"
4041

4142
/* ModSecurity structure */
4243

@@ -60,6 +61,8 @@ unsigned long int DSOLOCAL msc_pcre_match_limit = 0;
6061

6162
unsigned long int DSOLOCAL msc_pcre_match_limit_recursion = 0;
6263

64+
int DSOLOCAL status_engine_state = STATUS_ENGINE_DISABLED;
65+
6366
unsigned long int DSOLOCAL conn_read_state_limit = 0;
6467

6568
unsigned long int DSOLOCAL conn_write_state_limit = 0;
@@ -720,6 +723,17 @@ static int hook_post_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_t
720723
ap_log_error(APLOG_MARK, APLOG_NOTICE | APLOG_NOERRNO, 0, s,
721724
"Original server signature: %s", real_server_signature);
722725
}
726+
727+
#ifndef WIN32
728+
if (status_engine_state != STATUS_ENGINE_DISABLED) {
729+
msc_status_engine_call();
730+
}
731+
else {
732+
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
733+
"Status engine is currently disabled, enable it by set " \
734+
"SecStatusEngine to On.");
735+
}
736+
#endif
723737
}
724738

725739
srand((unsigned int)(time(NULL) * getpid()));

apache2/modsecurity.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ extern DSOLOCAL unsigned long int msc_pcre_match_limit;
142142

143143
extern DSOLOCAL unsigned long int msc_pcre_match_limit_recursion;
144144

145+
extern DSOLOCAL int status_engine_state;
146+
145147
extern DSOLOCAL unsigned long int conn_read_state_limit;
146148

147149
extern DSOLOCAL unsigned long int conn_write_state_limit;
@@ -182,6 +184,9 @@ extern DSOLOCAL int *unicode_map_table;
182184
#define MODSEC_DETECTION_ONLY 1
183185
#define MODSEC_ENABLED 2
184186

187+
#define STATUS_ENGINE_ENABLED 1
188+
#define STATUS_ENGINE_DISABLED 0
189+
185190
#define HASH_DISABLED 0
186191
#define HASH_ENABLED 1
187192

0 commit comments

Comments
 (0)