1662 Commits

Author SHA1 Message Date
Eldar Zaitov
207c85d9f7 Best practices: Checking if variables are null before use it 2016-02-02 18:06:51 -03:00
Andrei Belov
bc390c6659 Use ngx_cycle to obtain log object in handler function.
Previously used r->connection->log was causing segfault in some
circumstances (in particular, in proxy_unfinished.t test).
2016-02-02 15:06:06 -03:00
Andrei Belov
ce21d6b4dc Explicitly set log object to r->connection->log in preaccess phase handler.
This change fixes a number of scenarios when ModSecurity's log entries
may be written to the wrong file descriptors. In particular, there was
an issue with almost any configuration using nginx cache features
(proxy_cache, fastcgi_cache, etc) when garbage from ModSecurity logs
has been sent to the control socket used for communication between
nginx master process and auxiliary processes (workers, cache manager,
cache loader).

Described behavior was observed with nginx/1.7.0, modsecurity/2.8.0
and OWASP CRS v2.2.9.
2016-02-02 15:05:49 -03:00
Andrei Belov
0276b34507 All ngx_log_debug() calls changed to ngx_log_debug0(). 2016-02-02 15:05:27 -03:00
Felipe Zimmerle
94de8077cb Fixes in consequence of the rebase 2016-02-02 13:13:12 -03:00
Felipe Zimmerle
169e918a64 Small fix on the top of #950 to sanity check the variable before use it 2016-02-02 12:49:45 -03:00
Ngo The Trung
10bc802ee0 Use nginx's parsed hostname 2016-02-02 12:49:45 -03:00
Felipe Zimmerle
411dc15a4a Small fix on the top of the patch #950 2016-02-02 12:49:45 -03:00
Ramandeep Singh
e76e912bab Passthrough the saved Response headers in the response
Tickets: https://github.com/SpiderLabs/ModSecurity/issues/735
2016-02-02 12:49:45 -03:00
Felipe Zimmerle
5f9c4d75e8 nginx: cosmetics: Splits lines longer than 80 characters 2016-02-02 12:49:45 -03:00
Felipe Zimmerle
523ac1093c nginx: copies the req body chain to be processed instead of move
Add a check for the definition MOVE_REQUEST_CHAIN_TO_MODSEC, whenever it is
set the chain will be moved into the brigade. If it was not set the chain
will be only copied. Moving was causing segfaults on the following
regression tests:

 #15 - SecRequestBodyInMemoryLimit
 #16 - SecRequestBodyInMemoryLimit (greater)
 #19 - SecRequestBodyLimitAction ProcessPartial (multipart/greater - chunked)
 (from: regression/config/10-request-directives.t)
2016-02-02 12:49:45 -03:00
Felipe Zimmerle
d294e8f083 nginx: better dealing with chunked request body 2016-02-02 12:49:44 -03:00
Felipe Zimmerle
a3433c3d17 nginx refactoring
Refactoring on the nginx module, including:
 - Better handling larger posts;
 - Now using nginx echo module during the regression tests.
 - Better interacting with neginx chain rules
 - Separation of the request handling and content filters.
 - Better handling nginx sessions and resource counts to allow a
   more efficient garbage collector.
 - Handling both http/1.0 and 1.1, including keep-alive.
 - Tests are now capable to test nginx as a proxy or end-server.
 - Tested agains nginx 1.6 and 1.7.
