summaryrefslogtreecommitdiff
path: root/doc/source/config.rst
diff options
context:
space:
mode:
authorjvoisin2017-09-26 17:57:30 +0200
committerjvoisin2017-09-26 17:57:30 +0200
commit3040b02639bd71dbcd936311546ef9296165aea5 (patch)
tree871173e901c04255de595653b8e1dc237a675b51 /doc/source/config.rst
parent3c14dba94e837322e030b19b41654952624cb485 (diff)
Update a bit the configuration
Diffstat (limited to 'doc/source/config.rst')
-rw-r--r--doc/source/config.rst50
1 files changed, 30 insertions, 20 deletions
diff --git a/doc/source/config.rst b/doc/source/config.rst
index 7299fb1..760ae1b 100644
--- a/doc/source/config.rst
+++ b/doc/source/config.rst
@@ -13,6 +13,7 @@ Some rules applies in a specific ``function`` (context), on a specific ``variabl
13(data), like ``disable_functions``, others can only be enabled/disabled, like 13(data), like ``disable_functions``, others can only be enabled/disabled, like
14``harden_random``. 14``harden_random``.
15 15
16
16.. warning:: 17.. warning::
17 18
18 Careful, a wrongly configured Snuffleupagus might break your website. 19 Careful, a wrongly configured Snuffleupagus might break your website.
@@ -20,6 +21,11 @@ Some rules applies in a specific ``function`` (context), on a specific ``variabl
20 read the present documentation about how to configure them, 21 read the present documentation about how to configure them,
21 evaluate your threat model, and write your configuration file accordingly. 22 evaluate your threat model, and write your configuration file accordingly.
22 23
24Most of the features can be used in ``simulation`` mode by appending the
25``.simulation()`` option to them (eg. ``sp.readonly_exec.simulation()enable();``) to see
26if they might break your website. The simulation mode won't block the request,
27but will write a warning in the log.
28
23The rules are evaluated in the order that they are written, and the **first** one 29The rules are evaluated in the order that they are written, and the **first** one
24to match will terminate the evaluation (except for rules in simulation mode). 30to match will terminate the evaluation (except for rules in simulation mode).
25 31
@@ -34,7 +40,7 @@ global_strict
34forcing PHP to throw a `TypeError <https://secure.php.net/manual/en/class.typeerror.php>`_ 40forcing PHP to throw a `TypeError <https://secure.php.net/manual/en/class.typeerror.php>`_
35exception if an argument type being passed to a function does not match its corresponding declared parameter type. 41exception if an argument type being passed to a function does not match its corresponding declared parameter type.
36 42
37It can either be ``enabled`` or ``disabled`` 43It can either be ``enabled`` or ``disabled``.
38 44
39:: 45::
40 46
@@ -81,6 +87,8 @@ unserialize_hmac
81``unserialize_hmac`` will add integrity check to ``unserialize`` calls, preventing 87``unserialize_hmac`` will add integrity check to ``unserialize`` calls, preventing
82abritrary code execution in their context. 88abritrary code execution in their context.
83 89
90It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode.
91
84:: 92::
85 93
86 sp.unserialize_hmac.enable(); 94 sp.unserialize_hmac.enable();
@@ -116,7 +124,7 @@ cookie_encryption
116 124
117``cookie_secure`` will activate transparent encryption of specific cookies. 125``cookie_secure`` will activate transparent encryption of specific cookies.
118 126
119It can either be ``enabled`` or ``disabled``. 127It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode.
120 128
121:: 129::
122 130
@@ -130,7 +138,7 @@ readonly_exec
130 138
131``readonly_exec`` will prevent the execution of writable PHP files. 139``readonly_exec`` will prevent the execution of writable PHP files.
132 140
133It can either be ``enabled`` or ``disabled``. 141It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode.
134 142
135:: 143::
136 144
@@ -156,6 +164,8 @@ code, with something like `vld <https://derickrethans.nl/projects.html#vld>`_
156The upload will be **allowed** if the script return the value ``0``. Every other 164The upload will be **allowed** if the script return the value ``0``. Every other
157value will prevent the file from being uploaded. 165value will prevent the file from being uploaded.
158 166
167It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode.
168
159:: 169::
160 170
161 sp.upload_validation.script("/var/www/is_valid_php.py").enable(); 171 sp.upload_validation.script("/var/www/is_valid_php.py").enable();
@@ -191,22 +201,22 @@ Of course, this is a trivial example, and a lot can be achieved with this featur
191Filters 201Filters
192^^^^^^^ 202^^^^^^^
193 203
194- ``alias(:str)``: human-readable description of the rule 204- ``alias(description)``: human-readable ``description`` of the rule
195- ``cidr(ip/mask:str)``: match on the client's `cidr <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing>`_ 205- ``cidr(ip/mask)``: match on the client's `cidr <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing>`_
196- ``filename(name:str)``: match in the file ``name`` 206- ``filename(name)``: match in the file ``name``
197- ``filename_r(regexp:str)``: the file name matching the ``regexp`` 207- ``filename_r(regexp)``: the file name matching the ``regexp``
198- ``function(name:str)``: match on function ``name`` 208- ``function(name)``: match on function ``name``
199- ``function_r(regexp:str)``: the function matching the ``regexp`` 209- ``function_r(regexp)``: the function matching the ``regexp``
200- ``hash(:str)``: match on the file's `sha256 <https://en.wikipedia.org/wiki/SHA-2>`_ sum 210- ``hash(sha256)``: match on the file's `sha256 <https://en.wikipedia.org/wiki/SHA-2>`_ sum
201- ``param(name:str)``: match on the function's parameter ``name`` 211- ``param(name)``: match on the function's parameter ``name``
202- ``param_r(regexp:str)``: match on the function's parameter ``regexp`` 212- ``param_r(regexp)``: match on the function's parameter ``regexp``
203- ``param_type(type:str)``: match on the function's parameter ``type`` 213- ``param_type(type)``: match on the function's parameter ``type``
204- ``ret(value:str)``: match on the function's return ``value`` 214- ``ret(value)``: match on the function's return ``value``
205- ``ret_r(regexp:str)``: match with a ``regexp`` on the function's return 215- ``ret_r(regexp)``: match with a ``regexp`` on the function's return
206- ``ret_type(type_name:str)``: match on the ``type_name`` of the function's return value 216- ``ret_type(type_name)``: match on the ``type_name`` of the function's return value
207- ``value(:str)``: match on a litteral value 217- ``value(value)``: match on a litteral ``value``
208- ``value_r(:regexp)``: match on a value matching the ``regexp`` 218- ``value_r(regexp)``: match on a value matching the ``regexp``
209- ``var(name:str)``: match on a **local variable** ``name`` 219- ``var(name)``: match on a **local variable** ``name``
210 220
211The ``type`` must be one of the following values: 221The ``type`` must be one of the following values:
212 222
@@ -225,7 +235,7 @@ Actions
225 235
226- ``allow()``: **allow** the request if the rule matches 236- ``allow()``: **allow** the request if the rule matches
227- ``drop()``: **drop** the request if the rule matches 237- ``drop()``: **drop** the request if the rule matches
228- ``dump(directory:str)``: dump the request in the ``directory`` if it matches the rule 238- ``dump(directory)``: dump the request in the ``directory`` if it matches the rule
229- ``simulation()``: enabled the simulation mode 239- ``simulation()``: enabled the simulation mode
230 240
231Details 241Details