Commit graph

897 commits

Author SHA1 Message Date
deeplow
1837c826a6
Fix Qubes section from INSTALL.md
In Qubes by default the conversion happens in containers just like
other systems. This removes the mention that it used VMs by default.
2023-08-07 19:02:58 +01:00
deeplow
e8b28d6f87
Explicitly import html.parser for Cx_Freeze to build
The markdown dependency uses importlib to monkeypatch 'html.parser'
[1]. Due to this approach 'html.parser' is never explicitly stated
as a dependency. This works fine in most cases, since it's part of
the python standard lib. But on Windows the build tool (CxFreeze)
ships in the .exe only the modules needed. And because html.parser
is never mentioned, it fails with an error (see issue #501).

Fixes #501

[1]: https://github.com/Python-Markdown/markdown/blob/master/markdown/htmlparser.py#L29
2023-08-05 17:09:42 +01:00
deeplow
b7e212efd9
Add python3-pyside2.qtsvg dependency to debian builds
When the updater was added in commit 5b17f75047 [1], it it had missed
the dependencies on Debian.

[1]: 5b17f75047
2023-08-05 17:02:54 +01:00
deeplow
356f835d32
env.py: make env run in GUI mode (--no-gui otherwise)
Now that we have GUI tests, it makes more sense to have running with
the X11 socket mounted in the environment than not.
2023-08-05 17:02:26 +01:00
Alex Pyrgiotis
e3a8a651f1
Disable HWP / HWPX conversion on MacOS M1 / Qubes
The HWP / HWPX conversion feature does not work on the following
platforms:

* MacOS with Apple Silicon CPU
* Native Qubes OS

For this reason, we need to:

1. Disable it on the GUI side, by not allowing the user to select these
   files.
2. Throw an error on the isolation provider side, in case the user
   directly attempts to convert the file (either through CLI or via
   "Open With").

Refs #494
Refs #498
2023-08-05 16:50:49 +01:00
Alex Pyrgiotis
bc83341d2a
conversion: Detect when LibreOffice silently fails
Sometimes, LibreOffice returns with status code 0, but in reality, it
fails. It doesn't create a file, and Dangerzone does not detect this.
What happens next is that it fails in the next command, and throws an
unrelated error.

Detect that LibreOffice fails, by checking if the output file exists,
after the PDF conversion.
2023-08-05 16:50:47 +01:00
Alex Pyrgiotis
6736fb0153
Factor out MIME type detection
Factor out the MIME type detection logic, so that we can use it both in
Qubes and containers.
2023-08-05 16:50:35 +01:00
Alex Pyrgiotis
03df60db5f
Always pull base image when building ours
Always pull the base container image (alpine:latest) before building our
own container image. Else, in an environments that we haven't touched
for a while, an older image may be used.
2023-08-02 13:47:59 +03:00
Alex Pyrgiotis
0296844e36
Bump version to 0.4.2 2023-08-02 13:43:05 +03:00
Alex Pyrgiotis
4828299c99
Update changelog 2023-08-02 13:43:04 +03:00
Alex Pyrgiotis
664e0c1477
Update our release instructions
Update our release instructions in the following ways:

1. Make sure to check the Python dependencies / version before the
   release.
2. Make sure to upload the final container.tar.gz image as a release
   artifact.
2023-08-02 13:43:03 +03:00
deeplow
e2718c6f64
Update changelog with HWP support 2023-08-01 14:37:15 +01:00
Moon Sungjoon
075475c306
Add test files for hwp/hwpx (base64 encoded)
Add extra files and base64 encode externally contributed docs. This
prevents the accidental opening of such documents, since they couldn't
be rebuit by the Dangerzone developers to ensure their safety.
2023-08-01 14:37:14 +01:00
Moon Sungjoon
fa22e96af7
Clean up HWP/HWPX MIME types
Use the MIME types actually used by the `file` command, which was
recently changed for the detection of the HWPX format [1].

application/hwp+zip -> application/x-hwp+zip

But the HWPX format includes a 'mimetype' file, which contains the
MIME type string "application/hwp+zip", so that was left so because
it may be possible to detect it as "application/hwp+zip".

[1]: ceef7ead3a
2023-08-01 14:35:28 +01:00
Moon Sungjoon
a453c890a0
Fix dynamic loading of LibreOffice extensions
HWPX MIME type is recognized as 'application/zip' with current version of file command (file-5.44).
It will be recognized as 'application/hwp+zip' when new version of file is released.

For a temporary fix, when MIME type of file is 'application/zip',
check the file type again (without the MIME option).
And then check if it's 'Zip data (MIME type "application/hwp+zip"?)' or not.
2023-08-01 14:28:36 +01:00
deeplow
d16961bed6
Security: Dynamically load libreoffice extension (PoC)
Only load the LibreOffice extension for opening hwp/hwpx when it is
actually needed. Adding an extension to libreoffice may allow for it to
run arbitrary code. This makes it trust more scalable by trusting
LibreOffice extensions only for the filetypes which they target.

Reasoning
---------

Assuming a malicious `.oxt` extension this means that the extension has
arbitrary code execution in the container. While this is not an
existential threat in itself, we should not expose every Dangerzone user
to it. This is achieved by dynamically loading the extension at runtime
only when needed.

This ensures that a compromised extension will in its least malicious
form be able to modify the visual content of any hancom office files but
not *every file*. In the more malicious version, if the code execution
manages to do a container escape, this will only affect users that have
converted a Hancom office file.
2023-08-01 14:28:34 +01:00
Moon Sungjoon
3e895adbab
Add hwp hwpx support
hwp/hwpx has several custom MIME types

.hwp:
 - application/x-hwp
 - application/haansofthwp
 - application/vnd.hancom.hwp

.hwpx:
 - application/haansofthwpx
 - application/vnd.hancom.hwpx,
 - application/hwp+zip

Fixes #243
2023-08-01 14:27:18 +01:00
Moon Sungjoon
d8cc24cebe
container: Add H2ORestart for HWP/HWPX support
H2ORestart is a LibreOffice extension which adds Hancom HWP/HWPX (Hangul Word Processor)
supports for LibreOffice. This format is widely used in South Korea.

Version: v0.5.7
Extension Repository: https://github.com/ebandal/H2Orestart/releases
2023-08-01 14:07:51 +01:00
Alex Pyrgiotis
76a1a885f5
Force Podman use the overlay storage driver
Force Podman to use the overlay storage driver in our Dangerzone
environments. We have seen that in certain cases, Podman may opt to use
the vfs storage driver instead, which is more space-intensive.

Closes #489
2023-08-01 15:18:24 +03:00
Alex Pyrgiotis
6c374d8a7e
qubes: Mark Dangerzone messages as trusted
Mark the messages that Dangerzone creates once a conversion step
finishes as trusted, since they do not contain any string not controlled
by us.
2023-08-01 14:43:49 +03:00
deeplow
72536a05ac
container: Improve parsing of progress reports
Improve the `parse_progress()` method of the container isolation
provider in the following ways:

1. Make sure that the fields of the progress report have the expected
   type.
2. In case of a JSON parsing error, sanitize the invalid string so that
   it doesn't contain escape sequences, or the user considers it as
   trusted.
2023-08-01 14:43:49 +03:00
Alex Pyrgiotis
9410b68c1d
Sanitize progress reports in a provider-agnostic way
Update the common `print_progress()` method in the base
`IsolationProvider` class, with two extra features:

1. Always sanitize the provided text argument.
2. Mark the sanitized text argument as untrusted.

This is default behavior from now on, since this function is commonly
used to parse progress reports from the conversion sandbox.
2023-08-01 14:43:48 +03:00
Alex Pyrgiotis
cfa0c01d8f
Sanitize filenames before logging them
Sanitize filenames in various places in the code, before we write them
to the user's terminal. Filenames, especially in Linux, can contain
virtually any character except for '\0' and '/', so it's important to
sanitize them.
2023-08-01 14:43:48 +03:00
deeplow
3788139d26
Add utility for sanitizing strings
Add `replace_control_chars()` function in `util.py`, which can be used
to sanitize strings from ANSI escape sequences or weird Unicode symbols.
2023-08-01 14:43:48 +03:00
Alex Pyrgiotis
cb08c198ad
Force rendering of error messages as plain text
Make the `error_label` widget always render messages as plain text,
instead of auto discovering if the text is rich. We need this because
the error message may contain input from the sandbox, which we consider
untrusted.
2023-08-01 14:43:48 +03:00
Alex Pyrgiotis
a72a31980d
Run GUI tests on separate processes
Run our GUI tests on separate processes, because the combination of
Ubuntu Focal, Qt5, PySide6, and pytest-qt somehow leads to segfaults,
probably due to stale global state.

Closes #493
2023-08-01 14:43:42 +03:00
Alex Pyrgiotis
77f4b8115c
Add missing reset ANSI sequence
Do not forget to reset the red text once we print an error string to the
terminal
2023-08-01 14:38:32 +03:00
Alex Pyrgiotis
9768714b4a
Make isort compatible with Black
The isort tool is not compatible with Black by default. This leads to a
tug of war between these tools, when we run `make lint-apply` -> `make
lint`. Fix this by forcing isort to be compatible with Black.
2023-08-01 14:38:32 +03:00
Alex Pyrgiotis
81811e0aac
Add collapsible dialog for errors
Move the error message from a text browser to a collapsible widget.
2023-08-01 14:29:27 +03:00
deeplow
53ec1cad63
Add update error red dot to hamburger menu 2023-08-01 14:29:11 +03:00
Alex Pyrgiotis
c9eac42855
Improve updater messages
Improve the wording of updater messages for better UX.
2023-08-01 14:29:10 +03:00
Alex Pyrgiotis
d5ca6bb422
updater: Move "Ok" button to the right
Move the "Ok" button in the prompt that asks users if they want to
enable update checks to the right, to further reinforce that this is
the default action.
2023-07-28 19:57:46 +03:00
Alex Pyrgiotis
bc4bba4fa1
tests: Add full test coverage for updater checks
Fully test the update check logic, by introducing several Qt tests.
Also, improve the `UpdaterThread.get_letest_info()` method, that gets
the latest version and changelog from GitHub, with several checks.
These checks are also tested in our newly added tests.
2023-07-28 12:18:59 +03:00
Alex Pyrgiotis
fdc53efc35
tests: Test our own custom QApplication
By default, `pytest-qt` initializes the default QApplication class that
PySide offers. Dangerzone, however, defines its own QApplication
subclass.

Create a `qapp_cls` fixture that will force `pytest-qt` to use this
subclass. For more info, see:
https://pytest-qt.readthedocs.io/en/latest/qapplication.html#testing-custom-qapplications
2023-07-28 12:18:58 +03:00
Alex Pyrgiotis
24ba914cc8
updater: Differentiate between "X" and "Cancel"
We want to differentiate between the user clicking on "Cancel" and
clicking on "X", since in the second case, we want to remind them again
on the next run.
2023-07-28 11:50:44 +03:00
Alex Pyrgiotis
f6b5e1293d
gui: Add references to dialog buttons
Add references to dialog buttons, so that we can click on them from our
GUI tests.
2023-07-28 11:50:44 +03:00
Alex Pyrgiotis
a2177bfd34
Remove some stale FIXMEs 2023-07-28 11:50:44 +03:00
Alex Pyrgiotis
8d86b0a15f
Rename "Changelog" to "What's new" 2023-07-28 11:50:43 +03:00
Alex Pyrgiotis
b4bcd833e6
Force text color to be black 2023-07-28 10:41:01 +03:00
Alex Pyrgiotis
c541227dd3
Drop Ubuntu 22.10 (Kinetic Kudu) support
Drop support for Ubuntu 22.10 (Kinetic Kudu), because it's past its EOL
date [1].

Closes #485

[1]: https://endoflife.date/ubuntu
2023-07-28 10:40:04 +03:00
deeplow
f66375bd44
Add QA instructions for Qubes alpha support 2023-07-26 14:03:15 +01:00
deeplow
1ab14dbd86
Use containers in Qubes until Beta
Reverse the logic in Qubes to run in containers by default and only
perform the conversion with VMs when explicitly set by the env var
QUBES_CONVERSION=1. This will avoid surprises when someone installs
Dangerzone on Qubes expecting it to work out of the box just like any
other Linux.

Fixes #451
2023-07-26 14:02:06 +01:00
deeplow
8b8f2a207c
Remove remains of parallel tests completely
Parallel tests had given us issues in the part [1]. This time, they
weren't playing well with pytest-qt. One hypothesis is that Qt
application components run as singletons and don't play well when there
are two instances.

The symptom we were experiencing was infinite recursion and removing
pytest-xdist solved the issue.

[1]: https://github.com/freedomofpress/dangerzone/issues/217
2023-07-25 15:17:24 +01:00
deeplow
8254844724
Pass sample_pdf as fixture instead of via class
Now that sample_doc was renamed to sample_pdf it could cause some
confusion the fact that that the TestBase class had an attribute called
sample_doc which referenced  the sample PDF.

By removing this attribute and passing the fixture instead we are
following a more pytest-native approach of passing arguments explicitly.
2023-07-25 15:00:32 +01:00
deeplow
6216761058
remove number from test_doc2 variable
create a pytest fixture for a .doc file and .pdf file
2023-07-25 15:00:31 +01:00
deeplow
9ca27fd6fe
Add unit test to document change button
Fixes #428
2023-07-25 15:00:29 +01:00
deeplow
250a481f31
Store ref file_selection dialog
Allow an outside module (e.g. tests) to be able to "grab" the document
selection dialog.
2023-07-25 15:00:27 +01:00
deeplow
2bd97a036a
Add logic to handle documents removal
This implements the backend part of changing documents.
2023-07-25 15:00:12 +01:00
deeplow
d0c86fbbe2
Add change docs button to settings window
Implements the GUI logic necessary to change the selected document. When
"Change Selection" is clicked, it opens a File Dialog on the directory
of the previously selected files (if any)

Fixes #428
2023-07-25 13:44:26 +01:00
Alex Pyrgiotis
a478d14025
Update Poetry lock file
Run `poetry lock` and update the existing dependencies.

Closes #480
Closes #482
2023-07-25 15:02:44 +03:00