Skip to content

Commit 6366ee6

Browse files
author
jdv
committed
fixed some internal links
1 parent 9c7116e commit 6366ee6

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

crowdsec-docs/docs/contributing/specs/bouncer_appsec_specs.mdx

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import useBaseUrl from "@docusaurus/useBaseUrl"
77

88
## Context
99

10-
A **Remediation Component** *(aka **Bouncer**)* is enforcing **decisions** made by **CrowdSec Security Engine** based on detected malicious behaviors [\[See figure 1\]](#bookmark=id.1m5bs6wbkfr7), or Directly with CrowdSec SaaS endpoint channeling public, crowdsec or user made blocklsits.
10+
A **Remediation Component** *(aka **Bouncer**)* is enforcing **decisions** made by **CrowdSec Security Engine** based on detected malicious behaviors [\[See figure 1\]](#crowdsec-security-engine-diagram), or Directly with CrowdSec SaaS endpoint channeling public, crowdsec or user made blocklsits.
1111

1212
A **decision** dictates what action should be applied on incoming traffic from a specific **IP** or **IP-Range**. *(It could also be on the user scope or any other, but these specifications will focus on the IP and Range scopes)*
1313

@@ -20,15 +20,15 @@ The Bouncer applies the appropriate remediation *(we’ll only focus on ban/bloc
2020
* Communication with the Local API (aka LAPI) or its SaaS counterpart
2121
* Decisions retrieval and storage
2222
* Remediation
23-
* [Request Forwarding](#appsec-capability-\(request-forwarding\)) (for AppSec capabilities)
23+
* [Request Forwarding](#appsec-capability-request-forwarding) (for AppSec capabilities)
2424
* Communication with the AppSec endpoint
2525
* Forwarding protocol
2626
* [Config and support requirements](#extra-details-and-requirements)
2727

2828
Here is an existing remediation components *(bouncers)* for Nginx and its lua dependency
2929
[*cs-nginx-bouncer*](https://github.com/crowdsecurity/cs-nginx-bouncer) *\+ [lua-cs-bouncer](https://github.com/crowdsecurity/lua-cs-bouncer/)* (dependency)
3030

31-
And the yet unreviewed but functional [NGINX NJS version](https://github.com/crowdsecurity/cs-nginx-njs-bouncer/pull/1/files) (doesn’t have appsec capabilities yet)
31+
And the yet prototyped but functional [NGINX NJS version](https://github.com/crowdsecurity/cs-nginx-njs-bouncer/pull/1/files) (doesn’t have appsec capabilities yet)
3232

3333
⚠️ **Your bouncer must always delete/clean it’s resources on shutdown**
3434

@@ -40,20 +40,20 @@ The remediation can be blocking or displaying a captcha.
4040

4141
Fields in purple and/or with the mention (configurable) must appear in the config file, the case of the parameters names can be UPPER or LOWER depending on the type of config file, match the appropriate standard for the bouncer you’re implementing. Try to group them in a logical way in the config file template.
4242

43-
Details about the config file in the [Installation chapter](#installation-/-documentation)
43+
Details about the config file in the [Installation chapter](#installation--documentation)
4444

4545
### Connecting to the Local API (LAPI)
4646

47-
You can find the swagger here [https://crowdsecurity.github.io/api\_doc/lapi/](https://crowdsecurity.github.io/api_doc/lapi/)
48-
Details about the endpoints parameters can be found [in the appendix](#bookmark=id.h7yz6lpk4af7)
47+
You can find the swagger here [https://crowdsecurity.github.io/api_doc/lapi/](https://crowdsecurity.github.io/api_doc/lapi/)
48+
Details about the endpoints parameters can be found [in the appendix](#appendix)
4949

50-
* URL to Local API endpoint: configurable field **api\_url**
51-
* Default value likely to be: http://121.0.0.1:8080
52-
* Security Engine Config : /etc/crowdsec/config.yaml // api.server.listen\_url
50+
* URL to Local API endpoint: configurable field **api_url**
51+
* Default value likely to be: `http://121.0.0.1:8080`
52+
* Security Engine Config : /etc/crowdsec/config.yaml // api.server.listen_url
5353
* For now we only have a v1 of LAPI, bouncer states the version he’s using
5454
* Authentication
55-
* Either by API key passed in the header **X-Api-Key:** configurable field **api\_key**
56-
* Or via certificate configurable fields **tls.cert\_file \+ tls.key\_file**
55+
* Either by API key passed in the header **X-Api-Key:** configurable field **api_key**
56+
* Or via certificate configurable fields **tls.cert_file \+ tls.key_file**
5757

5858
### Retrieving decisions
5959

@@ -81,15 +81,15 @@ The live mode endpoint is **/decisions**
8181
* No need to make this configurable
8282
* Caching
8383
* To avoid consecutive calls for decisions about an IP we’ll cache the decisions per IP
84-
* default **1s** configurable field cache\_expiration
84+
* default **1s** configurable field cache_expiration
8585
* Timeout
8686
* If LAPI doesn’t respond
87-
* Default **200ms** configurable field lapi\_timeout
87+
* Default **200ms** configurable field lapi_timeout
8888
* **Fallback**:
8989
* Fallback in case of timeout
9090
* By default passthrough : let him pass
9191
* Possible values: passthrough, ban, captcha
92-
* configurable field lapi\_failure\_action
92+
* configurable field lapi_failure_action
9393

9494
#### Stream Mode (by default)
9595

@@ -100,7 +100,7 @@ Allows to pull all decisions from LAPI and then periodically get a delta
100100
* ⚠️ To retrieve the initial full list, use the **startup \= true** parameter
101101
* This is necessary if you don’t have the decision list in memory
102102
* Following calls need to have startup \= false
103-
* Recommended pull period **10s** configurable field stream\_update\_frequency
103+
* Recommended pull period **10s** configurable field stream_update_frequency
104104
* Parameters
105105

106106
*Only the following fields are to be considered for a basic bouncer implementation*
@@ -110,18 +110,18 @@ Allows to pull all decisions from LAPI and then periodically get a delta
110110
* empty by default mean all origins are considered
111111
* editable by the user to look in a specific origin: configurable field origins (same field as for live)
112112
* Origins are comma separated strings (e.g. crowdsec,capi,cscli)
113-
* **scenarios\_containing** and **scenarios\_not\_containing**
113+
* **scenarios_containing** and **scenarios_not_containing**
114114
* Means that the decisions are linked (or not) to alerts triggered by such or such scenario
115115
* The check done by LAPI is a string.contains(...)
116-
* Default as empty configurable fields scenarios\_containing && scenarios\_not\_containing
116+
* Default as empty configurable fields scenarios_containing && scenarios_not_containing
117117
* Storing decisions
118118
* ℹ️ The number of decisions you can expect is:
119119
* 30-70k ips from Fire (nominal case)
120120
* Can vary a lot depending on the BL subscription of the user
121121
* Have the code be able to handle 100k to be safe for the nominal case
122122
* Storing in memory is ideal, we recommend to convert IPs to integers
123123
* The decisions format is the following:
124-
* See [decisions example in appendix](#bookmark=id.6hv12rnhk5iz)
124+
* See [decisions example in appendix](#appendix)
125125
* There can be multiple decisions per IP
126126
* Store each decisions independently as they have their own remediation action and TTL
127127
* Ranges are stored too
@@ -137,27 +137,27 @@ If a remediation is found and for the LAPI timeout fallback here are the remedia
137137
* Remediation type
138138
* Remediation property will be “ban”, “captcha” or potentially any custom string
139139
* **ban** (block)
140-
* Return a 403: configurable field ban\_return\_code
140+
* Return a 403: configurable field ban_return_code
141141
* Accompanied by an HTML body
142-
* Default page model [provided (single HTML file)](#bookmark=id.rcfrhly566w8)
143-
* Page path configurable: configurable field ban\_template\_path
142+
* Default page model [provided (single HTML file)](#ban-template-page)
143+
* Page path configurable: configurable field ban_template_path
144144
* **captcha**
145145
* Various type of captcha must be supported
146146
* configurable fields:
147-
* captcha \_provider
148-
* captcha\_secret\_key
149-
* captcha\_site\_key
150-
* captcha\_template\_path
147+
* captcha _provider
148+
* captcha_secret_key
149+
* captcha_site_key
150+
* captcha_template_path
151151
* Type to support
152152
* RE-captcha
153153
* Turnstile
154154
* Hcaptcha
155155
* onFails
156156
* Re-present the captcha
157157
* ⚠️ Cache: in order not to repeat the captcha too often
158-
* **1h** cache **per IP** after successful captcha configurable field cache\_expiration
158+
* **1h** cache **per IP** after successful captcha configurable field cache_expiration
159159
* **Custom remediation**
160-
* Defaults to ignore/ban/captcha configurable field **remediation\_fallback**
160+
* Defaults to ignore/ban/captcha configurable field **remediation_fallback**
161161
* If ignored, you don’t even need to store the decision
162162
* Remediation priority
163163
* There is a priority in the remediation to take in account if an IP has multiple
@@ -197,23 +197,23 @@ An additional activatable capability of the bouncer is to forward the request to
197197

198198
The request forwarding is a blocking process, when the AppSec capability is activated the bouncer should wait for a response at each request forwarding to process with the request handling.
199199

200-
AppSec is disabled by default and activable if url exists configurable field appsec\_url
200+
AppSec is disabled by default and activable if url exists configurable field appsec_url
201201

202202
* Connect to AppSec endpoint
203203
* The security engine should have activated the AppSec and a listen address should be present in the SecurityEngine acquisition
204-
* Default endpoint http://127.0.0.1:7422
204+
* Default endpoint `http://127.0.0.1:7422`
205205
* Auth by API key passed in the header **X-Api-Key:** same param as LAPI apikey
206206
* Request forwarding
207-
* You can find information about the forwarding protocol on this doc page [https://docs.crowdsec.net/docs/next/appsec/protocol/](https://docs.crowdsec.net/docs/next/appsec/protocol/)
207+
* You can find information about the forwarding protocol on this doc page: [https://docs.crowdsec.net/docs/next/appsec/protocol/](https://docs.crowdsec.net/docs/next/appsec/protocol/)
208208
* When forwarding the query to the AppSec endpoint, the security engine will evaluate the actions to do and return the appropriate response code that the remediation component should display.
209209
* ⚠️ At the exception of codes **500** and **401** which mean that the forwarding or authentication to the endpoint failed. For those response codes you should trigger the fallback described there after..
210210
* ⚠️ As stated earlier this is a blocking process
211-
* **Timeout** 200ms configurable field appsec\_timeout
211+
* **Timeout** 200ms configurable field appsec_timeout
212212
* **Fallback**:
213213
* Fallback in case of timeout or response failure (500,401…)
214214
* By default passthrough : let him pass
215215
* Possible values: passthrough, ban, captcha
216-
* configurable field appsec\_failure\_action
216+
* configurable field appsec_failure_action
217217

218218
## Extra Details and Requirements
219219

@@ -299,6 +299,7 @@ You can refer to the AppSec documentation to test request forwarding.
299299

300300
## Appendix
301301

302+
### CrowdSec Security Engine diagram
302303
**Figure 1** : Interactions around **CrowdSec Security Engine**
303304
<div style={{ display: "flex" }}>
304305
<div style={{ textAlign: "center", flex: "1" }}>
@@ -310,14 +311,15 @@ You can refer to the AppSec documentation to test request forwarding.
310311
</div>
311312
</div>
312313

313-
**Details about LAPI endpoints parameters**
314+
### Details about LAPI endpoints parameters
315+
314316
**GET /decisions/stream**
315317

316318
* **startup:** set it to **TRUE** for the **initial call** to get all decisions *(when False you’ll get the delta from your last call)*
317319
* **scopes: “**ip,range” is the only relevant values when remediating on IPs
318-
* **origins:** Leave blank to allow all origins, test your configurable origins with [those tests](#bookmark=id.qso6jljxlov9)
319-
* **scenarios\_containing:** leave blank by default, allow change in config
320-
* **scenarios\_not\_containing:** leave blank by default, allow change in config
320+
* **origins:** Leave blank to allow all origins, test your configurable origins with [those tests](#decision-example)
321+
* **scenarios_containing:** leave blank by default, allow change in config
322+
* **scenarios_not_containing:** leave blank by default, allow change in config
321323

322324
**GET /decisions**
323325

@@ -327,11 +329,11 @@ You can refer to the AppSec documentation to test request forwarding.
327329
* **ip:** ignore/leave blank: shortcut for scope:ip \+ value
328330
* **range:** ignore/leave blank: shortcut for scope:range \+ value
329331
* **contains:** leave blank by default, configurable by user
330-
* **origins:** Leave blank to allow all origins, test your configurable origins with [those tests](#bookmark=id.qso6jljxlov9)
331-
* **scenarios\_containing:** leave blank by default, allow change in config
332-
* **scenarios\_not\_containing:** leave blank by default, allow change in config
332+
* **origins:** Leave blank to allow all origins, test your configurable origins with [those tests](#decision-example)
333+
* **scenarios_containing:** leave blank by default, allow change in config
334+
* **scenarios_not_containing:** leave blank by default, allow change in config
333335

334-
**Decision example**
336+
### Decision example
335337

336338
```javascript
337339
{
@@ -361,7 +363,7 @@ You can refer to the AppSec documentation to test request forwarding.
361363

362364
```
363365

364-
**Ban template page**
366+
### Ban template page
365367

366368
```javascript
367369
<!DOCTYPE html>
@@ -479,7 +481,9 @@ You can refer to the AppSec documentation to test request forwarding.
479481

480482
```
481483

482-
**Metrics payload**
484+
### Metrics payload
485+
486+
More details about metrics in [Metrics specs](/contributing/specs/bouncer_metrics_specs/)
483487

484488
```
485489
{

0 commit comments

Comments
 (0)