Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Stylistic clean-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Dec 22, 2016
1 parent b7a398e commit 1f71e8c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
19 changes: 10 additions & 9 deletions gratipay/security/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ def add_headers_to_response(response):
response.headers['X-XSS-Protection'] = '1; mode=block'

# CSP - https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
# Allow resources from gratipay.com & all gratipay subdomains.
# Allow resources from gratipay.com & assets.gratipay.com.
# Allow images from everywhere for now until we can deploy Camo.
# Allow fonts from cloud.typography.com.
if 'content-security-policy' not in response.headers:
response.headers['content-security-policy'] = ( 'default-src \'self\';'
'script-src assets.gratipay.com;'
'style-src assets.gratipay.com;'
'img-src *;'
'font-src cloud.typography.com;'
'upgrade-insecure-requests;'
'block-all-mixed-content;'
'reflected-xss block;')
response.headers['content-security-policy'] = ("default-src 'self';"
'script-src assets.gratipay.com;'
'style-src assets.gratipay.com;'
'img-src *;'
'font-src cloud.typography.com;'
'upgrade-insecure-requests;'
'block-all-mixed-content;'
'reflected-xss block;')
18 changes: 9 additions & 9 deletions tests/py/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ def test_ahtr_sets_x_xss_protection(self):
headers = self.client.GET('/about/').headers
assert headers['X-XSS-Protection'] == '1; mode=block'

def test_ahtr__csp(self):
def test_ahtr_sets_content_security_policy(self):
headers = self.client.GET('/about/').headers
policy = ('default-src \'self\';'
'script-src assets.gratipay.com;'
'style-src assets.gratipay.com;'
'img-src *;'
'font-src cloud.typography.com;'
'upgrade-insecure-requests;'
'block-all-mixed-content;'
'reflected-xss block;')
policy = ('default-src \'self\';'
'script-src assets.gratipay.com;'
'style-src assets.gratipay.com;'
'img-src *;'
'font-src cloud.typography.com;'
'upgrade-insecure-requests;'
'block-all-mixed-content;'
'reflected-xss block;')
assert headers['content-security-policy'] == policy


Expand Down

0 comments on commit 1f71e8c

Please sign in to comment.