You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crowdsec-docs/docs/appsec/configuration.md
+82Lines changed: 82 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,88 @@ inband_rules:
58
58
#...
59
59
```
60
60
61
+
## Disabling rules at runtime
62
+
63
+
Even though we try to provide rules without false positives, sometimes a virtual patching rule can block legitimate requests on a website.
64
+
65
+
You can disable rules at runtime, either globally (for all requests) or based on specific conditions (source IP, URI, ...).
66
+
67
+
You can can disable rules by:
68
+
- Name with `RemoveInBandRuleByName`: Intended for disabling rules provided by crowdsec (the name is the name of the appsec-rule as seen in `cscli appsec-rules list`).
69
+
- ID with `RemoveInBandRuleByID`: Intended for disabling seclang rules
70
+
- Tag with `RemoveInBandRuleByTag`: Intended for disabling seclang rules
71
+
72
+
The same functions exist for out-of-band rules, prefixed with `RemovedOutBandRuleBy...`
73
+
74
+
To disable a rule, we'll first create a new `appsec-config` to avoid tainting the configuration from the hub (if you are already using a custom configuration, you can update this one instead).
We are using the [hooks](/docs/appsec/hooks.md) provided by the appsec to modify the configuration in 2 places:
88
+
- `on_load`: Expressions here will be applied when crowdsec loads the configuration, effectively disabling the rule `crowdsecurity/vpatch-env-access` globally.
89
+
- `pre_eval`: Expressions here will be applied only if the provided filter matches. In this example, we are disabling the rule `crowdsecurity/generic-wordpress-uploads-php` only if the request URI starts with `/blog/` and if we are currently processing in-band rules.
90
+
91
+
You can also disable native (seclang) rules by providing their ID with the `RemoveInBandRuleByID` helper. See the [hooks](appsec/hooks.md) documentation for a list of available helpers.
92
+
93
+
Also note that we are not loading any rules in our custom config: the rules are loaded by the `crowdsecurity/appsec-default` config, and we are just modifying the runtime behavior with this config.
94
+
95
+
Finally, we need to tell crowdsec to load our new config:
If your reverse-proxy forwards all requests to crowdsec, regardless of the FQDN, you can disable the appsec for specific domain with a custom appsec-config (ie, the request will be always allowed):
With this config, the rules will still be evaluated, but if a rule matches no alert or event will be generated, and the remediation will be set to `allow`(ie, instruct the bouncer to let the request through).
142
+
61
143
## Appsec configuration
62
144
63
145
The AppSec configuration is referenced by the acquisition configuration (`appsec_config`, `appsec_configs` or `appsec_config_path`):
Copy file name to clipboardExpand all lines: crowdsec-docs/docs/appsec/protocol.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,14 +22,15 @@ This documentation can be useful in case you want to write your own remediation
22
22
23
23
To work with the CrowdSec application security component, some HTTP headers are require, in addition to the other HTTP headers and the body of the original request.
|`200`| The HTTP request is allowed |`{"action" : "allow"}`|
102
-
|`403`| The HTTP request triggered one or more application security component rules |`{"action" : "ban", "http_status": 403}` or `{"action" : "captcha", "http_status": 403}`|
103
-
|`500`| An error occurred in the application security component. The remediation component must support a `APPSEC_FAILURE_ACTION` parameter to handle this case |`null`|
104
-
|`401`| The remediation component is not authenticated. It must use the same API Key that was generated to pull the local API request |`null`|
|`200`| The HTTP request is allowed |`{"action" : "allow"}`|
103
+
|`403`| The HTTP request triggered one or more application security component rules |`{"action" : "ban", "http_status": 403}` or `{"action" : "captcha", "http_status": 403}`|
104
+
|`500`| An error occurred in the application security component. The remediation component must support a `APPSEC_FAILURE_ACTION` parameter to handle this case |`null`|
105
+
|`401`| The remediation component is not authenticated. It must use the same API Key that was generated to pull the local API request |`null`|
105
106
106
107
In case of a `403` response, the body will contain the action to take and the HTTP status code to return to the client.
enable: <true|false> # enable or disable local API
172
177
log_level: "(error|info|debug|trace>")"
@@ -223,6 +228,7 @@ common:
223
228
log_max_age: <max_age_of_log_file>
224
229
log_max_files: <number_of_log_files_to_keep>
225
230
compress_logs: (true|false)
231
+
log_format: "(text|json)"
226
232
```
227
233
228
234
#### `daemonize`
@@ -279,6 +285,11 @@ Maximum number of old log files to retain. The default is to retain 3 old log f
279
285
280
286
Whether to compress the log file after rotation or not.
281
287
288
+
#### `log_format`
289
+
> string
290
+
291
+
Format of crowdsec log. Can be `text` (default) or `json`
292
+
282
293
### `config_paths`
283
294
284
295
This section contains most paths to various sub configuration items.
@@ -452,6 +463,9 @@ db_config:
452
463
host: "<db_host_ip>" # for mysql/postgresql/pgx # must be omitted if using socket file
453
464
port: "<db_host_port>" # for mysql/postgresql/pgx # must be omitted if using socket file
454
465
sslmode: "<require/disable>" # for postgresql/pgx
466
+
ssl_ca_cert: "<path_to_ca_cert_file>" # for mysql/pgsql
467
+
ssl_client_cert: "<path_to_client_cert_file>" # for mysql/pgsql
468
+
ssl_client_key: "<path_to_client_key_file>" # for mysql/pgsql
455
469
max_open_conns: "<max_number_of_conns_to_db>"
456
470
decision_bulk_size: "<decision_bulk_size>"
457
471
flush:
@@ -549,13 +563,48 @@ db_config:
549
563
The port to connect to (only if the type of database is `mysql` or `postgresql`). Must be omitted if using socket file.
550
564
551
565
566
+
#### `sslmode`
567
+
552
568
```yaml
553
569
db_config:
554
570
type: postgresql
555
571
556
572
sslmode: require
557
573
```
558
-
Require or disable ssl connection to database (only if the type of database is `postgresql`). See [PostgreSQL SSL modes](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS) for possible values.
574
+
Require or disable ssl connection to database (only if the type of database is `mysql` or `postgresql` or `pgx`).
575
+
576
+
See [PostgreSQL SSL modes](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS) for possible values.
577
+
See [MySQL SSL modes](https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html) for possible values within the `Client-Side` configuration.
578
+
579
+
#### `ssl_ca_cert`
580
+
581
+
```yaml
582
+
db_config:
583
+
type: mysql|postgresql|pgx
584
+
585
+
ssl_ca_cert: /path/to/ca.crt
586
+
```
587
+
Path to the CA certificate file (only if the type of database is `mysql` or `postgresql` or `pgx`)
588
+
589
+
#### `ssl_client_cert`
590
+
591
+
```yaml
592
+
db_config:
593
+
type: mysql|postgresql|pgx
594
+
595
+
ssl_client_cert: /path/to/client.crt
596
+
```
597
+
Path to the client certificate file when using mTLS (only if the type of database is `mysql` or `postgresql` or `pgx`)
598
+
599
+
#### `ssl_client_key`
600
+
601
+
```yaml
602
+
db_config:
603
+
type: mysql|postgresql|pgx
604
+
605
+
ssl_client_key: /path/to/client.key
606
+
```
607
+
Path to the client key file when using mTLS (only if the type of database is `mysql` or `postgresql` or `pgx`)
0 commit comments