mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Add tests for e-mail actions, and cleanup the new logic a bit.
This commit is contained in:
parent
6d0f48abfc
commit
ac720a1313
17 changed files with 353 additions and 16 deletions
|
@ -0,0 +1,24 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-diff sendmail.out
|
||||
|
||||
@load base/frameworks/notice
|
||||
@load base/utils/site
|
||||
|
||||
redef Notice::mail_dest = "user@example.net";
|
||||
redef Notice::sendmail = "fake-sendmail";
|
||||
|
||||
redef Site::local_admins += { [1.0.0.0/8] = set("cloudflare@example.net", "postmaster@the.cloud") };
|
||||
|
||||
redef enum Notice::Type += {
|
||||
Test_Notice,
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
NOTICE([$note=Test_Notice, $msg="test", $identifier="static", $src=1.1.1.1, $dst=[::1]]);
|
||||
}
|
||||
|
||||
hook Notice::policy(n: Notice::Info) &priority=1
|
||||
{
|
||||
add n$actions[Notice::ACTION_EMAIL_ADMIN];
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-diff sendmail.out
|
||||
|
||||
# Tests overriding the e-mail destination for a specific notice
|
||||
|
||||
|
||||
@load base/frameworks/notice
|
||||
|
||||
hook Notice::policy(n: Notice::Info) &priority=1
|
||||
{
|
||||
add n$actions[Notice::ACTION_EMAIL];
|
||||
}
|
||||
|
||||
redef Notice::mail_dest = "user@example.net";
|
||||
redef Notice::sendmail = "fake-sendmail";
|
||||
|
||||
redef enum Notice::Type += {
|
||||
Test_Notice,
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
NOTICE([$note=Test_Notice, $msg="test", $identifier="static"]);
|
||||
}
|
||||
|
||||
hook Notice::policy(n: Notice::Info)
|
||||
{
|
||||
n$email_dest = set("admin@example.net");
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-diff sendmail.out
|
||||
|
||||
# Test what happens with PAGE and EMAIL
|
||||
|
||||
@load base/frameworks/notice
|
||||
|
||||
redef Notice::mail_dest = "user@example.net";
|
||||
redef Notice::mail_page_dest = "page@example.net";
|
||||
redef Notice::sendmail = "fake-sendmail";
|
||||
|
||||
redef enum Notice::Type += {
|
||||
Test_Notice,
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
NOTICE([$note=Test_Notice, $msg="test", $identifier="static"]);
|
||||
}
|
||||
|
||||
hook Notice::policy(n: Notice::Info) &priority=1
|
||||
{
|
||||
add n$actions[Notice::ACTION_PAGE];
|
||||
add n$actions[Notice::ACTION_EMAIL];
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-diff sendmail.out
|
||||
|
||||
@load base/frameworks/notice
|
||||
|
||||
redef Notice::mail_dest = "user@example.net";
|
||||
redef Notice::sendmail = "fake-sendmail";
|
||||
|
||||
redef enum Notice::Type += {
|
||||
Test_Notice,
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
NOTICE([$note=Test_Notice, $msg="test", $identifier="static"]);
|
||||
}
|
||||
|
||||
hook Notice::policy(n: Notice::Info) &priority=1
|
||||
{
|
||||
add n$actions[Notice::ACTION_EMAIL];
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-diff sendmail.out
|
||||
|
||||
@load base/frameworks/notice
|
||||
@load frameworks/notice/extend-email/hostnames
|
||||
|
||||
redef Notice::mail_dest = "user@example.net";
|
||||
redef Notice::mail_page_dest = "page@example.net";
|
||||
redef Notice::sendmail = "fake-sendmail";
|
||||
|
||||
redef enum Notice::Type += {
|
||||
Test_Notice,
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
NOTICE([$note=Test_Notice, $msg="test", $identifier="static", $src=1.1.1.1, $dst=[::1]]);
|
||||
}
|
||||
|
||||
hook Notice::policy(n: Notice::Info) &priority=1
|
||||
{
|
||||
add n$actions[Notice::ACTION_PAGE];
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-diff sendmail.out
|
||||
|
||||
@load base/frameworks/notice
|
||||
|
||||
redef Notice::mail_dest = "user@example.net";
|
||||
redef Notice::mail_page_dest = "page@example.net";
|
||||
redef Notice::sendmail = "fake-sendmail";
|
||||
|
||||
redef enum Notice::Type += {
|
||||
Test_Notice,
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
NOTICE([$note=Test_Notice, $msg="test", $identifier="static"]);
|
||||
}
|
||||
|
||||
hook Notice::policy(n: Notice::Info) &priority=1
|
||||
{
|
||||
add n$actions[Notice::ACTION_PAGE];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue