ContentSecurityPolicy.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. * @author Thomas Citharel <nextcloud@tcit.fr>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OC\Security\CSP;
  26. /**
  27. * Class ContentSecurityPolicy extends the public class and adds getter and setters.
  28. * This is necessary since we don't want to expose the setters and getters to the
  29. * public API.
  30. *
  31. * @package OC\Security\CSP
  32. */
  33. class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy {
  34. public function isInlineScriptAllowed(): bool {
  35. return $this->inlineScriptAllowed;
  36. }
  37. public function setInlineScriptAllowed(bool $inlineScriptAllowed): void {
  38. $this->inlineScriptAllowed = $inlineScriptAllowed;
  39. }
  40. public function isEvalScriptAllowed(): bool {
  41. return $this->evalScriptAllowed;
  42. }
  43. /**
  44. * @deprecated 17.0.0 Unsafe eval should not be used anymore.
  45. */
  46. public function setEvalScriptAllowed(bool $evalScriptAllowed): void {
  47. $this->evalScriptAllowed = $evalScriptAllowed;
  48. }
  49. public function isEvalWasmAllowed(): ?bool {
  50. return $this->evalWasmAllowed;
  51. }
  52. public function setEvalWasmAllowed(bool $evalWasmAllowed): void {
  53. $this->evalWasmAllowed = $evalWasmAllowed;
  54. }
  55. public function getAllowedScriptDomains(): array {
  56. return $this->allowedScriptDomains;
  57. }
  58. public function setAllowedScriptDomains(array $allowedScriptDomains): void {
  59. $this->allowedScriptDomains = $allowedScriptDomains;
  60. }
  61. public function isInlineStyleAllowed(): bool {
  62. return $this->inlineStyleAllowed;
  63. }
  64. public function setInlineStyleAllowed(bool $inlineStyleAllowed): void {
  65. $this->inlineStyleAllowed = $inlineStyleAllowed;
  66. }
  67. public function getAllowedStyleDomains(): array {
  68. return $this->allowedStyleDomains;
  69. }
  70. public function setAllowedStyleDomains(array $allowedStyleDomains): void {
  71. $this->allowedStyleDomains = $allowedStyleDomains;
  72. }
  73. public function getAllowedImageDomains(): array {
  74. return $this->allowedImageDomains;
  75. }
  76. public function setAllowedImageDomains(array $allowedImageDomains): void {
  77. $this->allowedImageDomains = $allowedImageDomains;
  78. }
  79. public function getAllowedConnectDomains(): array {
  80. return $this->allowedConnectDomains;
  81. }
  82. public function setAllowedConnectDomains(array $allowedConnectDomains): void {
  83. $this->allowedConnectDomains = $allowedConnectDomains;
  84. }
  85. public function getAllowedMediaDomains(): array {
  86. return $this->allowedMediaDomains;
  87. }
  88. public function setAllowedMediaDomains(array $allowedMediaDomains): void {
  89. $this->allowedMediaDomains = $allowedMediaDomains;
  90. }
  91. public function getAllowedObjectDomains(): array {
  92. return $this->allowedObjectDomains;
  93. }
  94. public function setAllowedObjectDomains(array $allowedObjectDomains): void {
  95. $this->allowedObjectDomains = $allowedObjectDomains;
  96. }
  97. public function getAllowedFrameDomains(): array {
  98. return $this->allowedFrameDomains;
  99. }
  100. public function setAllowedFrameDomains(array $allowedFrameDomains): void {
  101. $this->allowedFrameDomains = $allowedFrameDomains;
  102. }
  103. public function getAllowedFontDomains(): array {
  104. return $this->allowedFontDomains;
  105. }
  106. public function setAllowedFontDomains($allowedFontDomains): void {
  107. $this->allowedFontDomains = $allowedFontDomains;
  108. }
  109. /**
  110. * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
  111. */
  112. public function getAllowedChildSrcDomains(): array {
  113. return $this->allowedChildSrcDomains;
  114. }
  115. /**
  116. * @param array $allowedChildSrcDomains
  117. * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
  118. */
  119. public function setAllowedChildSrcDomains($allowedChildSrcDomains): void {
  120. $this->allowedChildSrcDomains = $allowedChildSrcDomains;
  121. }
  122. public function getAllowedFrameAncestors(): array {
  123. return $this->allowedFrameAncestors;
  124. }
  125. /**
  126. * @param array $allowedFrameAncestors
  127. */
  128. public function setAllowedFrameAncestors($allowedFrameAncestors): void {
  129. $this->allowedFrameAncestors = $allowedFrameAncestors;
  130. }
  131. public function getAllowedWorkerSrcDomains(): array {
  132. return $this->allowedWorkerSrcDomains;
  133. }
  134. public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains): void {
  135. $this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains;
  136. }
  137. public function getAllowedFormActionDomains(): array {
  138. return $this->allowedFormActionDomains;
  139. }
  140. public function setAllowedFormActionDomains(array $allowedFormActionDomains): void {
  141. $this->allowedFormActionDomains = $allowedFormActionDomains;
  142. }
  143. public function getReportTo(): array {
  144. return $this->reportTo;
  145. }
  146. public function setReportTo(array $reportTo): void {
  147. $this->reportTo = $reportTo;
  148. }
  149. public function isStrictDynamicAllowed(): bool {
  150. return $this->strictDynamicAllowed;
  151. }
  152. public function setStrictDynamicAllowed(bool $strictDynamicAllowed): void {
  153. $this->strictDynamicAllowed = $strictDynamicAllowed;
  154. }
  155. public function isStrictDynamicAllowedOnScripts(): bool {
  156. return $this->strictDynamicAllowedOnScripts;
  157. }
  158. public function setStrictDynamicAllowedOnScripts(bool $strictDynamicAllowedOnScripts): void {
  159. $this->strictDynamicAllowedOnScripts = $strictDynamicAllowedOnScripts;
  160. }
  161. }