1476 Commits

Author SHA1 Message Date
Felipe Zimmerle
a95f37196e Adds JSON support on ISS port
The JSON parse is already supported in Nginx and Apache
versions. This patch adds support on the IIS port.
2014-03-31 16:22:09 -07:00
Felipe Zimmerle
0787b45481 Adds support to JSON parser in the nginx module
Building with --enable-standalone-module was failing due
the lack of the reference to the msc_json.c file inside the
standalone/Makefile.am. This patch also place the dependency
of the yajl to the nginx module config script.
2014-03-31 16:22:09 -07:00
Felipe Zimmerle
09ced44ffa Supports the yajl version 2
Initially the code was made to support the yajl version 1. The
version 2 is now the default option in most of Linux distributions.
2014-03-31 16:22:09 -07:00
Felipe Zimmerle
8d4c3e4f5c Makes the build system to look for yajl using a macro file
Now searching for yajl using find_yajl.m4 macro file instead
of using pkg-config directly. If YAJL was not found or if it
was disabled in the configure phase, the code will be compiled
without JSON support.
2014-03-31 16:22:09 -07:00
Ulisses Albuquerque
e90874a694 Added sample JSON content-type rule 2014-03-31 16:22:09 -07:00
Ulisses Albuquerque
c23097ce18 Added support for JSON body processor 2014-03-31 16:22:09 -07:00
Felipe Zimmerle
410aca9d78 Optimization on the status engine call
The status string was too long. By removing meaningless stuff, such as: runtime
version of Lua, we have reduced the length of the status string. Limitations
were also placed regarding the size of the ModSecurity version. Big queries may
lead to failure, due to restrictions of "gethostbyname". There is also a bit of
code cosmetics in this patch: big functions were broken into smaller.
2014-03-31 16:22:05 -07:00
Felipe "Zimmerle" Costa
20014c808c Adds modsecStatusEngineCall to standalone API
In ModSecurityIIS the configuration is loaded upon the first request
is received. In other words, SecStatusEngine value can be only
loaded once the first request hit the server, and so, the status
function was moved to proceed just after the configuration got loaded.
This update is IIS only.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
d75e443b9b Adds regression test to SecStatusEngine
Just checking the error log while have SecStatusEngine set to On in a first
test and Off in a second.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
a6d93441c1 Places StatusEngine to be Off by default
StatusEngine is now marked as Off by default. This patch also adds the
SecStatusEngine directive to our recommend configuration file.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
e131e2222d Adds support to status engine on IIS version
Fixes on the windows versions: build, mac address and machine name retrieval
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
f86a71f7a7 Adds SecStatusEngine On/Off switch
Add the possibility to turn the Status Engine On or Off using the
directive SecStatusEngine [On/Off]. By default it is On.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
0c6a661c69 First version of the status engine implementation
The Status Engine allow the measurements of how many ModSecurity
instances are running around the world, as long as information
on how many times it had been restarted and so on. Everytime that
the server is started it perform a DNS query that is redirected
to our servers, that query constains information about the
ModSecurity version and it dependencies versions. It also sends a
unique indetification generate locally for the server, avoiding
counting the same server twice while generating the statistics.
This id is a sha-1 hash of the machine name + mac address of the
first network adapter. In this commit it is enabled by default,
in the release will be a configuration option to disable this
functionality. It also important to cite that the information
gather by this query will be also available in ModSecurity website
public open via a JSON stateless API. There will be an fancy
heatmap as well.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
d93ce9ceee Adds REQUEST_FULL and REQUEST_FULL_LENGTH variables
This variable is a combination from REQUEST_LINE, REQUEST_HEADERS and
REQUEST_BODY (if any). Expects for \n\n in between each of those values.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
62f3d02894 Adds utf8toUnicode.t to our unit tests
A bug was reported related to our utf8toUnicode transformation, so, adding this
unit test to confirm the bug and to check whenever it is fixed. Bug #671.
2014-03-31 07:14:55 -07:00
Greg Chow
5b0c933cf3 Fixes UTF8 to Unicode conversion bug in 4-byte encodings 2014-03-31 07:14:55 -07:00
Ewald Dieterich
7e459827e0 Log why writing to audit log failed
Add error description from apr_strerror() to message that is logged if
writing to audit log failed.
2014-03-31 07:14:55 -07:00
Ewald Dieterich
607dfd229a Fix segmentation fault if writing to audit log fails
A segmentation fault occurs if concurrent audit log format is enabled
(SecAuditLogType Concurrent) and writing to the log fails.
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
5342f36162 iis: Uses code 400 instead of 44 in modsecurity.conf
Following the recent changes that has been made on:
modsecurity.conf-recommended
2014-03-31 07:14:55 -07:00
Felipe Zimmerle
a0ed3dbbe2 Merge pull request #666 from derhansen/master
Uses code 400 instead of 44 in modsecurity.conf-recommended
2014-03-31 07:13:46 -07:00
David Andrews
dda91f1689 Standalone: independently destroy the connection and request pools
Add independent modsecFinishConnection API that allows you to independently
destroy the connection and request pools. This is to facilitate reuse of a
connection for multiple requests.
2014-03-03 14:17:00 -08:00
David Andrews
27dd513ab6 Flip allocations that happen during initialization (typically) over to use non-global apr memory pools. 2014-03-03 08:00:53 -08:00
Felipe Zimmerle
31d7fc6d38 Code cosmetics: Place copy_rules in nice shape.
Continuation of kukackajiri's work to provide fixes for errors pointed by
Parfait. The function copy_rules had an integer as return code but it was not
filed proper neither checked by its callers. This commit just adds sanity
checks and documentation for the copy_rules function. Marking were placed
on the copy_rules callers, but the return code is not handled yet.
For kukackajiri's work, see merge request: #612
2014-03-03 04:27:29 -08:00
Jiri Kukacka
62a6f228f8 Fixes for Parfait errors - mostly unhandled NULL pointer dereference and data type mismatch 2014-02-28 17:05:41 -08:00
Felipe Zimmerle
5f996d45f0 Adds regression test to SecRequestBodyLimitAction
This commits adds the following regiression test to SecRequestBodyLimitAction:
* config - SecRequestBodyLimitAction Reject (multipart/greater - chunked): passed
* config - SecRequestBodyLimitAction Reject (plain/greater): passed
* config - SecRequestBodyLimitAction ProcessPartial (multipart/greater - chunked): passed
* config - SecRequestBodyLimitAction ProcessPartial (plain/greater): passed
2014-02-28 13:33:49 -08:00
Justin Gerace
498b9b2e7a Don't reject a large request with ProcessPartial set 2014-02-28 12:36:48 -08:00
Torben Hansen
ab9aede2e5 Update status code for rule 200002
Removed the non standard compliant HTTP response status code 44 and replaced it with a 400 response status code. Refs #665
2014-02-25 15:44:40 +01:00
Felipe Zimmerle
063dd640e5 Adds internal error messages while parsing the configutarion
Before this patch, if something went wrong while loading the configuration in
memory, not in terms of syntax but other run time factors such as memory
allocation, the webserver will refuse to start and no further message was given
to the user. This patch adds "Internal Error messages" that are intend to let
the user know more information about the problem that he/she is facing.
2014-02-24 03:56:17 -08:00
Felipe Zimmerle
da2ec008bd Fixes a typo on the README.txt
Minor typo in the README.txt file, there was a double "h" in the
begining of an http address. The OWASP Core Rule Set Project
address was placed in an unique line, so that, the link will be
no longer broken on project's main page at GitHub.
2014-02-10 03:27:42 -08:00
Felipe Zimmerle
1694a0cf34 Merge branch 'nginx_regression' 2014-01-17 22:07:50 -08:00
Felipe Zimmerle
f043ba33a3 Adds .a to the list of expected liblua extension
While download and installed on MacOS, liblua5.1, by default, place
itself, under the folder /usr/local/lib with the extension: .a.
2014-01-18 01:29:02 -03:00
Felipe Zimmerle
5d2e3d4321 test: 10-misc-directives.t is not considering log anymore
In this case the new server name is expected to be logged, only in the Apache
version or the debug version of Nginx. The test is still valid, in the sense
that it is checking for the server response, expecting the new "Server:"
header.
2014-01-17 13:02:48 -08:00
Felipe Zimmerle
8804b55cdd test: Makes regression test mac friendly
Apache configuration was updated and the configure script is using
an alternative way to discovery the libexecdir.
2014-01-17 11:24:53 -08:00
Felipe Zimmerle
8314791c9e test: nginx: Adds timeout while listening for a socket. 2014-01-16 20:22:38 -08:00
Felipe Zimmerle
215042af21 test: nginx: Points the !# to envoriment.
Instead of using a hardcoded path to Perl, using what is provided by the
environment. Avoiding problems with MacOS, where two different
versions of Perl are expected. One provided by the system and other
by MacOS ports.
2014-01-16 10:31:59 -08:00
Felipe Zimmerle
d26e639512 test: nginx: Speeds up regression test in nginx.
Instead of use `sleep` it nows parser the nginx logs to figure out
whenever it start or stop. Audit log timeout was reduced to 8 seconds.
2014-01-16 10:30:23 -08:00
Felipe Zimmerle
fe14d9df4d nginx: Considering modsec state before apply any rules
For some reason the state of modsec (enable, disable or detecting only) was not
being checked under certain circumstances. For instance, while reading the
body. This was leading ModSecurity to fail and consequently nginx. This patch
added the to standalone implementation mechanism to verify the state that is now
verified under the nginx module.
2014-01-13 18:44:47 -08:00
Felipe Zimmerle
9bf1f6a2b3 test: removes uncessary ifDefine at 10-tfn-cache.t
IfDefines such as: <IfDefine MODSEC_2.5> are just compatible with Apache a
solution to check if some resource is available or not have to be developed
to be used in situations like that. This commit just removes the IfDefine.
2014-01-13 08:11:42 -08:00
Felipe Zimmerle
94097103c8 test: nginx: Adds missing environment variables.
Added the following environment variables:
 - DATA_DIR
 - TEMP_DIR
 - UPLOAD_DIR
