ContentSecurityPolicy.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. /**
  35. * @return boolean
  36. */
  37. public function isInlineScriptAllowed(): bool {
  38. return $this->inlineScriptAllowed;
  39. }
  40. /**
  41. * @param boolean $inlineScriptAllowed
  42. */
  43. public function setInlineScriptAllowed(bool $inlineScriptAllowed) {
  44. $this->inlineScriptAllowed = $inlineScriptAllowed;
  45. }
  46. /**
  47. * @return boolean
  48. */
  49. public function isEvalScriptAllowed(): bool {
  50. return $this->evalScriptAllowed;
  51. }
  52. /**
  53. * @param boolean $evalScriptAllowed
  54. *
  55. * @deprecated 17.0.0 Unsafe eval should not be used anymore.
  56. */
  57. public function setEvalScriptAllowed(bool $evalScriptAllowed) {
  58. $this->evalScriptAllowed = $evalScriptAllowed;
  59. }
  60. /**
  61. * @return array
  62. */
  63. public function getAllowedScriptDomains(): array {
  64. return $this->allowedScriptDomains;
  65. }
  66. /**
  67. * @param array $allowedScriptDomains
  68. */
  69. public function setAllowedScriptDomains(array $allowedScriptDomains) {
  70. $this->allowedScriptDomains = $allowedScriptDomains;
  71. }
  72. /**
  73. * @return boolean
  74. */
  75. public function isInlineStyleAllowed(): bool {
  76. return $this->inlineStyleAllowed;
  77. }
  78. /**
  79. * @param boolean $inlineStyleAllowed
  80. */
  81. public function setInlineStyleAllowed(bool $inlineStyleAllowed) {
  82. $this->inlineStyleAllowed = $inlineStyleAllowed;
  83. }
  84. /**
  85. * @return array
  86. */
  87. public function getAllowedStyleDomains(): array {
  88. return $this->allowedStyleDomains;
  89. }
  90. /**
  91. * @param array $allowedStyleDomains
  92. */
  93. public function setAllowedStyleDomains(array $allowedStyleDomains) {
  94. $this->allowedStyleDomains = $allowedStyleDomains;
  95. }
  96. /**
  97. * @return array
  98. */
  99. public function getAllowedImageDomains(): array {
  100. return $this->allowedImageDomains;
  101. }
  102. /**
  103. * @param array $allowedImageDomains
  104. */
  105. public function setAllowedImageDomains(array $allowedImageDomains) {
  106. $this->allowedImageDomains = $allowedImageDomains;
  107. }
  108. /**
  109. * @return array
  110. */
  111. public function getAllowedConnectDomains(): array {
  112. return $this->allowedConnectDomains;
  113. }
  114. /**
  115. * @param array $allowedConnectDomains
  116. */
  117. public function setAllowedConnectDomains(array $allowedConnectDomains) {
  118. $this->allowedConnectDomains = $allowedConnectDomains;
  119. }
  120. /**
  121. * @return array
  122. */
  123. public function getAllowedMediaDomains(): array {
  124. return $this->allowedMediaDomains;
  125. }
  126. /**
  127. * @param array $allowedMediaDomains
  128. */
  129. public function setAllowedMediaDomains(array $allowedMediaDomains) {
  130. $this->allowedMediaDomains = $allowedMediaDomains;
  131. }
  132. /**
  133. * @return array
  134. */
  135. public function getAllowedObjectDomains(): array {
  136. return $this->allowedObjectDomains;
  137. }
  138. /**
  139. * @param array $allowedObjectDomains
  140. */
  141. public function setAllowedObjectDomains(array $allowedObjectDomains) {
  142. $this->allowedObjectDomains = $allowedObjectDomains;
  143. }
  144. /**
  145. * @return array
  146. */
  147. public function getAllowedFrameDomains(): array {
  148. return $this->allowedFrameDomains;
  149. }
  150. /**
  151. * @param array $allowedFrameDomains
  152. */
  153. public function setAllowedFrameDomains(array $allowedFrameDomains) {
  154. $this->allowedFrameDomains = $allowedFrameDomains;
  155. }
  156. /**
  157. * @return array
  158. */
  159. public function getAllowedFontDomains(): array {
  160. return $this->allowedFontDomains;
  161. }
  162. /**
  163. * @param array $allowedFontDomains
  164. */
  165. public function setAllowedFontDomains($allowedFontDomains) {
  166. $this->allowedFontDomains = $allowedFontDomains;
  167. }
  168. /**
  169. * @return array
  170. * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
  171. */
  172. public function getAllowedChildSrcDomains(): array {
  173. return $this->allowedChildSrcDomains;
  174. }
  175. /**
  176. * @param array $allowedChildSrcDomains
  177. * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
  178. */
  179. public function setAllowedChildSrcDomains($allowedChildSrcDomains) {
  180. $this->allowedChildSrcDomains = $allowedChildSrcDomains;
  181. }
  182. /**
  183. * @return array
  184. */
  185. public function getAllowedFrameAncestors(): array {
  186. return $this->allowedFrameAncestors;
  187. }
  188. /**
  189. * @param array $allowedFrameAncestors
  190. */
  191. public function setAllowedFrameAncestors($allowedFrameAncestors) {
  192. $this->allowedFrameAncestors = $allowedFrameAncestors;
  193. }
  194. public function getAllowedWorkerSrcDomains(): array {
  195. return $this->allowedWorkerSrcDomains;
  196. }
  197. public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains) {
  198. $this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains;
  199. }
  200. public function getAllowedFormActionDomains(): array {
  201. return $this->allowedFormActionDomains;
  202. }
  203. public function setAllowedFormActionDomains(array $allowedFormActionDomains): void {
  204. $this->allowedFormActionDomains = $allowedFormActionDomains;
  205. }
  206. public function getReportTo(): array {
  207. return $this->reportTo;
  208. }
  209. public function setReportTo(array $reportTo) {
  210. $this->reportTo = $reportTo;
  211. }
  212. /**
  213. * @return boolean
  214. */
  215. public function isStrictDynamicAllowed(): bool {
  216. return $this->strictDynamicAllowed;
  217. }
  218. /**
  219. * @param boolean $strictDynamicAllowed
  220. */
  221. public function setStrictDynamicAllowed(bool $strictDynamicAllowed) {
  222. $this->strictDynamicAllowed = $strictDynamicAllowed;
  223. }
  224. }