Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Expose methods to disable CSP or loosen it for embedded iframes" #17952

Merged
merged 1 commit into from Sep 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 1 addition & 27 deletions core/View/SecurityPolicy.php
Expand Up @@ -16,13 +16,6 @@
*/
class SecurityPolicy
{
/*
* Commonly used rules
*/
const RULE_DEFAULT = "'self' 'unsafe-inline' 'unsafe-eval'";
const RULE_IMG_DEFAULT = "'self' 'unsafe-inline' 'unsafe-eval' data:"
const RULE_EMBEDDED_FRAME = "'self' 'unsafe-inline' 'unsafe-eval' data: https: http:";

/**
* The policies that will generate the CSP header.
* These are keyed by the directive.
Expand All @@ -38,8 +31,7 @@ class SecurityPolicy
* Constructor.
*/
public function __construct(Config $config) {
$this->policies['default-src'] = self::RULE_DEFAULT;
$this->policies['img-src'] = self::RULE_IMG_DEFAULT;
$this->policies['default-src'] = "'self' 'unsafe-inline' 'unsafe-eval'";

$generalConfig = $config->General;
$this->cspEnabled = $generalConfig['csp_enabled'];
Expand Down Expand Up @@ -76,14 +68,6 @@ public function overridePolicy($directive, $value) {
$this->policies[$directive] = $value;
}

/**
* Disable CSP
*
*/
public function disable() {
$this->cspEnabled = false;
}

/**
* Creates the Header String that can be inserted in the Content-Security-Policy header.
*
Expand All @@ -105,14 +89,4 @@ public function createHeaderString() {

return $headerString;
}

/**
* A less restrictive CSP which will allow embedding other sites with iframes
* (useful for heatmaps and session recordings)
*
*/
public function allowEmbedPage() {
$this->overridePolicy('default-src', self::RULE_EMBEDDED_FRAME);
$this->addPolicy('script-src', self::RULE_DEFAULT);
}
}