Commit graph

912 commits

Author SHA1 Message Date
Alex Pyrgiotis
89e8b998d6
ci: Add a test dependency
Add libqt5gui5 as a test dependency in the 'convert-test-docs' step.
This package brings several other Qt and graphics libraries, which are
the ones that we actually require to run the tests *with PySide6*. Else,
we encounter this error:

```
Traceback (most recent call last):
  File "/home/circleci/project/dangerzone/gui/__init__.py", line 19, in <module>
    from PySide6 import QtCore, QtGui, QtWidgets
ImportError: libEGL.so.1: cannot open shared object file: No such file or directory
```

Note that the same package is not required when importing PySide2.QtGui,
which is why we hadn't encountered this issue before. Also, in the rest
of our environments, we explicitly install libqt5gui5, in order to run
the Dangerzone GUI.
2023-02-07 17:14:01 +02:00
Alex Pyrgiotis
63a8748423
ci: Remove Poetry version pin
Remove a Poetry version pin to 1.2.2, which causes installation issues
on systems with Python 3.11.

The pin was originally introduced because Poetry 1.3 was deemed
unstable, due to the following bugs:

* https://github.com/freedomofpress/dangerzone/issues/292#issuecomment-1351368122
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1029156

The first problem still stands, but we can circumvent it with the
`--no-ansi` flag, at no functionality cost. The second problem has been
resolved, but it never affected Ubuntu Focal in the first place.

Refs #292
2023-02-07 17:14:01 +02:00
deeplow
bbbf8224f1
install: Remove PySide2-related code for Windows 2023-01-30 11:42:24 +00:00
deeplow
81e9ccf30a
Add PySide6 dependency for Windows and MacOS
We're not yet adding them to Linux, since PySide6 is not yet available
in Linux distros' packages, whereas with Linux and macOS our packaging
process includes the shipped binaries.

Fixes #211
2023-01-30 11:42:18 +00:00
deeplow
ab2f9ead9a
Replace PySide2-stubs with types-PySide2
Replace PySide2-stubs with types-PySide2, both of which are projects
that provide PySide2 typing hints, for the following reasons:

1. types-PySide2 is more complete and allows us to ditch some 'type:
   ignore' comments for Mypy.
2. PySide2-stubs also brings PySide2 as a dependency, which cannot be
   installed in MacOS M1 machines.

Refs #177
2023-01-30 11:42:09 +00:00
deeplow
56b5b98f1e
Report exceptions raised in document conversion
Exceptions raised during the document conversion process would be
silently hidden. This was because ThreadPoolExecuter in logic.py created
various contexts and hid any exceptions raised.

Fixes #309
2023-01-26 18:53:20 +00:00
deeplow
06fe53b0d6
Make 'make test' use the Python interpreter
On Windows this was failing [1] because it did not know to run
./dev_scripts/pytest-wrapper.py in the Python interpreter. The forward
slashes didn't seem to cause issue.

[1]: https://github.com/freedomofpress/dangerzone/actions/runs/3967654249/jobs/6799870096
2023-01-25 16:36:31 +00:00
deeplow
bf6eacccf7
Run windows/mac tests daily 2023-01-25 16:35:46 +00:00
deeplow
a565d9e580
CI: add macOS and Winwdows tests via Github Actions
Adds tests for macOS and Windows with the dummy converter. Tests won't
actually perform the conversion. But it should be enough for us to test
the remainder of the codebase.

Fixes #229
2023-01-25 16:34:46 +00:00
deeplow
724dd2a71f
Make container-specific methods static
Make these methods callable without having to create an instance of the
Container class. This was needed to make pytest-wrapper.py cleaner.
2023-01-25 14:55:43 +00:00
deeplow
f5c4847af2
De-duplicate print_progress() logic 2023-01-25 14:53:28 +00:00
deeplow
a339eff648
Add dummy conversion to GUI 2023-01-25 14:53:26 +00:00
deeplow
da0cb6b3c5
Add dummy isolation provider to CLI
When enabled, the conversion part does nothing but print some simulated
output. This can be useful for testing non-conversion code (e.g. GUI).

