Skip to content

Commit 32aa4dc

Browse files
committed
form-action change from self to base_url to avoid proxied sites
1 parent 1f9e0de commit 32aa4dc

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎Allura/allura/tests/functional/test_root.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_error_page(self):
212212
'csp.script_src_enforce': True})
213213
def test_headers(self):
214214
resp = self.app.get('/p')
215-
expected_headers = "form-action 'self'; frame-src 'self' www.youtube-nocookie.com; object-src 'none';"
215+
expected_headers = f"form-action {tg.config['base_url']}; frame-src 'self' www.youtube-nocookie.com; object-src 'none';"
216216
expected_headers += "frame-ancestors 'self'; report-uri https://example.com/r/d/csp/enforce; script-src 'self;"
217217
csp_headers = resp.headers.getall('Content-Security-Policy')[0]
218218
assert all([h.strip() in csp_headers for h in expected_headers.split(';')])
@@ -228,7 +228,7 @@ def test_headers_report(self):
228228
resp = self.app.get('/p/wiki/Home/')
229229
expected_headers = "report-uri https://example.com/r/d/csp/reportOnly;"
230230
expected_headers += "frame-src 'self' www.youtube-nocookie.com; script-src 'self' ;"
231-
expected_headers += "form-action 'self'"
231+
expected_headers += f"form-action {tg.config['base_url']}"
232232

233233
csp_headers = resp.headers.getall('Content-Security-Policy-Report-Only')[0]
234234
assert all([h.strip() in csp_headers for h in expected_headers.split(';')])
@@ -240,7 +240,7 @@ def test_headers_frame_sources_enforce(self):
240240
expected_headers = "report-uri https://example.com/r/d/csp/enforce;"
241241
expected_headers += "frame-src 'self' www.youtube-nocookie.com;"
242242
expected_headers += "object-src 'none'"
243-
expected_report_headers = "script-src 'self' ; form-action 'self'"
243+
expected_report_headers = f"script-src 'self' ; form-action {tg.config['base_url']}"
244244
csp_headers = resp.headers.getall('Content-Security-Policy')[0]
245245
csp_report_headers = resp.headers.getall('Content-Security-Policy-Report-Only')[0]
246246
assert all([h.strip() in csp_headers for h in expected_headers.split(';')])

‎Allura/test.ini‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ debug = false
5454
stats.sample_rate = 0
5555

5656
base_url = http://localhost
57+
csp.form_action_urls = http://localhost
5758

5859
; specify these without any build_key being included
5960
ew.script_name = /nf/_ew_/

0 commit comments

Comments
 (0)