Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions files/nginx/odk.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ server {
location = /-/single/check-submitted {
alias /usr/share/nginx/html/blank.html;
default_type text/html;

add_header Content-Security-Policy-Report-Only "default-src 'none'";
include /usr/share/odk/nginx/common-headers.conf;
}

# For that iframe to work, we'll need another path prefix (enketo-passthrough) under which we can
Expand Down
13 changes: 8 additions & 5 deletions test/nginx/test-nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const none = `'none'`;
const self = `'self'`;
const unsafeInline = `'unsafe-inline'`;
const contentSecurityPolicies = {
'restrictive': {
'backend-default': {
'default-src': none,
'connect-src': [
'https://translate.google.com',
Expand Down Expand Up @@ -36,6 +36,9 @@ const contentSecurityPolicies = {
'style-src-attr': unsafeInline,
'report-uri': '/csp-report',
},
'disallow-all': {
'default-src': none,
},
enketo: {
'default-src': none,
'connect-src': [
Expand Down Expand Up @@ -323,7 +326,7 @@ describe('nginx config', () => {
// then
assert.equal(res.status, 200);
assert.isEmpty((await res.text()).trim());
assertSecurityHeaders(res, { csp:'restrictive' });
assertSecurityHeaders(res, { csp:'disallow-all' });
await assertEnketoReceivedNoRequests();
});

Expand All @@ -334,7 +337,7 @@ describe('nginx config', () => {
// then
assert.equal(res.status, 200);
assert.equal(await res.text(), 'OK');
assertSecurityHeaders(res, { csp:'restrictive' });
assertSecurityHeaders(res, { csp:'backend-default' });
// and
await assertBackendReceived(
{ method:'GET', path:'/v1/some/central-backend/path' },
Expand All @@ -346,7 +349,7 @@ describe('nginx config', () => {
const res = await fetchHttps('/v1/reflect-headers');
// then
assert.equal(res.status, 200);
assertSecurityHeaders(res, { csp:'restrictive' });
assertSecurityHeaders(res, { csp:'backend-default' });

// when
const body = await res.json();
Expand All @@ -364,7 +367,7 @@ describe('nginx config', () => {
// then
assert.equal(res.status, 200);
// and
assertSecurityHeaders(res, { csp:'restrictive' });
assertSecurityHeaders(res, { csp:'backend-default' });

// when
const body = await res.json();
Expand Down