Skip to content

Commit fbae550

Browse files
committed
Revert all the recent changes for ModSecurity IIS.
We are reverting all IIS changes down to the last known stable version. (cherry picked from commit 886e633) Signed-off-by: Vladimir Krivopalov <[email protected]>
1 parent 2e9bd5a commit fbae550

35 files changed

Lines changed: 1538 additions & 966 deletions

.gitmodules

Lines changed: 0 additions & 4 deletions
This file was deleted.

apache2/apache2_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ static const char *add_rule(cmd_parms *cmd, directory_config *dcfg, int type,
820820
}
821821

822822
#ifndef ALLOW_ID_NOT_UNIQUE
823-
/* Rules must have uniq ID */
823+
/* Rules must have uniq ID */
824824
type_rule = (dcfg->tmp_chain_starter == NULL);
825825
#if defined(WITH_LUA)
826826
type_rule = (type != RULE_TYPE_LUA && type_rule);

apache2/apache2_util.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ char *get_env_var(request_rec *r, char *name) {
200200
static void get_field_value(const char* from, const char* to, const char* text, char* output) {
201201
char* first = strstr(text, from);
202202
int first_index = first - text;
203-
char backslash[] = "\\";
203+
char backslash[] = "\\";
204204

205205
if (first != NULL ) {
206206
if ((first_index > 0 && strncmp((first-1), backslash, 2) != 0) || (first_index == 0)) {
@@ -332,16 +332,16 @@ static void send_waf_log(struct waf_lock* lock, apr_file_t* fd, const char* str1
332332
char waf_ruleset_type[50] = "";
333333
char waf_ruleset_version[50] = "";
334334
char waf_detail_message[1024] = "";
335-
char waf_unique_id[100] = "";
335+
char waf_unique_id[100] = "";
336336

337337
get_field_value("[file ", "]", str1, waf_filename);
338338
get_field_value("[id ", "]", str1, waf_id);
339339
get_field_value("[line ", "]", str1, waf_line);
340340
get_field_value("[msg ", "]", str1, waf_message);
341341
get_field_value("[data ", "]", str1, waf_data);
342-
get_field_value("[ver ", "]", str1, waf_ruleset_info);
343-
get_field_value("[unique_id ", "]", unique_id, waf_unique_id);
344-
get_ip_port(ip_port, waf_ip, waf_port);
342+
get_field_value("[ver ", "]", str1, waf_ruleset_info);
343+
get_field_value("[unique_id ", "]", unique_id, waf_unique_id);
344+
get_ip_port(ip_port, waf_ip, waf_port);
345345
get_detail_message(str1, waf_detail_message);
346346
get_short_filename(waf_filename);
347347
get_ruleset_type_version(waf_ruleset_info, waf_ruleset_type, waf_ruleset_version);
@@ -438,8 +438,8 @@ static void internal_log_ex(request_rec *r, directory_config *dcfg, modsec_rec *
438438

439439
/* Send message levels 1-3 to the Apache error log and
440440
* add it to the message list in the audit log. */
441-
char *unique_id = (char *)get_env_var(r, "UNIQUE_ID");
442-
if (level <= 3) {
441+
char *unique_id = (char *)get_env_var(r, "UNIQUE_ID");
442+
if (level <= 3) {
443443
char *hostname = (char *)msr->hostname;
444444
char *requestheaderhostname = (char *)r->hostname;
445445

@@ -469,7 +469,7 @@ static void internal_log_ex(request_rec *r, directory_config *dcfg, modsec_rec *
469469

470470
if (rc != APR_SUCCESS) {
471471
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
472-
ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
472+
ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
473473
"ModSecurity not able to reopen %s file", WAF_LOG_UTIL_FILE);
474474
#else
475475
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r->server,
@@ -484,7 +484,7 @@ static void internal_log_ex(request_rec *r, directory_config *dcfg, modsec_rec *
484484
#endif
485485

486486
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
487-
ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
487+
ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
488488
"[client %s] ModSecurity: %s%s [uri \"%s\"]%s%s", r->useragent_ip ? r->useragent_ip : r->connection->client_ip, str1,
489489
hostname, log_escape(msr->mp, r->uri), unique_id, requestheaderhostname);
490490
#else

apache2/libinjection/libinjection_sqli.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ int libinjection_sqli_fold(struct libinjection_sqli_state * sf)
14441444
)
14451445
{
14461446
if (pos > LIBINJECTION_SQLI_MAX_TOKENS) {
1447-
st_copy(&(sf->tokenvec[1]), &(sf->tokenvec[LIBINJECTION_SQLI_MAX_TOKENS]));
1447+
st_copy(&(sf->tokenvec[1]), &(sf->tokenvec[LIBINJECTION_SQLI_MAX_TOKENS]));
14481448
pos = 2;
14491449
left = 0;
14501450
} else {
@@ -1521,9 +1521,9 @@ int libinjection_sqli_fold(struct libinjection_sqli_state * sf)
15211521
continue;
15221522
} else if (sf->tokenvec[left].type == TYPE_SEMICOLON &&
15231523
sf->tokenvec[left+1].type == TYPE_FUNCTION &&
1524-
(sf->tokenvec[left+1].val[0] == 'I' ||
1525-
sf->tokenvec[left+1].val[0] == 'i' ) &&
1526-
(sf->tokenvec[left+1].val[1] == 'F' ||
1524+
(sf->tokenvec[left+1].val[0] == 'I' ||
1525+
sf->tokenvec[left+1].val[0] == 'i' ) &&
1526+
(sf->tokenvec[left+1].val[1] == 'F' ||
15271527
sf->tokenvec[left+1].val[1] == 'f' )) {
15281528
/* IF is normally a function, except in Transact-SQL where it can be used as a
15291529
* standalone control flow operator, e.g. ; IF 1=1 ...

apache2/mod_security2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ int perform_interception(modsec_rec *msr) {
294294
csd = ap_get_module_config(msr->r->connection->conn_config, &core_module);
295295
}
296296
#else
297-
csd = ap_get_module_config(msr->r->connection->conn_config, &core_module);
297+
csd = ap_get_module_config(msr->r->connection->conn_config, &core_module);
298298
#endif
299299
if (csd) {
300300
if (apr_socket_close(csd) == APR_SUCCESS) {

apache2/modsecurity.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ extern DSOLOCAL char *msc_waf_lock_group;
231231
#define STATUS_ENGINE_ENABLED 1
232232
#define STATUS_ENGINE_DISABLED 0
233233

234-
#define REMOTE_RULES_ABORT_ON_FAIL 0
235-
#define REMOTE_RULES_WARN_ON_FAIL 1
234+
#define REMOTE_RULES_ABORT_ON_FAIL 0
235+
#define REMOTE_RULES_WARN_ON_FAIL 1
236236

237237
#define HASH_DISABLED 0
238238
#define HASH_ENABLED 1
@@ -412,8 +412,8 @@ struct modsec_rec {
412412

413413
apr_size_t msc_reqbody_no_files_length;
414414

415-
char *msc_full_request_buffer;
416-
int msc_full_request_length;
415+
char *msc_full_request_buffer;
416+
int msc_full_request_length;
417417

418418
char *multipart_filename;
419419
char *multipart_name;
@@ -439,15 +439,15 @@ struct modsec_rec {
439439

440440
/* performance measurement */
441441
apr_time_t request_time;
442-
apr_time_t time_phase1;
443-
apr_time_t time_phase2;
444-
apr_time_t time_phase3;
445-
apr_time_t time_phase4;
446-
apr_time_t time_phase5;
447-
apr_time_t time_storage_read;
448-
apr_time_t time_storage_write;
449-
apr_time_t time_logging;
450-
apr_time_t time_gc;
442+
apr_time_t time_phase1;
443+
apr_time_t time_phase2;
444+
apr_time_t time_phase3;
445+
apr_time_t time_phase4;
446+
apr_time_t time_phase5;
447+
apr_time_t time_storage_read;
448+
apr_time_t time_storage_write;
449+
apr_time_t time_logging;
450+
apr_time_t time_gc;
451451
apr_table_t *perf_rules;
452452

453453
apr_array_header_t *matched_rules;
@@ -670,7 +670,7 @@ struct directory_config {
670670
int xml_external_entity;
671671
#ifdef MEMORY_DATABASE_ENABLE
672672
/* AGMDB */
673-
directory_config *root_config;
673+
directory_config *root_config;
674674
int db_option;
675675
void *agmdb_handles;
676676
#endif

apache2/modsecurity_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* so this is here to prevent that by removing them.
33
*/
44

5-
#ifndef WIN32
5+
#ifndef WIN32
66

77
/* Undefine all these so there are no conflicts */
88
#undef PACKAGE

apache2/msc_json.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int DSOLOCAL json_complete(modsec_rec *msr, char **error_msg);
5454
apr_status_t DSOLOCAL json_cleanup(modsec_rec *msr);
5555

5656
int DSOLOCAL json_process_chunk(modsec_rec *msr, const char *buf,
57-
unsigned int size, char **error_msg);
57+
unsigned int size, char **error_msg);
5858

5959
#endif
6060
#endif

apache2/msc_logging.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ void sec_audit_logger_json(modsec_rec *msr) {
735735

736736
/* Lock the mutex, but only if we are using serial format. */
737737
if (msr->txcfg->auditlog_type != AUDITLOG_CONCURRENT) {
738-
rc = waf_get_exclusive_lock(msr->modsecurity->auditlog_lock);
738+
rc = waf_get_exclusive_lock(msr->modsecurity->auditlog_lock);
739739
if (waf_lock_is_error(rc)) {
740740
msr_log(msr, 1, "Audit log: Failed to lock global mutex: %s",
741741
get_apr_error(msr->mp, rc));
@@ -1279,7 +1279,7 @@ void sec_audit_logger_json(modsec_rec *msr) {
12791279
yajl_gen_map_close(g); // sanitized args map is finished
12801280
}
12811281
#ifdef LOG_NO_SERVER_CONTEXT
1282-
}
1282+
}
12831283
#endif
12841284

12851285
/* Web application info. */
@@ -1447,7 +1447,7 @@ void sec_audit_logger_json(modsec_rec *msr) {
14471447
if (msr->txcfg->auditlog_type != AUDITLOG_CONCURRENT) {
14481448

14491449
/* Unlock the mutex we used to serialise access to the audit log file. */
1450-
rc = waf_free_exclusive_lock(msr->modsecurity->auditlog_lock);
1450+
rc = waf_free_exclusive_lock(msr->modsecurity->auditlog_lock);
14511451
if (waf_lock_is_error(rc)) {
14521452
msr_log(msr, 1, "Audit log: Failed to unlock global mutex: %s",
14531453
get_apr_error(msr->mp, rc));
@@ -1622,7 +1622,7 @@ void sec_audit_logger_native(modsec_rec *msr) {
16221622

16231623
/* Lock the mutex, but only if we are using serial format. */
16241624
if (msr->txcfg->auditlog_type != AUDITLOG_CONCURRENT) {
1625-
rc = waf_get_exclusive_lock(msr->modsecurity->auditlog_lock);
1625+
rc = waf_get_exclusive_lock(msr->modsecurity->auditlog_lock);
16261626
if (waf_lock_is_error(rc)) {
16271627
msr_log(msr, 1, "Audit log: Failed to lock global mutex: %s",
16281628
get_apr_error(msr->mp, rc));
@@ -1991,16 +1991,16 @@ void sec_audit_logger_native(modsec_rec *msr) {
19911991

19921992
/* Apache-Handler */
19931993
#ifdef LOG_NO_HANDLER
1994-
if (msr->txcfg->debuglog_level >= 9)
1994+
if (msr->txcfg->debuglog_level >= 9)
19951995
#endif
1996-
if (msr->r->handler != NULL) {
1996+
if (msr->r->handler != NULL) {
19971997
text = apr_psprintf(msr->mp, "Apache-Handler: %s\n", msr->r->handler);
19981998
sec_auditlog_write(msr, text, strlen(text));
19991999
}
20002000

20012001
/* Stopwatch; left in for compatibility reasons */
20022002
#ifdef LOG_NO_STOPWATCH
2003-
if (msr->txcfg->debuglog_level >= 9) {
2003+
if (msr->txcfg->debuglog_level >= 9) {
20042004
#endif
20052005
text = apr_psprintf(msr->mp, "Stopwatch: %" APR_TIME_T_FMT " %" APR_TIME_T_FMT " (- - -)\n",
20062006
msr->request_time, (now - msr->request_time));
@@ -2022,7 +2022,7 @@ void sec_audit_logger_native(modsec_rec *msr) {
20222022
/* ENH Only write this when the output was chunked. */
20232023
/* ENH Add info when request body was decompressed, dechunked too. */
20242024
#ifdef LOG_NO_DECHUNK
2025-
if (msr->txcfg->debuglog_level >= 9)
2025+
if (msr->txcfg->debuglog_level >= 9)
20262026
#endif
20272027
if (wrote_response_body) {
20282028
text = apr_psprintf(msr->mp, "Response-Body-Transformed: Dechunked\n");
@@ -2101,10 +2101,10 @@ void sec_audit_logger_native(modsec_rec *msr) {
21012101
}
21022102
}
21032103
#ifdef LOG_NO_SERVER_CONTEXT
2104-
}
2104+
}
21052105
#endif
21062106

2107-
/* Web application info. */
2107+
/* Web application info. */
21082108
if ( ((msr->txcfg->webappid != NULL)&&(strcmp(msr->txcfg->webappid, "default") != 0))
21092109
|| (msr->sessionid != NULL) || (msr->userid != NULL))
21102110
{
@@ -2227,7 +2227,7 @@ void sec_audit_logger_native(modsec_rec *msr) {
22272227
sec_auditlog_write(msr, "\n", 1);
22282228

22292229
/* Unlock the mutex we used to serialise access to the audit log file. */
2230-
rc = waf_free_exclusive_lock(msr->modsecurity->auditlog_lock);
2230+
rc = waf_free_exclusive_lock(msr->modsecurity->auditlog_lock);
22312231
if (waf_lock_is_error(rc)) {
22322232
msr_log(msr, 1, "Audit log: Failed to unlock global mutex: %s",
22332233
get_apr_error(msr->mp, rc));

apache2/msc_release.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
MODSEC_VERSION_SUFFIX
5050

5151
/* Apache Module Defines */
52-
#ifdef VERSION_IIS
52+
#ifdef VERSION_IIS
5353
#define MODSEC_MODULE_NAME "ModSecurity for IIS (STABLE)"
5454
#else
55-
#ifdef VERSION_NGINX
55+
#ifdef VERSION_NGINX
5656
#define MODSEC_MODULE_NAME "ModSecurity for nginx (STABLE)"
5757
#else
58-
#ifdef VERSION_STANDALONE
58+
#ifdef VERSION_STANDALONE
5959
#define MODSEC_MODULE_NAME "ModSecurity Standalone (STABLE)"
6060
#else
6161
#define MODSEC_MODULE_NAME "ModSecurity for Apache"

0 commit comments

Comments
 (0)