-
Notifications
You must be signed in to change notification settings - Fork 3
feat(spoe): Migrate implementation to dropmorepackets/haproxy-go #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
LaurenceJJones
merged 17 commits into
main
from
feat/migrate-to-dropmorepackets-haproxy-go
Jan 12, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c43c867
Migrate SPOE implementation to dropmorepackets/haproxy-go
LaurenceJJones 024eb70
Fix linter issues
LaurenceJJones 3917cd1
fix(spoe): address Copilot PR review comments
LaurenceJJones 8cb3212
fix(spoe): remove unused error variables
LaurenceJJones 1426965
refactor(spoe): add reset() method to IPMessageData for consistency
LaurenceJJones fcb7dc4
perf(spoe): optimize readHeaders to avoid full byte slice to string c…
LaurenceJJones c40999c
perf(spoe): use bytes.SplitSeq for more efficient header parsing
LaurenceJJones c5aae82
fix(spoe): address memory safety and code quality issues
LaurenceJJones c58ae76
refactor(SPOE): use message groups (#141)
LaurenceJJones 37012a2
Merge main into feat/migrate-to-dropmorepackets-haproxy-go
LaurenceJJones 280ed7a
refactor(spoa): clean up and simplify SPOA functions
LaurenceJJones 5421eb9
perf(spoa): remove redundant reset() calls after pool Get()
LaurenceJJones 0dcb763
refactor: use ptr.Of and extract host/cookie from headers
LaurenceJJones 374fde2
config: increase buffer size and timeouts for WAF body inspection
LaurenceJJones c17be62
feat: improve HAProxy buffer config and add debug tooling
LaurenceJJones 225a912
perf: remove unnecessary body copy for AppSec requests
LaurenceJJones 3e955ab
refactor: simplify AppSec config logic and fix metrics counting
LaurenceJJones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,40 @@ | ||
| # /etc/haproxy/crowdsec.cfg | ||
| # SPOE configuration for CrowdSec HAProxy bouncer | ||
| # Used for both standard and upstream proxy deployments | ||
| # IP extraction is handled by HAProxy ACLs (see haproxy-upstreamproxy.cfg for upstream proxy setup) | ||
| [crowdsec] | ||
| spoe-agent crowdsec-agent | ||
| messages crowdsec-ip crowdsec-http | ||
| messages crowdsec-tcp | ||
| groups crowdsec-http-body crowdsec-http-no-body | ||
|
|
||
| option var-prefix crowdsec | ||
| option set-on-error error | ||
| timeout hello 100ms | ||
| timeout idle 30s | ||
| timeout hello 200ms | ||
| timeout idle 55s | ||
| timeout processing 500ms | ||
| use-backend crowdsec-spoa | ||
| log global | ||
|
|
||
| ## This message is used to customise the remediation from crowdsec-ip based on the host header | ||
| ## src-ip is included as fallback in case crowdsec-ip message didn't fire | ||
| spoe-message crowdsec-http | ||
| args remediation=var(txn.crowdsec.remediation) crowdsec_captcha_cookie=req.cook(crowdsec_captcha_cookie) id=unique-id host=hdr(Host) method=method path=path query=query version=req.ver headers=req.hdrs body=req.body url=url ssl=ssl_fc src-ip=src src-port=src_port | ||
| event on-frontend-http-request | ||
|
|
||
| ## This message should be the first to trigger in the chain | ||
| spoe-message crowdsec-ip | ||
| ## TCP/IP level check - runs early to check IP remediation | ||
| ## Uses event directive to trigger on each new client session (not sent as a group) | ||
| spoe-message crowdsec-tcp | ||
| args id=unique-id src-ip=src src-port=src_port | ||
| event on-client-session | ||
|
|
||
| ## HTTP message with body - used when body size is within limit for AppSec | ||
| ## Note: Host and captcha cookie are extracted from headers=req.hdrs, no need to send separately | ||
| spoe-message crowdsec-http-body | ||
| args remediation=var(txn.crowdsec.remediation) id=unique-id method=method path=path query=query version=req.ver headers=req.hdrs body=req.body url=url ssl=ssl_fc src-ip=src src-port=src_port | ||
|
|
||
| ## HTTP message without body - used when body is too large or not needed | ||
| ## Note: Host and captcha cookie are extracted from headers=req.hdrs, no need to send separately | ||
| spoe-message crowdsec-http-no-body | ||
| args remediation=var(txn.crowdsec.remediation) id=unique-id method=method path=path query=query version=req.ver headers=req.hdrs url=url ssl=ssl_fc src-ip=src src-port=src_port | ||
|
|
||
| ## Group for HTTP message with body - used when body size is within limit for AppSec | ||
| spoe-group crowdsec-http-body | ||
| messages crowdsec-http-body | ||
|
|
||
| ## Group for HTTP message without body - used when body is too large or not needed | ||
| spoe-group crowdsec-http-no-body | ||
| messages crowdsec-http-no-body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Development/Debug overlay for docker-compose.yaml | ||
| # Usage: podman compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d | ||
| # | ||
| # This adds a debug container with network tools for troubleshooting | ||
|
|
||
| services: | ||
| # Debug sidecar with network tools | ||
| debug: | ||
| image: alpine:latest | ||
| container_name: debug | ||
| command: > | ||
| sh -c "apk add --no-cache tcpdump socat curl bind-tools netcat-openbsd strace && sleep infinity" | ||
| networks: | ||
| - crowdsec | ||
| cap_add: | ||
| - NET_RAW # Required for tcpdump | ||
| - NET_ADMIN # Required for some network debugging | ||
| volumes: | ||
| # Mount shared sockets volume | ||
| - sockets:/run:ro | ||
| # Mount HAProxy tmp for stats socket access | ||
| - haproxy-tmp:/haproxy-tmp:ro | ||
| # Mount configs for inspection | ||
| - ./config:/config:ro | ||
| depends_on: | ||
| - haproxy | ||
| - spoa | ||
|
|
||
| # Override HAProxy to share /tmp via named volume | ||
| haproxy: | ||
| volumes: | ||
| - haproxy-tmp:/tmp | ||
|
|
||
| volumes: | ||
| haproxy-tmp: | ||
|
|
||
| # Example debug commands: | ||
| # | ||
| # Enter debug container: | ||
| # podman compose -f docker-compose.yaml -f docker-compose.dev.yaml exec debug ash | ||
| # | ||
| # Install tools (once inside): | ||
| # apk add --no-cache tcpdump socat curl bind-tools netcat-openbsd strace | ||
| # | ||
| # Capture SPOE traffic: | ||
| # tcpdump -i any -X port 9000 | ||
| # | ||
| # Test HAProxy stats socket: | ||
| # echo "show info" | socat /haproxy-tmp/haproxy.sock stdio | ||
| # | ||
| # DNS debugging: | ||
| # dig crowdsec | ||
| # nslookup spoa | ||
| # | ||
| # Test connectivity: | ||
| # curl -v http://haproxy:8080/ | ||
| # nc -zv spoa 9000 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.