Commit graph

482 commits

Author SHA1 Message Date
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
deeplow
a02801cc2d
add again the --security-opt flag
Had previously been added but removed in a refactor (see commit
488dca).
2022-08-22 08:43:32 +01:00
Guthrie McAfee Armstrong
e63c931800
Remove psutil, termcolor, and wmi dependencies 2022-08-19 15:16:19 +01:00
Guthrie McAfee Armstrong
575c4b2302
Remove macholib dependency (fix #145) 2022-08-19 15:16:16 +01:00
Guthrie McAfee Armstrong
395eba0a74
Remove requests dependency 2022-08-19 15:16:14 +01:00
Guthrie McAfee Armstrong
0b9e91434d
Update poetry.lock 2022-08-19 15:15:00 +01:00
deeplow
f2f2e6f143
in cli-mode banner should be printed instead
Was calling color spillover to the adjacent text if the banner was
logged instead of printed. Since this is the CLI version, it could
make sense to have this printed.
2022-08-18 12:20:26 +01:00
deeplow
67d91be81a
replace prints with logging
fixes #144: printing non-ascii characters in a macOS application
opened directly from finder would sometimes lead to an error
message in /var/log/system.log similar to this:

  Failed to execute script 'dangerzone' due to unhandled exception:
  'ascii' codec can't encode character '\u201c' in position 1:
  ordinal not in range(128)
2022-08-18 12:07:23 +01:00
deeplow
c2a140807f
simplify get_resource_path logic
Simplifying the logic for obtaining resource paths by using pathlib
instead inspect.

Co-authored-by: Guthrie McAfee Armstrong <git@gmarmstrong.dev>
Based on commit bbce13d
2022-08-16 17:06:43 +01:00
deeplow
4d9f729654
fix win build failure due to package autodiscovery
Setuptools was trying to autodiscover packages with an error
described in #178 [1]. Adding the packages arg to setup() solves
it. In the future we may want to centralize the package list in
a pyproject.toml, once it goes out of beta in setuptools [2].

Fixes #178

[1]: https://github.com/freedomofpress/dangerzone/issues/178
[2]: https://setuptools.pypa.io/en/latest/userguide/package_discovery.html?highlight=package%20discovery#package-discovery-and-namespace-packages
2022-08-16 14:29:11 +01:00
deeplow
80a3543202
Merge branch 'update-ci' 2022-08-05 11:38:20 +01:00
deeplow
c713801e77
remove EOL ubuntu versions 2022-08-04 19:23:41 +01:00
deeplow
47364c200c
disable debian 12 while waiting on upsteam fix
More details at https://github.com/freedomofpress/dangerzone/issues/172
2022-07-20 10:23:58 +01:00
deeplow
72f5200de5
Merge pull request #171 from montoyamoraga/patch-1
delete repetition of word "of"
2022-07-15 05:13:09 -04:00
deeplow
a04ed076cb
update distros in CI (deprecate old & add new ver.) 2022-07-11 11:01:19 +01:00
aarón montoya-moraga
9733e562f9
delete repetition of word "of" 2022-06-26 01:59:54 -04:00
Micah Lee
d8adb2e9cc
Properly cleanup after conversion 2021-12-14 12:29:55 -08:00
Micah Lee
17e1121e57
Version bump to 0.3.1 and update changelog 2021-12-14 10:27:41 -08:00
Micah Lee
ccb5d85afa
Fix "open with" Dangerzone in macOS 2021-12-14 10:21:42 -08:00
Micah Lee
c19d8aad86
Add icon to Windows binaries 2021-12-14 09:12:20 -08:00
Micah Lee
20c0edec4a
Merge pull request #142 from firstlookmedia/131-packaging
Switch Windows packaging to cx_Freeze
2021-12-13 16:46:33 -08:00
Micah Lee
0cf514eba7
Fix version path 2021-12-13 15:32:35 -08:00
Micah Lee
a710178d75
Add package scripts for windows 2021-12-13 15:25:41 -08:00
Micah Lee
bc8b9d62b4
Switch Windows package from pyinstaller to cx_freeze 2021-12-13 15:23:45 -08:00
Micah Lee
2206df0422
Merge pull request #141 from firstlookmedia/137-docker-exception
Ignore exceptions when there's an error deleting an old container image
2021-12-13 11:37:44 -08:00
Micah Lee
c312420aba
Ignore exceptions when there's an error deleting an old container image 2021-12-13 11:37:19 -08:00