chore(modules/firewall): Rewrite to simplify
All checks were successful
Build all the nodes / ap01 (push) Successful in 1m34s
Build all the nodes / geo02 (push) Successful in 2m22s
Build all the nodes / bridge01 (push) Successful in 2m27s
Build all the nodes / hypervisor01 (push) Successful in 2m29s
Build all the nodes / geo01 (push) Successful in 2m30s
Build all the nodes / netcore02 (push) Successful in 34s
Build all the nodes / hypervisor02 (push) Successful in 1m36s
Build all the nodes / compute01 (push) Successful in 3m15s
Build all the nodes / hypervisor03 (push) Successful in 1m46s
Build all the nodes / rescue01 (push) Successful in 1m56s
Build all the nodes / tower01 (push) Successful in 1m43s
Build all the nodes / storage01 (push) Successful in 2m10s
Build all the nodes / vault01 (push) Successful in 2m5s
Build the shell / build-shell (push) Successful in 43s
Run pre-commit on all files / pre-commit (push) Successful in 36s
Build all the nodes / web02 (push) Successful in 1m41s
Build all the nodes / web01 (push) Successful in 2m12s
Build all the nodes / web03 (push) Successful in 1m37s
All checks were successful
Build all the nodes / ap01 (push) Successful in 1m34s
Build all the nodes / geo02 (push) Successful in 2m22s
Build all the nodes / bridge01 (push) Successful in 2m27s
Build all the nodes / hypervisor01 (push) Successful in 2m29s
Build all the nodes / geo01 (push) Successful in 2m30s
Build all the nodes / netcore02 (push) Successful in 34s
Build all the nodes / hypervisor02 (push) Successful in 1m36s
Build all the nodes / compute01 (push) Successful in 3m15s
Build all the nodes / hypervisor03 (push) Successful in 1m46s
Build all the nodes / rescue01 (push) Successful in 1m56s
Build all the nodes / tower01 (push) Successful in 1m43s
Build all the nodes / storage01 (push) Successful in 2m10s
Build all the nodes / vault01 (push) Successful in 2m5s
Build the shell / build-shell (push) Successful in 43s
Run pre-commit on all files / pre-commit (push) Successful in 36s
Build all the nodes / web02 (push) Successful in 1m41s
Build all the nodes / web01 (push) Successful in 2m12s
Build all the nodes / web03 (push) Successful in 1m37s
Also disable the ai filter for nodes that don't have nginx enabled
This commit is contained in:
parent
e0cfd1ceb0
commit
3c9c38fb03
2 changed files with 55 additions and 59 deletions
|
@ -3,9 +3,9 @@
|
|||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
name,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
|
@ -13,6 +13,7 @@ let
|
|||
inherit (lib)
|
||||
concatStringsSep
|
||||
length
|
||||
optionalAttrs
|
||||
replicate
|
||||
splitString
|
||||
;
|
||||
|
@ -85,7 +86,9 @@ in
|
|||
|
||||
stop = [ (nft "delete table inet reaction") ];
|
||||
|
||||
streams = streams'.default // (streams'.${name} or { });
|
||||
streams = {
|
||||
inherit (streams') ssh;
|
||||
} // (optionalAttrs config.services.nginx.enable { inherit (streams') ai-crawlers; });
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -23,68 +23,61 @@ let
|
|||
cmd = act "delete";
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
available = {
|
||||
ai-crawlers = {
|
||||
cmd = [
|
||||
"tail"
|
||||
"-n0"
|
||||
"-f"
|
||||
"/var/log/nginx/access.log"
|
||||
{
|
||||
ai-crawlers = {
|
||||
cmd = [
|
||||
"tail"
|
||||
"-n0"
|
||||
"-f"
|
||||
"/var/log/nginx/access.log"
|
||||
];
|
||||
|
||||
filters.bots = {
|
||||
regex = builtins.map (name: ''^<ip>.*"[^"]*${name}[^"]*"$'') [
|
||||
"AI2Bot"
|
||||
"Amazonbot"
|
||||
"Applebot"
|
||||
"Applebot-Extended"
|
||||
"Bytespider"
|
||||
"CCBot"
|
||||
"ChatGPT-User"
|
||||
"ClaudeBot"
|
||||
"Diffbot"
|
||||
"DuckAssistBot"
|
||||
"FacebookBot"
|
||||
"GPTBot"
|
||||
"Google-Extended"
|
||||
"Kangaroo Bot"
|
||||
"Meta-ExternalAgent"
|
||||
"Meta-ExternalFetcher"
|
||||
"OAI-SearchBot"
|
||||
"PerplexityBot"
|
||||
"Timpibot"
|
||||
"Webzio-Extended"
|
||||
"YouBot"
|
||||
"omgili"
|
||||
];
|
||||
|
||||
filters.bots = {
|
||||
regex = builtins.map (name: ''^<ip>.*"[^"]*${name}[^"]*"$'') [
|
||||
"AI2Bot"
|
||||
"Amazonbot"
|
||||
"Applebot"
|
||||
"Applebot-Extended"
|
||||
"Bytespider"
|
||||
"CCBot"
|
||||
"ChatGPT-User"
|
||||
"ClaudeBot"
|
||||
"Diffbot"
|
||||
"DuckAssistBot"
|
||||
"FacebookBot"
|
||||
"GPTBot"
|
||||
"Google-Extended"
|
||||
"Kangaroo Bot"
|
||||
"Meta-ExternalAgent"
|
||||
"Meta-ExternalFetcher"
|
||||
"OAI-SearchBot"
|
||||
"PerplexityBot"
|
||||
"Timpibot"
|
||||
"Webzio-Extended"
|
||||
"YouBot"
|
||||
"omgili"
|
||||
];
|
||||
actions = ban "720h";
|
||||
};
|
||||
actions = ban "720h";
|
||||
};
|
||||
};
|
||||
|
||||
ssh = {
|
||||
cmd = journalctl "sshd";
|
||||
ssh = {
|
||||
cmd = journalctl "sshd";
|
||||
|
||||
filters = {
|
||||
failedlogin = {
|
||||
regex = [
|
||||
"authentication failure;.*rhost=<ip>"
|
||||
"Connection reset by authenticating user .* <ip>"
|
||||
"Connection closed by invalid user .* <ip> port .*"
|
||||
"Failed password for .* from <ip>"
|
||||
"Invalid user .* from <ip> port .*"
|
||||
"Unable to negotiate with <ip> port .*"
|
||||
];
|
||||
actions = ban "48h";
|
||||
};
|
||||
filters = {
|
||||
failedlogin = {
|
||||
regex = [
|
||||
"authentication failure;.*rhost=<ip>"
|
||||
"Connection reset by authenticating user .* <ip>"
|
||||
"Connection closed by invalid user .* <ip> port .*"
|
||||
"Failed password for .* from <ip>"
|
||||
"Invalid user .* from <ip> port .*"
|
||||
"Unable to negotiate with <ip> port .*"
|
||||
];
|
||||
actions = ban "48h";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
builtins.mapAttrs (_: builtins.foldl' (a: s: a // { ${s} = available.${s}; }) { }) {
|
||||
default = [
|
||||
"ai-crawlers"
|
||||
"ssh"
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue