Development of SecureDropUpdater in the journalist_gui Directory

The SecureDropUpdater is a tool used by the journalists and admins, this tool helps them to update their SecureDrop git repository to the latest released tag. It is a GUI tool and it is written using PyQt5 bindings of the Qt framework. This tool is written using Python3.

Installing the Dependencies in a Virtual Environment

You can use Python’s built-in venv module to install the dependencies in a virtual environment. From the journalist_gui directory:

$ python3 -m venv .venv && source .venv/bin/activate
$ pip install --require-hashes -r dev-requirements.txt

The first command will create a virtual environment and activate it. The second command will install the dependencies, using the exact hashes specified in dev-requirements.txt. Make sure you are using at least Python 3.8.

Note

The Updater GUI does not use a virtual environment on the Tails Workstations. As such, you can only use dependencies present in Tails.

You can run the GUI via:

$ python3 SecureDropUpdater

Note that since the application expects to run in Tails, you should test its functionality in a Tails VM. You can follow the instructions in the Virtualizing Tails guide to set up your Tails VM.

To Update the UI Design

The design of the GUI is saved in the journalist_gui/mainwindow.ui file. To update the UI, one has to first install qtcreator tool in the system. We are currently using 5.10.1 version of Qt for this project.

$ sudo apt install qtcreator python3-pyqt5

If we make any changes to the UI, we will have to use pyuic5 command to update the corresponding Python code.

$ pyuic5 journalist_gui/mainwindow.ui -o journalist_gui/updaterUI.py

Using Resources in the UI

All icons and images for the UI is stored in the journalist_gui/static directory. These are known as resources for the project. The journalist_gui/resources.qrc file contains the list of current resources for the project. Each resource needs to be defined inside of a <file></file>.

Example qrc file:

<RCC>
    <qresource prefix="/images">
        <file>static/securedrop.png</file>
        <file>static/securedrop_icon.png</file>
    </qresource>
</RCC>

We will have to update the corresponding Python file for any change in this resource file. We can do that using the following command:

$ pyrcc5 journalist_gui/resources.qrc -o journalist_gui/resources_rc.py

Note

The updaterUI.py and resources_rc.py files are generated by the tools. So, do not make any changes to these files. Any changes made to these files will be overridden.

Warning

As a reviewer of a PR involving changes to this resource file, you should verify the changes to the file by running pyrcc5 locally.

Adding and Running Test Cases

We have Python unit tests in the test_gui.py file. Any change in the actual application code will also require adding new test cases or updating the old ones. You can run the tests using the following command:

$ python3 test_gui.py