2016-01-28 16:33:02 +03:00
|
|
|
<?php
|
2018-03-05 17:27:05 +03:00
|
|
|
declare(strict_types=1);
|
2016-01-28 16:33:02 +03:00
|
|
|
/**
|
2016-07-21 18:07:57 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Thomas Citharel <tcit@tcit.fr>
|
2016-01-28 16:33:02 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
namespace OC\Security\CSP;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ContentSecurityPolicy extends the public class and adds getter and setters.
|
|
|
|
* This is necessary since we don't want to expose the setters and getters to the
|
|
|
|
* public API.
|
|
|
|
*
|
|
|
|
* @package OC\Security\CSP
|
|
|
|
*/
|
|
|
|
class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy {
|
|
|
|
/**
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function isInlineScriptAllowed(): bool {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->inlineScriptAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param boolean $inlineScriptAllowed
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setInlineScriptAllowed(bool $inlineScriptAllowed) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->inlineScriptAllowed = $inlineScriptAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function isEvalScriptAllowed(): bool {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->evalScriptAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param boolean $evalScriptAllowed
|
2019-07-30 17:27:38 +03:00
|
|
|
*
|
|
|
|
* @deprecated 17.0.0 Unsafe eval should not be used anymore.
|
2016-01-28 16:33:02 +03:00
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setEvalScriptAllowed(bool $evalScriptAllowed) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->evalScriptAllowed = $evalScriptAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedScriptDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedScriptDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedScriptDomains
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setAllowedScriptDomains(array $allowedScriptDomains) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->allowedScriptDomains = $allowedScriptDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function isInlineStyleAllowed(): bool {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->inlineStyleAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param boolean $inlineStyleAllowed
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setInlineStyleAllowed(bool $inlineStyleAllowed) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->inlineStyleAllowed = $inlineStyleAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedStyleDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedStyleDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedStyleDomains
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setAllowedStyleDomains(array $allowedStyleDomains) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->allowedStyleDomains = $allowedStyleDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedImageDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedImageDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedImageDomains
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setAllowedImageDomains(array $allowedImageDomains) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->allowedImageDomains = $allowedImageDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedConnectDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedConnectDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedConnectDomains
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setAllowedConnectDomains(array $allowedConnectDomains) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->allowedConnectDomains = $allowedConnectDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedMediaDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedMediaDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedMediaDomains
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setAllowedMediaDomains(array $allowedMediaDomains) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->allowedMediaDomains = $allowedMediaDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedObjectDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedObjectDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedObjectDomains
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setAllowedObjectDomains(array $allowedObjectDomains) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->allowedObjectDomains = $allowedObjectDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedFrameDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedFrameDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedFrameDomains
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function setAllowedFrameDomains(array $allowedFrameDomains) {
|
2016-01-28 16:33:02 +03:00
|
|
|
$this->allowedFrameDomains = $allowedFrameDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedFontDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedFontDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedFontDomains
|
|
|
|
*/
|
|
|
|
public function setAllowedFontDomains($allowedFontDomains) {
|
|
|
|
$this->allowedFontDomains = $allowedFontDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
2018-09-03 17:54:33 +03:00
|
|
|
* @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
|
2016-01-28 16:33:02 +03:00
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedChildSrcDomains(): array {
|
2016-01-28 16:33:02 +03:00
|
|
|
return $this->allowedChildSrcDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedChildSrcDomains
|
2018-09-03 17:54:33 +03:00
|
|
|
* @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
|
2016-01-28 16:33:02 +03:00
|
|
|
*/
|
|
|
|
public function setAllowedChildSrcDomains($allowedChildSrcDomains) {
|
|
|
|
$this->allowedChildSrcDomains = $allowedChildSrcDomains;
|
|
|
|
}
|
|
|
|
|
2017-06-19 14:55:46 +03:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-05 17:27:05 +03:00
|
|
|
public function getAllowedFrameAncestors(): array {
|
2017-06-19 14:55:46 +03:00
|
|
|
return $this->allowedFrameAncestors;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $allowedFrameAncestors
|
|
|
|
*/
|
|
|
|
public function setAllowedFrameAncestors($allowedFrameAncestors) {
|
|
|
|
$this->allowedFrameAncestors = $allowedFrameAncestors;
|
|
|
|
}
|
|
|
|
|
2018-09-03 17:47:52 +03:00
|
|
|
public function getAllowedWorkerSrcDomains(): array {
|
|
|
|
return $this->allowedWorkerSrcDomains;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains) {
|
|
|
|
$this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains;
|
|
|
|
}
|
|
|
|
|
2018-10-16 15:04:22 +03:00
|
|
|
public function getReportTo(): array {
|
|
|
|
return $this->reportTo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setReportTo(array $reportTo) {
|
|
|
|
$this->reportTo = $reportTo;
|
|
|
|
}
|
|
|
|
|
2016-01-28 16:33:02 +03:00
|
|
|
}
|