Commit graph

912 commits

Author SHA1 Message Date
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
Alex Pyrgiotis
4c346154b2
Minor fixes in the Fedora release instructions 2023-04-24 11:50:57 +03:00
Alex Pyrgiotis
7f7d8bc2cc
Update notarization instructions 2023-04-24 11:50:57 +03:00
Erik Moeller
cdd0d3a647
Minor changelog tweaks 2023-04-18 13:19:26 -07:00
Alex Pyrgiotis
70a2e710d6
Bump version to 0.4.1
This release brings a split in the MacOS binaries, since we now have
separate ones for Intel and Apple Silicon architectures, so we must
reflect this in the README as well.
2023-04-18 23:01:00 +03:00
Alex Pyrgiotis
d6ffa0ea2e
CHANGELOG: Point to the correct issue 2023-04-18 23:01:00 +03:00
Alex Pyrgiotis
e36213c0c8
CHANGELOG: add entry about change in release keys 2023-04-18 23:01:00 +03:00
Alex Pyrgiotis
bb5a709250
CHANGELOG: fix issue number 2023-04-18 23:01:00 +03:00
Alex Pyrgiotis
b5c1c1192e
Add user instructions for installing Debian packages 2023-04-14 10:54:43 +03:00
Alex Pyrgiotis
dce516b4e8
Add dev instructions for building Debian packages 2023-04-14 10:54:43 +03:00
deeplow
49f72320d9
Update macOS release building instructions
Make the instructions consistent with the release building changes.
2023-04-14 08:50:58 +01:00
deeplow
592009d4d1
Fix build_app_bundle() (missing arguments) 2023-04-14 08:50:48 +01:00
deeplow
18557f88fc
Allow "create-dmg" to be in other places
If installed with homebrew, create-dmg will be installed at a different
location. It makes more sense to use the 'which' utility to find where
it is.
2023-04-14 08:48:07 +01:00
deeplow
21875714b8
Update apple development key ID 2023-04-14 08:48:05 +01:00
deeplow
78959100a8
Update fedora installation / release instructions
Changes instructions from the packagecloud setup to
packages.freedom.press

Delegates the key import to .repo configuration, following the example
of docker's install instructions [1].

[1]: https://docs.docker.com/engine/install/fedora/#install-docker-engine
2023-04-14 08:41:55 +01:00
deeplow
1c0dfb45f5
Update Apple account to FPF's Developer ID 2023-04-10 10:41:03 +01:00
deeplow
3f23010394
Redo macOS build-app.py and add --codesign-only opt
Redoes the build-app.py script to add an option to sign only an already-
produced app bundle.
2023-04-10 10:40:01 +01:00
Alex Pyrgiotis
bb0de52b01
Bump version to 0.4.1-rc3 2023-04-03 19:36:48 +03:00
Alex Pyrgiotis
7fe01d6470
install/windows: Remove -rc identifiers from version
Remove any -rc identifiers (e.g., 0.4.1-rc3) from the Dangerzone
version, if it includes them. If we don't remove them, then building
the MSI for Windows will fail as follows:

    error CNDL0108: The Product/@Version attribute's value, '0.4.1-rc3',
    is not a valid version. Legal version values should look like
    'x.x.x.x' where x is an integer from 0 to 65534.
2023-04-03 19:35:19 +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
33f81f5064
tests: Add sample files for extra MIME types
In PR #378 ("container: Allow converting more document formats"), we
added support for the following MIME types:

* application/zip
* application/octet-stream
* application/x-ole-storage
* application/vnd.oasis.opendocument.spreadsheet-template
* application/vnd.oasis.opendocument.text-template

However, we forgot to add some tests for these MIME types in the repo.
In this commit, we add a file for each of these MIME types, to make sure
we have no regressions in the future.
2023-04-03 18:58:56 +03:00
Alex Pyrgiotis
58a8241844
container: Run LibreOffice in safe mode
The main use of safe mode [1] in LibreOffice is to run with a fresh user
profile, in case the default one got borked somehow. This is actually
not a concern of ours, since the user's profile is in the container and
is not persistent.

The main reason we want to preemptively run LibreOffice in safe mode is
to remove hardware acceleration capabilities. Whether hardware
acceleration actually works in a container is another question, but we
want to be extra sure.

[1]: https://help.libreoffice.org/latest/en-US/text/shared/01/profile_safe_mode.html
2023-03-28 14:47:07 +03:00
Alex Pyrgiotis
a1c87a207a
container: Allow converting more document formats
Remove the association between MIME types and export filters, because
LibreOffice is able to auto-detect them on its own. Instead, ask
LibreOffice to simply convert the document to a .pdf.

This association was cumbersome for yet another reason; there are MIME
types that may be associated with more than one file type. That's why
it's better to let LibreOffice decide the proper filter for the
conversion.

Our current understanding is that this change won't widen our attack
surface for the following reasons:

* The output filters for PDF documents are pretty specific, and we don't
  affect the input filters somehow.
* The default behavior of LibreOffice on Alpine Linux is to disable
  macros.

Closes #369
2023-03-28 14:46:47 +03:00
Alex Pyrgiotis
8b846820d2
Update typing hints for Mypy 1.1.1
Due to a bump in our Python dependencies, we now install Mypy 1.1.1
instead of 0.982. This change triggered the following errors:

* Incompatible default for argument <a> (default has type
  None, argument has type <t>):

  Mypy further explains here that PEP 484 prohibits implicit Optional,
  so we need to make these types explicit Optional.

* Unused "type: ignore" comment, use narrower [method-assign] instead of
  [assignment]:

  Mypy has specialized some of its lints, meaning that we should switch
  to the newer variants.

Also, it detected several other small inconsistencies. We fix all of
these errors in this commit.
2023-03-27 15:19:43 +03:00