From 81912feceb6150dd4b43af0aa802d38755bce62d Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Mon, 7 May 2018 17:19:08 -0700 Subject: [PATCH 1/3] Remove libjpeg-dev dependency. Also backs out handling of JPEG images in the custom logo and removes the resizing logic. This will need to be brought back in at a later date when we can add libjpeg-dev as an apt dependency. --- install_files/ansible-base/group_vars/all/securedrop | 2 -- install_files/securedrop-app-code/DEBIAN/control | 2 +- securedrop/Dockerfile | 2 +- securedrop/journalist_app/admin.py | 11 +++-------- securedrop/journalist_app/forms.py | 5 ++--- .../requirements/securedrop-app-code-requirements.in | 1 - .../requirements/securedrop-app-code-requirements.txt | 1 - securedrop/tests/test_journalist.py | 7 +++---- 8 files changed, 10 insertions(+), 21 deletions(-) diff --git a/install_files/ansible-base/group_vars/all/securedrop b/install_files/ansible-base/group_vars/all/securedrop index b50e82f928..00dce351b3 100644 --- a/install_files/ansible-base/group_vars/all/securedrop +++ b/install_files/ansible-base/group_vars/all/securedrop @@ -30,7 +30,6 @@ development_dependencies: - devscripts # for dch - gdb # for gcore in TestSubmissionNotInMemory - paxctl - - libjpeg-dev # These profiles are referenced by multiple machines, such as Application Server # for direct copying at install time, and the build machine for including them @@ -53,7 +52,6 @@ appserver_dependencies: - apparmor-utils - redis-server - supervisor - - libjpeg-dev tor_apt_repo_url: https://tor-apt.freedom.press diff --git a/install_files/securedrop-app-code/DEBIAN/control b/install_files/securedrop-app-code/DEBIAN/control index 355e1c3ae9..494b18a273 100644 --- a/install_files/securedrop-app-code/DEBIAN/control +++ b/install_files/securedrop-app-code/DEBIAN/control @@ -6,5 +6,5 @@ Homepage: https://securedrop.org Package: securedrop-app-code Version: 0.7.0~rc1 Architecture: amd64 -Depends: python-pip,apparmor-utils,gnupg2,haveged,python,python-pip,secure-delete,sqlite,apache2-mpm-worker,libapache2-mod-wsgi,libapache2-mod-xsendfile,redis-server,supervisor,securedrop-keyring,securedrop-config,libjpeg-dev +Depends: python-pip,apparmor-utils,gnupg2,haveged,python,python-pip,secure-delete,sqlite,apache2-mpm-worker,libapache2-mod-wsgi,libapache2-mod-xsendfile,redis-server,supervisor,securedrop-keyring,securedrop-config Description: Packages the SecureDrop application code pip dependencies and apparmor profiles. This package will put the apparmor profiles in enforce mode. This package does use pip to install the pip wheelhouse diff --git a/securedrop/Dockerfile b/securedrop/Dockerfile index a4ca61d990..ea225b558f 100644 --- a/securedrop/Dockerfile +++ b/securedrop/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update && \ apt-get install -y devscripts \ python-pip libpython2.7-dev libssl-dev secure-delete \ gnupg2 ruby redis-server firefox git xvfb haveged curl \ - gettext paxctl x11vnc enchant libjpeg-dev + gettext paxctl x11vnc enchant RUN gem install sass -v 3.4.23 diff --git a/securedrop/journalist_app/admin.py b/securedrop/journalist_app/admin.py index f011cadd4a..1d443c7a6d 100644 --- a/securedrop/journalist_app/admin.py +++ b/securedrop/journalist_app/admin.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from PIL import Image - import os from flask import (Blueprint, render_template, request, url_for, redirect, g, @@ -33,19 +31,16 @@ def manage_config(): form = LogoForm() if form.validate_on_submit(): f = form.logo.data - custom_logo_filepath = os.path.join(config.SECUREDROP_ROOT, - "static/i/custom_logo.png") + custom_logo_filepath = os.path.join(current_app.static_folder, 'i', + 'custom_logo.png') try: - with Image.open(f) as im: - im.thumbnail((500, 450), resample=3) - im.save(custom_logo_filepath, "PNG") + f.save(custom_logo_filepath) flash(gettext("Image updated."), "logo-success") except Exception: flash("Unable to process the image file." " Try another one.", "logo-error") finally: return redirect(url_for("admin.manage_config")) - else: for field, errors in form.errors.items(): for error in errors: diff --git a/securedrop/journalist_app/forms.py b/securedrop/journalist_app/forms.py index 44a09e6307..b3a37847c1 100644 --- a/securedrop/journalist_app/forms.py +++ b/securedrop/journalist_app/forms.py @@ -58,7 +58,6 @@ class ReplyForm(FlaskForm): class LogoForm(FlaskForm): logo = FileField(validators=[ FileRequired(message=gettext('File required.')), - FileAllowed(['jpg', 'png', 'jpeg'], - message=gettext("You can only upload JPG/JPEG" - " or PNG image files.")) + FileAllowed(['png'], + message=gettext("Upload images only.")) ]) diff --git a/securedrop/requirements/securedrop-app-code-requirements.in b/securedrop/requirements/securedrop-app-code-requirements.in index 67d934e70d..aa289a2990 100644 --- a/securedrop/requirements/securedrop-app-code-requirements.in +++ b/securedrop/requirements/securedrop-app-code-requirements.in @@ -17,4 +17,3 @@ scrypt SQLAlchemy typing Werkzeug==0.12.2 -Pillow diff --git a/securedrop/requirements/securedrop-app-code-requirements.txt b/securedrop/requirements/securedrop-app-code-requirements.txt index 07a8a906a0..8de2e9c017 100644 --- a/securedrop/requirements/securedrop-app-code-requirements.txt +++ b/securedrop/requirements/securedrop-app-code-requirements.txt @@ -17,7 +17,6 @@ itsdangerous==0.24 # via flask jinja2==2.10 jsmin==2.2.2 markupsafe==1.0 # via jinja2 -pillow==5.0.0 psutil==5.4.3 pycryptodomex==3.4.7 pyotp==2.2.6 diff --git a/securedrop/tests/test_journalist.py b/securedrop/tests/test_journalist.py index 7b86f27240..2830fb030d 100644 --- a/securedrop/tests/test_journalist.py +++ b/securedrop/tests/test_journalist.py @@ -1042,10 +1042,9 @@ def test_logo_upload_with_invalid_filetype_fails(self): resp = self.client.post(url_for('admin.manage_config'), data=form.data, follow_redirects=True) - self.assertMessageFlashed("You can only upload JPG/JPEG" - " or PNG image files.", "logo-error") - self.assertIn("You can only upload JPG/JPEG" - " or PNG image files.", resp.data) + self.assertMessageFlashed("Upload images only.", + "logo-error") + self.assertIn("Upload images only.", resp.data) def test_logo_upload_with_empty_input_field_fails(self): self._login_admin() From b5e81443d70f9853bc4c1eb583029f7d9df6c258 Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Tue, 8 May 2018 11:22:28 -0700 Subject: [PATCH 2/3] Docs: Fix instructions to run automatic user screenshots updater --- docs/development/documentation_guidelines.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/documentation_guidelines.rst b/docs/development/documentation_guidelines.rst index 5012979b63..d65321d10a 100644 --- a/docs/development/documentation_guidelines.rst +++ b/docs/development/documentation_guidelines.rst @@ -65,7 +65,7 @@ To update these screenshots automatically you can run: .. code:: sh - make -C securedrop images update-user-guides + make -C securedrop update-user-guides This will generate screenshots for each page in the web application and copy them to the folder under ``docs/images/manual/screenshots`` where they will From 6b63b78c5e84e3d08725540818b23ceca999f474 Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Tue, 8 May 2018 11:30:08 -0700 Subject: [PATCH 3/3] Docs: Be explicit that the logo image should be a PNG --- docs/admin.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/admin.rst b/docs/admin.rst index a02c66ada1..4d514843d2 100644 --- a/docs/admin.rst +++ b/docs/admin.rst @@ -332,7 +332,7 @@ Simply click the **Update Instance Config** button: |System Config Page| -And on the instance configuration page, select and upload the image you prefer. +And on the instance configuration page, select and upload the PNG image you prefer. You should see a message appear indicating the change was a success: |Logo Update|