freedomofpress / dangerzone

Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs
https://dangerzone.rocks/
GNU Affero General Public License v3.0
3.62k stars 172 forks source link

Handle container install failure #193

Open deeplow opened 2 years ago

deeplow commented 2 years ago

The install_container() method returns false when it fails but none of its calls check the return value.

This should also be passed on to the user interface so the user can see the issue.

deeplow commented 2 years ago

Failure cause: Disk is Full

I am getting a similar issue to https://github.com/freedomofpress/dangerzone/issues/152 but I think that is a consequence of this lack of failure handling.

In short, the instalation fails saying Error: payload does not match any of the supported image formats (oci, oci-archive, dir, docker-archive) but nothing is communicated via the user interface. It only shows the following error:

dez3

After digging runnning the volume instalation command with --log-level debug I saw this was related to full disk size and expanding it did solve the issue.

Before increasing disk size

$ dangerzone ``` [INFO] Installing Dangerzone container image... Getting image source signatures Copying blob 48a31ab7de6f [=====================>----------------] 900.8MiB / 1.5GiB Copying blob b56b9d864269 done Copying blob 64a1a52c74ff done Copying blob 4965dc1ce878 done Copying blob 99f8e046e98a done Copying blob 994393dc58e7 skipped: already exists Error: payload does not match any of the supported image formats (oci, oci-archive, dir, docker-archive) [ERROR] Failed to install the container image [INFO] > /usr/bin/podman run --network none -u dangerzone --security-opt no-new-privileges --userns keep-id --cap-drop all --rm -v /home/user/dangerzone/test_docs/sample.doc:/tmp/input_file -v /home/user/.config/dangerzone/tmp/tmprkiz5sfc/pixels:/dangerzone dangerzone.rocks/dangerzone /usr/bin/python3 /usr/local/bin/dangerzone.py document-to-pixels [ERROR] Invalid JSON returned from container: Trying to pull dangerzone.rocks/dangerzone:latest... [ERROR] Invalid JSON returned from container: Error: initializing source docker://dangerzone.rocks/dangerzone:latest: pinging container registry dangerzone.rocks: invalid status code from registry 404 (Not Found) [ERROR] documents-to-pixels failed ````
$ df -h ``` Filesystem Size Used Avail Use% Mounted on /dev/xvda3 9.6G 6.6G 2.5G 73% / none 9.6G 6.6G 2.5G 73% /usr/lib/modules devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 1.0G 84K 1.0G 1% /dev/shm tmpfs 58M 760K 57M 2% /run tmpfs 1.0G 4.0K 1.0G 1% /tmp /dev/xvdb 50G 8.8G 42G 18% /rw tmpfs 29M 144K 29M 1% /run/user/1000 ```

After increasing disk size

All went fine when I changed the root volume from 10GiB to 15GiB.

$ dangerzone ``` [INFO] Installing Dangerzone container image... Getting image source signatures Copying blob b56b9d864269 done Copying blob 48a31ab7de6f done Copying blob 64a1a52c74ff done Copying blob 4965dc1ce878 done Copying blob 99f8e046e98a done Copying blob 994393dc58e7 skipped: already exists Copying config a5ffd1129f done Writing manifest to image destination Storing signatures Loaded image(s): dangerzone.rocks/dangerzone:latest [INFO] Container image installed ```
$ df -h ``` Filesystem Size Used Avail Use% Mounted on /dev/xvda3 15G 6.7G 7.2G 49% / none 15G 6.7G 7.2G 49% /usr/lib/modules devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 1.0G 84K 1.0G 1% /dev/shm tmpfs 58M 760K 57M 2% /run tmpfs 1.0G 456K 1.0G 1% /tmp /dev/xvdb 50G 12G 39G 24% /rw tmpfs 29M 148K 29M 1% /run/user/1000 ```
deeplow commented 1 year ago

A way to reproduce this is to have a corrupt container image.

deeplow commented 1 year ago

Actually, this is more what an corrupted installer failure looks like when running Dangerzone for the first time:

This issue happened to my on the dev environment. It's not too concerning. I happened as a consequences of this other one https://github.com/freedomofpress/dangerzone/issues/380.

apyrgio commented 7 months ago

One other way that improper error handling bites us is when the container image is corrupted (possible only on dev environments).

How to reproduce:

  1. Create an invalid tar file (e.g. an empty file),
  2. gzip it, and store it as share/container.tar.gz, and
  3. run the Dangerzone GUI

The user will not see an error in their screen, because we don't handle them:

https://github.com/freedomofpress/dangerzone/blob/f569695bb094d64ee1c381d64cc227058af16184/dangerzone/gui/main_window.py#L341

apyrgio commented 2 months ago

Another dev has recently bumped into this issue (see https://github.com/freedomofpress/dangerzone/issues/883), which means we should prioritize it. After all, it's not that much work.

Adding it tentatively in the 0.8.0 milestone as a stretch goal.