These were needed by the testing framework, as the name explains.
2014-01-13 05:44:28 -08:00
Felipe Zimmerle
6c106b1fd7 test: disabling: SecAuditLogType Concurrent
The test is making usage of a custom script, which is not functional in
in Nginx due to timing issues. Disabling it for now until we came up
with a solution that works for every port/version.
2014-01-13 05:44:28 -08:00
Felipe Zimmerle
8e390899e0 test: nginx: Increses the timeout while reading the audit log.
Audit logs are taking too long to be written on the disk. One of the
consequence of that is to have tests that demands to read from audit
log failing. Increase the timeout makes it wait a little bit more for
the logs before gave up.
2014-01-13 05:44:14 -08:00
Felipe Zimmerle
3cf1701794 test: Adds loading tests also to nginx.
It was trying to match "ModSecurity for Apache.* configured". This patch
makes it expect for "ModSecurity for nginx.* configured" while nginx
version is being used/tested.
2014-01-09 12:13:47 -08:00
Felipe Zimmerle
795d6a64d2 nginx: Warn about not workable 'proxy'
Proxy is not yet ready for nginx. Instead of give a generic error, this patch
adds a clean message explains that such functionality is not available on the
nginx port. This patch also modifies the test cases to reflect this changes.
2014-01-09 11:12:28 -08:00
Felipe Zimmerle
7478faa5ce test: Adds support to handle different content in log depending on the version
Some functionalities are just enabled on Apache, not part of nginx or IIS. As
example we have the "proxy", currently just supported in Apache. This patches
add to our regression test suite the ability to expect different contents
based on the targert platform.
2014-01-09 09:40:06 -08:00
Felipe Zimmerle
7ac515ee29 nginx: Adds proper support to SecServerSignature
SecServerSignature was leading nginx to crash. It was trying to write over a
memory area that it was not allowed to. In order to fix that a new function was
created on the standalone api. This function is called
modsecIsServerSignatureAvailale. Whenever it returns data it means that the
function SecServerSignature was used by the user. Nginx module was also patched
to support this new function.
2014-01-08 18:06:32 -08:00
Felipe Zimmerle
2a43589395 nginx: Removes problematic performance improvement
In an attempt to boost the performance the headers were being checked in two
different situations, the first if SecResponseBodyAccess was Off and in a
second situation if SecResponseBodyAccess was set to On. This makes sense
however functionalities such as content injection demands the body even if
SecResponseBodyAccess was not enabled. This patch removes the first scenario,
leaving just the second one. After this modification the following regression
tests started to pass:

