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.
Files changed (31) hide show
  1. crowdsec_local_mcp/__init__.py +5 -0
  2. crowdsec_local_mcp/__main__.py +24 -0
  3. crowdsec_local_mcp/compose/waf-test/.gitignore +3 -0
  4. crowdsec_local_mcp/compose/waf-test/crowdsec/acquis.d/appsec.yaml +8 -0
  5. crowdsec_local_mcp/compose/waf-test/crowdsec/appsec-configs/mcp-appsec.yaml.template +8 -0
  6. crowdsec_local_mcp/compose/waf-test/crowdsec/init-bouncer.sh +29 -0
  7. crowdsec_local_mcp/compose/waf-test/docker-compose.yml +68 -0
  8. crowdsec_local_mcp/compose/waf-test/nginx/Dockerfile +67 -0
  9. crowdsec_local_mcp/compose/waf-test/nginx/crowdsec/crowdsec-openresty-bouncer.conf +25 -0
  10. crowdsec_local_mcp/compose/waf-test/nginx/nginx.conf +25 -0
  11. crowdsec_local_mcp/compose/waf-test/nginx/site-enabled/default-site.conf +15 -0
  12. crowdsec_local_mcp/compose/waf-test/rules/.gitkeep +0 -0
  13. crowdsec_local_mcp/compose/waf-test/rules/base-config.yaml +11 -0
  14. crowdsec_local_mcp/mcp_core.py +151 -0
  15. crowdsec_local_mcp/mcp_scenarios.py +380 -0
  16. crowdsec_local_mcp/mcp_waf.py +1170 -0
  17. crowdsec_local_mcp/prompts/prompt-scenario-deploy.txt +27 -0
  18. crowdsec_local_mcp/prompts/prompt-scenario-examples.txt +237 -0
  19. crowdsec_local_mcp/prompts/prompt-scenario.txt +84 -0
  20. crowdsec_local_mcp/prompts/prompt-waf-deploy.txt +118 -0
  21. crowdsec_local_mcp/prompts/prompt-waf-examples.txt +401 -0
  22. crowdsec_local_mcp/prompts/prompt-waf.txt +343 -0
  23. crowdsec_local_mcp/setup_cli.py +306 -0
  24. crowdsec_local_mcp/yaml-schemas/appsec_rules_schema.yaml +343 -0
  25. crowdsec_local_mcp/yaml-schemas/scenario_schema.yaml +591 -0
  26. crowdsec_local_mcp-0.0.2.dist-info/METADATA +74 -0
  27. crowdsec_local_mcp-0.0.2.dist-info/RECORD +31 -0
  28. crowdsec_local_mcp-0.0.2.dist-info/WHEEL +5 -0
  29. crowdsec_local_mcp-0.0.2.dist-info/entry_points.txt +3 -0
  30. crowdsec_local_mcp-0.0.2.dist-info/licenses/LICENSE +21 -0
  31. crowdsec_local_mcp-0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,343 @@
