Commit graph

885 commits

Author SHA1 Message Date
Alex Pyrgiotis
0e3255d091
share: Add hamburger menu status icons
Add three status icon for the hamburger menu:

* hamburger_menu.svg: The typical hamburger menu. Taken from
  https://commons.wikimedia.org/wiki/File:Hamburger_icon.svg, which is
  in the public domain.
* hamburger_menu_update_error.svg: A hamburger menu with a red
  notification bubble on the top right corner.
* hamburger_menu_update_success.svg: A hamburger menu with a green
  notification bubble on the top right corner.
2023-07-24 14:22:27 +03:00
Alex Pyrgiotis
47171a2722
tests: Add tests for update logic 2023-07-24 14:22:27 +03:00
Alex Pyrgiotis
f6e945805e
tests: Add a Pytest fixture for Updater
Add a Pytest fixture that returns an UpdaterThread instance which has
its own unique settings directory. Note that the UpdaterThread instance
needs to be slightly nerfed, so that it doesn't rely on Qt functionality
or any isolation providers.
2023-07-24 14:22:27 +03:00
Alex Pyrgiotis
5ae8b871b6
Add UpdaterThread class
Add a new Python module called "updater", which contains the logic for
prompting the user to enable updates, and checking our GitHub releases
for new updates.

This class has some light dependency to Qt functionality, since it needs
to:

* Show a prompt to the user,
* Run update checks asynchronously in a Qt thread,
* Provide the main window with the result of the update check

Refs #189
2023-07-24 14:22:27 +03:00
Alex Pyrgiotis
0ad489f80b
Get default settings without Settings instance
Get the default settings of Dangezone for the current version, without
having to instantiate the Settings class. Note that instantiating the
Settings class also writes the settings to the underlying
`settings.json` file, and there are cases where we don't want this
behavior.
2023-07-24 14:22:26 +03:00
Alex Pyrgiotis
266addb5b7
Make it easier to get and save updater settings
Add the following two features in the Settings class:

1. Add a way to save the settings, if the contents of a key have
   changed.
2. Add a way to get all the updater settings, by getting fetching the
   keys that start with `"updater_"`.
2023-07-24 14:22:26 +03:00
Alex Pyrgiotis
2df459bcfc
Add default settings for Dangerzone updater
Add some settings prefixed with `"updater_"`, which will be used for
updates later on.
2023-07-24 14:22:26 +03:00
Alex Pyrgiotis
a1e3cb27a7
ci: Pass X11 socket to tests
Pass the X11 socket of the Linux CI runners to the container where our
CI tests run, with the `-g` flag of `dev_scripts/env.py`. By having a
working X11 socket, we can run GUI tests. Prior to this fix, we would
encounter this error:

    tests/gui/test_main_window.py::test_change_document_button qt.qpa.xcb: could not connect to display
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

    Available platform plugins are: xcb, offscreen, wayland-egl, wayland, eglfs, vnc, minimalegl, vkkhrdisplay, linuxfb, minimal.

Another alternative we considered was to use the
`QT_QPA_PLATFORM=offscreen` environment variable. This alternative
works, but it's less close to the end-user's environment, so we decided
in favor of the approach above.
2023-07-24 14:22:26 +03:00
Alex Pyrgiotis
f58e31efe6
Run tests sequentially
Run tests sequentially, because in subsequent commits we will add
Qt tests that do not play nice when `pytest` creates new processes [1].

Also, remove the pytest wrapper, whose main task was to decide if tests
can run in parallel [2].

[1]: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2393
[2]: https://github.com/freedomofpress/dangerzone/issues/217
2023-07-24 14:22:26 +03:00
Manil Chowdhury
a1bbcdf2b6
Fix typos, clarify steps 2023-07-14 15:21:48 +03:00
Manil Chowdhury
680c57b8c5
Add to FAQ: suggest updating app
Maintainers have indicated preference for encouraging users to update app version rather than use workarounds to fix issues.
2023-07-14 15:21:48 +03:00
Manil Chowdhury
6926444c88
Add note for MacOS 11+ users blocked by SIP
A workaround to an issue related to SIP imposed on Docker has been identified in #371. Update README.md to include friendly instructions for MacOS 11+ users blocked by this issue.
2023-07-14 15:21:47 +03:00
deeplow
ef41cab76e
Add progress reports on Qubes (GUI)
Fixes #429
2023-07-13 12:57:23 +01:00
deeplow
bf38c24d99
Merge stdout_callback with print_progress
stdout_callback is used to flow progress information from the conversion
to some front-end. It was always used in tandem with printing to the
terminal (which is kind of a front-end). So it made sense to put them
always together.
2023-07-13 12:57:04 +01:00
deeplow
206c262554
Bump python version on Windows to 3.11
Python 3.10.12 fixes some CVEs for which Dangerzone does not appear to be
affected, however its binaries are not made available by the python
foundation. Moving to 3.11 should be trivial since this was already
deployed in Fedora 37+.
2023-07-06 14:32:31 +01:00
deeplow
e989069712
Add ubuntu 23.04 (lunar) support
The Ubuntu 23.04 docker image includes a user by default (ubuntu) which
overtakes the 1000 uid and so our user becomes 1001 which makes the user
directory unwritable. The solution as suggested in [1] was to remove
that user.