2016-02-02 12:49:44 -03:00
Felipe Zimmerle
fda20322fb Adds information about the issue #904 on the CHANGES file 2016-02-02 12:49:44 -03:00
Andrey Kolganov
06ba734542 Fix issues with uploading files over 8K : #142, #582 and #830 2016-02-02 12:49:40 -03:00
Felipe Zimmerle
d135f88254 Avoids segfault while running with proxy_pass
Duplicates the headers variables while coping data from/to ModSecurity.
This seems to fix the segfault that was happening while using proxy_pass.
The variable is later cleaned, which means that we don't have a leak
because of that.
2016-02-02 12:28:52 -03:00
Fabricio Oliveira
eb904c2666 Fix missing status_line when logging in nginx. 2016-02-02 12:28:52 -03:00
Ramandeep
005b42548a Allow non-zero Content-Length for HEAD requests 2016-02-02 12:28:52 -03:00
Ramandeep Singh
c226240df9 Passthrough the saved Response headers in the response
Tickets: https://github.com/SpiderLabs/ModSecurity/issues/735
2016-02-02 12:28:52 -03:00
Felipe Zimmerle
8907941f49 nginx: fixing fuzzyHash test case for nginx
POST was happening on a file that was not allowed by nginx to receive a POST.
Nginx was returning 405 instead of 200 making the test to fail. Fixed by
change the URL to one that is allowed to receive POST.
2016-02-02 12:28:52 -03:00
Andrei Belov
99a148f072 Obtain port from r->connection->local_sockaddr.
This eliminates segfaults caused by unset (NULL) r->port_start
and non-NULL r->port_end. In fact, r->port_start is always NULL,
so it is useless to rely on this pointer.
2016-02-02 12:28:52 -03:00
Andrei Belov
6ef8028720 Removed unneeded and invalid initialization. 2016-02-02 12:28:52 -03:00
paulyang
f7f3b32a27 Bugfix: add -P option in test script
Otherwise nginx's installation directory could not be specified.

Signed-off-by: paulyang <paulyang.inf@gmail.com>
2016-02-02 12:28:52 -03:00
Felipe Zimmerle
9de3bb6be7 niginx: cosmetics: Changes CRLF to LF 2016-02-02 12:28:52 -03:00
Felipe Zimmerle
feaf4c512b nginx: cosmetics: Removes trailing whitespace 2016-02-02 12:28:52 -03:00
Felipe Zimmerle
b1aed8d7c1 nginx: cosmetics: Splits lines longer than 80 characters 2016-02-02 12:28:52 -03:00
Felipe Zimmerle
0c8a5b2af0 nginx: copies the req body chain to be processed instead of move
Add a check for the definition MOVE_REQUEST_CHAIN_TO_MODSEC, whenever it is
set the chain will be moved into the brigade. If it was not set the chain
will be only copied. Moving was causing segfaults on the following
regression tests:

 #15 - SecRequestBodyInMemoryLimit
 #16 - SecRequestBodyInMemoryLimit (greater)
 #19 - SecRequestBodyLimitAction ProcessPartial (multipart/greater - chunked)
 (from: regression/config/10-request-directives.t)
2016-02-02 12:28:52 -03:00
Felipe Zimmerle
ed8666d386 nginx: better dealing with chunked request body 2016-02-02 12:28:52 -03:00
Felipe Zimmerle
0b5f3e123c nginx: looking for segfaults on the regression test.
If nginx segfaults it will return, warning that the test failed.
2016-02-02 12:28:52 -03:00
Felipe Zimmerle
9602fa4a44 nginx refactoring
Refactoring on the nginx module, including:
 - Better handling larger posts;
 - Now using nginx echo module during the regression tests.
 - Better interacting with neginx chain rules
 - Separation of the request handling and content filters.
 - Better handling nginx sessions and resource counts to allow a
   more efficient garbage collector.
 - Handling both http/1.0 and 1.1, including keep-alive.
 - Tests are now capable to test nginx as a proxy or end-server.
 - Tested agains nginx 1.6 and 1.7.
