crowdsec-local-mcp 0.0.2__tar.gz

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 (41) hide show
  1. crowdsec_local_mcp-0.0.2/.github/workflows/build.yml +21 -0
  2. crowdsec_local_mcp-0.0.2/.github/workflows/publish.yml +26 -0
  3. crowdsec_local_mcp-0.0.2/.gitignore +207 -0
  4. crowdsec_local_mcp-0.0.2/LICENSE +21 -0
  5. crowdsec_local_mcp-0.0.2/MANIFEST.in +3 -0
  6. crowdsec_local_mcp-0.0.2/PKG-INFO +74 -0
  7. crowdsec_local_mcp-0.0.2/README.md +61 -0
  8. crowdsec_local_mcp-0.0.2/pyproject.toml +34 -0
  9. crowdsec_local_mcp-0.0.2/setup.cfg +4 -0
  10. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/__init__.py +5 -0
  11. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/__main__.py +24 -0
  12. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/.gitignore +3 -0
  13. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/crowdsec/acquis.d/appsec.yaml +8 -0
  14. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/crowdsec/appsec-configs/mcp-appsec.yaml.template +8 -0
  15. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/crowdsec/init-bouncer.sh +29 -0
  16. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/docker-compose.yml +68 -0
  17. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/nginx/Dockerfile +67 -0
  18. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/nginx/crowdsec/crowdsec-openresty-bouncer.conf +25 -0
  19. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/nginx/nginx.conf +25 -0
  20. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/nginx/site-enabled/default-site.conf +15 -0
  21. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/rules/.gitkeep +0 -0
  22. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/compose/waf-test/rules/base-config.yaml +11 -0
  23. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/mcp_core.py +151 -0
  24. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/mcp_scenarios.py +380 -0
  25. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/mcp_waf.py +1170 -0
  26. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/prompts/prompt-scenario-deploy.txt +27 -0
  27. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/prompts/prompt-scenario-examples.txt +237 -0
  28. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/prompts/prompt-scenario.txt +84 -0
  29. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/prompts/prompt-waf-deploy.txt +118 -0
  30. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/prompts/prompt-waf-examples.txt +401 -0
  31. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/prompts/prompt-waf.txt +343 -0
  32. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/setup_cli.py +306 -0
  33. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/yaml-schemas/appsec_rules_schema.yaml +343 -0
  34. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp/yaml-schemas/scenario_schema.yaml +591 -0
  35. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp.egg-info/PKG-INFO +74 -0
  36. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp.egg-info/SOURCES.txt +39 -0
  37. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp.egg-info/dependency_links.txt +1 -0
  38. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp.egg-info/entry_points.txt +3 -0
  39. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp.egg-info/requires.txt +4 -0
  40. crowdsec_local_mcp-0.0.2/src/crowdsec_local_mcp.egg-info/top_level.txt +1 -0
  41. crowdsec_local_mcp-0.0.2/uv.lock +583 -0
