Commit graph

592 commits

Author SHA1 Message Date
deeplow
a8001d4f3e
Comment out settings_widget temporarily
The settings widget will be broken when we add multiple document
support in the GUI, at first, at least.
2022-11-21 12:37:43 +00:00
deeplow
bf8ca96a44
Rename 'convert_widget' to 'documents_list' 2022-11-21 12:37:42 +00:00
deeplow
0444fc56ec
Temporarily show all dangerzone widgets (for debugging) 2022-11-21 12:37:41 +00:00
deeplow
89f5e99b0c
Initial GUI multi-window opening via terminal
Allow opening multiple documents at the same time from the terminal
by calling

  $ dangerzone document1.pdf document2.pdf

It will open each document in its own window, making use of the
already existing 'multi-document multi-window' parallel conversion
implementation.
2022-11-21 12:37:39 +00:00
deeplow
1e16eca392
remove unneeded imports: plistlib, grp, getpass
plistlib:
  - originaly added in commit 3be1d63330
  - no longer needed

grp, getpass:
  - originally added in commit ae7c919d8e
  - used for finding the 'docker' executable. No longer needed.
2022-11-18 13:09:01 +00:00
deeplow
0b738ba490
Do not create outfile files when checking if writeable
Checking if files were writeable created files in the process. In the
case where someone adds a list of N files to dangerzone but exits before
converting, they would be left with N 0-byte files for the -safe
version. Now they don't.

Fixes #214
2022-11-14 09:04:54 +00:00
deeplow
93f17b3166
Specialize DocumentFilenameException() for disambiguation
All filename-related exceptions were of class DocumentFilenameException.
This made it difficult to disambiguate them. Specializing them makes it
it easier for tests to detect which exception in particular we want to
verify.
2022-11-14 09:04:23 +00:00
deeplow
1bdbb1959c
Changelog: add cli multi-doc support 2022-11-14 09:04:19 +00:00
deeplow
d71e230173
Update document state exclusively in convert()
The document's state update is better update in the convert() function.
This is because this function is always called for the conversion
progress regardless of the frontend.
2022-11-14 09:03:50 +00:00
deeplow
65ac0d19c3
Add an identifier to each document
With multiple input documents it is possible only one of them has
issues. Mentioning the document id can help debug.
2022-11-14 09:03:36 +00:00
deeplow
6d2fdf0afe
Deduplicate container output parsing (stdout_callback)
The container output logging logic was in both the CLI and the GUI.
This change moves the core parsing logic to container.py.

Since the code was largely the same, now cli does need to specify
a stdout_callback since all the necessary logging already happens.

The GUI now only adds an stdout_callback to detect if there was an
error during the conversion process.
2022-11-14 08:54:02 +00:00
deeplow
2d587f4082
Parallel cli bulk conversions via threading
Initial parallel document conversion: creates a pool of N threads
defined by the setting 'parallel_conversions'. Each thread calls
convert() on a document.
2022-11-14 08:54:00 +00:00
deeplow
e17912888a
Add test cases for bulk document conversion 2022-11-14 08:53:59 +00:00
deeplow
f9b564be03
Security: cli wildcard injection mitigation
Wildcard arguments like `*` can lead to security vulnerabilities
if files are maliciously named as would-be parameters. In the following
scenario if a file in the current directory was named '--help', running
the following command would show the help.

  $ dangerzone-cli *

By checking if parameters also happen to be files, we mitigate this
risk and have a chance to warn the user.
2022-11-14 08:53:38 +00:00
deeplow
981716ccff
Sequential bulk document support in cli
Basic implementation of bulk document support in dangerzone-cli.

Usage: dangerzone-cli [OPTIONS] doc1.pdf doc2.pdf
2022-11-14 08:51:00 +00:00
Alex Pyrgiotis
1147698287
Update changelog wrt Ubuntu Focal
Signed-off-by: Alex Pyrgiotis <alex.p@freedom.press>
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
e7a8ea8e9f
Add extra installation steps for Ubuntu Focal
Add extra installations steps for installing Podman in Ubuntu Focal,
since it's not present in the official Ubuntu repos. This is the final
requirement to reinstate Ubuntu Focal support.

Closes #206
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
badafaaf15
ci: Reinstate Ubuntu Focal support
Reinstate support for Ubuntu Focal, which was previously removed in
commit 229ebbda14.

Refs #206
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
1daaafe2a3
install: Introduce a script for installing Podman
Introduce a script for installing Podman in Ubuntu Focal, in
environments that may, or may not, have sudo installed.

Also, update our CircleCI configuration to use this script when
installing Podman.
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
5a3a46cd46
Support Click 7.x callback handling
Support Click version 7.x and below, which inspect the number of
arguments a callback handler supports.

Refs #206
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
ef5abe1419
Report missing supported versions
Report some Linux versions that were recently supported (Debian 12 /
Fedora 37) in the installation instructions. These instructions where
copied from the Dangerzone wiki, which is why the recently supported
versions were missing.
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
b9fdafe5cc
Copy installation instructions to source
Copy installation instructions from the Dangerzone wiki [1] into the
Dangerzone source. This has several benefits:

1. Devs can update installation instructions as part of a PR.
2. Users can see installation instructions for previous releases.

The last point is important, because we can update our instructions in
the main branch, without affecting the instructions a user follows from
the website (currently pointing to the Dangerzone Wiki).

Refs #240