[1]: https://bugs.launchpad.net/cloud-images/+bug/2005129

Fixes #452
2023-06-28 11:07:59 +01:00
deeplow
e773add68e
Adds support for Debian Trixie (13)
Fixes #452
2023-06-28 11:05:47 +01:00
Moon Sungjoon
5b58576854
Add --no-cache on the apk install option 2023-06-26 20:02:58 +03:00
Alex Pyrgiotis
20b24a6c71
Add development instructions for Qubes integration
Add instructions aimed at developers who want to try out Qubes
integration.

Fixes #411
2023-06-21 15:06:22 +03:00
deeplow
a1d40fde78
Create an RPM for Qubes
Allow creating an RPM package that is to be installed specifically on
Qubes. This package has the following extra properties from our regular
RPM packages:

1. Make `python3-magic`, `libreoffice` and `tesseract` requirements
   for installing Dangerzone, since the conversion takes place in a
   disposable qube that needs these packages.
2. Ignore the container.tar.gz file, if it exists.
3. Add our RPC calls under `/etc/qubes-rpc`
2023-06-21 11:46:43 +03:00
deeplow
5191556dcd
Use the Qubes isolation provider from CLI/GUI
Autodetect in the CLI/GUI if we should run the conversion in disposable
qubes.
2023-06-21 11:46:43 +03:00
deeplow
baeab9d7eb
Add Qubes isolation provider
Add an isolation provider for Qubes, that performs the document
conversion as follows:

Document to pixels phase
------------------------

1. Starts a disposable qube by calling either the dz.Convert or the
   dz.ConvertDev RPC call, depending on the execution context.
2. Sends the file to disposable qube through its stdin.
   * If we call the conversion from the development environment, also
     pass the conversion module as a Python zipfile, before the
     suspicious document.
3. Reads the number of pages, their dimensions, and the page data.

Pixels to PDF phase
-------------------

1. Writes the page data under /tmp/dangerzone, so that the
   `pixels_to_pdf` module can read them.
2. Pass OCR parameters as envvars.
3. Call the `pixels_to_pdf` main function, as if it was running within a
   container. Wait until the PDF gets created.
4. Move the resulting PDF to the proper directory.

Fixes #414
2023-06-21 11:46:34 +03:00
Alex Pyrgiotis
c194606550
Add Qubes RPC calls
Add two RPC calls that can run on disposable VMs:

* dz.Convert: This call simply imports the dangerzone package and runs
  the Qubes wrapper for the "document to pixels" code. This call is
  similar to the way we run the conversion part in a container.
* dz.ConvertDev: This call is for development purposes, and does the
  following:
  - First it receives the `dangerzone.conversion` module as Python
    zipfile. This way, we can quickly iterate on changes on the
    server-side part of Qubes, without altering the templates.
  - Second, it calls the Qubes wrapper for the "document to pixels"
    code, as dz.Convert does.
2023-06-21 11:45:08 +03:00
deeplow
a83f5dfc7a
Add Qubes-specific code for disposable VMs
The "document to pixels" code assumes that the client has called it with
some mount points in which it can write files. This is true for the
container isolation provider, but not for Qubes, who can communicate
with the client only via stdin/stdout.

Add a Qubes wrapper for this code that reads the suspicious document
from stdin and writes the pages to stdout. The on-wire format is the
same as the one that TrustedPDF uses.
2023-06-21 11:45:04 +03:00
Alex Pyrgiotis
cfdaec23c5
Support multiple Python libraries for libmagic
It seems that there are at least two Python libraries with libmagic
support:

* PyPI: python-magic (https://pypi.org/project/python-magic/)
  On Fedora it's `python3-magic`
* PyPI: filemagic (https://pypi.org/project/filemagic/)
  On Fedora it's `python3-file-magic`

The first package corresponds to the `py3-magic` package on Alpine
Linux, and it's the one we install in the container. The second package
uses a different API, and it's the only one we can use on Qubes.

To make matters worse, we:

* Can't install the first package on Fedora, because it installs the
  second under the hood:
  https://bugzilla.redhat.com/show_bug.cgi?id=1899279
* Can't install the second package on Alpine Linux (untested), due to
  Musl being used instead of libC:
  https://stackoverflow.com/a/53936722

Ultimately, we need to support both, by trying the first API, and on
failure using the other API.
2023-06-21 11:45:00 +03:00
deeplow
9410da762c
Check if conversion code runs on Qubes
Add a way to check if the code runs (or should run) on Qubes.

Refs #451
2023-06-21 11:44:58 +03:00
deeplow
a0d1a68302
Use /tmp/dangerzone for Qubes compatibility
For using in containers, creating a /dangerzone directory is fine but it
is more standard to do this in /tmp.
2023-06-21 11:44:53 +03:00
deeplow
814d533c3b
Restructure container code
The files in `container/` no longer make sense to have that name since
the "document to pixels" part will run in Qubes OS in its own virtual
machine.

To adapt to this, this PR does the following:
- Moves all the files in `container` to `dangerzone/conversion`
- Splits the old `container/dangerzone.py` into its two components
  `dangerzone/conversion/{doc_to_pixels,pixels_to_pdf}.py` with a
  `common.py` file for shared functions
- Moves the Dockerfile to the project root and adapts it to the new
  container code location
- Updates the CircleCI config to properly cache Docker images.
- Updates our install scripts to properly build Docker images.
- Adds the new conversion module to the container image, so that it can
  be imported as a package.
- Adapts the container isolation provider to use the new way of calling
  the code.

NOTE: We have made zero changes to the conversion code in this commit,
except for necessary imports in order to factor out some common parts.
Any changes necessary for Qubes integration follow in the subsequent
commits.
2023-06-21 11:44:47 +03:00
Alex Pyrgiotis
9a45bc12c5
ci: Fix CI races in Debian Bullseye tests 2023-06-07 10:54:37 +03:00
Alex Pyrgiotis
a2506e6968
ci: Ignore CVE-2023-28322 from security scans
Ignore CVE-2023-28322 from our security scans, because it targets
`libcurl`, which is not used/exploitable in our offline container.
2023-06-06 12:15:34 +03:00
Alex Pyrgiotis
3f3d0be2b4
ci: Test building a .deb and installing it
Update our GitHub Actions workflow with the following tests:

1. Build a .deb for Dangerzone on Debian Bookworm.
2. Install this .deb on every Debian-based platform that we support.
3. Test that the installed version runs successfully.

This way, we can be sure that .deb that we create on a single Debian
version (here we choose Debian Bookworm) works on all platforms.

Refs #358
2023-05-25 07:55:19 +03:00
Alex Pyrgiotis
517d3b58f8
dev_scripts: Map host user UID to container UID 1000
When we run our Dangerzone environments through dev_scripts/env.py, we
use the Podman flag `--userns keep-id`. This option maps the UID in the
host to the *same* UID in the container. This way, the container can
access mounted files from the host.

The reason this works is because the user within the container has UID
1000, and the user in the host *typically* has UID 1000 as well. This
setup can break though if the user outside the host has a different UID.
For instance, the UID of the GitHub actions user that runs our CI
command is 1001.

To fix this, we need to always map the host user UID (whatever that is)
to container UID 1000. We can achieve this with the following mapping:

  1000:0:1         # Map container UID 1000 to subordinate UID 0
                   # (sub UID 0 = owner of the user ns = host user UID)
  0:1:1000         # Map container UIDs 0-999 to subordinate UIDs 1-1000
  1001:1001:64536  # Map container UIDs 1001-65535 to subordinate UIDs 1001-65535

Refs #228
2023-05-25 07:55:19 +03:00
Alex Pyrgiotis
91f8f8b387
ci: Install recommended Podman packages
In Debian-based images, there are some Podman dependencies that are
marked as recommended, but are essential for rootless containers. These
dependencies will not be installed in our Dangerzone environments, due
to the `--no-install-recommends` flag.

Our approach was to find these dependencies through trial and error,
and hardcode them in our image. Turns out though that there are some
dependencies (e.g., `netavark`) that may be necessary in some Debian
flavors, and not others.

In order to not impact the readability of the env.py file, we prefer
installing Podman with all of its recommended packages. On one hand,
this will make the image size of our Debian-based Dangerzone
environments slightly larger, but on the other hand, it will make CI
tests less flaky.
2023-05-25 07:51:02 +03:00
Alex Pyrgiotis
14063349bb
ci: Fix transient errors in Debian Bullseye
Fix transient errors in Debian Bullseye CI tests by using a different
machine image (Ubuntu 22.04 vs Ubuntu 20.04), and solving some Podman
config issues along the way.

Fixes #388
2023-05-24 13:45:56 +03:00
Alex Pyrgiotis
641aa131c9
ci: Add test for OCR languages
Test that the languages that we provide to users for OCR match the
languages that are installed in the container image

Fixes #417
2023-05-24 13:43:29 +03:00
Alex Pyrgiotis
5bd609781d
Remove Kurdish (Arabic) language
Remove the Kurdish (Arabic) language ("kur_ara") from the list of
languages that we offer for OCR, since it's not included in the
installed languages.

Interestingly, it is not present in the Apline Linux repos as well, so
this was probably an omission in the first place.
2023-05-24 13:43:29 +03:00
Alex Pyrgiotis
35e439f9e8
Restore the OCR languages
Restore the OCR languages to the state they were in
66d3c40163, with some minor changes. We
can now do so because we download all the trained models, not just the
ones that Alpine Linux offers.
2023-05-24 13:43:29 +03:00
Alex Pyrgiotis
a0d6f0d719
container: Grab trained OCR models from GitHub
Grab Tesseract's trained models from GitHub, instead of from the Alpine
Linux repos. Over the past few months, the models in the Alpine Linux
repos did not remain stable, leading to CI issues.

Since the models are already pre-trained and available through
Tesseract's repo on GitHub, we can use the release tarball that they
offer to install them in the container image, which is basically what
the upstream packages are doing as well.

In order to make sure that we have no regressions, at the time of this
commit we ensured that the hashes of the models offered through the
Alpine Linux repos and the models offered from the GitHub release are
the same. Also, in order to detect future regressions or foul play, we
check the downloaded models against a known checksum. Given that these
models change every few years, updating the checksum should not be an
issue.

Fix #357
2023-05-23 16:27:40 +03:00
deeplow
8059c8e1f1
Deprecate Fedora 36 support
Fixes #420
2023-05-23 09:22:59 +01:00
deeplow
09a0e51c3f
Sync qa.py and README (missed on PR#416) 2023-05-18 12:38:52 +01:00
Alex Pyrgiotis
3d822e1aa3
container: Install a renamed package
The tesseract-ocr-data-ell package for the Greek language has been
renamed to tesseract-ocr-data-grc. Use the new name in our Dockerfile.
2023-05-17 20:29:13 +03:00
Alex Pyrgiotis
8b2c5bba75
ci: Ignore two CVEs from our security scans
Ignore two CVEs from our security scans, which were triggered when
scanning the Dangerzone container image for v0.4.1. These CVEs do not
affect out users, and we offer an explanation why.
2023-05-17 20:29:13 +03:00
Alex Pyrgiotis
75be9b5c00
ci: Add security scanning
Add two GitHub Actions workflows, that perform the following checks:

* Security scan the Python dependencies of the Dangerzone application
  (`poetry.lock`), for the current/main branch.
* Build and security scan the Dangerzone container image for the
  current/main branch.
* Security scan the Python dependencies of the Dangerzone application
  (`poetry.lock`), for the latest release of Dangerzone (currently
  v0.4.1).
* Download and security scan the Dangerzone container image for the
  latest release of Dangerzone (currently v0.4.1).

The first two checks will run on branch pushes, PRs, and nightly. The
last two checks will run only nightly, since the code in the current
branch cannot affect already released artifacts.

Also, besides the security scans, these workflows will also update the
Security alerts in the GitHub page for the Dangerzone project, and print
the SARIF report to the stdout, for debugging purposes.

Closes #222
2023-05-17 20:29:13 +03:00
Chris Kerr
1a82962224
Fix typo
"keying" -> "keyring"

Signed-off-by: deeplow <deeplower@protonmail.com>
2023-05-17 08:52:34 +01:00
Alex Pyrgiotis
558b4bffea
Update changelog for Fedora 38 2023-05-16 16:20:32 +03:00
Alex Pyrgiotis
f4b29b72fc
Add support for Fedora 38 in the QA script
Update the release instructions and the QA script to support Fedora 38.
2023-05-16 16:20:32 +03:00
Alex Pyrgiotis
739ef87d6c
ci: Add checks for Fedora 38
Update our CircleCI config with checks for Fedora 38:

* Build RPMs
* Run tests
2023-05-16 16:20:32 +03:00
sudwhiwdh
f8f9cf304e
fix gui typo 2023-05-08 12:53:09 +01:00
Erik Moeller
8bdafce660
Appease linter 2023-04-24 11:50:58 +03:00
Alex Pyrgiotis
1ae7581df6
Use a different certificate for MacOS
Replace our reference to an Apple development certificate with a
Developer ID Application certificate. The former is not accepted during
the code notarization phase, whereas the latter is.
2023-04-24 11:50:58 +03:00