from: regression/action/10-append-prepend.t
  1) action - append content: passed
  2) action - prepend content: passed
2014-01-07 19:26:43 -08:00
Felipe Zimmerle
21e25c50af test: nginx: Adds missing files
This commit is just to circunvent a problem, there is no need to have
those files duplicated in our repository, that will be fixed soon.
2014-01-06 19:52:10 -08:00
Felipe Zimmerle
176396ddc1 tests: nginx: Allow POSTs in static files
By default Nginx does not allow POST in static files, which is very
used by the regression test. This is a ugly hack just to make possible
to gather some numbers. Better solution will arrive soon.
2014-01-06 19:22:27 -08:00
Felipe Zimmerle
e20c800044 nginx: fix missing headers while SecResponseBodyAccess was On
The problem was caused by the fact that ModSecutiry was telling Nginx that
headers had been sent when, in fact, had not. This modification was added in
the past, along with others, in the following commit: fd2c30fa2311e783eecf3bf02bf3dcfbabc3968a
This patch, just removes the "r->header_sent = 1". After that modification
the following regression tests started to work again:

from: action/00-disruptive-actions.t
   3) action - pass in phase:3
   4) action - pass in phase:4
  11) action - deny in phase:3
  12) action - deny in phase:4
  19) action - redirect in phase:3 (get)
  20) action - redirect in phase:4 (get)
  23) action - proxy in phase:3 (get)
  24) action - proxy in phase:4 (get)
from: config/10-response-directives.t
   2) config - SecResponseBodyAccess On
   6) config - SecResponseBodyLimit (greater)
   7) config - SecResponseBodyLimitAction Reject
2014-01-06 19:10:24 -08:00
Felipe Zimmerle
445783d067 tests: Sleeps over 20 seconds if nginx failed to exit immediately
Sometimes nginx failed to exit cleanly in the expected time. This patch adds
the capability to wait for more 20 seconds.
2014-01-03 13:09:44 -08:00