Commit graph

507 commits

Author SHA1 Message Date
Micah Lee
d7cbe419cc
Comment out deploying to fedora 37, because packagecloud.io does not support it yet 2022-09-06 10:43:18 -07:00
Micah Lee
5dd23d13f4
Update download links to 0.3.2 in readme 2022-09-06 10:27:40 -07:00
Micah Lee
b5249284a4
Merge pull request #197 from freedomofpress/196-container-leakage
remove container after use
2022-09-06 10:20:03 -07:00
deeplow
42b4d164cb
Merge pull request #198 from origin/0.3.2-release-updates
Updates to the macOS and Windows build scripts and documentation:
  - Switched from hardcoding the exact minor release of Python 3.9
    to just using Python 3.9
  - Switches from 32-bit Windows Python binaries to 64-bit
  - Install poetry in Windows using pip, which is much simpler and
    less error-prone than the PowerShell way
  - Includes instructions for making the Windows release in a
    Windows 11 VM, and building the container image on the host
  - Updates the fingerprint of the Windows signing key
  - Fixes a small bug with the .wxs file used to build the MSI
    package
2022-08-29 08:41:56 +01:00
Micah Lee
383bd5dbed
Enforce code style 2022-08-26 14:12:01 -07:00
Micah Lee
6713cce503
Updates to the macOS and Windows build scripts and documentation 2022-08-26 14:06:06 -07:00
deeplow
1fa1b90c30
remove container after use
The containers and their respective volumes where not being deleted.
By adding `--rm` to the `podman run` it now removes the containers
after use along with anonymous (unnamed) volumes [1]. The same
happens in docker [2].

Fixes #196

[1]: https://docs.podman.io/en/latest/markdown/podman-run.1.html#volume-v-source-volume-host-dir-container-dir-options
[2]: https://docs.docker.com/storage/volumes/#remove-volumes
2022-08-26 10:14:43 +01:00
deeplow
eabf7a9c18
bump version (0.3.2) & append to CHANGELOG.md 2022-08-25 09:23:40 +01:00
deeplow
6b385abfef
fix regression: --output-filename fails
--output-filename failed with the message:

   Safe PDF filename is not writable

Bug introduced in commit 95ed346.
2022-08-25 09:03:43 +01:00
deeplow
83e6b0475f
add to RELEASE intructions to bump brew cask
fixes #190
2022-08-22 13:20:30 +01:00
deeplow
ec3b92a008
install_container return true when already installed 2022-08-22 12:28:50 +01:00
deeplow
092456434b
don't type check dev scripts 2022-08-22 12:28:48 +01:00
deeplow
23e30ae40a
check that OCR_LANGUAGE has also been set 2022-08-22 12:28:46 +01:00
deeplow
463ff97b97
add type hints to container dz py code 2022-08-22 12:28:44 +01:00
deeplow
f44e6521b6
better handle QFileDialog.getOpenFileName filename 2022-08-22 12:28:39 +01:00
deeplow
e0b3c5b599
resolve naming conflict: QWidget.update()
QWidget.update() is already a built-in Qt method [1]. This method
was unintentionally being overriden. Renamed it to update_progress
to fix it.

[1]: https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QWidget.html#PySide2.QtWidgets.PySide2.QtWidgets.QWidget.update
2022-08-22 11:13:37 +01:00
deeplow
75ce244195
type hint application wrapper monkeypatch
ignore method assignment. Currently mypy cannot check this.
Related upstream issues:
  - https://github.com/python/mypy/issues/2427
  - https://github.com/python/mypy/issues/708
2022-08-22 11:13:35 +01:00
deeplow
bc7188eb4d
add dev dependency: PySide2-stubs
Mypy was returning many errors relating to PySide2, which didn't
make much sense. This is apparently because there are missing type
hinting stubs for PySide2.

The temporary solution is to add this devel dependency.

Upstream issue: (remove dep. when solved)
  - https://bugreports.qt.io/browse/PYSIDE-1675
2022-08-22 11:13:29 +01:00
deeplow
ec8bafa27c
add mypy lint check 2022-08-22 11:12:24 +01:00
deeplow
392c4bddb5
add blank line at end of file (black lint)
Satisfy the black lint tool
2022-08-22 11:12:22 +01:00
deeplow
201bf5ec03
simplify ansi disabling on mac (removing type issues) 2022-08-22 11:12:20 +01:00
deeplow
95ed34626d
fix type hint in checking if output files exist 2022-08-22 11:12:18 +01:00
deeplow
46a62c1669
fix type hints with commonn input/output filename
Input_filename and output_filename could be None or Str. This lead
to typing issues where the static analysis type hint tool could not
check that the type colisions would not happen in runtime.

So the logic was replaced by throwing a runtime exception if either
of these valiables is ever used without first having been set.
2022-08-22 11:12:16 +01:00
deeplow
7b46d1e3cf
fix spacing (black lint tool) 2022-08-22 11:12:14 +01:00
deeplow
f67c1c3656
fix TypeErrors "object is not subscriptable"
The type hint shoudld be List[] instead of list[] [1] and TypeError:
'ABCMeta' object is not subscriptable (using instead typing.Callable).

