Skip to content
Snippets Groups Projects
Unverified Commit 9163790b authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Set frame-ancestors to none if none are filled


frame-ancestors doesn't fall back to default-src. So when we apply a
very restricted CSP we should make sure to set it to 'none' and not
leave it empty.

Signed-off-by: default avatarRoeland Jago Douma <roeland@famdouma.nl>
parent 5acabcf5
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ Feature: sharing ...@@ -14,7 +14,7 @@ Feature: sharing
Then the OCS status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200" And the HTTP status code should be "200"
And The following headers should be set And The following headers should be set
| Content-Security-Policy | default-src 'none';base-uri 'none';manifest-src 'self' | | Content-Security-Policy | default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none' |
Scenario: Creating a share with a group Scenario: Creating a share with a group
Given user "user0" exists Given user "user0" exists
......
...@@ -509,6 +509,8 @@ class EmptyContentSecurityPolicy { ...@@ -509,6 +509,8 @@ class EmptyContentSecurityPolicy {
if (!empty($this->allowedFrameAncestors)) { if (!empty($this->allowedFrameAncestors)) {
$policy .= 'frame-ancestors ' . implode(' ', $this->allowedFrameAncestors); $policy .= 'frame-ancestors ' . implode(' ', $this->allowedFrameAncestors);
$policy .= ';'; $policy .= ';';
} else {
$policy .= 'frame-ancestors \'none\';';
} }
if (!empty($this->allowedWorkerSrcDomains)) { if (!empty($this->allowedWorkerSrcDomains)) {
......
...@@ -112,7 +112,7 @@ class ControllerTest extends \Test\TestCase { ...@@ -112,7 +112,7 @@ class ControllerTest extends \Test\TestCase {
'test' => 'something', 'test' => 'something',
'Cache-Control' => 'no-cache, no-store, must-revalidate', 'Cache-Control' => 'no-cache, no-store, must-revalidate',
'Content-Type' => 'application/json; charset=utf-8', 'Content-Type' => 'application/json; charset=utf-8',
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'", 'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'",
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'", 'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
'X-Robots-Tag' => 'none', 'X-Robots-Tag' => 'none',
]; ];
......
...@@ -65,7 +65,7 @@ class DataResponseTest extends \Test\TestCase { ...@@ -65,7 +65,7 @@ class DataResponseTest extends \Test\TestCase {
$expectedHeaders = [ $expectedHeaders = [
'Cache-Control' => 'no-cache, no-store, must-revalidate', 'Cache-Control' => 'no-cache, no-store, must-revalidate',
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'", 'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'",
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'", 'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
'X-Robots-Tag' => 'none', 'X-Robots-Tag' => 'none',
]; ];
......
...@@ -57,7 +57,7 @@ class ResponseTest extends \Test\TestCase { ...@@ -57,7 +57,7 @@ class ResponseTest extends \Test\TestCase {
$this->childResponse->setHeaders($expected); $this->childResponse->setHeaders($expected);
$headers = $this->childResponse->getHeaders(); $headers = $this->childResponse->getHeaders();
$expected['Content-Security-Policy'] = "default-src 'none';base-uri 'none';manifest-src 'self'"; $expected['Content-Security-Policy'] = "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'";
$expected['Feature-Policy'] = "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'"; $expected['Feature-Policy'] = "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'";
$this->assertEquals($expected, $headers); $this->assertEquals($expected, $headers);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment