Commit graph

1217 commits

Author SHA1 Message Date
Alex Pyrgiotis
88a2d151ab
Update changelog entries 2024-05-09 17:36:05 +03:00
Alex Pyrgiotis
a8e51c17d9
Install Python from python.org
Add a note in our release instructions to install Python from
python.org. This should fix some incompatibilities with older macOS
versions.

Refs #471
2024-05-09 17:36:04 +03:00
Alex Pyrgiotis
8c59589be1
Inform users about Pyside6 and conmon packages
Inform users that for specific distros and versions, we install some
extra packages (PySide6, conmon), in order to fix some incompatibilities
between Dangerzone and the base system. Provide also a link to the
source / build instructions for the package, as well as any relevant
issues.

Fixes #767
2024-05-09 17:36:04 +03:00
Alex Pyrgiotis
341e29c0e3
Make our collapsible blocks more noticable
Make our collapsible blocks in our instructions more noticeable, by
enclosing them in an HTML table (<table>).
2024-05-09 17:36:04 +03:00
Alex Pyrgiotis
d55dee2f37
Add user instructions for verifying our signatures
Add a section for our end-users in INSTALL.md, that explains how to
verify that our Dangerzone assets have been signed by our advertised
signing key.

This section explains what are the .asc files that users see next to our
release assets, and how they can verify each asset individually using
GPG. It is heavily inspired by a similar section for OnionShare.

Closes #761
2024-05-09 17:36:04 +03:00
Alex Pyrgiotis
83c165ae33
dev_scripts: Sign our assets and calculate their hashes
Add a new script called `sign-assets.py`, which produces the hash of all
the Dangerzone assets for a release (Windows/macOS installers, container
image), and signs them individually.

Also update our RELEASE.md document, to incorporate this script into our
release workflow.
2024-05-09 17:32:07 +03:00
Alex Pyrgiotis
f6a39ec140
Add some extra entries to the 0.6.1 changelog 2024-05-09 16:46:16 +03:00
Alex Pyrgiotis
549ed23193
dev_scripts: Fix bug during env build
Create the build directory first, and then add the PySide6 package in
it.
2024-05-09 16:46:16 +03:00
Alex Pyrgiotis
b97e9540c1
Fix minor typos in RELEASE.md 2024-05-09 16:46:16 +03:00
Alex Pyrgiotis
ff25fa3045
Fix stuck conversion processes
Gracefully terminate certain conversion processes that may get stuck
when writing lots of data to stdout. Also, handle a race condition when
a conversion process terminates slightly after the associated container.

Fixes #791
2024-05-09 16:46:15 +03:00
Alex Pyrgiotis
0557e34429
Exclude Dangerzone from the discovered PDF viewers
We have recently [1] changed the name of the Dangerzone application to
capital-case "Dangerzone", but this breaks our PDF viewer detection
logic. Adjust our check to exclude Dangerzone from the list.

Fixes #790

[1]: See commit 3d426ed36b
2024-05-09 15:57:42 +03:00
Alex Pyrgiotis
37bf9badf4
Remove extraneous log sanitization
Remove an extra call to `replace_control_chars()`, as well as an
unnecessary method.
2024-05-09 15:57:42 +03:00
Alex Pyrgiotis
0b45360384
Keep newlines when reading debug logs
In d632908a44 we improved our
`replace_control_chars()` function, by replacing every control or
invalid Unicode character with a placeholder one. This change, however,
made our debug logs harder to read, since newlines were not preserved.

There are indeed various cases in which replacing newlines is wise
(e.g., in filenames), so we should keep this behavior by default.
However, specifically for reading debug logs, we add an option to keep
newlines to improve readability, at no expense to security.
2024-05-09 15:57:42 +03:00
Alex Pyrgiotis
e11aaec3ac
Always use sys.exit when exiting the application
The `exit()` [1] function is not necessarily present in every Python
environment, as it's added by the `site` module. Also, this function is
"[...] useful for the interactive interpreter shell and should not be
used in programs"

