crowdsec-local-mcp 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crowdsec_local_mcp/__init__.py +5 -0
- crowdsec_local_mcp/__main__.py +24 -0
- crowdsec_local_mcp/compose/waf-test/.gitignore +3 -0
- crowdsec_local_mcp/compose/waf-test/crowdsec/acquis.d/appsec.yaml +8 -0
- crowdsec_local_mcp/compose/waf-test/crowdsec/appsec-configs/mcp-appsec.yaml.template +8 -0
- crowdsec_local_mcp/compose/waf-test/crowdsec/init-bouncer.sh +29 -0
- crowdsec_local_mcp/compose/waf-test/docker-compose.yml +68 -0
- crowdsec_local_mcp/compose/waf-test/nginx/Dockerfile +67 -0
- crowdsec_local_mcp/compose/waf-test/nginx/crowdsec/crowdsec-openresty-bouncer.conf +25 -0
- crowdsec_local_mcp/compose/waf-test/nginx/nginx.conf +25 -0
- crowdsec_local_mcp/compose/waf-test/nginx/site-enabled/default-site.conf +15 -0
- crowdsec_local_mcp/compose/waf-test/rules/.gitkeep +0 -0
- crowdsec_local_mcp/compose/waf-test/rules/base-config.yaml +11 -0
- crowdsec_local_mcp/mcp_core.py +151 -0
- crowdsec_local_mcp/mcp_scenarios.py +380 -0
- crowdsec_local_mcp/mcp_waf.py +1170 -0
- crowdsec_local_mcp/prompts/prompt-scenario-deploy.txt +27 -0
- crowdsec_local_mcp/prompts/prompt-scenario-examples.txt +237 -0
- crowdsec_local_mcp/prompts/prompt-scenario.txt +84 -0
- crowdsec_local_mcp/prompts/prompt-waf-deploy.txt +118 -0
- crowdsec_local_mcp/prompts/prompt-waf-examples.txt +401 -0
- crowdsec_local_mcp/prompts/prompt-waf.txt +343 -0
- crowdsec_local_mcp/setup_cli.py +306 -0
- crowdsec_local_mcp/yaml-schemas/appsec_rules_schema.yaml +343 -0
- crowdsec_local_mcp/yaml-schemas/scenario_schema.yaml +591 -0
- crowdsec_local_mcp-0.0.2.dist-info/METADATA +74 -0
- crowdsec_local_mcp-0.0.2.dist-info/RECORD +31 -0
- crowdsec_local_mcp-0.0.2.dist-info/WHEEL +5 -0
- crowdsec_local_mcp-0.0.2.dist-info/entry_points.txt +3 -0
- crowdsec_local_mcp-0.0.2.dist-info/licenses/LICENSE +21 -0
- crowdsec_local_mcp-0.0.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
### CrowdSec Scenario Deployment Helper
|
|
2
|
+
|
|
3
|
+
Use this checklist to package, publish, and roll out a new CrowdSec scenario safely.
|
|
4
|
+
|
|
5
|
+
**Preflight**
|
|
6
|
+
- Confirm the scenario YAML validates against the official schema.
|
|
7
|
+
- Ensure associated parsers, collections, and data files are already published or bundled.
|
|
8
|
+
- Document expected labels (`service`, `behavior`, `classification`) for downstream consumers.
|
|
9
|
+
|
|
10
|
+
**Local Packaging**
|
|
11
|
+
- Create or update a collection under `hub/collections/` with your scenario in `scenarios/`.
|
|
12
|
+
- Run `cscli lint` on the collection to verify metadata, dependency graph, and manifest.
|
|
13
|
+
- Execute `cscli hubtest run <collection>` or tailored replay tests before shipping.
|
|
14
|
+
|
|
15
|
+
**Versioning & Metadata**
|
|
16
|
+
- Bump the collection `version` and add a concise changelog entry.
|
|
17
|
+
- Update `description`, `author`, and `tags` to reflect the new detection surface.
|
|
18
|
+
- Include `references` or `data` source URLs when external threat intel is consumed.
|
|
19
|
+
|
|
20
|
+
**Distribution**
|
|
21
|
+
- For private rollouts: publish to an internal mirror via `cscli hub push --url <repo>`.
|
|
22
|
+
- For community sharing: open a PR against the public CrowdSec hub with scenario, collection, and documentation updates.
|
|
23
|
+
- Communicate migration guidance (e.g., new labels, breaking filter changes) to operators.
|
|
24
|
+
|
|
25
|
+
**Post-Deployment**
|
|
26
|
+
- Monitor `cscli decisions list` and alerting channels for noise or missed detections.
|
|
27
|
+
- Gather feedback and iterate quickly; update the scenario or collection version as needed.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
### Example: SSH Bruteforce (crowdsecurity/ssh-bf)
|
|
2
|
+
|
|
3
|
+
**Overview**
|
|
4
|
+
Detects repeated failed SSH authentications from the same source IP and reacts quickly to shut down short, intense brute-force bursts.
|
|
5
|
+
|
|
6
|
+
**Signals**
|
|
7
|
+
- Log source: `ssh_failed-auth`
|
|
8
|
+
- Grouping: `evt.Meta.source_ip`
|
|
9
|
+
- Threshold: 5 failures leaking over 10 seconds, bans for 1 minute
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
type: leaky
|
|
13
|
+
name: crowdsecurity/ssh-bf
|
|
14
|
+
description: "Detect ssh bruteforce"
|
|
15
|
+
filter: evt.Meta.log_type == 'ssh_failed-auth'
|
|
16
|
+
leakspeed: "10s"
|
|
17
|
+
references:
|
|
18
|
+
- http://wikipedia.com/ssh-bf-is-bad
|
|
19
|
+
capacity: 5
|
|
20
|
+
groupby: evt.Meta.source_ip
|
|
21
|
+
blackhole: 1m
|
|
22
|
+
reprocess: true
|
|
23
|
+
labels:
|
|
24
|
+
service: ssh
|
|
25
|
+
confidence: 3
|
|
26
|
+
spoofable: 0
|
|
27
|
+
classification:
|
|
28
|
+
- attack.T1110
|
|
29
|
+
label: "SSH Bruteforce"
|
|
30
|
+
behavior: "ssh:bruteforce"
|
|
31
|
+
remediation: true
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Notes**
|
|
35
|
+
- Works with the stock `crowdsecurity/ssh` parser that emits `ssh_failed-auth` events.
|
|
36
|
+
- `reprocess: true` allows earlier buckets to be reconsidered if new evidence arrives.
|
|
37
|
+
|
|
38
|
+
### Example: WordPress Scan (crowdsecurity/http-wordpress-scan)
|
|
39
|
+
|
|
40
|
+
**Overview**
|
|
41
|
+
Flags HTTP clients enumerating vulnerable WordPress PHP endpoints, combining access and error logs to catch probing noise.
|
|
42
|
+
|
|
43
|
+
**Signals**
|
|
44
|
+
- Log source: `http_access-log` and `http_error-log`
|
|
45
|
+
- Grouping: `evt.Meta.source_ip` with path distinctness
|
|
46
|
+
- Threshold: 3 distinct PHP paths with `/wp-` prefix in 10 seconds
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
type: leaky
|
|
50
|
+
name: crowdsecurity/http-wordpress-scan
|
|
51
|
+
description: "Detect exploitation attempts against common WordPress endpoints"
|
|
52
|
+
filter: |
|
|
53
|
+
evt.Meta.service == 'http' and
|
|
54
|
+
evt.Meta.log_type in ['http_access-log', 'http_error-log'] and
|
|
55
|
+
evt.Meta.http_status in ['404', '403'] and
|
|
56
|
+
Lower(evt.Meta.http_path) contains "/wp-" and
|
|
57
|
+
Lower(evt.Meta.http_path) endsWith ".php"
|
|
58
|
+
groupby: evt.Meta.source_ip
|
|
59
|
+
distinct: evt.Meta.http_path
|
|
60
|
+
capacity: 3
|
|
61
|
+
leakspeed: "10s"
|
|
62
|
+
blackhole: 5m
|
|
63
|
+
labels:
|
|
64
|
+
remediation: true
|
|
65
|
+
classification:
|
|
66
|
+
- attack.T1595
|
|
67
|
+
behavior: "http:scan"
|
|
68
|
+
label: "WordPress Vuln Hunting"
|
|
69
|
+
spoofable: 0
|
|
70
|
+
service: wordpress
|
|
71
|
+
confidence: 3
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Notes**
|
|
75
|
+
- Requires parsers that normalize HTTP status, verb, and path fields (e.g., `crowdsecurity/nginx`).
|
|
76
|
+
- The `distinct` clause suppresses repeated hits on the same file while still tracking breadth.
|
|
77
|
+
|
|
78
|
+
### Example: Kubernetes Pod Exec (crowdsecurity/k8s-audit-pod-exec)
|
|
79
|
+
|
|
80
|
+
**Overview**
|
|
81
|
+
Traces `kubectl exec` attempts captured by Kubernetes audit logs, highlighting possible lateral movement inside clusters.
|
|
82
|
+
|
|
83
|
+
**Signals**
|
|
84
|
+
- Log source: `k8s-audit`
|
|
85
|
+
- Filter: matches `pods/exec` subresource across differing audit payload shapes
|
|
86
|
+
- Action: trigger immediately for notification
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
type: trigger
|
|
90
|
+
name: crowdsecurity/k8s-audit-pod-exec
|
|
91
|
+
description: "Detect execution (via kubectl exec) in pods"
|
|
92
|
+
filter: |
|
|
93
|
+
evt.Meta.log_type == 'k8s-audit' &&
|
|
94
|
+
(
|
|
95
|
+
(evt.Meta.datasource_type == "k8s-audit" && evt.Unmarshaled.k8s_audit.ObjectRef?.Resource == 'pods' && evt.Unmarshaled.k8s_audit.ObjectRef?.Subresource == 'exec')
|
|
96
|
+
||
|
|
97
|
+
(evt.Meta.datasource_type != "k8s-audit" && evt.Unmarshaled.k8s_audit.objectRef?.resource == 'pods' && evt.Unmarshaled.k8s_audit.objectRef?.subresource == 'exec')
|
|
98
|
+
)
|
|
99
|
+
labels:
|
|
100
|
+
notification: true
|
|
101
|
+
classification:
|
|
102
|
+
- attack.T1609
|
|
103
|
+
behavior: "k8s:audit"
|
|
104
|
+
label: "Kubernetes Exec Into Pod"
|
|
105
|
+
spoofable: 0
|
|
106
|
+
confidence: 3
|
|
107
|
+
cti: false
|
|
108
|
+
service: k8s
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Notes**
|
|
112
|
+
- Handles both legacy and new audit formats via optional chaining syntax.
|
|
113
|
+
- Set up alert routing for `notification: true` events rather than automated bans.
|
|
114
|
+
|
|
115
|
+
### Example: HTTP Open Proxy Probe (crowdsecurity/http-open-proxy)
|
|
116
|
+
|
|
117
|
+
**Overview**
|
|
118
|
+
Spots scanners testing whether your HTTP service relays outbound requests via the CONNECT method or full URLs.
|
|
119
|
+
|
|
120
|
+
**Signals**
|
|
121
|
+
- Log source: `http_access-log`
|
|
122
|
+
- Grouping: `evt.Meta.source_ip`
|
|
123
|
+
- Threshold: instant trigger with `400`/`405` status and suspicious request line
|
|
124
|
+
|
|
125
|
+
```yaml
|
|
126
|
+
type: trigger
|
|
127
|
+
name: crowdsecurity/http-open-proxy
|
|
128
|
+
description: "Detect scan for open proxy"
|
|
129
|
+
#apache returns 405, nginx 400
|
|
130
|
+
filter: "evt.Meta.log_type == 'http_access-log' && evt.Meta.http_status in ['400','405'] && (evt.Parsed.verb == 'CONNECT' || evt.Parsed.request matches '^http[s]?://')"
|
|
131
|
+
blackhole: 2m
|
|
132
|
+
groupby: evt.Meta.source_ip
|
|
133
|
+
labels:
|
|
134
|
+
service: http
|
|
135
|
+
type: scan
|
|
136
|
+
remediation: true
|
|
137
|
+
classification:
|
|
138
|
+
- attack.T1595
|
|
139
|
+
behavior: "http:scan"
|
|
140
|
+
label: "HTTP Open Proxy Probing"
|
|
141
|
+
spoofable: 0
|
|
142
|
+
confidence: 3
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Notes**
|
|
146
|
+
- Combine with rate-limiting scenarios (e.g., leaky buckets) for persistent scanners.
|
|
147
|
+
- Retains a short `blackhole` so subsequent hits from the same IP reuse the bucket without re-triggering immediately.
|
|
148
|
+
|
|
149
|
+
### Example: Log4Shell CVE-2021-44228 (crowdsecurity/apache_log4j2_cve-2021-44228)
|
|
150
|
+
|
|
151
|
+
**Overview**
|
|
152
|
+
Captures Log4Shell payloads embedded anywhere in HTTP requests by matching against an updated signature list fetched from CrowdSec hub data.
|
|
153
|
+
|
|
154
|
+
**Signals**
|
|
155
|
+
- Log source: `http_access-log` and `http_error-log`
|
|
156
|
+
- Grouping: `evt.Meta.source_ip`
|
|
157
|
+
- External data: downloads `log4j2_cve_2021_44228.txt` with known exploit markers
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
type: trigger
|
|
161
|
+
format: 2.0
|
|
162
|
+
name: crowdsecurity/apache_log4j2_cve-2021-44228
|
|
163
|
+
description: "Detect cve-2021-44228 exploitation attemps"
|
|
164
|
+
filter: |
|
|
165
|
+
evt.Meta.log_type in ["http_access-log", "http_error-log"] and
|
|
166
|
+
(
|
|
167
|
+
any(File("log4j2_cve_2021_44228.txt"), { Upper(evt.Meta.http_path) contains Upper(#)})
|
|
168
|
+
or
|
|
169
|
+
any(File("log4j2_cve_2021_44228.txt"), { Upper(evt.Parsed.http_user_agent) contains Upper(#)})
|
|
170
|
+
or
|
|
171
|
+
any(File("log4j2_cve_2021_44228.txt"), { Upper(evt.Parsed.http_referer) contains Upper(#)})
|
|
172
|
+
)
|
|
173
|
+
data:
|
|
174
|
+
- source_url: https://hub-data.crowdsec.net/web/log4j2_cve_2021_44228.txt
|
|
175
|
+
dest_file: log4j2_cve_2021_44228.txt
|
|
176
|
+
type: string
|
|
177
|
+
groupby: "evt.Meta.source_ip"
|
|
178
|
+
blackhole: 2m
|
|
179
|
+
labels:
|
|
180
|
+
service: apache
|
|
181
|
+
confidence: 3
|
|
182
|
+
spoofable: 0
|
|
183
|
+
classification:
|
|
184
|
+
- attack.T1595
|
|
185
|
+
- attack.T1190
|
|
186
|
+
- cve.CVE-2021-44228
|
|
187
|
+
behavior: "http:exploit"
|
|
188
|
+
label: "Log4j CVE-2021-44228"
|
|
189
|
+
remediation: true
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Notes**
|
|
193
|
+
- The `data` block keeps the exploit keyword list current without redeploying the scenario.
|
|
194
|
+
- Checks multiple headers and path fields to cover obfuscated payload placements.
|
|
195
|
+
|
|
196
|
+
### Example: ThinkPHP CVE-2018-20062 (crowdsecurity/thinkphp-cve-2018-20062)
|
|
197
|
+
|
|
198
|
+
**Overview**
|
|
199
|
+
Monitors for ThinkPHP remote code execution probes by matching request paths against a curated regex list refreshed on the fly.
|
|
200
|
+
|
|
201
|
+
**Signals**
|
|
202
|
+
- Log source: `http_access-log` and `http_error-log`
|
|
203
|
+
- Grouping: `evt.Meta.source_ip`
|
|
204
|
+
- External data: LRU-cached regex file `thinkphp_cve_2018-20062.txt` with a 10-second TTL
|
|
205
|
+
|
|
206
|
+
```yaml
|
|
207
|
+
type: trigger
|
|
208
|
+
format: 2.0
|
|
209
|
+
name: crowdsecurity/thinkphp-cve-2018-20062
|
|
210
|
+
description: "Detect ThinkPHP CVE-2018-20062 exploitation attemps"
|
|
211
|
+
filter: |
|
|
212
|
+
evt.Meta.log_type in ["http_access-log", "http_error-log"] and RegexpInFile(Lower(evt.Meta.http_path), "thinkphp_cve_2018-20062.txt")
|
|
213
|
+
data:
|
|
214
|
+
- source_url: https://hub-data.crowdsec.net/web/thinkphp_cve_2018-20062.txt
|
|
215
|
+
dest_file: thinkphp_cve_2018-20062.txt
|
|
216
|
+
type: regexp
|
|
217
|
+
strategy: LRU
|
|
218
|
+
size: 20
|
|
219
|
+
ttl: 10s
|
|
220
|
+
groupby: "evt.Meta.source_ip"
|
|
221
|
+
blackhole: 2m
|
|
222
|
+
labels:
|
|
223
|
+
confidence: 3
|
|
224
|
+
spoofable: 0
|
|
225
|
+
classification:
|
|
226
|
+
- attack.T1190
|
|
227
|
+
- attack.T1595
|
|
228
|
+
- cve.CVE-2018-20062
|
|
229
|
+
behavior: "http:exploit"
|
|
230
|
+
label: "ThinkPHP CVE-2018-20062"
|
|
231
|
+
remediation: true
|
|
232
|
+
service: thinkphp
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Notes**
|
|
236
|
+
- `RegexpInFile` leverages the downloaded expressions, which are refreshed using an LRU cache for performance.
|
|
237
|
+
- Tight `ttl` ensures your defender stays aligned with the latest offensive payload variants.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
You are helping to author a CrowdSec scenario (detection rule) from raw log observations. Follow CrowdSec's official scenario format and directives: https://doc.crowdsec.net/docs/log_processor/scenarios/format
|
|
2
|
+
|
|
3
|
+
Goals:
|
|
4
|
+
- Understand the attack or behaviour being modelled, including log fields used as signals.
|
|
5
|
+
- Design a concise, maintainable scenario YAML using CrowdSec's DSL.
|
|
6
|
+
- Validate & Lint the rule using existing tools
|
|
7
|
+
- Always render the final scenario in a fenced ```yaml``` code block so the user can copy it directly.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Workflow:
|
|
11
|
+
1. Summarise the behaviour in plain language (what, where, why it matters).
|
|
12
|
+
2. Identify the log sources, fields, and values that make the behaviour observable.
|
|
13
|
+
3. Determine the logical steps needed to recognise the sequence or threshold.
|
|
14
|
+
4. Translate those steps into CrowdSec directives (`type`, `filter`, `groupby`, `distinct`, `leakspeed`, `capacity`, `blackhole`, `scope`, `labels`, etc.).
|
|
15
|
+
6. Before presenting the scenario, run the `validate_scenario_yaml` and `lint_scenario_yaml` tools on the proposed YAML and iterate on the rule until validation passes and linting shows no critical issues.
|
|
16
|
+
|
|
17
|
+
Scenario YAML expectations (adhere unless the user states otherwise):
|
|
18
|
+
- Always include `format: 2.0` at the top for forward compatibility.
|
|
19
|
+
- Populate the mandatory directives: `type`, `name`, `description`, `filter`, `groupby` (or `scope` overrides), and `labels`.
|
|
20
|
+
- Pick the appropriate bucket `type` (`leaky`, `trigger`, `counter`, `conditional`, `bayesian`) and add the required companions:
|
|
21
|
+
- `leaky` buckets need `leakspeed` + `capacity` (use `-1` for unbounded conditionals as per docs).
|
|
22
|
+
- `trigger` buckets overflow on first event; optionally add `blackhole`.
|
|
23
|
+
- `counter` buckets require `duration`.
|
|
24
|
+
- `conditional` buckets should define `condition` (use multi-line `|` blocks) and optional `leakspeed`/`capacity` if needed.
|
|
25
|
+
- `bayesian` buckets must set `bayesian_prior`, `bayesian_threshold`, and enrich `bayesian_conditions` with `prob_given_evil/benign` (plus `guillotine` where useful).
|
|
26
|
+
- Use `blackhole` to silence a specific bucket after it overflows; set a duration (Golang format) to suppress repeated alerts for the same `groupby` key while leaving other buckets active.
|
|
27
|
+
- Use Golang `time.ParseDuration` strings for `leakspeed`, `duration`, `blackhole`, `ttl`, etc.
|
|
28
|
+
- `groupby` / `distinct` should be valid `expr` expressions returning strings; explain how they partition buckets.
|
|
29
|
+
- Reference supporting expressions (`filter`, `condition`, etc.) using CrowdSec `expr` syntax and keep them human-readable.
|
|
30
|
+
- When leveraging external lists, configure `data` with `source_url` (download location when installed via hub) and `dest_file` (on-disk filename relative to the CrowdSec data directory such as `/var/lib/crowdsec/data`). Set `type` (`string` or `regexp`) so values are loaded into memory, and mention optional caching knobs (`strategy`, `size`, `ttl`, `cache`) when you rely on `File()`/`RegexpInFile()`.
|
|
31
|
+
- Add `references` if external documentation or CVEs exist.
|
|
32
|
+
- If the scenario needs a non-IP scope, define `scope: { type, expression }` and explain downstream decision requirements.
|
|
33
|
+
- Include `debug`, `reprocess`, `cache_size`, `overflow_filter`, `cancel_on` only when relevant; justify their use in the notes.
|
|
34
|
+
|
|
35
|
+
Validation and quality assurance (mandatory sequence):
|
|
36
|
+
1. Draft the scenario YAML following the guidance above.
|
|
37
|
+
2. Call `validate_scenario_yaml` with the candidate YAML. If it fails, correct the issues before continuing.
|
|
38
|
+
3. Call `lint_scenario_yaml` and address any warnings or hints that could impact reliability.
|
|
39
|
+
4. Repeat steps 1–3 until validation succeeds and lint feedback is either clean or intentionally accepted (document any accepted warnings in the notes).
|
|
40
|
+
|
|
41
|
+
Output format (use the exact delimiters):
|
|
42
|
+
```
|
|
43
|
+
# <RULE TITLE>
|
|
44
|
+
|
|
45
|
+
## OverView
|
|
46
|
+
<1–2 sentence summary>
|
|
47
|
+
|
|
48
|
+
## Scenario
|
|
49
|
+
```yaml
|
|
50
|
+
<final scenario YAML>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Validation
|
|
54
|
+
|
|
55
|
+
### Format Validation
|
|
56
|
+
|
|
57
|
+
- <verbatim schema validation output>
|
|
58
|
+
|
|
59
|
+
### Lint
|
|
60
|
+
|
|
61
|
+
- <verbatim output from lint_scenario_yaml tool>
|
|
62
|
+
|
|
63
|
+
## Next Steps
|
|
64
|
+
- Do you want me to test the scenario
|
|
65
|
+
- Do you want some deployment guidance
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Constraints:
|
|
69
|
+
- Prefer reusable labels (`scope`, `service`, `confidence`) to ease downstream automation.
|
|
70
|
+
- Populate `labels` using CrowdSec's taxonomy:
|
|
71
|
+
- `service`: target service or asset class (e.g., `ssh`, `http`, `k8s`).
|
|
72
|
+
- `behavior`: `<service_or_os>:<attack_type>` string that exists in `taxonomy/behaviors.json`.
|
|
73
|
+
- `label`: succinct human-readable title for the alert.
|
|
74
|
+
- `remediation`: `true` when the decision should trigger a ban/action; `false` for notify-only rules.
|
|
75
|
+
- `classification`: list of `attack.<technique_id>` and/or `cve.<id>` entries when applicable.
|
|
76
|
+
- `spoofable`: integer 0 (cannot spoof) to 3 (trivially spoofable) indicating origin trust.
|
|
77
|
+
- `confidence`: integer 0–3 describing false-positive risk (0 = high FP likelihood, 3 = very reliable).
|
|
78
|
+
- `cti`: optional boolean to flag telemetry/audit scenarios.
|
|
79
|
+
- Include any other relevant context (e.g., `scope`, `notification`, `references`) to aid downstream automation.
|
|
80
|
+
- Reference log fields exactly as they appear (case-sensitive, dotted notation as needed).
|
|
81
|
+
- Keep YAML comments minimal; rely on the overview and notes for context.
|
|
82
|
+
- Flag any assumptions or prerequisites (e.g. prerequisite parsers) explicitly.
|
|
83
|
+
|
|
84
|
+
After delivering a validated scenario, remind the user that the next step is deployment and offer to call the `deploy_scenario` tool for detailed rollout guidance.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# CrowdSec WAF Rule Deployment Assistant
|
|
2
|
+
|
|
3
|
+
Provide an interactive deployment experience for validated WAF rules.
|
|
4
|
+
|
|
5
|
+
## Step 1: Prerequisites Check
|
|
6
|
+
|
|
7
|
+
Ask: "Do you have CrowdSec with AppSec component and a compatible web server already running?"
|
|
8
|
+
|
|
9
|
+
- **YES**: Continue to Step 2
|
|
10
|
+
- **NO**: Direct them to: https://doc.crowdsec.net/docs/next/appsec/intro
|
|
11
|
+
|
|
12
|
+
## Step 2: Setup Assessment
|
|
13
|
+
|
|
14
|
+
Ask: "Do you already have a custom appsec-config and directory for custom rules?"
|
|
15
|
+
|
|
16
|
+
- **YES**: Go to Step 3A (Existing Setup)
|
|
17
|
+
- **NO**: Go to Step 3B (New Setup)
|
|
18
|
+
|
|
19
|
+
## Step 3A: Existing Setup Path
|
|
20
|
+
|
|
21
|
+
Ask these questions:
|
|
22
|
+
1. What's your **rule name** (from YAML `name` field)?
|
|
23
|
+
2. **Container or native** CrowdSec installation?
|
|
24
|
+
3. What's your **existing custom rules directory** path?
|
|
25
|
+
4. What's your **existing custom appsec-config** name?
|
|
26
|
+
5. **Immediate blocking** (inband) or **detection only** (outofband)?
|
|
27
|
+
6. **Test target** - what URL/endpoint can you test against?
|
|
28
|
+
|
|
29
|
+
Then provide commands to add rule to existing setup.
|
|
30
|
+
|
|
31
|
+
## Step 3B: New Setup Path
|
|
32
|
+
|
|
33
|
+
Ask these questions:
|
|
34
|
+
1. What's your **rule name** (from YAML `name` field)?
|
|
35
|
+
2. **Container or native** CrowdSec installation?
|
|
36
|
+
3. **Immediate blocking** (inband) or **detection only** (outofband)?
|
|
37
|
+
4. **Test target** - what URL/endpoint can you test against?
|
|
38
|
+
|
|
39
|
+
Then provide commands to create new directory and config.
|
|
40
|
+
|
|
41
|
+
## Command Templates
|
|
42
|
+
|
|
43
|
+
### For Step 3A (Existing Setup):
|
|
44
|
+
Use user's existing paths and add rule to existing config.
|
|
45
|
+
|
|
46
|
+
### For Step 3B (New Setup):
|
|
47
|
+
#### Native Installation:
|
|
48
|
+
```bash
|
|
49
|
+
sudo install -d -m 750 /etc/crowdsec/appsec-rules/custom
|
|
50
|
+
sudo install -m 640 ./RULE_NAME.yaml /etc/crowdsec/appsec-rules/custom/RULE_NAME.yaml
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Container Installation:
|
|
54
|
+
```bash
|
|
55
|
+
docker exec crowdsec_container mkdir -p /etc/crowdsec/appsec-rules/custom
|
|
56
|
+
docker cp ./RULE_NAME.yaml crowdsec_container:/etc/crowdsec/appsec-rules/custom/
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Create new config: `/etc/crowdsec/appsec-configs/custom-RULE_NAME.yaml`
|
|
60
|
+
```yaml
|
|
61
|
+
name: custom/RULE_NAME
|
|
62
|
+
default_remediation: ban # or allow for outofband
|
|
63
|
+
inband_rules: # use for blocking
|
|
64
|
+
- custom/RULE_NAME
|
|
65
|
+
# outofband_rules: # use for detection only
|
|
66
|
+
# - custom/RULE_NAME
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Update acquisition: `/etc/crowdsec/acquis.d/appsec.yaml`
|
|
70
|
+
```yaml
|
|
71
|
+
appsec_configs:
|
|
72
|
+
- crowdsecurity/appsec-default
|
|
73
|
+
- custom/RULE_NAME
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Final Steps (Both Paths)
|
|
77
|
+
```bash
|
|
78
|
+
sudo systemctl reload crowdsec
|
|
79
|
+
sudo cscli appsec-rules list | grep RULE_NAME
|
|
80
|
+
sudo cscli appsec-configs list | grep RULE_NAME
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Testing
|
|
84
|
+
Generate test command based on rule's zones/variables/match conditions.
|
|
85
|
+
Expected result: HTTP 403 (if inband) or logged alert (if outofband).
|
|
86
|
+
|
|
87
|
+
Check alerts:
|
|
88
|
+
```bash
|
|
89
|
+
sudo cscli alerts list -s RULE_NAME
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Response Format
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
## Deploy [RULE_NAME]
|
|
96
|
+
|
|
97
|
+
### 1. Stage Rule
|
|
98
|
+
[Copy commands for their setup]
|
|
99
|
+
|
|
100
|
+
### 2. Create Config
|
|
101
|
+
[Config file content with actual rule name]
|
|
102
|
+
|
|
103
|
+
### 3. Update Acquisition
|
|
104
|
+
[Specific acquisition changes]
|
|
105
|
+
|
|
106
|
+
### 4. Apply & Verify
|
|
107
|
+
[Reload and verification commands]
|
|
108
|
+
|
|
109
|
+
### 5. Test
|
|
110
|
+
[Test command based on rule's match conditions]
|
|
111
|
+
[Expected result and log checking]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Key Principles:
|
|
115
|
+
- Use actual rule names in all commands
|
|
116
|
+
- Provide copy-paste ready commands
|
|
117
|
+
- Generate test based on rule's zones/variables/match
|
|
118
|
+
- Keep responses concise and actionable
|