Skip to content
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

Enforce updates on login via dom0 launcher app #396

Merged
merged 24 commits into from Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
836fe11
Adds securedrop-workstation launcher
emkll Jan 6, 2020
a48e620
Fix progress/status bar
emkll Jan 10, 2020
3c29276
Reboot AppVMs after updating their associated TemplateVMs
emkll Jan 10, 2020
06f429a
Write flags to sd-svs and dom0
emkll Jan 10, 2020
6eaa3f7
Reboot if updates to dom0 or fedora template
emkll Jan 10, 2020
2a6a4a0
Powercycle vms after update
emkll Jan 10, 2020
290595d
Adds python tests for sdw-launcher Updater script
emkll Jan 13, 2020
4c6b9a8
CI: Add launcher tests
emkll Jan 13, 2020
c3774be
Add more tests, coverage, add tempfile for tests that write files to …
emkll Jan 13, 2020
3719190
Write update status flag to dom0
emkll Jan 14, 2020
2356a92
Add test coverage
emkll Jan 14, 2020
34aecda
Fix reboot logic
emkll Jan 14, 2020
fe1ab6b
Use generator to iterate through update checks/upgrades
emkll Jan 14, 2020
4bab247
Only use tempfiles for testing for dom0, sd-svs paths are not required.
emkll Jan 14, 2020
b938816
Use --skip-if-running when starting VMs
emkll Jan 14, 2020
f2abeab
Re-use shutdown function instead of calling qvm-shutdown
emkll Jan 15, 2020
e0a21c6
Address review comments:
emkll Jan 15, 2020
e3b3a3a
UI fixes: Remove redundant text box, hide buttons in-place, resize wi…
emkll Jan 15, 2020
ce048c7
Update text
emkll Jan 16, 2020
3d4ce23
Address review comments
emkll Jan 17, 2020
8ede5f4
Bug/UI fixes:
emkll Jan 17, 2020
2728e59
Edits mainly for brevity, formatting, punctuation tweaks
eloquence Jan 17, 2020
91efa24
Rename VMs based on latest changes
emkll Jan 20, 2020
d9a8d1f
Bugfix: Require a reboot if previous reboot was not performed
emkll Jan 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .circleci/config.yml
Expand Up @@ -13,10 +13,25 @@ jobs:
steps:
- checkout
- run: make dom0-rpm
launcher-tests-buster:
docker:
- image: circleci/python:3.7-buster
steps:
- checkout
- run:
name: Install dependencies and run Python tests for launcher
command: |
cd launcher/
set -e
virtualenv .venv
source .venv/bin/activate
pip install --require-hashes -r test-requirements.txt
make test && make bandit

workflows:
version: 2
securedrop_workstation_ci:
jobs:
- lint
- buildrpm
- launcher-tests-buster
1 change: 1 addition & 0 deletions dom0/sd-clean-all.sls
Expand Up @@ -20,6 +20,7 @@ remove-dom0-sdw-config-files:
- /usr/bin/securedrop-login
- /etc/qubes-rpc/policy/securedrop.Log
- /etc/qubes-rpc/policy/securedrop.Proxy
- /home/{{ gui_user }}/Desktop/securedrop-launcher.desktop

sd-cleanup-sys-firewall:
cmd.run:
Expand Down
25 changes: 25 additions & 0 deletions dom0/sd-dom0-files.sls
Expand Up @@ -167,3 +167,28 @@ dom0-tag-whonix-gw-15:
- tags:
- add:
- sd-workstation-updates

dom0-securedrop-launcher-directory:
file.recurse:
- name: /opt/securedrop/launcher
- source: "salt://launcher"
- user: root
- group: root
- file_mode: 644
- dir_mode: 755

dom0-securedrop-launcher-entrypoint-executable:
file.managed:
- name: /opt/securedrop/launcher/sdw-launcher.py
- user: root
- group: root
- mode: 755
- replace: false

dom0-securedrop-launcher-desktop-shortcut:
file.managed:
- name: /home/{{ gui_user }}/Desktop/securedrop-launcher.desktop
- source: "salt://securedrop-launcher.desktop"
- user: {{ gui_user }}
- group: {{ gui_user }}
- mode: 755
7 changes: 7 additions & 0 deletions dom0/securedrop-launcher.desktop
@@ -0,0 +1,7 @@
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=/usr/share/securedrop/icons/sd-logo.png
Name=SecureDrop Workstation Launcher
Copy link
Member

@eloquence eloquence Jan 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ninavizz and I would recommend changing this icon label simply to "SecureDrop". The preflight updater will or will not run in some situations (particularly if we get to #402), and from the user's standpoint, at this stage, they simply want to launch the SecureDrop app.

Exec=/opt/securedrop/launcher/sdw-launcher.py
25 changes: 25 additions & 0 deletions launcher/Makefile
@@ -0,0 +1,25 @@
.PHONY: update-pip-requirements
update-pip-requirements: ## Updates all Python requirements files via pip-compile.
pip-compile --allow-unsafe --generate-hashes --output-file=test-requirements.txt test-requirements.in

.PHONY: bandit
bandit:
bandit -ll --exclude ./.venv/ -r .

.PHONY: test
test:
pytest --cov-report term-missing --cov=sdw_updater_gui/ -v tests/

# Explanation of the below shell command should it ever break.
# 1. Set the field separator to ": ##" to parse lines for make targets.
# 2. Check for second field matching, skip otherwise.
# 3. Print fields 1 and 2 with colorized output.
# 4. Sort the list of make targets alphabetically
# 5. Format columns with colon as delimiter.
.PHONY: help
help: ## Prints this message and exits
@printf "Makefile for developing and testing SecureDrop Workstation.\n"
@printf "Subcommands:\n\n"
@perl -F':.*##\s+' -lanE '$$F[1] and say "\033[36m$$F[0]\033[0m : $$F[1]"' $(MAKEFILE_LIST) \
| sort \
| column -s ':' -t
50 changes: 50 additions & 0 deletions launcher/sdw-launcher.py
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
from logging.handlers import TimedRotatingFileHandler
from PyQt4 import QtGui
from sdw_updater_gui.UpdaterApp import UpdaterApp
import logging
import os
import sys

DEFAULT_HOME = os.path.join(os.path.expanduser("~"), ".securedrop_launcher")
logger = ""


def main():
configure_logging()
logger = logging.getLogger(__name__)
logger.info("Starting SecureDrop Launcher")
app = QtGui.QApplication(sys.argv)
form = UpdaterApp()
form.show()
sys.exit(app.exec_())


def configure_logging():
"""
All logging related settings are set up by this function.
"""
log_folder = os.path.join(DEFAULT_HOME, "logs")
if not os.path.exists(log_folder):
os.makedirs(log_folder)

log_file = os.path.join(DEFAULT_HOME, "logs", "launcher.log")

# set logging format
log_fmt = (
"%(asctime)s - %(name)s:%(lineno)d(%(funcName)s) " "%(levelname)s: %(message)s"
)
formatter = logging.Formatter(log_fmt)

handler = TimedRotatingFileHandler(log_file)
handler.setFormatter(formatter)
handler.setLevel(logging.INFO)

# set up primary log
log = logging.getLogger()
log.setLevel(logging.INFO)
log.addHandler(handler)


if __name__ == "__main__":
main()