crowdsec-local-mcp 0.1.0__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 +22 -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 +150 -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/yaml-schemas/appsec_rules_schema.yaml +343 -0
- crowdsec_local_mcp/yaml-schemas/scenario_schema.yaml +591 -0
- crowdsec_local_mcp-0.1.0.dist-info/METADATA +93 -0
- crowdsec_local_mcp-0.1.0.dist-info/RECORD +30 -0
- crowdsec_local_mcp-0.1.0.dist-info/WHEEL +5 -0
- crowdsec_local_mcp-0.1.0.dist-info/entry_points.txt +2 -0
- crowdsec_local_mcp-0.1.0.dist-info/licenses/LICENSE +21 -0
- crowdsec_local_mcp-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
$schema: "https://json-schema.org/draft-04/schema"
|
|
2
|
+
$id: "http://schemas.crowdsec.net/schemas/scenario.yaml"
|
|
3
|
+
title: "CrowdSec Scenario"
|
|
4
|
+
oneOf:
|
|
5
|
+
- $ref: "#/$defs/leaky"
|
|
6
|
+
- $ref: "#/$defs/counter"
|
|
7
|
+
- $ref: "#/$defs/trigger"
|
|
8
|
+
- $ref: "#/$defs/conditional"
|
|
9
|
+
$defs:
|
|
10
|
+
leaky:
|
|
11
|
+
type: object
|
|
12
|
+
properties:
|
|
13
|
+
type:
|
|
14
|
+
type: string
|
|
15
|
+
enum:
|
|
16
|
+
- leaky
|
|
17
|
+
description: |
|
|
18
|
+
Defines the type of the bucket. Currently three types are
|
|
19
|
+
supported : leaky : a leaky bucket that must be configured
|
|
20
|
+
with a capacity and a leakspeed trigger : a bucket that
|
|
21
|
+
overflows as soon as an event is poured (it is like a leaky
|
|
22
|
+
bucket is a capacity of 0) counter : a bucket that only
|
|
23
|
+
overflows every duration. It is especially useful to count
|
|
24
|
+
things.
|
|
25
|
+
leakspeed:
|
|
26
|
+
type: string
|
|
27
|
+
description: |
|
|
28
|
+
Only applies to leaky buckets. A duration that represent how
|
|
29
|
+
often an event will be leaking from the bucket.
|
|
30
|
+
pattern: >-
|
|
31
|
+
^([0-9]+(\.[0-9]+)*d)?([0-9]+(\.[0-9]+)*h)?([0-9]+(\.[0-9]+)*m)?([0-9]+(\.[0-9]+)*s)?([0-9]+(\.[0-9]+)*ms)?([0-9]+(\.[0-9]+)*(us|µs))?([0-9]+(\.[0-9]+)*ns)?$
|
|
32
|
+
references:
|
|
33
|
+
description: |
|
|
34
|
+
Reference to external paper or documentation
|
|
35
|
+
anyOf:
|
|
36
|
+
- type: string
|
|
37
|
+
- type: array
|
|
38
|
+
name:
|
|
39
|
+
type: string
|
|
40
|
+
description: |
|
|
41
|
+
"github_account_name/my_scenario_name" or name:
|
|
42
|
+
"my_author_name/my_scenario_name" name is mandatory
|
|
43
|
+
capacity:
|
|
44
|
+
type: integer
|
|
45
|
+
description: |
|
|
46
|
+
Only applies to leaky buckets. A positive integer
|
|
47
|
+
representing the bucket capacity. If there are more than
|
|
48
|
+
capacity item in the bucket, it will overflow.
|
|
49
|
+
description:
|
|
50
|
+
type: string
|
|
51
|
+
description: |
|
|
52
|
+
The description is mandatory. It is a short description,
|
|
53
|
+
probably one sentence, describing what it detects.
|
|
54
|
+
filter:
|
|
55
|
+
type: string
|
|
56
|
+
description: |
|
|
57
|
+
filter must be a valid expr expression that will be evaluated
|
|
58
|
+
against the event. If filter evaluation returns true or is
|
|
59
|
+
absent, event will be pour in the bucket. If filter returns
|
|
60
|
+
false or a non-boolean, the event will be skipped for this
|
|
61
|
+
bucket.
|
|
62
|
+
groupby:
|
|
63
|
+
type: string
|
|
64
|
+
description: |
|
|
65
|
+
An expr expression that must return a string. This string will
|
|
66
|
+
be used as a partition for the buckets.
|
|
67
|
+
distinct:
|
|
68
|
+
type: string
|
|
69
|
+
description: |
|
|
70
|
+
An expr expression that must return a string. The event will be
|
|
71
|
+
poured only if the string is not already present in the bucket.
|
|
72
|
+
format:
|
|
73
|
+
description: |
|
|
74
|
+
CrowdSec has a notion of format support for parsers and
|
|
75
|
+
scenarios for compatibility management. Running cscli version
|
|
76
|
+
will show you such compatibility matrix :
|
|
77
|
+
type: number
|
|
78
|
+
minimum: 1.0
|
|
79
|
+
labels:
|
|
80
|
+
$ref: "#/$defs/labels"
|
|
81
|
+
blackhole:
|
|
82
|
+
type: string
|
|
83
|
+
description: |
|
|
84
|
+
A duration for which a bucket will be "silenced" after
|
|
85
|
+
overflowing. This is intended to limit / avoid spam of buckets
|
|
86
|
+
that might be very rapidly triggered. The blackhole only
|
|
87
|
+
applies to the individual bucket rather than the whole
|
|
88
|
+
scenario. Must be compatible with golang ParseDuration format.
|
|
89
|
+
pattern: >-
|
|
90
|
+
^([0-9]+(\.[0-9]+)*d)?([0-9]+(\.[0-9]+)*h)?([0-9]+(\.[0-9]+)*m)?([0-9]+(\.[0-9]+)*s)?([0-9]+(\.[0-9]+)*ms)?([0-9]+(\.[0-9]+)*(us|µs))?([0-9]+(\.[0-9]+)*ns)?$
|
|
91
|
+
debug:
|
|
92
|
+
type: boolean
|
|
93
|
+
description: |
|
|
94
|
+
If set to to true, enabled scenario level debugging. It is meant
|
|
95
|
+
to help understanding scenario behavior by providing contextual
|
|
96
|
+
reprocess:
|
|
97
|
+
type: boolean
|
|
98
|
+
description: |
|
|
99
|
+
If set to true, the resulting overflow will be sent again in the
|
|
100
|
+
scenario/parsing pipeline. It is useful when you want to have
|
|
101
|
+
further scenarios that will rely on past-overflows to take
|
|
102
|
+
decision
|
|
103
|
+
cache_size:
|
|
104
|
+
type: number
|
|
105
|
+
description: |
|
|
106
|
+
By default, a bucket holds capacity events "in memory". However,
|
|
107
|
+
for a number of cases, you don't want this, as it might lead to
|
|
108
|
+
excessive memory consumption. By setting cache_size to a
|
|
109
|
+
positive integer, we can control the maximum in-memory cache
|
|
110
|
+
size of the bucket, without changing its capacity and such. It
|
|
111
|
+
is useful when buckets are likely to stay alive for a long time
|
|
112
|
+
or ingest a lot of events to avoid storing a lot of events in
|
|
113
|
+
memory.
|
|
114
|
+
overflow_filter:
|
|
115
|
+
type: string
|
|
116
|
+
description: |
|
|
117
|
+
overflow_filter is an expression that is run when the bucket
|
|
118
|
+
overflows. If this expression is present and returns false, the
|
|
119
|
+
overflow will be discarded.
|
|
120
|
+
cancel_on:
|
|
121
|
+
type: string
|
|
122
|
+
description: |
|
|
123
|
+
cancel_on is an expression that runs on each event poured to the
|
|
124
|
+
bucket. If the cancel_on expression returns true, the bucket is
|
|
125
|
+
immediately destroyed (and doesn't overflow).
|
|
126
|
+
data:
|
|
127
|
+
$ref: "#/$defs/data"
|
|
128
|
+
scope:
|
|
129
|
+
type: object
|
|
130
|
+
description: |
|
|
131
|
+
While most scenarios might focus on IP addresses, CrowdSec and Bouncers can work with any scope. The scope directive allows you to override the default scope :
|
|
132
|
+
type is a string representing the scope name
|
|
133
|
+
expression is an expr expression that will be evaluated to fetch the value
|
|
134
|
+
properties:
|
|
135
|
+
type:
|
|
136
|
+
type: string
|
|
137
|
+
expression:
|
|
138
|
+
type: string
|
|
139
|
+
additionalProperties: false
|
|
140
|
+
additionalProperties: false
|
|
141
|
+
required:
|
|
142
|
+
- type
|
|
143
|
+
- name
|
|
144
|
+
- leakspeed
|
|
145
|
+
- description
|
|
146
|
+
counter:
|
|
147
|
+
type: object
|
|
148
|
+
properties:
|
|
149
|
+
type:
|
|
150
|
+
type: string
|
|
151
|
+
enum:
|
|
152
|
+
- counter
|
|
153
|
+
description: |
|
|
154
|
+
Defines the type of the bucket. Currently three types are
|
|
155
|
+
supported : leaky : a leaky bucket that must be configured
|
|
156
|
+
with a capacity and a leakspeed trigger : a bucket that
|
|
157
|
+
overflows as soon as an event is poured (it is like a leaky
|
|
158
|
+
bucket is a capacity of 0) counter : a bucket that only
|
|
159
|
+
overflows every duration. It is especially useful to count
|
|
160
|
+
things.
|
|
161
|
+
duration:
|
|
162
|
+
type: string
|
|
163
|
+
description: |
|
|
164
|
+
Only applies to leaky buckets.
|
|
165
|
+
A duration that represent how often an event will be leaking from the bucket.
|
|
166
|
+
pattern: >-
|
|
167
|
+
^([0-9]+(\.[0-9]+)*d)?([0-9]+(\.[0-9]+)*h)?([0-9]+(\.[0-9]+)*m)?([0-9]+(\.[0-9]+)*s)?([0-9]+(\.[0-9]+)*ms)?([0-9]+(\.[0-9]+)*(us|µs))?([0-9]+(\.[0-9]+)*ns)?$
|
|
168
|
+
references:
|
|
169
|
+
description: |
|
|
170
|
+
Reference to external paper or documentation
|
|
171
|
+
anyOf:
|
|
172
|
+
- type: string
|
|
173
|
+
- type: array
|
|
174
|
+
name:
|
|
175
|
+
type: string
|
|
176
|
+
description: |
|
|
177
|
+
"github_account_name/my_scenario_name" or name:
|
|
178
|
+
"my_author_name/my_scenario_name" name is mandatory
|
|
179
|
+
description:
|
|
180
|
+
type: string
|
|
181
|
+
description: |
|
|
182
|
+
The description is mandatory. It is a short description,
|
|
183
|
+
probably one sentence, describing what it detects.
|
|
184
|
+
filter:
|
|
185
|
+
type: string
|
|
186
|
+
description: |
|
|
187
|
+
filter must be a valid expr expression that will be evaluated
|
|
188
|
+
against the event. If filter evaluation returns true or is
|
|
189
|
+
absent, event will be pour in the bucket. If filter returns
|
|
190
|
+
false or a non-boolean, the event will be skipped for this
|
|
191
|
+
bucket.
|
|
192
|
+
groupby:
|
|
193
|
+
type: string
|
|
194
|
+
description: |
|
|
195
|
+
An expr expression that must return a string. This string will
|
|
196
|
+
be used as a partition for the buckets.
|
|
197
|
+
distinct:
|
|
198
|
+
type: string
|
|
199
|
+
description: |
|
|
200
|
+
An expr expression that must return a string. The event will be
|
|
201
|
+
poured only if the string is not already present in the bucket.
|
|
202
|
+
format:
|
|
203
|
+
description: |
|
|
204
|
+
CrowdSec has a notion of format support for parsers and
|
|
205
|
+
scenarios for compatibility management. Running cscli version
|
|
206
|
+
will show you such compatibility matrix :
|
|
207
|
+
type: number
|
|
208
|
+
minimum: 1.0
|
|
209
|
+
labels:
|
|
210
|
+
$ref: "#/$defs/labels"
|
|
211
|
+
blackhole:
|
|
212
|
+
type: string
|
|
213
|
+
description: |
|
|
214
|
+
A duration for which a bucket will be "silenced" after
|
|
215
|
+
overflowing. This is intended to limit / avoid spam of buckets
|
|
216
|
+
that might be very rapidly triggered. The blackhole only
|
|
217
|
+
applies to the individual bucket rather than the whole
|
|
218
|
+
scenario. Must be compatible with golang ParseDuration format.
|
|
219
|
+
pattern: >-
|
|
220
|
+
^([0-9]+(\.[0-9]+)*d)?([0-9]+(\.[0-9]+)*h)?([0-9]+(\.[0-9]+)*m)?([0-9]+(\.[0-9]+)*s)?([0-9]+(\.[0-9]+)*ms)?([0-9]+(\.[0-9]+)*(us|µs))?([0-9]+(\.[0-9]+)*ns)?$
|
|
221
|
+
debug:
|
|
222
|
+
type: boolean
|
|
223
|
+
description: |
|
|
224
|
+
If set to to true, enabled scenario level debugging. It is meant
|
|
225
|
+
to help understanding scenario behavior by providing contextual
|
|
226
|
+
reprocess:
|
|
227
|
+
type: boolean
|
|
228
|
+
description: |
|
|
229
|
+
If set to true, the resulting overflow will be sent again in the
|
|
230
|
+
scenario/parsing pipeline. It is useful when you want to have
|
|
231
|
+
further scenarios that will rely on past-overflows to take
|
|
232
|
+
decision
|
|
233
|
+
cache_size:
|
|
234
|
+
type: number
|
|
235
|
+
description: |
|
|
236
|
+
By default, a bucket holds capacity events "in memory". However,
|
|
237
|
+
for a number of cases, you don't want this, as it might lead to
|
|
238
|
+
excessive memory consumption. By setting cache_size to a
|
|
239
|
+
positive integer, we can control the maximum in-memory cache
|
|
240
|
+
size of the bucket, without changing its capacity and such. It
|
|
241
|
+
is useful when buckets are likely to stay alive for a long time
|
|
242
|
+
or ingest a lot of events to avoid storing a lot of events in
|
|
243
|
+
memory.
|
|
244
|
+
overflow_filter:
|
|
245
|
+
type: string
|
|
246
|
+
description: |
|
|
247
|
+
overflow_filter is an expression that is run when the bucket
|
|
248
|
+
overflows. If this expression is present and returns false, the
|
|
249
|
+
overflow will be discarded.
|
|
250
|
+
cancel_on:
|
|
251
|
+
type: string
|
|
252
|
+
description: |
|
|
253
|
+
cancel_on is an expression that runs on each event poured to the
|
|
254
|
+
bucket. If the cancel_on expression returns true, the bucket is
|
|
255
|
+
immediately destroyed (and doesn't overflow).
|
|
256
|
+
data:
|
|
257
|
+
$ref: "#/$defs/data"
|
|
258
|
+
scope:
|
|
259
|
+
type: object
|
|
260
|
+
description: |
|
|
261
|
+
While most scenarios might focus on IP addresses, CrowdSec and Bouncers can work with any scope. The scope directive allows you to override the default scope :
|
|
262
|
+
type is a string representing the scope name
|
|
263
|
+
expression is an expr expression that will be evaluated to fetch the value
|
|
264
|
+
properties:
|
|
265
|
+
type:
|
|
266
|
+
type: string
|
|
267
|
+
expression:
|
|
268
|
+
type: string
|
|
269
|
+
additionalProperties: false
|
|
270
|
+
additionalProperties: false
|
|
271
|
+
required:
|
|
272
|
+
- type
|
|
273
|
+
- name
|
|
274
|
+
- duration
|
|
275
|
+
- description
|
|
276
|
+
trigger:
|
|
277
|
+
type: object
|
|
278
|
+
properties:
|
|
279
|
+
type:
|
|
280
|
+
type: string
|
|
281
|
+
enum:
|
|
282
|
+
- trigger
|
|
283
|
+
description: |
|
|
284
|
+
Defines the type of the bucket. Currently three types are
|
|
285
|
+
supported : leaky : a leaky bucket that must be configured
|
|
286
|
+
with a capacity and a leakspeed trigger : a bucket that
|
|
287
|
+
overflows as soon as an event is poured (it is like a leaky
|
|
288
|
+
bucket is a capacity of 0) counter : a bucket that only
|
|
289
|
+
overflows every duration. It is especially useful to count
|
|
290
|
+
things.
|
|
291
|
+
name:
|
|
292
|
+
type: string
|
|
293
|
+
description: |
|
|
294
|
+
"github_account_name/my_scenario_name" or name:
|
|
295
|
+
"my_author_name/my_scenario_name" name is mandatory
|
|
296
|
+
references:
|
|
297
|
+
description: |
|
|
298
|
+
Reference to external paper or documentation
|
|
299
|
+
anyOf:
|
|
300
|
+
- type: string
|
|
301
|
+
- type: array
|
|
302
|
+
description:
|
|
303
|
+
type: string
|
|
304
|
+
description: |
|
|
305
|
+
The description is mandatory. It is a short description,
|
|
306
|
+
probably one sentence, describing what it detects.
|
|
307
|
+
filter:
|
|
308
|
+
type: string
|
|
309
|
+
description: |
|
|
310
|
+
filter must be a valid expr expression that will be evaluated
|
|
311
|
+
against the event. If filter evaluation returns true or is
|
|
312
|
+
absent, event will be pour in the bucket. If filter returns
|
|
313
|
+
false or a non-boolean, the event will be skipped for this
|
|
314
|
+
bucket.
|
|
315
|
+
groupby:
|
|
316
|
+
type: string
|
|
317
|
+
description: |
|
|
318
|
+
An expr expression that must return a string. This string will
|
|
319
|
+
be used as a partition for the buckets.
|
|
320
|
+
distinct:
|
|
321
|
+
type: string
|
|
322
|
+
description: |
|
|
323
|
+
An expr expression that must return a string. The event will be
|
|
324
|
+
poured only if the string is not already present in the bucket.
|
|
325
|
+
format:
|
|
326
|
+
description: |
|
|
327
|
+
CrowdSec has a notion of format support for parsers and
|
|
328
|
+
scenarios for compatibility management. Running cscli version
|
|
329
|
+
will show you such compatibility matrix :
|
|
330
|
+
type: number
|
|
331
|
+
minimum: 1.0
|
|
332
|
+
labels:
|
|
333
|
+
$ref: "#/$defs/labels"
|
|
334
|
+
blackhole:
|
|
335
|
+
type: string
|
|
336
|
+
description: |
|
|
337
|
+
A duration for which a bucket will be "silenced" after
|
|
338
|
+
overflowing. This is intended to limit / avoid spam of buckets
|
|
339
|
+
that might be very rapidly triggered. The blackhole only
|
|
340
|
+
applies to the individual bucket rather than the whole
|
|
341
|
+
scenario. Must be compatible with golang ParseDuration format.
|
|
342
|
+
pattern: >-
|
|
343
|
+
^([0-9]+(\.[0-9]+)*d)?([0-9]+(\.[0-9]+)*h)?([0-9]+(\.[0-9]+)*m)?([0-9]+(\.[0-9]+)*s)?([0-9]+(\.[0-9]+)*ms)?([0-9]+(\.[0-9]+)*(us|µs))?([0-9]+(\.[0-9]+)*ns)?$
|
|
344
|
+
debug:
|
|
345
|
+
type: boolean
|
|
346
|
+
description: |
|
|
347
|
+
If set to to true, enabled scenario level debugging. It is meant
|
|
348
|
+
to help understanding scenario behavior by providing contextual
|
|
349
|
+
reprocess:
|
|
350
|
+
type: boolean
|
|
351
|
+
description: |
|
|
352
|
+
If set to true, the resulting overflow will be sent again in the
|
|
353
|
+
scenario/parsing pipeline. It is useful when you want to have
|
|
354
|
+
further scenarios that will rely on past-overflows to take
|
|
355
|
+
decision
|
|
356
|
+
cache_size:
|
|
357
|
+
type: number
|
|
358
|
+
description: |
|
|
359
|
+
By default, a bucket holds capacity events "in memory". However,
|
|
360
|
+
for a number of cases, you don't want this, as it might lead to
|
|
361
|
+
excessive memory consumption. By setting cache_size to a
|
|
362
|
+
positive integer, we can control the maximum in-memory cache
|
|
363
|
+
size of the bucket, without changing its capacity and such. It
|
|
364
|
+
is useful when buckets are likely to stay alive for a long time
|
|
365
|
+
or ingest a lot of events to avoid storing a lot of events in
|
|
366
|
+
memory.
|
|
367
|
+
overflow_filter:
|
|
368
|
+
type: string
|
|
369
|
+
description: |
|
|
370
|
+
overflow_filter is an expression that is run when the bucket
|
|
371
|
+
overflows. If this expression is present and returns false, the
|
|
372
|
+
overflow will be discarded.
|
|
373
|
+
cancel_on:
|
|
374
|
+
type: string
|
|
375
|
+
description: |
|
|
376
|
+
cancel_on is an expression that runs on each event poured to the
|
|
377
|
+
bucket. If the cancel_on expression returns true, the bucket is
|
|
378
|
+
immediately destroyed (and doesn't overflow).
|
|
379
|
+
data:
|
|
380
|
+
$ref: "#/$defs/data"
|
|
381
|
+
scope:
|
|
382
|
+
type: object
|
|
383
|
+
description: |
|
|
384
|
+
While most scenarios might focus on IP addresses, CrowdSec
|
|
385
|
+
and Bouncers can work with any scope. The scope directive
|
|
386
|
+
allows you to override the default scope : type is a string
|
|
387
|
+
representing the scope name expression is an expr expression
|
|
388
|
+
that will be evaluated to fetch the value
|
|
389
|
+
properties:
|
|
390
|
+
type:
|
|
391
|
+
type: string
|
|
392
|
+
expression:
|
|
393
|
+
type: string
|
|
394
|
+
additionalProperties: false
|
|
395
|
+
additionalProperties: false
|
|
396
|
+
required:
|
|
397
|
+
- type
|
|
398
|
+
- name
|
|
399
|
+
- description
|
|
400
|
+
labels:
|
|
401
|
+
type: object
|
|
402
|
+
description: |
|
|
403
|
+
Labels is a list of label: values that provide context to an
|
|
404
|
+
overflow. The labels are (currently) not stored in the database,
|
|
405
|
+
nor they are sent to the API. Special labels : The remediation
|
|
406
|
+
label, if set to true indicate the the originating IP should be
|
|
407
|
+
banned.
|
|
408
|
+
patternProperties:
|
|
409
|
+
"^.*$":
|
|
410
|
+
type:
|
|
411
|
+
- string
|
|
412
|
+
- boolean
|
|
413
|
+
- array
|
|
414
|
+
- integer
|
|
415
|
+
conditional:
|
|
416
|
+
type: object
|
|
417
|
+
properties:
|
|
418
|
+
type:
|
|
419
|
+
type: string
|
|
420
|
+
enum:
|
|
421
|
+
- conditional
|
|
422
|
+
description: |
|
|
423
|
+
Defines the type of the bucket. Currently three types are
|
|
424
|
+
supported : leaky : a leaky bucket that must be configured
|
|
425
|
+
with a capacity and a leakspeed trigger : a bucket that
|
|
426
|
+
overflows as soon as an event is poured (it is like a leaky
|
|
427
|
+
bucket is a capacity of 0) counter : a bucket that only
|
|
428
|
+
overflows every duration. It is especially useful to count
|
|
429
|
+
things.
|
|
430
|
+
condition:
|
|
431
|
+
type: string
|
|
432
|
+
description: |
|
|
433
|
+
Make the bucket overflow when it returns true. The expression is evaluated each time an event is poured to the bucket.
|
|
434
|
+
leakspeed:
|
|
435
|
+
type: string
|
|
436
|
+
description: |
|
|
437
|
+
Only applies to leaky buckets. A duration that represent how
|
|
438
|
+
often an event will be leaking from the bucket.
|
|
439
|
+
pattern: >-
|
|
440
|
+
^([0-9]+(\.[0-9]+)*d)?([0-9]+(\.[0-9]+)*h)?([0-9]+(\.[0-9]+)*m)?([0-9]+(\.[0-9]+)*s)?([0-9]+(\.[0-9]+)*ms)?([0-9]+(\.[0-9]+)*(us|µs))?([0-9]+(\.[0-9]+)*ns)?$
|
|
441
|
+
references:
|
|
442
|
+
description: |
|
|
443
|
+
Reference to external paper or documentation
|
|
444
|
+
anyOf:
|
|
445
|
+
- type: string
|
|
446
|
+
- type: array
|
|
447
|
+
name:
|
|
448
|
+
type: string
|
|
449
|
+
description: |
|
|
450
|
+
"github_account_name/my_scenario_name" or name:
|
|
451
|
+
"my_author_name/my_scenario_name" name is mandatory
|
|
452
|
+
capacity:
|
|
453
|
+
type: integer
|
|
454
|
+
description: |
|
|
455
|
+
Only applies to leaky buckets. A positive integer
|
|
456
|
+
representing the bucket capacity. If there are more than
|
|
457
|
+
capacity item in the bucket, it will overflow.
|
|
458
|
+
description:
|
|
459
|
+
type: string
|
|
460
|
+
description: |
|
|
461
|
+
The description is mandatory. It is a short description,
|
|
462
|
+
probably one sentence, describing what it detects.
|
|
463
|
+
filter:
|
|
464
|
+
type: string
|
|
465
|
+
description: |
|
|
466
|
+
filter must be a valid expr expression that will be evaluated
|
|
467
|
+
against the event. If filter evaluation returns true or is
|
|
468
|
+
absent, event will be pour in the bucket. If filter returns
|
|
469
|
+
false or a non-boolean, the event will be skipped for this
|
|
470
|
+
bucket.
|
|
471
|
+
groupby:
|
|
472
|
+
type: string
|
|
473
|
+
description: |
|
|
474
|
+
An expr expression that must return a string. This string will
|
|
475
|
+
be used as a partition for the buckets.
|
|
476
|
+
distinct:
|
|
477
|
+
type: string
|
|
478
|
+
description: |
|
|
479
|
+
An expr expression that must return a string. The event will be
|
|
480
|
+
poured only if the string is not already present in the bucket.
|
|
481
|
+
format:
|
|
482
|
+
description: |
|
|
483
|
+
CrowdSec has a notion of format support for parsers and
|
|
484
|
+
scenarios for compatibility management. Running cscli version
|
|
485
|
+
will show you such compatibility matrix :
|
|
486
|
+
type: number
|
|
487
|
+
minimum: 1.0
|
|
488
|
+
labels:
|
|
489
|
+
$ref: "#/$defs/labels"
|
|
490
|
+
blackhole:
|
|
491
|
+
type: string
|
|
492
|
+
description: |
|
|
493
|
+
A duration for which a bucket will be "silenced" after
|
|
494
|
+
overflowing. This is intended to limit / avoid spam of buckets
|
|
495
|
+
that might be very rapidly triggered. The blackhole only
|
|
496
|
+
applies to the individual bucket rather than the whole
|
|
497
|
+
scenario. Must be compatible with golang ParseDuration format.
|
|
498
|
+
pattern: >-
|
|
499
|
+
^([0-9]+(\.[0-9]+)*d)?([0-9]+(\.[0-9]+)*h)?([0-9]+(\.[0-9]+)*m)?([0-9]+(\.[0-9]+)*s)?([0-9]+(\.[0-9]+)*ms)?([0-9]+(\.[0-9]+)*(us|µs))?([0-9]+(\.[0-9]+)*ns)?$
|
|
500
|
+
debug:
|
|
501
|
+
type: boolean
|
|
502
|
+
description: |
|
|
503
|
+
If set to to true, enabled scenario level debugging. It is meant
|
|
504
|
+
to help understanding scenario behavior by providing contextual
|
|
505
|
+
reprocess:
|
|
506
|
+
type: boolean
|
|
507
|
+
description: |
|
|
508
|
+
If set to true, the resulting overflow will be sent again in the
|
|
509
|
+
scenario/parsing pipeline. It is useful when you want to have
|
|
510
|
+
further scenarios that will rely on past-overflows to take
|
|
511
|
+
decision
|
|
512
|
+
cache_size:
|
|
513
|
+
type: number
|
|
514
|
+
description: |
|
|
515
|
+
By default, a bucket holds capacity events "in memory". However,
|
|
516
|
+
for a number of cases, you don't want this, as it might lead to
|
|
517
|
+
excessive memory consumption. By setting cache_size to a
|
|
518
|
+
positive integer, we can control the maximum in-memory cache
|
|
519
|
+
size of the bucket, without changing its capacity and such. It
|
|
520
|
+
is useful when buckets are likely to stay alive for a long time
|
|
521
|
+
or ingest a lot of events to avoid storing a lot of events in
|
|
522
|
+
memory.
|
|
523
|
+
overflow_filter:
|
|
524
|
+
type: string
|
|
525
|
+
description: |
|
|
526
|
+
overflow_filter is an expression that is run when the bucket
|
|
527
|
+
overflows. If this expression is present and returns false, the
|
|
528
|
+
overflow will be discarded.
|
|
529
|
+
cancel_on:
|
|
530
|
+
type: string
|
|
531
|
+
description: |
|
|
532
|
+
cancel_on is an expression that runs on each event poured to the
|
|
533
|
+
bucket. If the cancel_on expression returns true, the bucket is
|
|
534
|
+
immediately destroyed (and doesn't overflow).
|
|
535
|
+
data:
|
|
536
|
+
$ref: "#/$defs/data"
|
|
537
|
+
scope:
|
|
538
|
+
type: object
|
|
539
|
+
description: |
|
|
540
|
+
While most scenarios might focus on IP addresses, CrowdSec and Bouncers can work with any scope. The scope directive allows you to override the default scope :
|
|
541
|
+
type is a string representing the scope name
|
|
542
|
+
expression is an expr expression that will be evaluated to fetch the value
|
|
543
|
+
properties:
|
|
544
|
+
type:
|
|
545
|
+
type: string
|
|
546
|
+
expression:
|
|
547
|
+
type: string
|
|
548
|
+
additionalProperties: false
|
|
549
|
+
additionalProperties: false
|
|
550
|
+
required:
|
|
551
|
+
- type
|
|
552
|
+
- name
|
|
553
|
+
- leakspeed
|
|
554
|
+
- description
|
|
555
|
+
- condition
|
|
556
|
+
data:
|
|
557
|
+
type: array
|
|
558
|
+
description: |
|
|
559
|
+
data allows user to specify an external source of data. This
|
|
560
|
+
section is only relevant when cscli is used to install parser
|
|
561
|
+
from hub, as it will download the source_url and store it to
|
|
562
|
+
dest_file. When the parser is not installed from the hub,
|
|
563
|
+
CrowdSec won't download the URL, but the file must exist for the
|
|
564
|
+
parser to be loaded correctly.
|
|
565
|
+
items:
|
|
566
|
+
type: object
|
|
567
|
+
properties:
|
|
568
|
+
source_url:
|
|
569
|
+
type: string
|
|
570
|
+
description: |
|
|
571
|
+
url to download file from
|
|
572
|
+
dest_file:
|
|
573
|
+
type: string
|
|
574
|
+
description: |
|
|
575
|
+
destination to store the downloaded file to
|
|
576
|
+
type:
|
|
577
|
+
type: string
|
|
578
|
+
pattern: "^(string|regexp)$"
|
|
579
|
+
additionalProperties: false
|
|
580
|
+
description: |
|
|
581
|
+
The type is mandatory if you want to evaluate the data in
|
|
582
|
+
the file, and should be regex for valid (re2) regular
|
|
583
|
+
expression per line or string for string per line. The
|
|
584
|
+
regexps will be compiled, the strings will be loaded into
|
|
585
|
+
a list and both will be kept in memory. Without specifying
|
|
586
|
+
a type, the file will be downloaded and stored as file and
|
|
587
|
+
not in memory.
|
|
588
|
+
required:
|
|
589
|
+
- type
|
|
590
|
+
- dest_file
|
|
591
|
+
additionalProperties: false
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crowdsec-local-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An MCP exposing prompts and tools to help users write WAF rules, scenarios etc.
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: jsonschema>=4.25.1
|
|
9
|
+
Requires-Dist: mcp>=1.15.0
|
|
10
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
11
|
+
Requires-Dist: requests>=2.32.5
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<img src="https://github.com/crowdsecurity/crowdsec-docs/blob/main/crowdsec-docs/static/img/crowdsec_logo.png" alt="CrowdSec" title="CrowdSec" width="400" height="260"/>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
**Life is too short to write YAML, just ask nicely!**
|
|
20
|
+
|
|
21
|
+
> A Model Context Protocol (MCP) server to generate, validate, and deploy CrowdSec WAF rules & Scenarios.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
### WAF Rules Features
|
|
27
|
+
|
|
28
|
+
- **WAF Rule Generation**: Generate CrowdSec WAF rules from user input or a CVE reference
|
|
29
|
+
- **Validation**: Validate syntaxical correctness of WAF rules
|
|
30
|
+
- **Linting**: Get warnings and hints to improve your WAF rules
|
|
31
|
+
- **Deployment Guide**: Step-by-step deployment instructions
|
|
32
|
+
- **Docker Test Harness**: Spin up CrowdSec + nginx + bouncer to exercise rules for false positives/negatives
|
|
33
|
+
- **Nuclei Lookup**: Quickly jump to existing templates in the official `projectdiscovery/nuclei-templates` repository for a given CVE
|
|
34
|
+
|
|
35
|
+
### Scenarios Features
|
|
36
|
+
|
|
37
|
+
- **CrowdSec Scenarios Generation**: Generate CrowdSec scenarios
|
|
38
|
+
- **Validation**: Validate syntaxical correctness of scenarios
|
|
39
|
+
- **Linting**: Get warnings and hints to improve your scenarios
|
|
40
|
+
- **Deployment Guide**: Step-by-step deployment instructions
|
|
41
|
+
- **Docker Test Harness**: Spin up CrowdSec to test scenario behavior
|
|
42
|
+
|
|
43
|
+
## Demo
|
|
44
|
+
|
|
45
|
+
### WAF Rules Creation and testing
|
|
46
|
+
|
|
47
|
+
- [Rule creation from natural language with Claude Desktop](https://claude.ai/share/f0f246b2-6b20-4d70-a16c-c6b627ab2d80)
|
|
48
|
+
- [Rule creation from CVE reference](https://claude.ai/share/b6599407-82dd-443c-a12d-9a9825ed99df)
|
|
49
|
+
|
|
50
|
+
### Scenario Creation and testing
|
|
51
|
+
|
|
52
|
+
- XX
|
|
53
|
+
- XX
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
### Setup
|
|
58
|
+
|
|
59
|
+
Install dependencies using `uv`:
|
|
60
|
+
```bash
|
|
61
|
+
uv sync
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Configuration for Claude Desktop
|
|
65
|
+
|
|
66
|
+
### macOS/Linux
|
|
67
|
+
|
|
68
|
+
1. Find your Claude Desktop config file:
|
|
69
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
70
|
+
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
71
|
+
|
|
72
|
+
2. Add the MCP server configuration:
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"crowdsec-prompt-server": {
|
|
77
|
+
"command": "/path/to/crowdsec-mcp-rule-helper/.venv/bin/python",
|
|
78
|
+
"args": [
|
|
79
|
+
"/path/to/crowdsec-mcp-rule-helper/mcp-prompt.py"
|
|
80
|
+
],
|
|
81
|
+
"cwd": "/path/to/crowdsec-mcp-rule-helper"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Important**: Replace `/path/to/crowdsec-mcp-rule-helper` with the actual absolute path to your cloned repository.
|
|
88
|
+
|
|
89
|
+
## Pre Requisites
|
|
90
|
+
|
|
91
|
+
- Docker + Docker Compose
|
|
92
|
+
|
|
93
|
+
- Python
|