@@ -0,0 +1,21 @@
1
+ name: "Build"
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v5
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v6
18
+ - name: Install Python 3.13
19
+ run: uv python install 3.13
20
+ - name: Build package
21
+ run: uv build
@@ -0,0 +1,26 @@
1
+ name: "Publish"
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - released
7
+
8
+ jobs:
9
+ run:
10
+ runs-on: ubuntu-latest
11
+ environment:
12
+ name: pypi
13
+ permissions:
14
+ id-token: write
15
+ contents: read
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v5
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v6
21
+ - name: Install Python 3.13
22
+ run: uv python install 3.13
23
+ - name: Build
24
+ run: uv build
25
+ - name: Publish
26
+ run: uv publish
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 crowdsec
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ recursive-include src/crowdsec_local_mcp/prompts *.txt
2
+ recursive-include src/crowdsec_local_mcp/compose *
3
+ recursive-include src/crowdsec_local_mcp/yaml-schemas *.yaml
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.4
2
+ Name: crowdsec-local-mcp
3
+ Version: 0.0.2
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
+ ### Quick MCP client setup
58
+
59
+ - Configure supported clients automatically with `uvx run --from crowdsec-local-mcp init <client>`, where `<client>` is one of `claude-desktop`, `chatgpt`, `vscode`, or `stdio`:
60
+
61
+ ```bash
62
+ uvx --from crowdsec-local-mcp init
63
+ ```
64
+
65
+ ## Logging
66
+
67
+ - The MCP server writes its log file to your operating system's temporary directory. On Linux/macOS this is typically `/tmp/crowdsec-mcp.log`; on Windows it resolves via `%TEMP%\crowdsec-mcp.log`.
68
+
69
+ ## Pre Requisites
70
+
71
+ - Docker + Docker Compose
72
+
73
+ - Python >= 3.12
74
+
@@ -0,0 +1,61 @@
1
+ <p align="center">
2
+ <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"/>
3
+ </p>
4
+
5
+
6
+ **Life is too short to write YAML, just ask nicely!**
7
+
8
+ > A Model Context Protocol (MCP) server to generate, validate, and deploy CrowdSec WAF rules & Scenarios.
9
+
10
+
11
+ ## Features
12
+
13
+ ### WAF Rules Features
14
+
15
+ - **WAF Rule Generation**: Generate CrowdSec WAF rules from user input or a CVE reference
16
+ - **Validation**: Validate syntaxical correctness of WAF rules
17
+ - **Linting**: Get warnings and hints to improve your WAF rules
18
+ - **Deployment Guide**: Step-by-step deployment instructions
19
+ - **Docker Test Harness**: Spin up CrowdSec + nginx + bouncer to exercise rules for false positives/negatives
20
+ - **Nuclei Lookup**: Quickly jump to existing templates in the official `projectdiscovery/nuclei-templates` repository for a given CVE
21
+
22
+ ### Scenarios Features
23
+
24
+ - **CrowdSec Scenarios Generation**: Generate CrowdSec scenarios
25
+ - **Validation**: Validate syntaxical correctness of scenarios
26
+ - **Linting**: Get warnings and hints to improve your scenarios
27
+ - **Deployment Guide**: Step-by-step deployment instructions
28
+ - **Docker Test Harness**: Spin up CrowdSec to test scenario behavior
29
+
30
+ ## Demo
31
+
32
+ ### WAF Rules Creation and testing
33
+
34
+ - [Rule creation from natural language with Claude Desktop](https://claude.ai/share/f0f246b2-6b20-4d70-a16c-c6b627ab2d80)
35
+ - [Rule creation from CVE reference](https://claude.ai/share/b6599407-82dd-443c-a12d-9a9825ed99df)
36
+
37
+ ### Scenario Creation and testing
38
+
39
+ - XX
40
+ - XX
41
+
42
+ ## Installation
43
+
44
+ ### Quick MCP client setup
45
+
46
+ - Configure supported clients automatically with `uvx run --from crowdsec-local-mcp init <client>`, where `<client>` is one of `claude-desktop`, `chatgpt`, `vscode`, or `stdio`:
47
+
48
+ ```bash
49
+ uvx --from crowdsec-local-mcp init
50
+ ```
51
+
52
+ ## Logging
53
+
54
+ - The MCP server writes its log file to your operating system's temporary directory. On Linux/macOS this is typically `/tmp/crowdsec-mcp.log`; on Windows it resolves via `%TEMP%\crowdsec-mcp.log`.
55
+
56
+ ## Pre Requisites
57
+
58
+ - Docker + Docker Compose
59
+
60
+ - Python >= 3.12
61
+
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "crowdsec-local-mcp"
3
+ dynamic = ["version"]
4
+ description = "An MCP exposing prompts and tools to help users write WAF rules, scenarios etc."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "jsonschema>=4.25.1",
9
+ "mcp>=1.15.0",
10
+ "pyyaml>=6.0.3",
11
+ "requests>=2.32.5",
12
+ ]
13
+
14
+ [project.scripts]
15
+ crowdsec-mcp = "crowdsec_local_mcp.__main__:run"
16
+ init = "crowdsec_local_mcp.setup_cli:main"
17
+
18
+ [build-system]
19
+ requires = ["setuptools>=69", "wheel", "setuptools_scm>=8"]
20
+ build-backend = "setuptools.build_meta"
21
+
22
+ [tool.setuptools]
23
+ include-package-data = true
24
+
25
+ [tool.setuptools.package-dir]
26
+ "" = "src"
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
30
+
31
+ [tool.setuptools_scm]
32
+ tag_regex = "^v?(?P<version>[0-9]+(\\.[0-9]+)*)$"
33
+ version_scheme = "no-guess-dev"
34
+ local_scheme = "no-local-version"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """CrowdSec MCP package."""
2
+
3
+ from .mcp_core import main
4
+
5
+ __all__ = ["main"]
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Use `uv run --project . <command>` to run this module directly for testing.
4
+
5
+ import asyncio
6
+
7
+ from .mcp_core import LOGGER, main
8
+
9
+ # Import modules for their registration side effects.
10
+ from . import mcp_waf # noqa: F401
11
+
12
+ try:
13
+ from . import mcp_scenarios # noqa: F401
14
+ except ModuleNotFoundError:
15
+ LOGGER.warning("Scenario module not available; scenario tools disabled")
16
+
17
+
18
+ def run() -> None:
19
+ """Entry-point used by console scripts."""
20
+ asyncio.run(main())
21
+
22
+
23
+ if __name__ == "__main__":
24
+ run()
@@ -0,0 +1,3 @@
1
+ # Generated at runtime by the MCP integration.
2
+ rules/current-rule.yaml
3
+ crowdsec/appsec-configs/mcp-appsec.yaml
@@ -0,0 +1,8 @@
1
+ # Acquisition file registering the MCP-generated AppSec configuration.
2
+ appsec_configs:
3
+ - mcp-appsec
4
+ labels:
5
+ type: appsec
6
+ listen_addr: 0.0.0.0:7422
7
+ source: appsec
8
+ name: myAppSecComponent
@@ -0,0 +1,8 @@
1
+ name: mcp-appsec
2
+ default_remediation: ban
3
+ inband_rules:
4
+ # Keep the CrowdSec base config to ensure essential protections remain active.
5
+ - crowdsecurity/base-config
6
+ # The MCP tooling copies the user rule into the custom directory as current-rule.yaml
7
+ ## XXX FIXME : make this a variable :)
8
+ - __PLACEHOLDER_FOR_USER_RULE__
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ API_KEY="mcp-nginx-bouncer-test-key"
5
+ BOUNCER_NAME="mcp-nginx-bouncer"
6
+
7
+ /bin/bash /docker_start.sh "$@" &
8
+ PID=$!
9
+ trap 'kill "$PID" 2>/dev/null || true' EXIT
10
+
11
+ for _ in $(seq 1 90); do
12
+ if cscli lapi status >/dev/null 2>&1; then
13
+ break
14
+ fi
15
+ sleep 2;
16
+ done
17
+
18
+ if ! cscli lapi status >/dev/null 2>&1; then
19
+ echo "CrowdSec LAPI did not become ready in time" >&2
20
+ wait "$PID"
21
+ exit 1
22
+ fi
23
+
24
+ cscli bouncers delete "$BOUNCER_NAME" >/dev/null 2>&1 || true
25
+ cscli bouncers add "$BOUNCER_NAME" -k "$API_KEY"
26
+
27
+ trap - EXIT
28
+ wait "$PID"
29
+ exit $?
@@ -0,0 +1,68 @@
1
+ version: "3.9"
2
+
3
+ services:
4
+ crowdsec:
5
+ image: crowdsecurity/crowdsec:latest
6
+ hostname: crowdsec
7
+ container_name: crowdsec-appsec
8
+ restart: "no"
9
+ entrypoint:
10
+ - /bin/bash
11
+ - /usr/local/bin/init-bouncer.sh
12
+ environment:
13
+ # Ensure the local API stays accessible for the nginx bouncer.
14
+ - DISABLE_LOCAL_API=0
15
+ - DISABLE_ONLINE_API=1
16
+ # Turn on AppSec mode inside the CrowdSec container.
17
+ - ENABLE_APPSEC=1
18
+ volumes:
19
+ # Persist CrowdSec data (buckets, alerts, etc.) between restarts.
20
+ - crowdsec-data:/var/lib/crowdsec/data
21
+ # Allow templated acquisition and AppSec config overrides without replacing the whole /etc/crowdsec tree.
22
+ - ./crowdsec/acquis.d/appsec.yaml:/etc/crowdsec/acquis.d/appsec-mcp.yaml:ro
23
+ - ./crowdsec/appsec-configs/mcp-appsec.yaml:/etc/crowdsec/appsec-configs/mcp-appsec.yaml:ro
24
+ - ./crowdsec/init-bouncer.sh:/usr/local/bin/init-bouncer.sh:ro
25
+ # The MCP tooling will drop the user-provided rule in this folder as current-rule.yaml
26
+ - ./rules:/etc/crowdsec/appsec-rules/custom
27
+ ports:
28
+ - "18080:8080" # LAPI (use non-default host port to avoid conflicts)
29
+ - "17422:7422" # AppSec Live mode (non-default host port)
30
+ networks:
31
+ - waf-net
32
+
33
+ nginx:
34
+ build:
35
+ context: ./nginx
36
+ container_name: nginx-appsec
37
+ restart: "no"
38
+ depends_on:
39
+ - crowdsec
40
+ - backend
41
+ ports:
42
+ - "8081:80"
43
+ command:
44
+ - openresty
45
+ - -g
46
+ - 'daemon off;'
47
+ volumes:
48
+ - ./nginx/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf:ro
49
+ # Site config enabling the CrowdSec module and proxying to the backend.
50
+ - ./nginx/site-enabled:/usr/local/openresty/nginx/conf/site-enabled:ro
51
+ # Override the bouncer configuration shipped in the image with the harness version.
52
+ - ./nginx/crowdsec/crowdsec-openresty-bouncer.conf:/etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf:ro
53
+ networks:
54
+ - waf-net
55
+
56
+ backend:
57
+ image: nginxdemos/hello:latest
58
+ container_name: app-backend
59
+ restart: unless-stopped
60
+ networks:
61
+ - waf-net
62
+
63
+ volumes:
64
+ crowdsec-data:
65
+
66
+ networks:
67
+ waf-net:
68
+ driver: bridge
@@ -0,0 +1,67 @@
1
+
2
+ FROM ubuntu:24.04
3
+
4
+ # Install dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ git \
7
+ make \
8
+ software-properties-common \
9
+ wget \
10
+ gnupg \
11
+ ca-certificates \
12
+ gettext \
13
+ curl
14
+
15
+ RUN wget -O - https://openresty.org/package/pubkey.gpg | apt-key add -
16
+ RUN echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"| tee /etc/apt/sources.list.d/openresty.list
17
+ RUN curl -s https://install.crowdsec.net | bash
18
+
19
+ RUN apt update
20
+
21
+ RUN apt install -y openresty openresty-opm gettext-base
22
+
23
+ RUN apt install -y crowdsec-openresty-bouncer
24
+
25
+
26
+
27
+ EXPOSE 80
28
+
29
+
30
+ # # Install the bouncer
31
+ # COPY build.sh /build.sh
32
+ # COPY start.sh /start.sh
33
+
34
+ # RUN chmod +x /build.sh && /build.sh
35
+ # RUN chmod +x /start.sh
36
+
37
+ # # Set the script as the entrypoint
38
+ # ENTRYPOINT ["/start.sh"]
39
+
40
+
41
+
42
+ # FROM debian:bookworm
43
+
44
+ # ENV DEBIAN_FRONTEND=noninteractive
45
+
46
+ # # Install nginx with Lua module support and prerequisites for the CrowdSec nginx bouncer.
47
+ # RUN set -eux; \
48
+ # apt-get update; \
49
+ # apt-get install -y --no-install-recommends \
50
+ # ca-certificates \
51
+ # curl \
52
+ # gnupg2 \
53
+ # iproute2 \
54
+ # libnginx-mod-http-lua \
55
+ # lsb-release \
56
+ # nginx \
57
+ # procps; \
58
+ # curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | bash; \
59
+ # apt-get install -y --no-install-recommends crowdsec-nginx-bouncer; \
60
+ # rm -rf /var/lib/apt/lists/*
61
+
62
+ # # Prepare directories that will receive bind mounts at runtime.
63
+ # RUN mkdir -p /etc/nginx/conf.d /etc/nginx/crowdsec
64
+
65
+ # EXPOSE 80
66
+
67
+ # CMD ["nginx", "-g", "daemon off;"]