Commit graph

36 commits

Author SHA1 Message Date
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
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
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
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
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
6c7c0b615f
dev_scripts: Add missing packages in Dangerzone envs
Install the following packages in Dangerzone envs:

* python3-setuptools: We've seen that this package is necessary to build
  the RPM package for Dangerzone. The error that we encountered was the
  following:

      * Deleting old build and dist
      * Building RPM package
      Traceback (most recent call last):
        File "/home/user/dangerzone/setup.py", line 5, in <module>
          import setuptools
      ModuleNotFoundError: No module named 'setuptools'
      Traceback (most recent call last):
        File "/home/user/./dangerzone/install/linux/build-rpm.py", line 43, in <module>
          main()
        File "/home/user/./dangerzone/install/linux/build-rpm.py", line 30, in main
          subprocess.run(
        File "/usr/lib64/python3.11/subprocess.py", line 571, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command 'python3 setup.py bdist_rpm --requires='podman,python3-pyside2,python3-appdirs,python3-click,python3-pyxdg,python3-colorama'' returned non-zero exit status 1.

* fuse-overlayfs: In Ubuntu 22.10 (at least), we encountered the
  following error when running Podman:

      ERRO[0000] User-selected graph driver "overlay" overwritten by
      graph driver "vfs" from database - delete libpod local files to
      resolve

  The `vfs` driver is much slower than the `overlayfs` storage driver,
  so we need to fix this. The reason why we encounter this error is
  explained in the Podman docs [1]:

      [...] and is vfs for non-root users when fuse-overlayfs is not
      available.

  Normally, the `fuse-overlayfs` package would have been installed, but
  we don't install it due to the `--no-install-recommends` flag, so we
  install it manually.

[1]: https://docs.podman.io/en/latest/markdown/podman.1.html#storage-driver-value
2023-04-03 18:58:56 +03:00
Alex Pyrgiotis
1f308e9cc5
Reformat code with Black 23
Due to a bump in our Python dependencies, we now install Black 23
instead of 22, which detects some of our files as badly formatted.
2023-03-27 15:17:23 +03:00
Alex Pyrgiotis
330766665d
Update instructions in qa.py 2023-03-08 17:56:25 +02:00
Alex Pyrgiotis
b32f215c7c
dev_scripts: Handle alt name for Ubuntu Focal 2023-03-08 17:36:42 +02:00
Alex Pyrgiotis
aaecfdb63e
dev_scripts: Immitate mkdir -p when creating state dirs
The first time we run the env.py script, we may not have the necessary
dirs under envs. It's best to create them with `parents=True`.
2023-03-08 17:36:42 +02:00
Alex Pyrgiotis
96d8cdef94
Suggest users to install Poetry via pipx
Replace the command to install Poetry globally via `pip` in our build
instructions, with a command that installs Poetry under ~/.local/bin
via `pipx`. The rationale is the same as in the previous commit, i.e.,
PEP 668 does not allow it.

Note that in this case, we don't have any CI restrictions, so we could
use the official installer instead. However, for security reasons, we
prefer suggesting `pipx` to the users, and of course give them a list of
alternatives.

Note that for Windows and MacOS we leave the command as is, until we
figure out how PEP 668 applies in there.
2023-03-08 17:36:42 +02:00
Alex Pyrgiotis
7310977343
dev_scripts: Install Poetry via pipx
We can no longer install Poetry via `pip`, since Debian Bookworm now
enforces PEP 668, meaning that both `pip install poetry` and `pip
install --user poetry` cannot work [1]. Since we use the same
installation steps for all of our dev environments, we need to find a
common way to install Poetry.

Poetry's website provides several ways to install Poetry [2]. Moreover,
it also has a special section with CI recommendations [3]. In this
section, it strongly suggests to install Poetry via `pipx`, instead of
the installer script that you download from the Internet.

Follow Poetry's suggestion to install it via `pipx` in CI environments,
with one minor change. Do not use `pipx ensurepath`, as that will
affect the `.bashrc` of the dev environment, which at some point in the
future may be mounted by the dev. Instead, set a PATH environment
variable that includes `~/.local/bin`.

[1]: https://github.com/freedomofpress/dangerzone/issues/351
[2]: https://python-poetry.org/docs/#installation
[3]: https://python-poetry.org/docs/#ci-recommendations

Fixes #351
2023-03-08 17:36:42 +02:00
Alex Pyrgiotis
9bf65bc829
dev_scripts: Add extra distros in QA script
Add some distros in the QA script that were missing from the list of our
supported ones.
2023-02-21 20:20:04 +02:00
Alex Pyrgiotis
ce86c1b126
dev_scripts: Enable building envs on Ubuntu Focal
Enable installing Podman in Ubuntu Focal, by re-using the instructions
we have in our installation section. This enables us building a dev
environment for Ubuntu Focal, which we couldn't previously.
2023-02-21 20:20:04 +02:00
Alex Pyrgiotis
5100e15213
Add missing build dependencies for Ubuntu Focal
Add some missing build dependencies that we encountered for Ubuntu
Focal, but they apply to the rest of the Debian-based distros as well.
2023-02-21 20:20:03 +02:00
Alex Pyrgiotis
081c68c27f
dev_scripts: Alter the shadow-utils fix
Instead of reinstalling shadow-utils, use the actual fix that the Fedora
devs have suggested (rpm --restore shadow-utils). The previous method
does not seem to work on Fedora 37, and it threw the following error
when building the development environment:

    Installed package shadow-utils-2:4.12.3-3.fc37.x86_64 (from koji-override-0) not available.
    Error: No packages marked for reinstall.
    Error: building at STEP "RUN dnf reinstall -y shadow-utils && dnf clean all": while running runtime: exit status 1
2023-02-07 18:52:08 +02:00
Alex Pyrgiotis
e7eb3bf18b
dev_scripts: Fix a recursion issue in our PyTest wrapper
Fix an issue in our PyTest wrapper, that caused this recursion error:

```
  File "shibokensupport/signature/loader.py", line 61, in feature_importedgc
  File "shibokensupport/feature.py", line 137, in feature_importedgc
  File "shibokensupport/feature.py", line 148, in _mod_uses_pysidegc
  File "/usr/lib/python3.10/inspect.py", line 1147, in getsourcegc
    lines, lnum = getsourcelines(object)gc
  File "/usr/lib/python3.10/inspect.py", line 1129, in getsourcelinesgc
    lines, lnum = findsource(object)gc
  File "/usr/lib/python3.10/inspect.py", line 954, in findsourcegc
    lines = linecache.getlines(file, module.__dict__)gc
  File "/home/user/.cache/pypoetry/virtualenvs/dangerzone-hQU0mwlP-py3.10/lib/python3.10/site-packages/py/_vendored_packages/apipkg/__init__.py", line 177, in __dict__gc
    self.__makeattr(name)gc
  File "/home/user/.cache/pypoetry/virtualenvs/dangerzone-hQU0mwlP-py3.10/lib/python3.10/site-packages/py/_vendored_packages/apipkg/__init__.py", line 157, in __makeattrgc
    result = importobj(modpath, attrname)gc
  File "/home/user/.cache/pypoetry/virtualenvs/dangerzone-hQU0mwlP-py3.10/lib/python3.10/site-packages/py/_vendored_packages/apipkg/__init__.py", line 75, in importobjgc
    module = __import__(modpath, None, None, ["__doc__"])gc
  File "shibokensupport/signature/loader.py", line 54, in feature_importgc
RecursionError: maximum recursion depth exceededgc
```

This error seems to be related to
https://github.com/pytest-dev/pytest/issues/1794. By not importing
`pytest` in our test wrapper, and instead executing directly, we can
avoid it.

Note that this seems to be triggered only by Shiboken6, which is why we
hadn't previously encountered it.
2023-02-07 18:52:08 +02: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
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
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
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
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
deeplow
4d8e4c53e3
sort imports with isort linter 2022-08-22 10:15:26 +01:00
Micah Lee
173f31ff41 Start porting VM to Windows 2021-08-09 12:04:17 -07:00
Micah Lee
c9c01f6e79
Remove separate dangerzone-container entry point, make CLI work with it, and refactor container code to be more DRY 2021-08-04 16:21:00 -07:00
Micah Lee
3105a2c229 Change a bunch of stuff so Windows will work again 2021-06-16 16:55:25 -07:00
Micah Lee
6ff68f88ea
Refactor dangerzone to move GUI code into its own module 2021-06-09 15:24:03 -07:00
Micah Lee
cf367adcfa
This creates a separate script dangerzone-container which is a wrapper for running the container. This lets us run dangerzone as unprivileged, but dangerzone-container as privileged, to avoid adding the user to the dangerzone group. 2020-03-13 16:49:53 -07:00
Micah Lee
0b9823a34e
Initial commit 2020-01-06 14:40:09 -08:00