Activated with the hidden flag --unsafe-dummy-conversion.
2023-01-25 14:51:50 +00:00
deeplow
538df18709
Split isolation providers into their own .py files
Provides more clear code organization having each provider in their own
python file rather than a single one.
2023-01-25 14:19:05 +00:00
deeplow
7ed1fd6b59
Isolation-provider-specific methods in _convert()
All isolation providers will some similar steps when convert() is
called. For this reason, all the common parts are captured in convert()
and then each isolation provider implements its own specific conversion
process in _convert() (which is called from the convert() method).
2023-01-25 13:10:39 +00:00
deeplow
a4f27afdc6
Abstract container into an IsolationProvider
Encapsulate container logic into an implementation of
AbstractIsolationProvider. This flexibility will allow for other types
of isolation managers, such as a Dummy one.
2023-01-24 11:03:39 +00:00
deeplow
1114a0dfa1
Rename container.py to isolation_provider.py
First step in encapsulating the isolation provider.
2023-01-24 11:03:36 +00:00
deeplow
2da973232b
Remove sudo: no longer needed
Fixes #232
2023-01-23 14:13:56 +00:00
deeplow
d7be28ec2a
Remove openjdk-8 as a dependency.
default-jre and java dependencies dependencies had been added initially
[1] because of libreoffice-java-common, which is no longer present.
Then, when the image was changed from ubuntu to alpine [2], default-jre
was replaced with openjdk-8.

If java is still a dependency for libreoffice, then it should be pulled
automatically.

[1] 9ecdb9e995
[2] 650ae6eee1
2023-01-23 14:13:48 +00:00
deeplow
272d25aee0
Make pdf to ppm conversion dependent on num pages 2023-01-23 14:01:32 +00:00
deeplow
d28aa5a25b
Remove PDFtk dependency (replace w/ pdftoppm)
PDFtk actually isn't needed. It was being used for breaking a PDF
into pages but this is something that be replaced by the already present
'pdftoppm'. Furthermore, by removing this dependency we contribute to
reproducible builds and overall supply chain security because it was
obtained from gitlab with no signature verification or version pinning.

The replacement 'pdftoppm' enabled us to do a shortcut:
 - before: PDF -> PDF pages -> PNG images -> RGB images
 - after:  PDF -> PPM images -> RGB images

And this last conversion step is trivial since the RGB format we were
using is just a PPM file without the metadata in its header.
2023-01-23 14:00:57 +00:00
deeplow
08937239a5
Fix qa.py following BUILD.md update in 3b2544a
This BUILD.md was merged into main without updating qa.py to reflect it
because our linters were down due to the now-fixed poetry bug (see prev
commit).
2023-01-20 09:58:37 +00:00
deeplow
affc0ca2a8
Unpin PIP in CI; replace w/ --no-ansi fix same bug
Alternative solution to commit 0ebfe45169
but without pining the pip version.
2023-01-20 09:52:39 +00:00
Alex Pyrgiotis
0ebfe45169
Fix a failing lint check
Fix a failing lint check, that got introduced due to an upstream Debian
bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1029156
2023-01-19 17:27:11 +02:00
Alex Pyrgiotis
a8421bcdb7
Fix exclusion of dev_scripts/envs from isort
The previous way of excluding files under `dev_scripts/envs` does not
seem to work. Ditching the glob and excluding the whole path works, so
we can go with that.
2023-01-19 17:27:11 +02:00
deeplow
3b2544a2cd
Add comment about poetry install keyring prompt
Running `poetry install` would show a keyring prompt asking the user for
a password or to create a new keyring. This should not be needed for a
successful install.

discussion context: https://github.com/freedomofpress/dangerzone/pull/284#issue-1477773398
2023-01-18 14:17:59 +00:00
Alex Pyrgiotis
7d0b6d44ba
ci: Remove Fedora 35 support
Fedora 35 has reached its end of life [1], so we remove it from our CI
builds.

Closes #308

[1]: https://endoflife.date/fedora
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
586240ec22
ci: Add CI tests for missing platforms
Use the `dev_scripts/env.py` script to run CI tests for some platforms
we couldn't run before.
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
ea99b1e1dd
Narrow down installed system packages
Narrow down the system packages that we install in dev environments. The
rationale is that we get most of the Python dependencies from Poetry, so
we don't need to install them from the system as well.

The packages that we do need to install are non-Python ones, and this
commit adds some that were missing: make, python3-stdeb. Also, we
explicitly install the base Qt5 libraries, in order to get the graphics
and C++ libraries that we can't get from PyPI.
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
f16b42bb18
Ignore dev_scripts/envs for tests/lints
Ignore the `dev_scripts/envs` folder when running tests or linting code,
as it may contain files that are not owned by the current user. In this
case, we've seen that pytest/black etc. fail.