2016-02-02 12:28:52 -03:00
Felipe Zimmerle
ad0a29ea2f Adds information about the pull request #1060 on the CHANGES file 2016-02-02 12:28:52 -03:00
root
c5fd8c7cea This is fix for reborn of https://github.com/SpiderLabs/ModSecurity/issues/334 This bug has been reborn, because Apache (at least in RedHat/CentOS) since version 2.2.15-47 returns in same case APR_INCOMPLETE (not APR_EOF). Based on same patch I have added handler for APR_INCOMPLETE. 2016-02-02 12:28:52 -03:00
Chaim Sanders
eef2c03e64 Fixed broken link in readme #1059 2016-02-01 11:16:13 -05:00
Felipe Zimmerle
c131dcc93c Adds information about the pull request #914 on the CHANGES file 2016-01-29 13:27:30 -03:00
Robert Paprocki
374871e10e Updates to parse_modsec.pl 2016-01-29 11:59:52 -03:00
Robert Paprocki
2307a8b55b Add JSON log parse script 2016-01-29 11:59:52 -03:00
Robert Paprocki
8f8645f3d6 Whitespace fix for pull request 2016-01-29 11:59:52 -03:00
Robert Paprocki
ddc25dbbaa Fix 'is_chained' value for final rule in chain
'is_chained' should be true for an actionset when the is_chained
member of the struct is true, or when its rule has a valid
chain_starter member.
2016-01-29 11:59:52 -03:00
Robert Paprocki
5bc75ec871 Do not compile in JSON logging support if yajl is not found 2016-01-29 11:59:52 -03:00
Robert Paprocki
0c95a7a2cd Clean up JSON rule writer
* Escape rule actionset metadata
* Escape and truncate logdata
* Lazily add actionset tags as an array
* Add negated rule op_param
* Add unparsed rule representation
2016-01-29 11:59:52 -03:00
Robert Paprocki
8559399ebd Update JSON structure for matched rules
Create a separate map for each matched rule chain,
making it easier to identify chains in which only a portion
of rules actually matched.
2016-01-29 11:59:52 -03:00
Robert Paprocki
7a39b4b5b9 Make JSON audit logging a configurable option
Remove compile-time setting for generating audit logs
as JSON, creating a new config option (SecAuditLogFormat).
sec_audit_logger is now a wrapper for sec_audit_logger_json
or sec_audit_logger_native. This has the disadvantage of
making the audit log generation code harder to maintain,
but the logger function itself now is no longer pepper
with binary branches.
2016-01-29 11:59:52 -03:00
Robert Paprocki
dd79bea0b4 Additional updates for JSON logging
* Write Stopwatch2 values into a separate map
* Remove legacy Stopwatch
* Proper sanitization of request/response headers
* Lazily open maps for keys that may not have content
2016-01-29 11:59:52 -03:00
Robert Paprocki
7b2ca1617e first pass at JSON logging implementation 2016-01-29 11:59:52 -03:00
Felipe Zimmerle
4eb095ad25 Adds information about the pull request #852 on the CHANGES file 2016-01-26 09:28:20 -03:00
Felipe Zimmerle
0db247f0e9 Replicates CREATEMODE patch to the secondary auditlog file
At patch 45805be, @littlecho changed the behaviour to set the audit log
index/serial file permission. Before, it was using the default permission now
it is respecting the permission configured via SecAuditLogFileMode. This patch
replicates @littlecho's work to the secundary auditlog file.
2016-01-26 09:20:25 -03:00
littlecho
b175c5cf60 Update apache2_config.c
Change third parameter(which is the apr file permission flag) from CREATEMODE to dcfg->auditlog_fileperms. Due to the user can specify the desired file permission setting for the audit log files with setting the value of SecAuditLogFileMode, we should follow the file permission setting from the config file. Therefore, as the dcfg->auditlog_fileperms will be modified in cmd_audit_log_dirmode function, we can use the value while calling apr_file_open to meet the file permission that specified in modsecurity.conf.
2016-01-26 09:08:13 -03:00
Felipe Zimmerle
35fbc76ecc Adds information about the pull request #1041 on the CHANGES file 2016-01-25 14:58:24 -03:00
Chaim Sanders
d434a6c043 Fixing missing return value check for hashing response injection failure 2016-01-25 14:54:56 -03:00
Felipe Zimmerle
b3f197dd1f Adds information about the pull request #709 on the CHANGES file 2016-01-25 13:40:46 -03:00