1
+ $schema: "https://json-schema.org/draft-04/schema"
2
+ $id: "http://schemas.crowdsec.net/schemas/appsec-rule.yaml"
3
+ title: "CrowdSec AppSec Rule"
4
+
5
+ # Top-level definition for a CrowdSec AppSec rule.
6
+ #
7
+ # This schema is derived from the official CrowdSec AppSec rule
8
+ # specification. It describes the structure of an application
9
+ # security rule used by the CrowdSec WAF. A rule defines a
10
+ # human‑readable `name` and `description`, one or more `rules`
11
+ # describing matching conditions, and optional `labels`. For
12
+ # compatibility with ModSecurity/Seclang rules, `seclang_rules`
13
+ # and `seclang_files_rules` may also be provided.
14
+ type: object
15
+ additionalProperties: false
16
+ properties:
17
+ name:
18
+ type: string
19
+ description: |
20
+ Unique identifier for the AppSec rule. Names follow the
21
+ `author/name` convention (e.g. `crowdsecurity/vpatch-CVE-2024-0001`).
22
+ description:
23
+ type: string
24
+ description: |
25
+ Free‑form description of what the rule detects. This text
26
+ appears in the Hub and the CrowdSec console.
27
+ format:
28
+ type: number
29
+ description: |
30
+ Optional format version. If specified, it MUST be a
31
+ positive number. This allows CrowdSec to ensure that the
32
+ running version understands all features used by the rule.
33
+ minimum: 1.0
34
+ rules:
35
+ type: array
36
+ description: |
37
+ A non‑empty list of conditions and/or logical groups that
38
+ define when the rule is triggered. Each item in the list
39
+ can either be a leaf (matching a specific request part) or a
40
+ composite rule using `and` or `or` to combine other
41
+ conditions. When multiple top‑level items are present they
42
+ are evaluated in order and each matching item will trigger
43
+ the rule independently.
44
+ minItems: 1
45
+ items:
46
+ $ref: "#/$defs/ruleItem"
47
+ labels:
48
+ $ref: "#/$defs/labels"
49
+ seclang_rules:
50
+ type: array
51
+ description: |
52
+ Inline ModSecurity/Seclang rules to be loaded by the AppSec
53
+ engine. These are interpreted by the Coraza runtime.
54
+ items:
55
+ type: string
56
+ seclang_files_rules:
57
+ type: array
58
+ description: |
59
+ A list of file names containing ModSecurity/Seclang rules. The
60
+ referenced files must live in the CrowdSec data directory
61
+ (e.g. `/var/lib/crowdsec/data`). Each entry SHOULD be a
62
+ relative file name without path traversal.
63
+ items:
64
+ type: string
65
+ data:
66
+ type: array
67
+ description: |
68
+ External data files required by the rule. When installing a rule from
69
+ the hub, `cscli` will fetch each `source_url` and store it at
70
+ `dest_file`. The optional `type` controls how the contents are
71
+ parsed in memory.
72
+ items:
73
+ type: object
74
+ additionalProperties: false
75
+ properties:
76
+ source_url:
77
+ type: string
78
+ format: uri
79
+ description: |
80
+ URL where the data file can be downloaded.
81
+ dest_file:
82
+ type: string
83
+ description: |
84
+ Local filename (within the CrowdSec data directory) where the
85
+ downloaded file will be stored.
86
+ type:
87
+ type: string
88
+ description: |
89
+ How to interpret the downloaded file. `modsec` denotes a
90
+ ModSecurity rules file. `regex` means the file contains one
91
+ RE2 regular expression per line, while `string` means one
92
+ literal string per line.
93
+ enum:
94
+ - modsec
95
+ - regex
96
+ - string
97
+ required:
98
+ - source_url
99
+ - dest_file
100
+ required:
101
+ - name
102
+ anyOf:
103
+ - required: ["rules"]
104
+ - required: ["seclang_rules"]
105
+ - required: ["seclang_files_rules"]
106
+ $defs:
107
+ labels:
108
+ type: object
109
+ description: |
110
+ A map of labels applied to the rule. Labels are free‑form
111
+ key/value pairs used by the Hub and console to categorise
112
+ rules. The following keys are commonly used:
113
+
114
+ * `type` — high level category (e.g. `exploit`)
115
+ * `service` — service targeted by the rule (e.g. `http`)
116
+ * `behavior` — behaviour tag used by the remediation engine (e.g. `http:exploit`)
117
+ * `confidence` — integer from 1 to 5 describing how confident we are in the detection
118
+ * `spoofable` — integer (`0` or `1`) indicating if the detection can be spoofed
119
+ * `label` — human readable summary of the rule
120
+ * `classification` — list of reference identifiers (e.g. CVE or ATT&CK IDs)
121
+
122
+ Additional keys MAY be present and MUST have string, number or
123
+ boolean values. The schema only constrains known keys and
124
+ leaves room for extensibility.
125
+ additionalProperties:
126
+ anyOf:
127
+ - type: string
128
+ - type: number
129
+ - type: boolean
130
+ - type: array
131
+ items:
132
+ type: string
133
+
134
+ properties:
135
+ type:
136
+ type: string
137
+ service:
138
+ type: string
139
+ behavior:
140
+ type: string
141
+ confidence:
142
+ type: integer
143
+ minimum: 0
144
+ spoofable:
145
+ type: integer
146
+ minimum: 0
147
+ label:
148
+ type: string
149
+ classification:
150
+ type: array
151
+ items:
152
+ type: string
153
+ description: "MITRE/ATT&CK-like tags."
154
+ references:
155
+ description: |
156
+ A reference to external resources, such as CVE identifiers, blog posts
157
+ or other documentation. The value can be either a single string or
158
+ an array of strings.
159
+ anyOf:
160
+ - type: string
161
+ - type: array
162
+ items:
163
+ type: string
164
+ additionalProperties:
165
+ type: string
166
+ required:
167
+ - type
168
+ - service
169
+ - behavior
170
+ - confidence
171
+ - spoofable
172
+ - classification
173
+
174
+ # A ruleItem can either be a leaf rule (matching on request
175
+ # content) or a composite rule that groups other ruleItems with a
176
+ # logical operator. Note: unlike the original schema, this version
177
+ # omits `additionalProperties: false` at this level. Without it,
178
+ # the validator will correctly allow either the `and`/`or` keys of
179
+ # a composite rule or the `zones`/`match` keys of a leaf rule.
180
+ ruleItem:
181
+ type: object
182
+ oneOf:
183
+ - $ref: "#/$defs/compositeRule"
184
+ - $ref: "#/$defs/leafRule"
185
+
186
+ compositeRule:
187
+ type: object
188
+ additionalProperties: false
189
+ description: |
190
+ A composite rule groups several sub‑rules together using
191
+ either `and` or `or`. Only one of these keys MUST be
192
+ present. The evaluation semantics follow boolean logic:
193
+ * `and`: all sub‑rules MUST match for the composite rule to
194
+ trigger.
195
+ * `or`: any sub‑rule matching triggers the composite rule.
196
+ properties:
197
+ and:
198
+ type: array
199
+ minItems: 1
200
+ items:
201
+ $ref: "#/$defs/ruleItem"
202
+ or:
203
+ type: array
204
+ minItems: 1
205
+ items:
206
+ $ref: "#/$defs/ruleItem"
207
+ oneOf:
208
+ - required: [and]
209
+ - required: [or]
210
+
211
+ leafRule:
212
+ type: object
213
+ additionalProperties: false
214
+ description: |
215
+ A leaf rule describes a single condition evaluated against
216
+ specific parts of the HTTP request. It MUST provide at
217
+ least one zone via the `zones` list and a `match` object
218
+ describing the comparison to perform.
219
+ properties:
220
+ zones:
221
+ type: array
222
+ description: |
223
+ List of zones specifying which parts of the HTTP request
224
+ to inspect.
225
+ minItems: 1
226
+ items:
227
+ type: string
228
+ enum:
229
+ - ARGS
230
+ - ARGS_NAMES
231
+ - BODY_ARGS
232
+ - ARGS_POST,
233
+ - BODY_ARGS_NAMES
234
+ - COOKIES
235
+ - COOKIES_NAMES
236
+ - REQUEST_COOKIES_NAMES
237
+ - FILES
238
+ - FILES_NAMES
239
+ - FILES_TOTAL_SIZE
240
+ - HEADERS_NAMES
241
+ - HEADERS
242
+ - METHOD
243
+ - PROTOCOL
244
+ - URI
245
+ - URI_FULL
246
+ - RAW_BODY
247
+ - FILENAMES
248
+ variables:
249
+ type: array
250
+ description: |
251
+ Restricts the match to specific variable names within the
252
+ selected zones. Only relevant when zones include
253
+ `ARGS`, `BODY_ARGS` or `HEADERS`. Each entry MUST be
254
+ a non‑empty string.
255
+ items:
256
+ type: string
257
+ transform:
258
+ type: array
259
+ description: |
260
+ List of transformations applied sequentially on the
261
+ target before performing the match.
262
+ items:
263
+ type: string
264
+ enum:
265
+ - lowercase
266
+ - uppercase
267
+ - b64decode
268
+ - length
269
+ - urldecode
270
+ - trim
271
+ - normalizepath
272
+ - htmlEntitydecode
273
+ - count
274
+ name:
275
+ type: string
276
+ description: |
277
+ A single variable name to restrict the match. This is a
278
+ convenience shorthand equivalent to specifying `variables` with a
279
+ one‑element array.
280
+ match:
281
+ $ref: "#/$defs/match"
282
+ required:
283
+ - zones
284
+ - match
285
+
286
+ match:
287
+ type: object
288
+ description: |
289
+ Specifies how to compare the extracted target against a
290
+ constant value. Both `type` and `value` are required.
291
+ oneOf:
292
+ - properties:
293
+ type:
294
+ type: string
295
+ enum:
296
+ - libinjectionSQL
297
+ - libinjectionXSS
298
+ required:
299
+ - type
300
+ additionalProperties: false
301
+ - properties:
302
+ type:
303
+ type: string
304
+ description: |
305
+ Method used to compare the target to the value.
306
+ enum:
307
+ - regex
308
+ - equals
309
+ - startsWith
310
+ - endsWith
311
+ - contains
312
+ - libinjectionSQL
313
+ - libinjectionXSS
314
+ value:
315
+ type: string
316
+ description: |
317
+ The constant value to compare the target against. Its meaning
318
+ depends on the selected `type` (e.g. a RE2 regular expression for
319
+ `regex`).
320
+ required:
321
+ - type
322
+ - value
323
+ - properties:
324
+ type:
325
+ type: string
326
+ description: |
327
+ Method used to compare the target to the value.
328
+ enum:
329
+ - gt
330
+ - lt
331
+ - gte
332
+ - lte
333
+ - equals
334
+ value:
335
+ type: number
336
+ description: |
337
+ The constant value to compare the target against. Its meaning
338
+ depends on the selected `type` (e.g. gt, lt, gte, lte requires a
339
+ number)
340
+ required:
341
+ - type
342
+ - value
343
+ additionalProperties: false