SYN flood, brute force fail2ban + session.mail.is-allowed expression (closes #482 closes #688 closes #609)

This commit is contained in:
mdecimus
2024-08-29 12:22:44 +02:00
parent 7e1b6bd06d
commit 36fd5797b7
35 changed files with 325 additions and 114 deletions

View File

@@ -406,9 +406,11 @@ pub async fn insert_test_metrics(core: Arc<Core>) {
EventType::Queue(QueueEvent::QueueReport),
EventType::MessageIngest(MessageIngestEvent::Ham),
EventType::MessageIngest(MessageIngestEvent::Spam),
EventType::Auth(AuthEvent::Banned),
EventType::Auth(AuthEvent::Failed),
EventType::Network(NetworkEvent::DropBlocked),
EventType::Security(SecurityEvent::AuthenticationBan),
EventType::Security(SecurityEvent::BruteForceBan),
EventType::Security(SecurityEvent::LoiterBan),
EventType::Security(SecurityEvent::IpBlocked),
EventType::IncomingReport(IncomingReportEvent::DmarcReport),
EventType::IncomingReport(IncomingReportEvent::DmarcReportWithWarnings),
EventType::IncomingReport(IncomingReportEvent::TlsReport),

View File

@@ -100,8 +100,10 @@ enable = true
implicit = false
certificate = "default"
[server.fail2ban]
authentication = "101/5s"
[authentication]
fail2ban = "101/5s"
rate-limit = "100/2s"
[session.ehlo]

View File

@@ -56,6 +56,9 @@ requiretls = [{if = "remote_ip = '10.0.0.2'", then = true},
mt-priority = [{if = "remote_ip = '10.0.0.2'", then = 'nsep'},
{else = false}]
[session.mail]
is-allowed = "sender_domain != 'blocked.com'"
[session.data.limits]
size = [{if = "remote_ip = '10.0.0.2'", then = 2048},
{else = 1024}]
@@ -70,8 +73,8 @@ enable = true
#[tokio::test]
async fn mail() {
// Enable logging
crate::enable_logging();
// Enable logging
crate::enable_logging();
let tmp_dir = TempDir::new("smtp_mail_test", true);
let mut config = Config::new(tmp_dir.update_config(CONFIG)).unwrap();
@@ -115,9 +118,16 @@ async fn mail() {
.unwrap();
session.response().assert_code("503 5.5.1");
// Both IPREV and SPF should pass
// Test sender not allowed
session.ingest(b"EHLO mx1.foobar.org\r\n").await.unwrap();
session.response().assert_code("250");
session
.ingest(b"MAIL FROM:<bill@blocked.com>\r\n")
.await
.unwrap();
session.response().assert_code("550 5.7.1");
// Both IPREV and SPF should pass
session
.ingest(b"MAIL FROM:<bill@foobar.org>\r\n")
.await