-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ossec: never send more than one journalist notification per 24h
Relates to: #3368
- Loading branch information
Loic Dachary
committed
May 5, 2018
1 parent
ed9f041
commit 856b180
Showing
2 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -70,6 +70,8 @@ def test_procmail(self, host): | |
for (destination, payload) in ( | ||
('journalist', today_payload), | ||
('ossec', 'MYGREATPAYLOAD')): | ||
assert self.run(host, | ||
"/var/ossec/process_submissions_today.sh forget") | ||
assert self.run(host, "postsuper -d ALL") | ||
assert self.run( | ||
host, | ||
|
@@ -82,7 +84,12 @@ def test_procmail(self, host): | |
self.service_stopped(host, "postfix") | ||
|
||
def test_process_submissions_today(self, host): | ||
self.run(host, "/var/ossec/process_submissions_today.sh test_main") | ||
assert self.run(host, | ||
"/var/ossec/process_submissions_today.sh " | ||
"test_handle_notification") | ||
assert self.run(host, | ||
"/var/ossec/process_submissions_today.sh " | ||
"test_modified_in_the_past_24h") | ||
|
||
def test_send_encrypted_alert(self, host): | ||
self.service_started(host, "postfix") | ||
|
@@ -185,10 +192,15 @@ def test_journalist_mail_notification(self, host): | |
# empty the mailq on mon in case there were leftovers | ||
# | ||
assert self.run(mon, "postsuper -d ALL") | ||
# | ||
# forget about past notifications in case there were leftovers | ||
# | ||
assert self.run(mon, "/var/ossec/process_submissions_today.sh forget") | ||
|
||
# | ||
# the command fires every time ossec starts, | ||
# regardless of the frequency | ||
# https://github.com/ossec/ossec-hids/issues/1415 | ||
# | ||
with app.sudo(): | ||
self.service_restarted(app, "ossec") | ||
|
@@ -203,6 +215,21 @@ def test_journalist_mail_notification(self, host): | |
mon, | ||
"test 1 = $(mailq | grep [email protected] | wc -l)") | ||
|
||
assert self.run( | ||
mon, | ||
"grep --count 'notification suppressed' /var/log/syslog " | ||
"> /tmp/before") | ||
|
||
# | ||
# The second notification within less than 24h is suppressed | ||
# | ||
with app.sudo(): | ||
self.service_restarted(app, "ossec") | ||
assert self.wait_for_command(mon, """ | ||
grep --count 'notification suppressed' /var/log/syslog > /tmp/after | ||
test $(cat /tmp/before) -lt $(cat /tmp/after) | ||
""") | ||
|
||
# | ||
# teardown the ossec and postfix on mon and app | ||
# | ||
|