For this reason, we replace all such occurrences with `sys.exit()` [2],
which is the canonical function to exit Python programs.

[1]: https://docs.python.org/3/library/constants.html#exit
[2]: https://docs.python.org/3/library/sys.html#sys.exit
2024-05-09 15:57:42 +03:00
Alex Pyrgiotis
d6202cd028
Invoke external command on Windows properly
On Windows, if we don't use the `startupinfo=` argument of
subprocess.Popen, then a terminal window will flash while running the
command.

Use `startupinfo=` when killing a container, as we do for every other
command.
2024-05-09 15:57:42 +03:00
Alex Pyrgiotis
1c70ee6771
Fix archiving the same doc twice on Windows
On Windows, if we somehow attempt to archive the same document twice
(e.g, because it got archived once, and then we copy it back), we will
get an error, because Windows does not overwrite the target path, if it
already exists.

Fix this issue by always removing the previously archived version, when
performing the next archival action, and update our tests.
2024-05-09 15:57:42 +03:00
Alex Pyrgiotis
63b12abbdf
tests: Fix text sanitization tests on Windows
Fix a failing test case on Windows, due to a character that cannot
exist in a filename.
2024-05-09 15:57:42 +03:00
Naglis Jonaitis
ff1677672e
Bump pytest-cov package version
pytest-cov 3.0.0 running under pytest 7.2 produces warnings during CI
(see also pytest-dev/pytest-cov#561 [1]):

> PytestDeprecationWarning: The hookimpl CovPlugin.pytest_configure_node
> uses old-style configuration options (marks or attributes).

and

> PytestDeprecationWarning: The hookimpl CovPlugin.pytest_testnodedown
> uses old-style configuration options (marks or attributes).

The warnings were fixed in pytest-cov 4.0.0 [2].

[1]: https://github.com/pytest-dev/pytest-cov/issues/561
[2]: https://github.com/pytest-dev/pytest-cov/issues/561#issuecomment-1297143745
2024-05-08 15:40:14 +03:00
Naglis Jonaitis
5b6cc861d8
Don't use pytest-mock mocker.patch as context manager
Quote from `pytest-mock` docs [1]:

> The purpose of this plugin is to make the use of context managers and
> function decorators for mocking unnecessary, so it will emit a warning
> when used as such.

Thus using it as a context manager currently produces a warning during
test runs in CI which is extra noise that could make new (possibly more
important) warnings harder to spot.

[1]: https://pytest-mock.readthedocs.io/en/latest/usage.html#usage-as-context-manager
2024-05-08 15:40:14 +03:00
Naglis Jonaitis
c3a570eb7d
Use %F field code in .desktop entry
On Linux, the `%u` field code results in multiple Dangerzone instances
being launched when opening multiple documents with Dangerzone from
e.g. Nautilus, as `%u` signifies that the application (in this case -
Dangerzone) can only open a single file/URL at once.

This changes the field code to `%F` as Dangerzone (now) supports
converting multiple files at once. We use `%F` (multiple local files)
instead of `%U` (multiple files and/or URLs) since Dangerzone does not
support opening URLs.

See also the Desktop Entry Specification [1] for more information on the
field codes.

Fixes #797

[1]: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html
2024-05-08 14:17:35 +03:00
Naglis Jonaitis
8cdb2d5720
Set the desktop filename and app name of the Qt application
Currently, the app ID of the Dangerzone GUI application when running
under Wayland is `python3`, which is not very useful if one wants to
automate some action related to the Dangerzone application window (e.g.
to always start Dangerzone window in floating mode under Sway WM).

Setting the desktop filename property also sets the app ID of the
application under Wayland. According to Qt documentation[1], the
property value should be the name of the application's .desktop file but
without the extension.

Qt documentation also states:

> This property gives a precise indication of what desktop entry
> represents the application and it is needed by the windowing system to
> retrieve such information without resorting to imprecise heuristics.

Therefore I also think that setting this property is needed to display
the correct application name and icon (taken from the .desktop entry)
when running under certain windowing systems (like Wayland)
(see also #402).

Note that this property is not enough, as we've encountered systems
where setting just the desktop file name does not alter the detected
application name by the window manager. For this reason, we also use
set the application name [2] to `dangerzone`, to remove any ambiguity.

[1]: https://doc.qt.io/qt-6/qguiapplication.html#desktopFileName-prop
[2]: https://doc.qt.io/qt-6/qcoreapplication.html#applicationName-prop

Fixes #402
2024-04-25 17:23:02 +03:00
Alex Pyrgiotis
307ecd495c
tests: Ignore a lint error found by mypy 1.9.0
Ignore a lint error that has started showing up since mypy 1.9.0. The
official docs show that the `.instance()` method does not accept a `cls`
argument [1], so either the stubs or mypy are wrong here.

[1]: https://doc.qt.io/qtforpython-6.5/PySide6/QtCore/QCoreApplication.html#PySide6.QtCore.PySide6.QtCore.QCoreApplication.instance
2024-04-25 16:23:39 +03:00
Alex Pyrgiotis
53062a9c36
Bump Poetry dependencies
Bump our poetry.lock file, to get the latest versions of our
dependencies. Note that we are aware that this bump does not bring in
the latest PySide6 version.

Refs #773
2024-04-25 16:23:39 +03:00
Alex Pyrgiotis
d54a152eeb
Update pre-release task for PySide6
Update the description in the pre-release task for PySide6, since a lot
has changed after writing this section. Now that `python3-pyside6` is in
the Fedora Rawhide repo, and will soon get backported in the stable
repos, we no longer check for newer upstream versions, but if Fedora
finally did the backport.

Refs freedomofpress/maint-dangerzone-pyside6#5
2024-04-25 16:23:39 +03:00
Alex Pyrgiotis
83265009a3
Small revamp in our release instructions
Reword, revise, remove release procedure steps, to better reflect what's
the proper time to perform a step.
2024-04-25 16:23:39 +03:00
Alex Pyrgiotis
2e3e3842df
Add entries to changelog for 0.6.1 2024-04-25 16:23:39 +03:00
Alex Pyrgiotis
bc36c97840
Bump version to 0.6.1 2024-04-25 16:23:39 +03:00
Naglis Jonaitis
d632908a44
Fix printing of filenames with surrogate escapes
On Unix systems a filename can be a sequence of bytes that is not valid
UTF-8. Python uses[1] surrogate escapes to allow to decode such
filenames to Unicode (bytes that cannot be decoded are replaced by a
surrogate; upon encoding the surrogate is converted to the original
byte).

From `click` docs[2]:

> Invalid bytes or surrogate escapes will raise an error when written
> to a stream with `errors="strict"`. This will typically happen with
> `stdout` when the locale is something like `en_GB.UTF-8`.

To fix that, we use `utils.replace_control_chars()` before printing the
filenames to `stdout` so that surrogate escapes are replaced by �.

Fixes #768
2024-04-25 14:11:25 +03:00
Naglis Jonaitis
52ced04507
Relax the restrictions of util.replace_control_chars
The `util.replace_control_chars()` function was overly strict, and
would replace every non-ASCII character with "_". This included both
control characters, as well as normal characters in a non-English
alphabet.

Relax these restrictions by checking each character and deciding if it's
a Unicode control character, using the `unicodedata` Python package.
With this change, emojis and non-English letters are now allowed.
2024-04-25 14:11:16 +03:00
Alex Pyrgiotis
2fa592eb69
tests: Add a fixture for uncommon filenames
Add a pytest fixture that crafts a filename with Unicode characters that
are not considered common for this use. By default, this fixture uses
an invalid Unicode character as well, but we strip it in case of macOS
(APFS) since filenames must be UTF-8 encoded.

[1]: https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations
2024-04-25 13:23:22 +03:00
Alex Pyrgiotis
94179a1d91
ci: Include test dependencies when linting
Include the test dependencies when linting, especially `pytest`. We need
this because `mypy` cannot understand the `pytest.raises` exception, and
specifically the fact that it catches exceptions. It assumes that the
next code block is unreachable, since it doesn't see any try ... except.
2024-04-24 16:27:14 +03:00
Alex Pyrgiotis
d4974b1229
tests: Add termination tests for Dummy provider
Add termination tests for the Dummy provider, so that we can have
cross-platform coverage in our Windows/macOS CI runners, which can't use
the Container isolation providers.
2024-04-24 15:06:01 +03:00
Alex Pyrgiotis
abc66840a8
tests: Add termination tests for Qubes
Add termination-related tests for Qubes. To achieve this, we need
to make a change to the Qubes isolation provider. More specifically,
we need to make the isolation provider yield control to the caller only
when the disposable qube is up and running.

Qubes does not provide us a solid guarantee to do so, but we've found a
hacky workaround, whereby we wait until the `qrexec-client-vm` process
opens a `/dev/xen` character device. This should happen, in theory, once
the disposable qube is ready, and has sent a `MSG_SERVICE_CONNECT` RPC
message to the caller.
2024-04-24 14:39:15 +03:00
Alex Pyrgiotis
875d49fe10
tests: Add termination tests for containers
Add termination-related tests for containers. To achieve this, we need
to make a change to the container isolation provider. More specifically,
we need to make the isolation provider yield control to the caller only
when the container is up and running. Failure to do so may lead to
lingering processes.
2024-04-24 14:39:15 +03:00
Alex Pyrgiotis
fec7609547
tests: Add some termination-related test cases
Add some test cases in the isolation provider tests, that check how it
behaves when a process completes successfully, lingers, or cannot
terminate.

These tests cannot run yet, since they must be imported by a concrete
isolation provider test class. In subsequent commits, we will start
enabling them.
2024-04-24 14:39:15 +03:00
Alex Pyrgiotis
f57d2f7191
isolation_provider: Always terminate spawned process
Previously, we always assumed that the spawned process would quit
within 3 seconds. This was an arbitrary call, and did not work in
practice.

We can improve our standing here by doing the following:

1. Make `Popen.wait()` calls take a generous amount of time (since they
   are usually on the sad path), and handle any timeout errors that they
   throw. This way, a slow conversion process cleanup does not take too
   much of our users time, nor is it reported as an error.
2. Always make sure that once the conversion of doc to pixels is over,
   the corresponding process will finish within a reasonable amount of
   time as well.

Fixes #749
2024-04-24 14:39:15 +03:00
Alex Pyrgiotis
cd4cbdb00a
isolation_provider: Get exit code without timing out
Get the exit code of the spawned process for the doc-to-pixels phase,
without timing out. More specifically, if the spawned process has not
finished within a generous amount of time (hardcode to 15 seconds),
return UnexpectedConversionError, with a custom message.

This way, the happy path is not affected, and we still make our best to
learn the underlying cause of the I/O error.
2024-04-24 14:36:14 +03:00
Alex Pyrgiotis
171a7eca52
isolation_provider: Terminate doc-to-pixels proc
Extend the IsolationProvider class with a
`terminate_doc_to_pixels_proc()` method, which must be implemented by
the Qubes/Container providers and gracefully terminate a process started
for the doc to pixels phase.

Refs #563
2024-04-24 14:36:14 +03:00
Alex Pyrgiotis
a63f4b85eb
isolation_provider: Set a unique name for spawned containers
Set a unique name for spawned containers, based on the ID of the
provided document. This ID is not globally unique, as it has few bits of
entropy.  However, since we only want to avoid collisions within a
single Dangerzone invocation, and since we can't support multiple
containers running in parallel, this ID will suffice.
2024-04-24 14:33:33 +03:00
Alex Pyrgiotis
6850d31edc
isolation_provider: Pass doc when creating doc-to-pixels proc
Pass the Document instance that will be converted to the
`IsolationProvider.start_doc_to_pixels_proc()` method. Concrete classes
can then associate this name with the started process, so that they can
later on kill it.
2024-04-24 14:33:33 +03:00
Alex Pyrgiotis
b920de36d1
Announce our Ubuntu Noble / Fedora 40 support
Closes #762
2024-04-24 14:30:40 +03:00
Alex Pyrgiotis
7a9facb3c1
dev_scripts: Add Ubuntu Noble / Fedora 40 in our QA scripts 2024-04-23 18:00:48 +03:00
Alex Pyrgiotis
88c39a4fd5
ci: Add Ubuntu Noble / Fedora 40 support in GitHub actions
Extend our GitHub actions job to build an end-user environment for
Ubuntu Noble / Fedora 40, and then run a simple test in it.
2024-04-23 18:00:48 +03:00
Alex Pyrgiotis
0cd3241556
ci: Build and test Dangerzone in Fedora 40 on CircleCI
Extend our CircleCI jobs to:
* Build an .rpm package for Dangerzone in Fedora 40
* Run CI tests in Fedora 40
2024-04-23 18:00:48 +03:00
Alex Pyrgiotis
ad1b866dbb
ci: Test Dangerzone in Ubuntu Noble on CircleCI
Extend our CircleCI jobs to run CI tests in Ubuntu Noble.

This commit also adds support for building the Dangerzone .deb package
in Ubuntu Noble, but does not actually enable it. The reason is that
stdeb, which produces our Debian packages, does not work with Python
3.12, which ships with Ubuntu Noble

Refs #773
2024-04-23 18:00:48 +03:00
Archit Sharma
114881c291
Added Dependabot for Github actions
Signed-off-by: Archit Sharma <74408634+iArchitSharma@users.noreply.github.com>

Fixes #782
2024-04-22 22:02:15 +03:00
Alex Pyrgiotis
7cd73cab0e
ci: Bump PySide6 version in Fedora end-user envs
Our end-user Fedora environments, that we create for testing how
Dangerzone would operate on a clean Fedora system, require PySide6 to be
installed. This package is not available from the official Fedora repos
yet.

We have a way instead to check the poetry.lock file, grab the latest
PySide6 version from there, and install it from a URL. This is no longer
necessary, now that PySide6 6.7.0 will soon be available in all stable
Fedora releases. Since the last release maintained by FPF will be
6.6.3.1, we should pin this version in our env.py script. This way, we
can bump poetry.lock independently, and let Windows/macOS users get
different versions.

Refs freedomofpress/maint-dangerzone-pyside6#5
2024-04-19 00:54:07 +03:00
Naglis Jonaitis
7c4e62954f
Update GitHub actions
The `checkout`, `setup-python`, `upload-artifact` and `download-artifact`
actions produce warnings about deprecated Node.js 16.

Update the actions to use Node.js 20.
2024-04-09 14:39:26 +03:00
Naglis Jonaitis
fc503d0a96
Fix test-large phony target name 2024-04-08 17:38:18 +03:00
Naglis Jonaitis
a4b20ae101
Avoid DUMMY_CONVERSION env var treated as bool in CI
`DUMMY_CONVERSION: True` is treated as a boolean value in YAML[1]. As a
result, during GitHub CI the environment variable setup during tests is
formatted as `DUMMY_CONVERSION=true`.

The value is used[2] in tests and passed as the `condition` to the
`pytest.mark.skipif`[3] decorator. The `skipif` `condition` can be
either a `bool` or `str`. When it is a `str` (our case, as we use
`os.environ.get()`), it is treated as a condition string[4] by pytest.

Since the condition string is `eval()`ed[5] by pytest, trying to
evaluate `true` results in:

> Failed: Error evaluating 'skipif' condition
>     true
> NameError: name 'true' is not defined

To avoid the implicit conversion to a JSON boolean, or marking the
"True" value as a string literal, use the value `1` instead.

[1]: https://yaml.org/type/bool.html
[2]: 9bb1993e77/tests/isolation_provider/base.py (L25)
[3]: https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif-ref
[4]: https://docs.pytest.org/en/stable/historical-notes.html#string-conditions
[5]: f75dd87eb7/src/_pytest/skipping.py (L117)
2024-04-08 15:24:19 +03:00