-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add security update notification script #389
Conversation
hey @pierwill thanks for this! would you be interested in making this notify-send notification a pyqt4 dialog? This would make the notification very hard to miss: from the user's perspective a little window would pop up which they'd need to actively dismiss. Once the related functionality in #396 is merged we'll then also want to modify the conditions in which this alert pops up, see my comment in #236. |
I'll look into this! |
@pierwill If you have time to poke at this in the next few days, that'd be awesome; we'll need some version of this for the pilot, so we can work on this in the next sprint if you're busy. :) |
I had a tough time trying to understand how to use pyqt when I tried this week. I'm going to try again this weekend. I'll likely end up needing some help from the team, I think! |
Check out the graphical updater that's being worked on in #396 for some inspiration. |
Will do! Thanks― 👀 |
Hi @pierwill, you had mentioned on Gitter that you were running into difficulties using PyQt4 and you don't mind us taking this one over. I'm happy to do so, but in case you want to take another stab at it, here's an example of how to do a simple alert in PyQt4 that will work on dom0: https://gist.github.com/eloquence/940646c3e4e11a5b2d05bc418244bdb7 I was also able to test this outside Qubes on an Ubuntu 18.04 system by installing the pyqt4 system package from the Ubuntu repositories. In terms of the check itself, I think we should check both uptime and the timestamp written to dom0 by the preflight updater (see changes introduced in #396). If both uptime and the time since the last update check are > 8 hours, we show the warning. Otherwise we do nothing. That's not something we've discussed as a team yet but if you put in that logic, we can reason through it together. Let me know if you want to poke at this again; otherwise I'll set aside some time tomorrow to work on it further. |
71dc013
to
9b85d5b
Compare
Hi @pierwill, this is coming together nicely. I added a commit that uses an exclusive lock to ensure we only show one dialog at a time, and renamed the file given that the intended use cases extend beyond an uptime check. We spec'd the desired behavior out a bit more, here: To cover the base case, we need to inspect the contents of The current uptime check should only run when this file doesn't exist at all. There's some additional logic described in the GDoc, but if you have time to just work on the base case, that would already get us one big step closer. If not I'll pick this up again ASAP. |
Hi @pierwill, thanks for adding the additional timestamp. I cleaned things up a bit, added some logging, and fleshed out the business logic to utilize uptime and timestamp as intended. The main case we have yet to cover is the one where the updater itself is already running (in which case we don't want to annoy the user with a separate warning). @emkll and I talked about using a simple "ps" output check for this, though I am tempted to add lockfile support to the main updater for this since we already have it here anyway. If you have time to start poking at adding tests, that would be awesome; I'll be looking into the "is the updater running" check and inviting some feedback from a maintainer on the overall approach so far. |
3a915f4
to
61a56a2
Compare
Lockfile support added to preflight updater in 61a56a2. Not tested in Qubes yet. Force-pushed to rebase to latest upstream master. For the cron job to work, we need to obtain the user's Qubes username, as the script has to write to their home directory, not Then I'll attempt to implement the lockfile logic to ensure that it's impossible to get the warning when the updater is running, but it's possible to run the updater while the warning is shown. |
The lockfile implementation is now done. In non-Qubes testing the warning now doesn't show if the updater is running, but the updater can still be run if the warning is shown. I've also cleaned up the code a fair bit. I've also added code for getting the GUI user. I used Next up:
@pierwill, as always, please jump in if you have time to collaborate :). Even manual testing is appreciated. |
Changes I just pushed:
Launcher tests are currently failing because bandit doesn't like the hardcoded path that's used for the launcher lockfile. I'll have to read up on that a bit more, but just to recap, it writes its lockfile to As with previous revisions, will need to do another round of |
I think the logical next steps here are:
|
Now can run as the GUI user, stores both lock files in |
This is now done. The script is added via a new Salt state, Functionally this all works as expected so far in my local testing, including lockfile interaction. Automated tests still TK. |
999d919
to
92e2058
Compare
Made the following changes:
Now would be a good checkpoint to make sure I'm on the right track before fleshing out the tests. :) |
FWIW, to test the lock file behavior I'm using |
import json | ||
import os | ||
import pytest | ||
import subprocess | ||
from datetime import datetime | ||
from importlib.machinery import SourceFileLoader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using importlib
instead of imp
here helps us to avoid the deprecation warning for imp
.
They share code and testing strategies, so it really makes no sense for it to be a standalone script elsewhere
Adds one example test
71deb04
to
15b0a64
Compare
Further changes today:
The tests for the notification business logic are still pending, and relatively straightforward. Will aim to tackle those tomorrow. |
Testing manually is relatively straightforward:
Once automated tests are done and after some final refactoring, I'll structure this test plan a bit more carefully and do a final squash-rebase before submitting this formally for review, but all of the above should work for anyone wanting to give it a spin. |
- Remove another sys.exit() side effect - Always patch sdlog.warning as well
I am closing this PR in favor of #445, which represents a squashed branch for easier review, with a PR body that represents the current state and test plan. However, I've kept the non-squashed branch in place here in case it is of historical interest. |
Couldn't help myself—gave addressing #236 a try. This approach uses a script in
/etc/cron.hourly/
to display a notification on the hour if system uptime exceeds 5 days: "This SecureDrop Workstation has been operating for more than 5 days. For security reasons, we recommend restarting the system now."The
notify-send
command does not support click actions, so to offer the user a button to shutdown the system (as @eloquence originally suggested), we might look into the approach used here: https://github.com/vlevit/notify-send.sh. However, users might be unlikely to be ready to shutdown at the time of notification, so the approach here might be good enough.