[1]: https://github.com/freedomofpress/dangerzone/wiki/Installing-Dangerzone
2022-11-10 16:35:43 +02:00
Guthrie McAfee Armstrong
2085405d05
Remove redundant f-strings 2022-11-10 09:59:09 +00:00
deeplow
968fd20ac7
fix comma typo 2022-11-10 09:59:08 +00:00
deeplow
e4ff9801ee
make lint happy 2022-11-10 09:59:05 +00:00
Guthrie McAfee Armstrong
1bd8354228
simplify setting percentage to 0.0 2022-11-10 09:59:04 +00:00
Guthrie McAfee Armstrong
9989ffea37
catch ValueError, simplify try/except on top-level job runs
See https://github.com/freedomofpress/dangerzone/pull/167#discussion_r915757189
2022-11-10 09:59:02 +00:00
Guthrie McAfee Armstrong
6b44db9043
Update container/dangerzone.py
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:59:01 +00:00
Guthrie McAfee Armstrong
3ef8b183e2
Update container/dangerzone.py
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:58:59 +00:00
Guthrie McAfee Armstrong
2533eac4be
Rename ConversionJob back to DangerzoneConverter
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:58:57 +00:00
Guthrie McAfee Armstrong
5a4bf99211
Remove another "END OF FOR LOOP" comment 2022-11-10 09:58:54 +00:00
Guthrie McAfee Armstrong
c18f170caf
Remove "END OF FOR LOOP" comment
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:58:53 +00:00
Guthrie McAfee Armstrong
17939cb70c
Wrap dangerzone.py back into a class to keep track of percentage 2022-11-10 09:58:51 +00:00
Guthrie McAfee Armstrong
eaa08c9c3d
refactor dangerzone.py, raise exceptions instead of returning int
Standardize calls to subprocess.run to shrink file by about 100 lines
2022-11-10 09:58:50 +00:00
Guthrie McAfee Armstrong
7a84b89410
(container functions): Replace int return codes with raised exceptions 2022-11-10 09:58:48 +00:00
Guthrie McAfee Armstrong
c78b1ea71b
Flatten DangerzoneConverter methods into functions 2022-11-10 09:58:45 +00:00
Alex Pyrgiotis
82fc69655e
Align Poetry instructions across OSes
Align build instructions about Python Poetry, which where previously
present only on MacOS and Windows. With this commit we:

1. Add Poetry instructions on Linux.
2. Add missing Poetry instructions on Windows, when running Dangerzone
   from source.
2022-11-07 12:03:24 +02:00
Alex Pyrgiotis
1ea015bb68
Bump changelog 2022-11-07 12:03:24 +02:00
Alex Pyrgiotis
43617366a5
Update poetry.lock
Run `poetry update` to update the `poetry.lock` file to the latest
version.
2022-11-07 11:46:41 +02:00
deeplow
b1892077fa
Add fedora 37 support in CI
Fedora 37 had been removed (commit d7cbe41) due to lack of support by
packagecloud (our package hosting solution at the time). This will no
longer be true and thus we can add this distro to the list of supported.
2022-10-27 14:53:17 +01:00
deeplow
52bd7b3033
Add long description to setup.py
Building stdeb on bookworm is failing [1] on a missing long_description:

    File "/usr/lib/python3/dist-packages/stdeb/util.py", line 934, in __init__
        for line in long_description.split('\n'):
    AttributeError: 'NoneType' object has no attribute 'split'

[1]: https://app.circleci.com/pipelines/github/freedomofpress/dangerzone/484/workflows/38c579d5-b335-49ab-b56d-9539d93ef16e/jobs/2110
2022-10-27 14:49:25 +01:00
deeplow
77c7cba563
Add support for Debian Bookworm
Fixes #172
2022-10-27 14:49:23 +01:00
Alex Pyrgiotis
a14b4e9620
Fix a minor typo 2022-10-27 13:44:18 +01:00
deeplow
649e427486
Make DangerzoneGui a subclass of DangerzoneCore
Simplify state sharing by having all dangerzone core logic in one
single class instead of two.
2022-10-27 13:44:16 +01:00
deeplow
dca290fb6b
Rename gui.common.GuiCommon class to gui.logic.DangerzoneGui
Rename the `gui.common` module and `gui.common.GuiCommon` class
to `gui.logic` and `gui.logic.DangerzoneGui` respectively. We keep as is
the original names of the variables that hold instances of this class,
since they will change in subsequent commits.

This change is part of the initial refactor to make the DangerzoneGui
class handle the GUI logic of the Dangerzone project.
2022-10-27 13:44:15 +01:00
deeplow
cb8130042e
Rename global_common.GlobalCommon class to logic.Dangerzone
Rename the `global_common` module and `global_common.GlobalCommon` class
to `logic` and `logic.Dangerzone` respectively. Also rename variables
that hold instances of this class.

This change is part of the initial refactor to make the Dangerzone class
handle the core logic of the Dangerzone project.
2022-10-27 13:44:13 +01:00
deeplow
2bed3c10e4
Move safe PDF naming logic to document.py
Let the Document class suggest the default filename for the safe PDF,
based on the provided input filename, appended with the extension
`-safe.pdf`.

Previously, this logic was copy-pasted throughout the code, which made
it difficult to maintain.
2022-10-27 13:44:12 +01:00
deeplow
7aa08457bd
Always resolve relative paths in Document class
Make the Document class always resolve relative input/output file paths,
which are usually passed as arguments by users.

Previously, resolving relative filepaths was a job left to the
instantiators of the Document class. This was error-prone since this
conversion must happen in all the places where we instantiated the
Document class.
2022-10-27 13:44:11 +01:00
deeplow
be5a942a73
Add unit tests for document.py 2022-10-27 13:44:09 +01:00
Alex Pyrgiotis
a068770ab4
Validate filename arguments through Click
Implement Click's callback interface and create validators for the
input/output filenames, using the logic from the Document class. This
way, we can catch user errors as early as possible.
2022-10-27 13:44:08 +01:00