nixos/crowdsec-firewall-bouncer: init module #446106
Open
+385
−0
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.
Fixes #358457
Initialize a module for configuring the CrowdSec Firewall Bouncer, fetching decisions from a CrowdSec API and applying them to the configured firewall.
This module defaults to a configuration that connects to the
services.crowdsec
local API such that a configuration like:would work as intended, but should be configurable enough that it can support other types of configuration (e.g. leaving the user manage the rulesets itself, connect to an external CrowdSec API, etc.).
The module requires the user to manually register the bouncer to get the API key before enabling this module.It may be possible to create another service that does this work automatically but this is not simple to do in a robust way and would not work when using an external CrowdSec API.
There is now an option (enabled by default if
config.services.crowdsec.enable
is set) to automatically register to the locally running crowdsec service, allowing for a no-manual-intervention setup.This options is optional and the module still allows for other use-cases (e.g. specify an api_key to connect to an external CrowdSec API).
I have tested the
nftables
mode, both with the module creating the rulesets (set-only = true
), or leaving the bouncer creating and updating them (set-only = false
).In both cases, the bouncer manages to create/update the appropriate
nftables
elements to block the IPs based on the current CrowdSec decisions.I have not tested the
iptables
mode, where the bouncer will automatically create the ruleset for theiptables
firewall. If one is able to test this case, I would be thankful.I also did not write the creation of the ruleset for the
iptables
firewall as I was not too familiar on this topic.-> Thus, I added an assertion when the user has set the
ipset
mode (the bouncer expects the ruleset to be created) and thecreate_rulesets
option is left enabled.I've only added myself as a maintainer but if others such as the crowdsec module maintainers want to also be added to this module, let me know and I will add you.
Upstream documentation and interesting files:
Pinging the maintainers of the
crowdsec
module: @M0ustach3 @TornaxO7 @06kellyjacThings done
passthru.tests
.nixpkgs-review
on this PR. See nixpkgs-review usage../result/bin/
.Add a 👍 reaction to pull requests you find important.