Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
0.1.3: Update PyYAML to 5.1
Browse files Browse the repository at this point in the history
Also simplify package versioning with a VERSION file containing the
version string, e.g. 0.1.3, which will be read in setup.py and
securedrop_proxy/version.py. Now we just have to remember to update
the package version in one place.

Add a test making sure that the proxy reports the same version used in
setup.py.
  • Loading branch information
rmol committed Apr 15, 2019
1 parent 20ec30d commit 974e79b
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 107 deletions.
11 changes: 6 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
include securedrop_proxy/*.py
include requirements.txt
include README.md
include LICENSE
include setup.py
include Pipfile
include Pipfile.lock
include qubes/securedrop.Proxy
include README.md
include VERSION
include config-example.yaml
include qubes/securedrop.Proxy
include requirements.txt
include securedrop_proxy/*.py
include setup.py
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python_version = "3.5"

[packages]
furl = "==2.0.0"
pyyaml = "==3.13"
pyyaml = ">=5.1,<6"
requests = "==2.20.0"
werkzeug = "==0.14.1"

Expand Down
156 changes: 79 additions & 77 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
certifi==2018.10.15 --hash=sha256:a5471c55b011bd45d6155f5c3629310c1d2f1e1a5a899b7e438a223343de583d
certifi==2019.3.9 --hash=sha256:c853c417cf219b632463f6c2b6c8c6dd019604629fa64edc4f6a2eab3562b787
chardet==3.0.4 --hash=sha256:9f178988ca4c86e8a319b51aac1185b6fe5192328eb5a163c286f4bf50b7b3d8
furl==2.0.0 --hash=sha256:cc0eb8998dcc7c5b58bc8625891a9ff563e2765e112024fa3d1e3521481de8b6
idna==2.7 --hash=sha256:954e65e127d0433a352981f43f291a438423d5b385ebf643c70fd740e0634111
orderedmultidict==1.0 --hash=sha256:25489716d76d2cc8aa656bfb00cd40b6ca29d5e11ccde0db60c2b46ad52bb40a
pyyaml==3.13 --hash=sha256:59fa6f097310e25248d5aa1d7b7e619ea22dfaada67e9c65262457b3e5b3a5c8
pyyaml==5.1 --hash=sha256:7645d962897fc1fb04d884af00b8553d64286d6f2fa221a4b38d2f3519a92d7b
requests==2.20.0 --hash=sha256:2a539dd6af40a611f3b8eb3f99d3567781352ece1698b2fab42bf4c2218705b5
six==1.11.0 --hash=sha256:4663c7a1dbed033cfb294f2d534bd6151c0698dc12ecabb4eaa3cb041d758528
six==1.12.0 --hash=sha256:015858cb76044634fe51dc1b729c6bff9550f206971844748a95359fdf42d9a0
urllib3==1.24.1 --hash=sha256:ac4755b0ae019d670d5fb420c39cb531389ab6ca8b652e12f56259f5cbc0ce21
werkzeug==0.14.1 --hash=sha256:177ea4248bf0475cbc060edb35a0bdcf6e6daeac9e1296de5ddb3493e5ec15b9
1 change: 1 addition & 0 deletions securedrop_proxy/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.3
28 changes: 15 additions & 13 deletions securedrop_proxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@
import json
import werkzeug

class Req:
import securedrop_proxy.version as version


class Req:
def __init__(self):
self.method = ''
self.path_query = ''
self.method = ""
self.path_query = ""
self.body = None
self.headers = {}

class Response:

class Response:
def __init__(self, status):
self.status = status
self.body = None
self.headers = {}
self.version = "0.1.2"
self.version = version.version

class Proxy:

class Proxy:
@staticmethod
def _on_done(res):
print(json.dumps(res.__dict__))
Expand Down Expand Up @@ -63,15 +65,15 @@ def prep_request(self):
method = self.req.method

if not self.valid_path(path):
self.simple_error(400, 'Path provided in request did not look valid')
raise ValueError('Path provided was invalid')
self.simple_error(400, "Path provided in request did not look valid")
raise ValueError("Path provided was invalid")

try:
url = furl.furl("{}://{}:{}/{}".format(scheme, host, port, path))
except Exception as e:

self.simple_error(500, 'Proxy error while generating URL to request')
raise ValueError('Error generating URL from provided values')
self.simple_error(500, "Proxy error while generating URL to request")
raise ValueError("Error generating URL from provided values")

url.path.normalize()

Expand Down Expand Up @@ -113,7 +115,7 @@ def handle_non_json_response(self):

def handle_response(self):

ctype = werkzeug.http.parse_options_header(self._presp.headers['content-type'])
ctype = werkzeug.http.parse_options_header(self._presp.headers["content-type"])

if ctype[0] == "application/json":
self.handle_json_response()
Expand All @@ -128,8 +130,8 @@ def proxy(self):

try:
if self.on_save is None:
self.simple_error(400, 'Request callback is not set.')
raise ValueError('Request callback is not set.')
self.simple_error(400, "Request callback is not set.")
raise ValueError("Request callback is not set.")

self.prep_request()
s = requests.Session()
Expand Down
3 changes: 3 additions & 0 deletions securedrop_proxy/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import pkgutil

version = pkgutil.get_data("securedrop_proxy", "VERSION").decode("utf-8")
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import pkgutil
import setuptools

with open("README.md", "r") as fh:
long_description = fh.read()

version = pkgutil.get_data("securedrop_proxy", "VERSION").decode("utf-8")

setuptools.setup(
name="securedrop-proxy",
version="0.1.2",
version=version,
author="Freedom of the Press Foundation",
author_email="securedrop@freedom.press",
description="SecureDrop Qubes proxy service",
long_description=long_description,
long_description_content_type="text/markdown",
license="GPLv3+",
install_requires=["requests","furl", "pyyaml", "werkzeug"],
install_requires=["requests", "furl", "pyyaml", "werkzeug"],
python_requires=">=3.5",
url="https://github.com/freedomofpress/securedrop-proxy",
packages=setuptools.find_packages(exclude=["docs", "tests"]),
Expand All @@ -24,9 +27,5 @@
"Intended Audience :: Developers",
"Operating System :: OS Independent",
),
entry_points={
'console_scripts': [
'sd-proxy = securedrop_proxy.entrypoint:start',
],
},
entry_points={"console_scripts": ["sd-proxy = securedrop_proxy.entrypoint:start"]},
)

0 comments on commit 974e79b

Please sign in to comment.