This typically happens when the user has run Dangerzone in a
containerized environment (see #286), and Podman created a directory
with files owned by the user in the nested container.
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
e3431c7ac2
dev_scripts: Add documentation for the QA script
Add a short explanation of what is the purpose of the QA script, and
what it uses underneath.

Refs #287
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
14a7ca1ae5
dev_scripts: Add QA script
Add a script that makes the user go through the QA steps for a supported
Dangerzone platform, and may optionally run them automatically, if the
user agrees.

Closes #287
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
feec73c60c
dev_scripts: Add design document for env.py
Add a design document for `dev_scripts/env.py`, which is a script that
creates Dangerzone environments for various Linux distros. In this
design document, we explain various architectural decisions that we have
taken for this script, as well as how it works under the hood, what are
its shortcomings, etc.

Refs #286
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
b51691416f
dev_scripts: Introduce script for Dangerzone envs
Introduce `dev_scripts/env.py`, which is a script for building
Dangerzone environments for various Linux distros, and running commands
in them.

Closes #286
2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
4eead90c00
install: Fail early when image build fails 2023-01-16 18:48:09 +02:00
Alex Pyrgiotis
624d480cca
install: Do not create intermediate tarfile for container
Skip the creation of the `share/container.tar` file, since it's not used
anywhere. Instead, pipe our `docker/podman save` invocations to `gzip`
directly, which will compress the tarfile on the fly. This saves both
time and disk space.
2023-01-16 18:48:08 +02:00
Alex Pyrgiotis
a0503c8c40
install: Do not create Debian source package twice 2023-01-16 18:48:08 +02:00
Alex Pyrgiotis
c36443b01e
Add note for python-all 2023-01-16 18:48:08 +02:00
deeplow
b9dc882663
CLI: prefix non-INFO logs with log type
In non-development mode, the CLI shows the user information via the INFO
log level. The message is shown directly without [INFO] as a prefix.
Otherwise it would quickly get annoying to the user seeing [INFO] on
every line of a CLI application.

However, if an error happens it's important for the user to recognize
it's an error or a warning. This commit prints the log level in these
cases.
2023-01-16 14:58:13 +00:00
deeplow
c442c443df
CLI: add missing logging format to non-dev env 2023-01-16 14:50:10 +00:00
deeplow
ad908f5d16
CLI: increase logging from ERROR to INFO level
ERROR level would only show errors and criticals and miss out on all
info-level logging.
2023-01-16 14:50:08 +00:00
deeplow
eb3fd5ae16
CLI: don't print DEBUG logs
The CLI version was mistakenly printing debug logs.
2023-01-16 14:50:06 +00:00
deeplow
c406c95cec
GUI: Add version to header bar
Fixes #219
2023-01-16 14:39:27 +00:00
deeplow
c08fddb443
Add unit test for --version 2023-01-16 14:39:25 +00:00
deeplow
fb3cb98793
Add --version flag 2023-01-16 14:39:24 +00:00
deeplow
0ab9f42dd9
Windows: fix "Open with" dialog showing dz description
The "open with" dialog on windows was showing the description of
Dangerzone instead of its app name. The issue was that on windows it
shows the description there.

Fixes #283
2023-01-16 11:38:08 +00:00
deeplow
84b8212e5d
Fix test instability: pytest in seq. podman<4.3.0
Instability in the automated tests sometimes would sometimes fail when
running "podman images --format {{.ID}}". It turns out that in versions
prior to podman 4.3.0, podman volumes (stored in
~/.local/share/contaiers) would get corrupted when multiple tests were
run in parallel.

The current solution is to wrap the test command to run sequentially in
versions prior to the fix and in parallel for versions after that.

Fixes #217
2023-01-09 11:54:24 +00:00
Ro
ffdc1425bb
Update Debian, Fedora instructions, add QubesOS instructions. 2023-01-09 11:13:12 +00:00
Alex Pyrgiotis
fc313d8744
ci: Fix convert-test-docs step
Fix the failing convert-test-docs step, by pinning Poetry to version
1.2.2. This way, we avoid a bug in Poetry 1.3 [1], which was recently
released on PyPI.

[1]: https://github.com/python-poetry/poetry/issues/7184

Closes #292
2022-12-15 18:32:48 +02:00
Alex Pyrgiotis
147caca524
ci: Fix failing build-debian-bookworm step
Debian has removed the python-all package from its Bookworm repos, which
breaks our CI tests. Looking into why python-all is required in the
first place, we found that it's an artificial stdeb requirement [1],
prior to 0.9.1 versions

The only platform affected by this issue is Ubuntu Focal, so our
solution is to install python-all specifically for that platform.

Finally, we further simplify our build tasks [2] (on Debian-like
distros) by not letting dh-python run tests when building the packages.
Running the tests has some issues after all:

1. It requires installing all the runtime dependencies of Dangerzone,
   since it uses `python -m unittest discover` underneath.
2. It doesn't aid in the stability of the package, since unittest cannot
   run test cases for PyTest.

[1]: https://github.com/astraw/stdeb/issues/153
[2]: https://github.com/freedomofpress/dangerzone/issues/292#issuecomment-1349967888
2022-12-15 18:30:19 +02:00