[1]: https://mail.python.org/pipermail/python-dev/2017-April/147818.html
2022-08-22 11:12:10 +01:00
deeplow
dcc0b269cd
fix typing for filename in gui_main (is optional) 2022-08-22 11:10:04 +01:00
deeplow
e76132a2f0
add typed hints to Settings dictionary
Originally tied to implment following PEP 589 [1] – TypedDict: Type
Hints for Dictionaries with a Fixed Set of Keys for the Settings
dict.

But this quickly turned out to very challenging without redoing the
code. So we opted instead for using the Any keyword.

[1]: https://peps.python.org/pep-0589/
2022-08-22 11:09:13 +01:00
deeplow
b1c039c4a4
add type hinting to systray (avoid circular imports) 2022-08-22 11:09:11 +01:00
deeplow
b34f7381b4
fix GlobalCommon ref. that was supposed to be Common
The type hints actually warned about this inconsistency.
2022-08-22 11:09:09 +01:00
deeplow
ccacf50db5
simplify resources_path logic to reolve type hint
The following logic was leading to type hint issues:

>	inspect.getfile(inspect.currentframe())

But this code is overly complex for what it does is the same as
simply __file__. So we kill two birds with one stone, so to speak.
2022-08-22 11:09:03 +01:00
deeplow
c69f228261
handle case for no Popen.stdin
Similar to the previous commit (cb0f828)
2022-08-22 10:52:39 +01:00
deeplow
f99131e30c
type hints for container.py & handle no stdout
We added the following check as well:

+        if stdout_callback and p.stdout is not None:

Because, according to the subprocess docs[1]:

>  If the stdout argument was not PIPE, this attribute is None.

In this case, it should not need to confirm that p.stdout is not
None in the mypy static analysis. However it still complained. So
we made mypy the favor and confirmed this was the case.

[1]: https://docs.python.org/3/library/subprocess.html#subprocess.Popen.stdout
2022-08-22 10:52:17 +01:00
deeplow
78daf75638
add type hint to GuiCommon app argument 2022-08-22 10:49:04 +01:00
deeplow
4aab47af38
ignore type hint to windows-only subprocess command
`subprocess.STARTUPINFO()` only exists in windows systems. Because
of this, in linux-based systems it was raising type hint issues
as it didn't recognize the return function.
2022-08-22 10:49:02 +01:00
deeplow
6ddd411be8
add type get_container_runtime & handle no runtime
There was no code to handle if at this stage the runtime existed.
This caused issues with type hints since `shutil.which()` can
return None, which had not previously been accounted for.

We did not use the opportunity to consolidate all the code for
detecting the runtime, to make this review easier.
2022-08-22 10:48:57 +01:00
deeplow
665e4d54f7
add type hints (1st pass: non problematic cases) 2022-08-22 10:33:28 +01:00
deeplow
d579a47a84
add type hints (1st pass: non problematic cases) 2022-08-22 10:33:23 +01:00
deeplow
1f8e23f164
make mypy more pedantic
Borrow the mypy configuration from the securedrop-client Makefile
2022-08-22 10:30:40 +01:00
deeplow
75c4ee3d2b
add mypy lint to makefile 2022-08-22 10:30:38 +01:00
deeplow
93392f8206
add mypy as dev dependency (type checking lint) 2022-08-22 10:30:35 +01:00
deeplow
7bac3eb6b1
remove get_resource_path() comments (too long)
The black lint tool complained.
2022-08-22 10:15:32 +01:00
deeplow
ece36dc287
add lint checks on CI 2022-08-22 10:15:30 +01:00
deeplow
4d8e4c53e3
sort imports with isort linter 2022-08-22 10:15:26 +01:00
deeplow
90a51a0004
apply black lint tool's suggestions 2022-08-22 10:03:59 +01:00
deeplow
6fc0e2c15f
add Makefile with linters (black & isort)
- borrowed makefile self-help code from SecureDrop
- considered windows dev env case: GNU make available via Cygwin
2022-08-22 10:03:57 +01:00
deeplow
b73efb30ae
add isort as dev dependency 2022-08-22 10:03:49 +01:00
deeplow
bd51947fca
deduplicate container_args
The container arguments was duplicated. This could potentially lead
to refactor errors. For example security arg could be added in one
container call but forgotten to be added in a second one.
2022-08-22 09:24:40 +01:00
deeplow
345ac8a396
podman run with --userns=keep-id to mount volumes
Moving to /dangerzone was failing with insuficient permissions:

    Invalid JSON returned from container: PermissionError: [Errno
    13] Permission denied: '/dangerzone/page-3.rgb'

A previous approach was removed in commit 805222. It started with
root at first in a wrapper script and then dropped these
priviledges which running the script.

`--userns=keep-id` solves the mountpoint issues as it maps the user
starting the container is mapped in the container [1].

[1]: https://www.redhat.com/sysadmin/user-flag-rootless-containers
2022-08-22 08:44:00 +01:00
deeplow
21a9a6c98c
running dangerzone without root in container
There was previously a user created in the container but it was not
used via the dockerfile RUN directive (as pointed out by
gmarmstrong[1]).

Fixes #169

[1]: https://github.com/freedomofpress/dangerzone/issues/169#issue-1268399245
2022-08-22 08:43:58 +01:00
deeplow
2d4bad680e
drop all linux kernel capabilities from containers
These are not needed in order to convert documents in the
dangerzone containers.
2022-08-22 08:43:56 +01:00