Status
Ready for Review
Description of Changes
Fixes #1195
A cron job runs daily on the app server and updates the
/var/lib/securedrop/submissions_today.txt
file which contains the number of submissions sent in the past 24h, as
created by the manage.py how_many_submissions_today command.
The OSSEC agent on the app server runs a command daily, displaying
the content of /var/lib/securedrop/submissions_today.txt. The output
of the command is sent to the OSSEC server.
A new rule is defined on the OSSEC server to send a mail to when the
output is received from the OSSEC agent running on the app server.
A new procmail rule is definied on the OSSEC server to catch mails
encrypt mails containing the /var/lib/securedrop/submissions_today.txt
string and send them to the email defined by the
journalist_alert_email ansible variable.
A new set of (optional) ansible variables, similar to
ossec_alert_gpg_public_key, ossec_gpg_fpr, ossec_alert_email are
defined: journalist_alert_gpg_public_key, journalist_gpg_fpr,
journalist_alert_email. They are used to upload a journalist public
key to the OSSEC server and inserted into the send_encrypted_alarm.sh
script which handles mails received by procmail.
The modified send_encrypted_alarm.sh script takes one
argument (journalist or ossec) and dispatches the mail read from
stdin to the corresponding recipient.
Integration tests are implemented to verify the following:
- manage.py how_many_submissions_today
- the app OSSEC agent sends a mail to the journalist address
- cover all branches of send_encrypted_alarm.sh
Testing
- make build-debs
- vagrant up /staging/
- ./testinfra/test.py staging
Running Testinfra suite against 'staging'...
Target roles:
- testinfra/ossec
==================================================================== test session starts =====================================================================
platform linux2 -- Python 2.7.13, pytest-3.3.1, py-1.5.2, pluggy-0.6.0 -- /home/loic/software/securedrop/virtualenv/bin/python2
cachedir: .cache
rootdir: /home/loic/software/securedrop/securedrop, inifile: setup.cfg
plugins: testinfra-1.7.1, xdist-1.21.0, forked-0.2
collected 10 items
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_procmail[ansible://app-staging] SKIPPED [ 10%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_send_encrypted_alert[ansible://app-staging] SKIPPED [ 20%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_missing_journalist_alert[ansible://app-staging] SKIPPED [ 30%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_ossec_rule_journalist[ansible://app-staging] SKIPPED [ 40%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_journalist_mail_notification[ansible://app-staging] SKIPPED [ 50%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_procmail[ansible://mon-staging] PASSED [ 60%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_send_encrypted_alert[ansible://mon-staging] PASSED [ 70%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_missing_journalist_alert[ansible://mon-staging] PASSED [ 80%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_ossec_rule_journalist[ansible://mon-staging] PASSED [ 90%]
testinfra/ossec/test_journalist_mail.py::TestJournalistMail::test_journalist_mail_notification[ansible://mon-staging] PASSED [100%]
====================================================================== warnings summary ======================================================================
None
Module already imported so cannot be rewritten: testinfra
-- Docs: http://doc.pytest.org/en/latest/warnings.html
===================================================== 5 passed, 5 skipped, 1 warnings in 106.35 seconds ======================================================
Comments
See the forum discussion for the rationale behind the testinfra: remove some XXX tests duplicating Ansible commits.
Deployment
- The journalist emails is not set for existing installations, nothing will happen
- During sdconfig the admin will be prompted for the email of the journalist and the encryption key. If set, the daily notification mails will be sent.
Checklist
If you made changes to the app code:
- [x] Unit and functional tests pass on the development VM
If you made changes to the system configuration:
If you made changes to documentation:
- [x] Doc linting passed locally
feature goals: journalist experience OSSEC