Completed
Push — master ( 373630...52012b )
by Roeland
12:43
created
lib/public/AppFramework/Http/ContentSecurityPolicy.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -42,56 +42,56 @@
 block discarded – undo
42 42
  * @deprecated 14.0.0 Use one of our stricter CSP policies
43 43
  */
44 44
 class ContentSecurityPolicy extends EmptyContentSecurityPolicy {
45
-	/** @var bool Whether inline JS snippets are allowed */
46
-	protected $inlineScriptAllowed = false;
47
-	/**
48
-	 * @var bool Whether eval in JS scripts is allowed
49
-	 * TODO: Disallow per default
50
-	 * @link https://github.com/owncloud/core/issues/11925
51
-	 */
52
-	protected $evalScriptAllowed = true;
53
-	/** @var array Domains from which scripts can get loaded */
54
-	protected $allowedScriptDomains = [
55
-		'\'self\'',
56
-	];
57
-	/**
58
-	 * @var bool Whether inline CSS is allowed
59
-	 * TODO: Disallow per default
60
-	 * @link https://github.com/owncloud/core/issues/13458
61
-	 */
62
-	protected $inlineStyleAllowed = true;
63
-	/** @var array Domains from which CSS can get loaded */
64
-	protected $allowedStyleDomains = [
65
-		'\'self\'',
66
-	];
67
-	/** @var array Domains from which images can get loaded */
68
-	protected $allowedImageDomains = [
69
-		'\'self\'',
70
-		'data:',
71
-		'blob:',
72
-	];
73
-	/** @var array Domains to which connections can be done */
74
-	protected $allowedConnectDomains = [
75
-		'\'self\'',
76
-	];
77
-	/** @var array Domains from which media elements can be loaded */
78
-	protected $allowedMediaDomains = [
79
-		'\'self\'',
80
-	];
81
-	/** @var array Domains from which object elements can be loaded */
82
-	protected $allowedObjectDomains = [];
83
-	/** @var array Domains from which iframes can be loaded */
84
-	protected $allowedFrameDomains = [];
85
-	/** @var array Domains from which fonts can be loaded */
86
-	protected $allowedFontDomains = [
87
-		'\'self\'',
88
-	];
89
-	/** @var array Domains from which web-workers and nested browsing content can load elements */
90
-	protected $allowedChildSrcDomains = [];
45
+    /** @var bool Whether inline JS snippets are allowed */
46
+    protected $inlineScriptAllowed = false;
47
+    /**
48
+     * @var bool Whether eval in JS scripts is allowed
49
+     * TODO: Disallow per default
50
+     * @link https://github.com/owncloud/core/issues/11925
51
+     */
52
+    protected $evalScriptAllowed = true;
53
+    /** @var array Domains from which scripts can get loaded */
54
+    protected $allowedScriptDomains = [
55
+        '\'self\'',
56
+    ];
57
+    /**
58
+     * @var bool Whether inline CSS is allowed
59
+     * TODO: Disallow per default
60
+     * @link https://github.com/owncloud/core/issues/13458
61
+     */
62
+    protected $inlineStyleAllowed = true;
63
+    /** @var array Domains from which CSS can get loaded */
64
+    protected $allowedStyleDomains = [
65
+        '\'self\'',
66
+    ];
67
+    /** @var array Domains from which images can get loaded */
68
+    protected $allowedImageDomains = [
69
+        '\'self\'',
70
+        'data:',
71
+        'blob:',
72
+    ];
73
+    /** @var array Domains to which connections can be done */
74
+    protected $allowedConnectDomains = [
75
+        '\'self\'',
76
+    ];
77
+    /** @var array Domains from which media elements can be loaded */
78
+    protected $allowedMediaDomains = [
79
+        '\'self\'',
80
+    ];
81
+    /** @var array Domains from which object elements can be loaded */
82
+    protected $allowedObjectDomains = [];
83
+    /** @var array Domains from which iframes can be loaded */
84
+    protected $allowedFrameDomains = [];
85
+    /** @var array Domains from which fonts can be loaded */
86
+    protected $allowedFontDomains = [
87
+        '\'self\'',
88
+    ];
89
+    /** @var array Domains from which web-workers and nested browsing content can load elements */
90
+    protected $allowedChildSrcDomains = [];
91 91
 
92
-	/** @var array Domains which can embed this Nextcloud instance */
93
-	protected $allowedFrameAncestors = [];
92
+    /** @var array Domains which can embed this Nextcloud instance */
93
+    protected $allowedFrameAncestors = [];
94 94
 
95
-	/** @var array Domains from which web-workers can be loaded */
96
-	protected $allowedWorkerSrcDomains = [];
95
+    /** @var array Domains from which web-workers can be loaded */
96
+    protected $allowedWorkerSrcDomains = [];
97 97
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php 2 patches
Indentation   +437 added lines, -437 removed lines patch added patch discarded remove patch
@@ -37,441 +37,441 @@
 block discarded – undo
37 37
  * @since 9.0.0
38 38
  */
39 39
 class EmptyContentSecurityPolicy {
40
-	/** @var bool Whether inline JS snippets are allowed */
41
-	protected $inlineScriptAllowed = null;
42
-	/** @var string Whether JS nonces should be used */
43
-	protected $useJsNonce = null;
44
-	/**
45
-	 * @var bool Whether eval in JS scripts is allowed
46
-	 * TODO: Disallow per default
47
-	 * @link https://github.com/owncloud/core/issues/11925
48
-	 */
49
-	protected $evalScriptAllowed = null;
50
-	/** @var array Domains from which scripts can get loaded */
51
-	protected $allowedScriptDomains = null;
52
-	/**
53
-	 * @var bool Whether inline CSS is allowed
54
-	 * TODO: Disallow per default
55
-	 * @link https://github.com/owncloud/core/issues/13458
56
-	 */
57
-	protected $inlineStyleAllowed = null;
58
-	/** @var array Domains from which CSS can get loaded */
59
-	protected $allowedStyleDomains = null;
60
-	/** @var array Domains from which images can get loaded */
61
-	protected $allowedImageDomains = null;
62
-	/** @var array Domains to which connections can be done */
63
-	protected $allowedConnectDomains = null;
64
-	/** @var array Domains from which media elements can be loaded */
65
-	protected $allowedMediaDomains = null;
66
-	/** @var array Domains from which object elements can be loaded */
67
-	protected $allowedObjectDomains = null;
68
-	/** @var array Domains from which iframes can be loaded */
69
-	protected $allowedFrameDomains = null;
70
-	/** @var array Domains from which fonts can be loaded */
71
-	protected $allowedFontDomains = null;
72
-	/** @var array Domains from which web-workers and nested browsing content can load elements */
73
-	protected $allowedChildSrcDomains = null;
74
-	/** @var array Domains which can embed this Nextcloud instance */
75
-	protected $allowedFrameAncestors = null;
76
-	/** @var array Domains from which web-workers can be loaded */
77
-	protected $allowedWorkerSrcDomains = null;
78
-
79
-	/**
80
-	 * Whether inline JavaScript snippets are allowed or forbidden
81
-	 * @param bool $state
82
-	 * @return $this
83
-	 * @since 8.1.0
84
-	 * @deprecated 10.0 CSP tokens are now used
85
-	 */
86
-	public function allowInlineScript($state = false) {
87
-		$this->inlineScriptAllowed = $state;
88
-		return $this;
89
-	}
90
-
91
-	/**
92
-	 * Use the according JS nonce
93
-	 *
94
-	 * @param string $nonce
95
-	 * @return $this
96
-	 * @since 11.0.0
97
-	 */
98
-	public function useJsNonce($nonce) {
99
-		$this->useJsNonce = $nonce;
100
-		return $this;
101
-	}
102
-
103
-	/**
104
-	 * Whether eval in JavaScript is allowed or forbidden
105
-	 * @param bool $state
106
-	 * @return $this
107
-	 * @since 8.1.0
108
-	 */
109
-	public function allowEvalScript($state = true) {
110
-		$this->evalScriptAllowed = $state;
111
-		return $this;
112
-	}
113
-
114
-	/**
115
-	 * Allows to execute JavaScript files from a specific domain. Use * to
116
-	 * allow JavaScript from all domains.
117
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
118
-	 * @return $this
119
-	 * @since 8.1.0
120
-	 */
121
-	public function addAllowedScriptDomain($domain) {
122
-		$this->allowedScriptDomains[] = $domain;
123
-		return $this;
124
-	}
125
-
126
-	/**
127
-	 * Remove the specified allowed script domain from the allowed domains.
128
-	 *
129
-	 * @param string $domain
130
-	 * @return $this
131
-	 * @since 8.1.0
132
-	 */
133
-	public function disallowScriptDomain($domain) {
134
-		$this->allowedScriptDomains = array_diff($this->allowedScriptDomains, [$domain]);
135
-		return $this;
136
-	}
137
-
138
-	/**
139
-	 * Whether inline CSS snippets are allowed or forbidden
140
-	 * @param bool $state
141
-	 * @return $this
142
-	 * @since 8.1.0
143
-	 */
144
-	public function allowInlineStyle($state = true) {
145
-		$this->inlineStyleAllowed = $state;
146
-		return $this;
147
-	}
148
-
149
-	/**
150
-	 * Allows to execute CSS files from a specific domain. Use * to allow
151
-	 * CSS from all domains.
152
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
153
-	 * @return $this
154
-	 * @since 8.1.0
155
-	 */
156
-	public function addAllowedStyleDomain($domain) {
157
-		$this->allowedStyleDomains[] = $domain;
158
-		return $this;
159
-	}
160
-
161
-	/**
162
-	 * Remove the specified allowed style domain from the allowed domains.
163
-	 *
164
-	 * @param string $domain
165
-	 * @return $this
166
-	 * @since 8.1.0
167
-	 */
168
-	public function disallowStyleDomain($domain) {
169
-		$this->allowedStyleDomains = array_diff($this->allowedStyleDomains, [$domain]);
170
-		return $this;
171
-	}
172
-
173
-	/**
174
-	 * Allows using fonts from a specific domain. Use * to allow
175
-	 * fonts from all domains.
176
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
177
-	 * @return $this
178
-	 * @since 8.1.0
179
-	 */
180
-	public function addAllowedFontDomain($domain) {
181
-		$this->allowedFontDomains[] = $domain;
182
-		return $this;
183
-	}
184
-
185
-	/**
186
-	 * Remove the specified allowed font domain from the allowed domains.
187
-	 *
188
-	 * @param string $domain
189
-	 * @return $this
190
-	 * @since 8.1.0
191
-	 */
192
-	public function disallowFontDomain($domain) {
193
-		$this->allowedFontDomains = array_diff($this->allowedFontDomains, [$domain]);
194
-		return $this;
195
-	}
196
-
197
-	/**
198
-	 * Allows embedding images from a specific domain. Use * to allow
199
-	 * images from all domains.
200
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
201
-	 * @return $this
202
-	 * @since 8.1.0
203
-	 */
204
-	public function addAllowedImageDomain($domain) {
205
-		$this->allowedImageDomains[] = $domain;
206
-		return $this;
207
-	}
208
-
209
-	/**
210
-	 * Remove the specified allowed image domain from the allowed domains.
211
-	 *
212
-	 * @param string $domain
213
-	 * @return $this
214
-	 * @since 8.1.0
215
-	 */
216
-	public function disallowImageDomain($domain) {
217
-		$this->allowedImageDomains = array_diff($this->allowedImageDomains, [$domain]);
218
-		return $this;
219
-	}
220
-
221
-	/**
222
-	 * To which remote domains the JS connect to.
223
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
224
-	 * @return $this
225
-	 * @since 8.1.0
226
-	 */
227
-	public function addAllowedConnectDomain($domain) {
228
-		$this->allowedConnectDomains[] = $domain;
229
-		return $this;
230
-	}
231
-
232
-	/**
233
-	 * Remove the specified allowed connect domain from the allowed domains.
234
-	 *
235
-	 * @param string $domain
236
-	 * @return $this
237
-	 * @since 8.1.0
238
-	 */
239
-	public function disallowConnectDomain($domain) {
240
-		$this->allowedConnectDomains = array_diff($this->allowedConnectDomains, [$domain]);
241
-		return $this;
242
-	}
243
-
244
-	/**
245
-	 * From which domains media elements can be embedded.
246
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
247
-	 * @return $this
248
-	 * @since 8.1.0
249
-	 */
250
-	public function addAllowedMediaDomain($domain) {
251
-		$this->allowedMediaDomains[] = $domain;
252
-		return $this;
253
-	}
254
-
255
-	/**
256
-	 * Remove the specified allowed media domain from the allowed domains.
257
-	 *
258
-	 * @param string $domain
259
-	 * @return $this
260
-	 * @since 8.1.0
261
-	 */
262
-	public function disallowMediaDomain($domain) {
263
-		$this->allowedMediaDomains = array_diff($this->allowedMediaDomains, [$domain]);
264
-		return $this;
265
-	}
266
-
267
-	/**
268
-	 * From which domains objects such as <object>, <embed> or <applet> are executed
269
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
270
-	 * @return $this
271
-	 * @since 8.1.0
272
-	 */
273
-	public function addAllowedObjectDomain($domain) {
274
-		$this->allowedObjectDomains[] = $domain;
275
-		return $this;
276
-	}
277
-
278
-	/**
279
-	 * Remove the specified allowed object domain from the allowed domains.
280
-	 *
281
-	 * @param string $domain
282
-	 * @return $this
283
-	 * @since 8.1.0
284
-	 */
285
-	public function disallowObjectDomain($domain) {
286
-		$this->allowedObjectDomains = array_diff($this->allowedObjectDomains, [$domain]);
287
-		return $this;
288
-	}
289
-
290
-	/**
291
-	 * Which domains can be embedded in an iframe
292
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
293
-	 * @return $this
294
-	 * @since 8.1.0
295
-	 */
296
-	public function addAllowedFrameDomain($domain) {
297
-		$this->allowedFrameDomains[] = $domain;
298
-		return $this;
299
-	}
300
-
301
-	/**
302
-	 * Remove the specified allowed frame domain from the allowed domains.
303
-	 *
304
-	 * @param string $domain
305
-	 * @return $this
306
-	 * @since 8.1.0
307
-	 */
308
-	public function disallowFrameDomain($domain) {
309
-		$this->allowedFrameDomains = array_diff($this->allowedFrameDomains, [$domain]);
310
-		return $this;
311
-	}
312
-
313
-	/**
314
-	 * Domains from which web-workers and nested browsing content can load elements
315
-	 * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
316
-	 * @return $this
317
-	 * @since 8.1.0
318
-	 * @deprecated 15.0.0 use addAllowedWorkerSrcDomains or addAllowedFrameDomain
319
-	 */
320
-	public function addAllowedChildSrcDomain($domain) {
321
-		$this->allowedChildSrcDomains[] = $domain;
322
-		return $this;
323
-	}
324
-
325
-	/**
326
-	 * Remove the specified allowed child src domain from the allowed domains.
327
-	 *
328
-	 * @param string $domain
329
-	 * @return $this
330
-	 * @since 8.1.0
331
-	 * @deprecated 15.0.0 use the WorkerSrcDomains or FrameDomain
332
-	 */
333
-	public function disallowChildSrcDomain($domain) {
334
-		$this->allowedChildSrcDomains = array_diff($this->allowedChildSrcDomains, [$domain]);
335
-		return $this;
336
-	}
337
-
338
-	/**
339
-	 * Domains which can embed an iFrame of the Nextcloud instance
340
-	 *
341
-	 * @param string $domain
342
-	 * @return $this
343
-	 * @since 13.0.0
344
-	 */
345
-	public function addAllowedFrameAncestorDomain($domain) {
346
-		$this->allowedFrameAncestors[] = $domain;
347
-		return $this;
348
-	}
349
-
350
-	/**
351
-	 * Domains which can embed an iFrame of the Nextcloud instance
352
-	 *
353
-	 * @param string $domain
354
-	 * @return $this
355
-	 * @since 13.0.0
356
-	 */
357
-	public function disallowFrameAncestorDomain($domain) {
358
-		$this->allowedFrameAncestors = array_diff($this->allowedFrameAncestors, [$domain]);
359
-		return $this;
360
-	}
361
-
362
-	/**
363
-	 * Domain from which workers can be loaded
364
-	 *
365
-	 * @param string $domain
366
-	 * @return $this
367
-	 * @since 15.0.0
368
-	 */
369
-	public function addAllowedWorkerSrcDomain(string $domain) {
370
-		$this->allowedWorkerSrcDomains[] = $domain;
371
-		return $this;
372
-	}
373
-
374
-	/**
375
-	 * Remove domain from which workers can be loaded
376
-	 *
377
-	 * @param string $domain
378
-	 * @return $this
379
-	 * @since 15.0.0
380
-	 */
381
-	public function disallowWorkerSrcDomain(string $domain) {
382
-		$this->allowedWorkerSrcDomains = array_diff($this->allowedWorkerSrcDomains, [$domain]);
383
-		return $this;
384
-	}
385
-
386
-	/**
387
-	 * Get the generated Content-Security-Policy as a string
388
-	 * @return string
389
-	 * @since 8.1.0
390
-	 */
391
-	public function buildPolicy() {
392
-		$policy = "default-src 'none';";
393
-		$policy .= "base-uri 'none';";
394
-		$policy .= "manifest-src 'self';";
395
-
396
-		if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) {
397
-			$policy .= 'script-src ';
398
-			if(is_string($this->useJsNonce)) {
399
-				$policy .= '\'nonce-'.base64_encode($this->useJsNonce).'\'';
400
-				$allowedScriptDomains = array_flip($this->allowedScriptDomains);
401
-				unset($allowedScriptDomains['\'self\'']);
402
-				$this->allowedScriptDomains = array_flip($allowedScriptDomains);
403
-				if(count($allowedScriptDomains) !== 0) {
404
-					$policy .= ' ';
405
-				}
406
-			}
407
-			if(is_array($this->allowedScriptDomains)) {
408
-				$policy .= implode(' ', $this->allowedScriptDomains);
409
-			}
410
-			if($this->inlineScriptAllowed) {
411
-				$policy .= ' \'unsafe-inline\'';
412
-			}
413
-			if($this->evalScriptAllowed) {
414
-				$policy .= ' \'unsafe-eval\'';
415
-			}
416
-			$policy .= ';';
417
-		}
418
-
419
-		if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) {
420
-			$policy .= 'style-src ';
421
-			if(is_array($this->allowedStyleDomains)) {
422
-				$policy .= implode(' ', $this->allowedStyleDomains);
423
-			}
424
-			if($this->inlineStyleAllowed) {
425
-				$policy .= ' \'unsafe-inline\'';
426
-			}
427
-			$policy .= ';';
428
-		}
429
-
430
-		if(!empty($this->allowedImageDomains)) {
431
-			$policy .= 'img-src ' . implode(' ', $this->allowedImageDomains);
432
-			$policy .= ';';
433
-		}
434
-
435
-		if(!empty($this->allowedFontDomains)) {
436
-			$policy .= 'font-src ' . implode(' ', $this->allowedFontDomains);
437
-			$policy .= ';';
438
-		}
439
-
440
-		if(!empty($this->allowedConnectDomains)) {
441
-			$policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains);
442
-			$policy .= ';';
443
-		}
444
-
445
-		if(!empty($this->allowedMediaDomains)) {
446
-			$policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains);
447
-			$policy .= ';';
448
-		}
449
-
450
-		if(!empty($this->allowedObjectDomains)) {
451
-			$policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains);
452
-			$policy .= ';';
453
-		}
454
-
455
-		if(!empty($this->allowedFrameDomains)) {
456
-			$policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains);
457
-			$policy .= ';';
458
-		}
459
-
460
-		if(!empty($this->allowedChildSrcDomains)) {
461
-			$policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains);
462
-			$policy .= ';';
463
-		}
464
-
465
-		if(!empty($this->allowedFrameAncestors)) {
466
-			$policy .= 'frame-ancestors ' . implode(' ', $this->allowedFrameAncestors);
467
-			$policy .= ';';
468
-		}
469
-
470
-		if (!empty($this->allowedWorkerSrcDomains)) {
471
-			$policy .= 'worker-src ' . implode(' ', $this->allowedWorkerSrcDomains);
472
-			$policy .= ';';
473
-		}
474
-
475
-		return rtrim($policy, ';');
476
-	}
40
+    /** @var bool Whether inline JS snippets are allowed */
41
+    protected $inlineScriptAllowed = null;
42
+    /** @var string Whether JS nonces should be used */
43
+    protected $useJsNonce = null;
44
+    /**
45
+     * @var bool Whether eval in JS scripts is allowed
46
+     * TODO: Disallow per default
47
+     * @link https://github.com/owncloud/core/issues/11925
48
+     */
49
+    protected $evalScriptAllowed = null;
50
+    /** @var array Domains from which scripts can get loaded */
51
+    protected $allowedScriptDomains = null;
52
+    /**
53
+     * @var bool Whether inline CSS is allowed
54
+     * TODO: Disallow per default
55
+     * @link https://github.com/owncloud/core/issues/13458
56
+     */
57
+    protected $inlineStyleAllowed = null;
58
+    /** @var array Domains from which CSS can get loaded */
59
+    protected $allowedStyleDomains = null;
60
+    /** @var array Domains from which images can get loaded */
61
+    protected $allowedImageDomains = null;
62
+    /** @var array Domains to which connections can be done */
63
+    protected $allowedConnectDomains = null;
64
+    /** @var array Domains from which media elements can be loaded */
65
+    protected $allowedMediaDomains = null;
66
+    /** @var array Domains from which object elements can be loaded */
67
+    protected $allowedObjectDomains = null;
68
+    /** @var array Domains from which iframes can be loaded */
69
+    protected $allowedFrameDomains = null;
70
+    /** @var array Domains from which fonts can be loaded */
71
+    protected $allowedFontDomains = null;
72
+    /** @var array Domains from which web-workers and nested browsing content can load elements */
73
+    protected $allowedChildSrcDomains = null;
74
+    /** @var array Domains which can embed this Nextcloud instance */
75
+    protected $allowedFrameAncestors = null;
76
+    /** @var array Domains from which web-workers can be loaded */
77
+    protected $allowedWorkerSrcDomains = null;
78
+
79
+    /**
80
+     * Whether inline JavaScript snippets are allowed or forbidden
81
+     * @param bool $state
82
+     * @return $this
83
+     * @since 8.1.0
84
+     * @deprecated 10.0 CSP tokens are now used
85
+     */
86
+    public function allowInlineScript($state = false) {
87
+        $this->inlineScriptAllowed = $state;
88
+        return $this;
89
+    }
90
+
91
+    /**
92
+     * Use the according JS nonce
93
+     *
94
+     * @param string $nonce
95
+     * @return $this
96
+     * @since 11.0.0
97
+     */
98
+    public function useJsNonce($nonce) {
99
+        $this->useJsNonce = $nonce;
100
+        return $this;
101
+    }
102
+
103
+    /**
104
+     * Whether eval in JavaScript is allowed or forbidden
105
+     * @param bool $state
106
+     * @return $this
107
+     * @since 8.1.0
108
+     */
109
+    public function allowEvalScript($state = true) {
110
+        $this->evalScriptAllowed = $state;
111
+        return $this;
112
+    }
113
+
114
+    /**
115
+     * Allows to execute JavaScript files from a specific domain. Use * to
116
+     * allow JavaScript from all domains.
117
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
118
+     * @return $this
119
+     * @since 8.1.0
120
+     */
121
+    public function addAllowedScriptDomain($domain) {
122
+        $this->allowedScriptDomains[] = $domain;
123
+        return $this;
124
+    }
125
+
126
+    /**
127
+     * Remove the specified allowed script domain from the allowed domains.
128
+     *
129
+     * @param string $domain
130
+     * @return $this
131
+     * @since 8.1.0
132
+     */
133
+    public function disallowScriptDomain($domain) {
134
+        $this->allowedScriptDomains = array_diff($this->allowedScriptDomains, [$domain]);
135
+        return $this;
136
+    }
137
+
138
+    /**
139
+     * Whether inline CSS snippets are allowed or forbidden
140
+     * @param bool $state
141
+     * @return $this
142
+     * @since 8.1.0
143
+     */
144
+    public function allowInlineStyle($state = true) {
145
+        $this->inlineStyleAllowed = $state;
146
+        return $this;
147
+    }
148
+
149
+    /**
150
+     * Allows to execute CSS files from a specific domain. Use * to allow
151
+     * CSS from all domains.
152
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
153
+     * @return $this
154
+     * @since 8.1.0
155
+     */
156
+    public function addAllowedStyleDomain($domain) {
157
+        $this->allowedStyleDomains[] = $domain;
158
+        return $this;
159
+    }
160
+
161
+    /**
162
+     * Remove the specified allowed style domain from the allowed domains.
163
+     *
164
+     * @param string $domain
165
+     * @return $this
166
+     * @since 8.1.0
167
+     */
168
+    public function disallowStyleDomain($domain) {
169
+        $this->allowedStyleDomains = array_diff($this->allowedStyleDomains, [$domain]);
170
+        return $this;
171
+    }
172
+
173
+    /**
174
+     * Allows using fonts from a specific domain. Use * to allow
175
+     * fonts from all domains.
176
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
177
+     * @return $this
178
+     * @since 8.1.0
179
+     */
180
+    public function addAllowedFontDomain($domain) {
181
+        $this->allowedFontDomains[] = $domain;
182
+        return $this;
183
+    }
184
+
185
+    /**
186
+     * Remove the specified allowed font domain from the allowed domains.
187
+     *
188
+     * @param string $domain
189
+     * @return $this
190
+     * @since 8.1.0
191
+     */
192
+    public function disallowFontDomain($domain) {
193
+        $this->allowedFontDomains = array_diff($this->allowedFontDomains, [$domain]);
194
+        return $this;
195
+    }
196
+
197
+    /**
198
+     * Allows embedding images from a specific domain. Use * to allow
199
+     * images from all domains.
200
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
201
+     * @return $this
202
+     * @since 8.1.0
203
+     */
204
+    public function addAllowedImageDomain($domain) {
205
+        $this->allowedImageDomains[] = $domain;
206
+        return $this;
207
+    }
208
+
209
+    /**
210
+     * Remove the specified allowed image domain from the allowed domains.
211
+     *
212
+     * @param string $domain
213
+     * @return $this
214
+     * @since 8.1.0
215
+     */
216
+    public function disallowImageDomain($domain) {
217
+        $this->allowedImageDomains = array_diff($this->allowedImageDomains, [$domain]);
218
+        return $this;
219
+    }
220
+
221
+    /**
222
+     * To which remote domains the JS connect to.
223
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
224
+     * @return $this
225
+     * @since 8.1.0
226
+     */
227
+    public function addAllowedConnectDomain($domain) {
228
+        $this->allowedConnectDomains[] = $domain;
229
+        return $this;
230
+    }
231
+
232
+    /**
233
+     * Remove the specified allowed connect domain from the allowed domains.
234
+     *
235
+     * @param string $domain
236
+     * @return $this
237
+     * @since 8.1.0
238
+     */
239
+    public function disallowConnectDomain($domain) {
240
+        $this->allowedConnectDomains = array_diff($this->allowedConnectDomains, [$domain]);
241
+        return $this;
242
+    }
243
+
244
+    /**
245
+     * From which domains media elements can be embedded.
246
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
247
+     * @return $this
248
+     * @since 8.1.0
249
+     */
250
+    public function addAllowedMediaDomain($domain) {
251
+        $this->allowedMediaDomains[] = $domain;
252
+        return $this;
253
+    }
254
+
255
+    /**
256
+     * Remove the specified allowed media domain from the allowed domains.
257
+     *
258
+     * @param string $domain
259
+     * @return $this
260
+     * @since 8.1.0
261
+     */
262
+    public function disallowMediaDomain($domain) {
263
+        $this->allowedMediaDomains = array_diff($this->allowedMediaDomains, [$domain]);
264
+        return $this;
265
+    }
266
+
267
+    /**
268
+     * From which domains objects such as <object>, <embed> or <applet> are executed
269
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
270
+     * @return $this
271
+     * @since 8.1.0
272
+     */
273
+    public function addAllowedObjectDomain($domain) {
274
+        $this->allowedObjectDomains[] = $domain;
275
+        return $this;
276
+    }
277
+
278
+    /**
279
+     * Remove the specified allowed object domain from the allowed domains.
280
+     *
281
+     * @param string $domain
282
+     * @return $this
283
+     * @since 8.1.0
284
+     */
285
+    public function disallowObjectDomain($domain) {
286
+        $this->allowedObjectDomains = array_diff($this->allowedObjectDomains, [$domain]);
287
+        return $this;
288
+    }
289
+
290
+    /**
291
+     * Which domains can be embedded in an iframe
292
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
293
+     * @return $this
294
+     * @since 8.1.0
295
+     */
296
+    public function addAllowedFrameDomain($domain) {
297
+        $this->allowedFrameDomains[] = $domain;
298
+        return $this;
299
+    }
300
+
301
+    /**
302
+     * Remove the specified allowed frame domain from the allowed domains.
303
+     *
304
+     * @param string $domain
305
+     * @return $this
306
+     * @since 8.1.0
307
+     */
308
+    public function disallowFrameDomain($domain) {
309
+        $this->allowedFrameDomains = array_diff($this->allowedFrameDomains, [$domain]);
310
+        return $this;
311
+    }
312
+
313
+    /**
314
+     * Domains from which web-workers and nested browsing content can load elements
315
+     * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
316
+     * @return $this
317
+     * @since 8.1.0
318
+     * @deprecated 15.0.0 use addAllowedWorkerSrcDomains or addAllowedFrameDomain
319
+     */
320
+    public function addAllowedChildSrcDomain($domain) {
321
+        $this->allowedChildSrcDomains[] = $domain;
322
+        return $this;
323
+    }
324
+
325
+    /**
326
+     * Remove the specified allowed child src domain from the allowed domains.
327
+     *
328
+     * @param string $domain
329
+     * @return $this
330
+     * @since 8.1.0
331
+     * @deprecated 15.0.0 use the WorkerSrcDomains or FrameDomain
332
+     */
333
+    public function disallowChildSrcDomain($domain) {
334
+        $this->allowedChildSrcDomains = array_diff($this->allowedChildSrcDomains, [$domain]);
335
+        return $this;
336
+    }
337
+
338
+    /**
339
+     * Domains which can embed an iFrame of the Nextcloud instance
340
+     *
341
+     * @param string $domain
342
+     * @return $this
343
+     * @since 13.0.0
344
+     */
345
+    public function addAllowedFrameAncestorDomain($domain) {
346
+        $this->allowedFrameAncestors[] = $domain;
347
+        return $this;
348
+    }
349
+
350
+    /**
351
+     * Domains which can embed an iFrame of the Nextcloud instance
352
+     *
353
+     * @param string $domain
354
+     * @return $this
355
+     * @since 13.0.0
356
+     */
357
+    public function disallowFrameAncestorDomain($domain) {
358
+        $this->allowedFrameAncestors = array_diff($this->allowedFrameAncestors, [$domain]);
359
+        return $this;
360
+    }
361
+
362
+    /**
363
+     * Domain from which workers can be loaded
364
+     *
365
+     * @param string $domain
366
+     * @return $this
367
+     * @since 15.0.0
368
+     */
369
+    public function addAllowedWorkerSrcDomain(string $domain) {
370
+        $this->allowedWorkerSrcDomains[] = $domain;
371
+        return $this;
372
+    }
373
+
374
+    /**
375
+     * Remove domain from which workers can be loaded
376
+     *
377
+     * @param string $domain
378
+     * @return $this
379
+     * @since 15.0.0
380
+     */
381
+    public function disallowWorkerSrcDomain(string $domain) {
382
+        $this->allowedWorkerSrcDomains = array_diff($this->allowedWorkerSrcDomains, [$domain]);
383
+        return $this;
384
+    }
385
+
386
+    /**
387
+     * Get the generated Content-Security-Policy as a string
388
+     * @return string
389
+     * @since 8.1.0
390
+     */
391
+    public function buildPolicy() {
392
+        $policy = "default-src 'none';";
393
+        $policy .= "base-uri 'none';";
394
+        $policy .= "manifest-src 'self';";
395
+
396
+        if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) {
397
+            $policy .= 'script-src ';
398
+            if(is_string($this->useJsNonce)) {
399
+                $policy .= '\'nonce-'.base64_encode($this->useJsNonce).'\'';
400
+                $allowedScriptDomains = array_flip($this->allowedScriptDomains);
401
+                unset($allowedScriptDomains['\'self\'']);
402
+                $this->allowedScriptDomains = array_flip($allowedScriptDomains);
403
+                if(count($allowedScriptDomains) !== 0) {
404
+                    $policy .= ' ';
405
+                }
406
+            }
407
+            if(is_array($this->allowedScriptDomains)) {
408
+                $policy .= implode(' ', $this->allowedScriptDomains);
409
+            }
410
+            if($this->inlineScriptAllowed) {
411
+                $policy .= ' \'unsafe-inline\'';
412
+            }
413
+            if($this->evalScriptAllowed) {
414
+                $policy .= ' \'unsafe-eval\'';
415
+            }
416
+            $policy .= ';';
417
+        }
418
+
419
+        if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) {
420
+            $policy .= 'style-src ';
421
+            if(is_array($this->allowedStyleDomains)) {
422
+                $policy .= implode(' ', $this->allowedStyleDomains);
423
+            }
424
+            if($this->inlineStyleAllowed) {
425
+                $policy .= ' \'unsafe-inline\'';
426
+            }
427
+            $policy .= ';';
428
+        }
429
+
430
+        if(!empty($this->allowedImageDomains)) {
431
+            $policy .= 'img-src ' . implode(' ', $this->allowedImageDomains);
432
+            $policy .= ';';
433
+        }
434
+
435
+        if(!empty($this->allowedFontDomains)) {
436
+            $policy .= 'font-src ' . implode(' ', $this->allowedFontDomains);
437
+            $policy .= ';';
438
+        }
439
+
440
+        if(!empty($this->allowedConnectDomains)) {
441
+            $policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains);
442
+            $policy .= ';';
443
+        }
444
+
445
+        if(!empty($this->allowedMediaDomains)) {
446
+            $policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains);
447
+            $policy .= ';';
448
+        }
449
+
450
+        if(!empty($this->allowedObjectDomains)) {
451
+            $policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains);
452
+            $policy .= ';';
453
+        }
454
+
455
+        if(!empty($this->allowedFrameDomains)) {
456
+            $policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains);
457
+            $policy .= ';';
458
+        }
459
+
460
+        if(!empty($this->allowedChildSrcDomains)) {
461
+            $policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains);
462
+            $policy .= ';';
463
+        }
464
+
465
+        if(!empty($this->allowedFrameAncestors)) {
466
+            $policy .= 'frame-ancestors ' . implode(' ', $this->allowedFrameAncestors);
467
+            $policy .= ';';
468
+        }
469
+
470
+        if (!empty($this->allowedWorkerSrcDomains)) {
471
+            $policy .= 'worker-src ' . implode(' ', $this->allowedWorkerSrcDomains);
472
+            $policy .= ';';
473
+        }
474
+
475
+        return rtrim($policy, ';');
476
+    }
477 477
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -393,82 +393,82 @@
 block discarded – undo
393 393
 		$policy .= "base-uri 'none';";
394 394
 		$policy .= "manifest-src 'self';";
395 395
 
396
-		if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) {
396
+		if (!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) {
397 397
 			$policy .= 'script-src ';
398
-			if(is_string($this->useJsNonce)) {
398
+			if (is_string($this->useJsNonce)) {
399 399
 				$policy .= '\'nonce-'.base64_encode($this->useJsNonce).'\'';
400 400
 				$allowedScriptDomains = array_flip($this->allowedScriptDomains);
401 401
 				unset($allowedScriptDomains['\'self\'']);
402 402
 				$this->allowedScriptDomains = array_flip($allowedScriptDomains);
403
-				if(count($allowedScriptDomains) !== 0) {
403
+				if (count($allowedScriptDomains) !== 0) {
404 404
 					$policy .= ' ';
405 405
 				}
406 406
 			}
407
-			if(is_array($this->allowedScriptDomains)) {
407
+			if (is_array($this->allowedScriptDomains)) {
408 408
 				$policy .= implode(' ', $this->allowedScriptDomains);
409 409
 			}
410
-			if($this->inlineScriptAllowed) {
410
+			if ($this->inlineScriptAllowed) {
411 411
 				$policy .= ' \'unsafe-inline\'';
412 412
 			}
413
-			if($this->evalScriptAllowed) {
413
+			if ($this->evalScriptAllowed) {
414 414
 				$policy .= ' \'unsafe-eval\'';
415 415
 			}
416 416
 			$policy .= ';';
417 417
 		}
418 418
 
419
-		if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) {
419
+		if (!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) {
420 420
 			$policy .= 'style-src ';
421
-			if(is_array($this->allowedStyleDomains)) {
421
+			if (is_array($this->allowedStyleDomains)) {
422 422
 				$policy .= implode(' ', $this->allowedStyleDomains);
423 423
 			}
424
-			if($this->inlineStyleAllowed) {
424
+			if ($this->inlineStyleAllowed) {
425 425
 				$policy .= ' \'unsafe-inline\'';
426 426
 			}
427 427
 			$policy .= ';';
428 428
 		}
429 429
 
430
-		if(!empty($this->allowedImageDomains)) {
431
-			$policy .= 'img-src ' . implode(' ', $this->allowedImageDomains);
430
+		if (!empty($this->allowedImageDomains)) {
431
+			$policy .= 'img-src '.implode(' ', $this->allowedImageDomains);
432 432
 			$policy .= ';';
433 433
 		}
434 434
 
435
-		if(!empty($this->allowedFontDomains)) {
436
-			$policy .= 'font-src ' . implode(' ', $this->allowedFontDomains);
435
+		if (!empty($this->allowedFontDomains)) {
436
+			$policy .= 'font-src '.implode(' ', $this->allowedFontDomains);
437 437
 			$policy .= ';';
438 438
 		}
439 439
 
440
-		if(!empty($this->allowedConnectDomains)) {
441
-			$policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains);
440
+		if (!empty($this->allowedConnectDomains)) {
441
+			$policy .= 'connect-src '.implode(' ', $this->allowedConnectDomains);
442 442
 			$policy .= ';';
443 443
 		}
444 444
 
445
-		if(!empty($this->allowedMediaDomains)) {
446
-			$policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains);
445
+		if (!empty($this->allowedMediaDomains)) {
446
+			$policy .= 'media-src '.implode(' ', $this->allowedMediaDomains);
447 447
 			$policy .= ';';
448 448
 		}
449 449
 
450
-		if(!empty($this->allowedObjectDomains)) {
451
-			$policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains);
450
+		if (!empty($this->allowedObjectDomains)) {
451
+			$policy .= 'object-src '.implode(' ', $this->allowedObjectDomains);
452 452
 			$policy .= ';';
453 453
 		}
454 454
 
455
-		if(!empty($this->allowedFrameDomains)) {
456
-			$policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains);
455
+		if (!empty($this->allowedFrameDomains)) {
456
+			$policy .= 'frame-src '.implode(' ', $this->allowedFrameDomains);
457 457
 			$policy .= ';';
458 458
 		}
459 459
 
460
-		if(!empty($this->allowedChildSrcDomains)) {
461
-			$policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains);
460
+		if (!empty($this->allowedChildSrcDomains)) {
461
+			$policy .= 'child-src '.implode(' ', $this->allowedChildSrcDomains);
462 462
 			$policy .= ';';
463 463
 		}
464 464
 
465
-		if(!empty($this->allowedFrameAncestors)) {
466
-			$policy .= 'frame-ancestors ' . implode(' ', $this->allowedFrameAncestors);
465
+		if (!empty($this->allowedFrameAncestors)) {
466
+			$policy .= 'frame-ancestors '.implode(' ', $this->allowedFrameAncestors);
467 467
 			$policy .= ';';
468 468
 		}
469 469
 
470 470
 		if (!empty($this->allowedWorkerSrcDomains)) {
471
-			$policy .= 'worker-src ' . implode(' ', $this->allowedWorkerSrcDomains);
471
+			$policy .= 'worker-src '.implode(' ', $this->allowedWorkerSrcDomains);
472 472
 			$policy .= ';';
473 473
 		}
474 474
 
Please login to merge, or discard this patch.
lib/private/Security/CSP/ContentSecurityPolicy.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -31,196 +31,196 @@
 block discarded – undo
31 31
  * @package OC\Security\CSP
32 32
  */
33 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
-	/**
42
-	 * @param boolean $inlineScriptAllowed
43
-	 */
44
-	public function setInlineScriptAllowed(bool $inlineScriptAllowed) {
45
-		$this->inlineScriptAllowed = $inlineScriptAllowed;
46
-	}
47
-
48
-	/**
49
-	 * @return boolean
50
-	 */
51
-	public function isEvalScriptAllowed(): bool {
52
-		return $this->evalScriptAllowed;
53
-	}
54
-
55
-	/**
56
-	 * @param boolean $evalScriptAllowed
57
-	 */
58
-	public function setEvalScriptAllowed(bool $evalScriptAllowed) {
59
-		$this->evalScriptAllowed = $evalScriptAllowed;
60
-	}
61
-
62
-	/**
63
-	 * @return array
64
-	 */
65
-	public function getAllowedScriptDomains(): array {
66
-		return $this->allowedScriptDomains;
67
-	}
68
-
69
-	/**
70
-	 * @param array $allowedScriptDomains
71
-	 */
72
-	public function setAllowedScriptDomains(array $allowedScriptDomains) {
73
-		$this->allowedScriptDomains = $allowedScriptDomains;
74
-	}
75
-
76
-	/**
77
-	 * @return boolean
78
-	 */
79
-	public function isInlineStyleAllowed(): bool {
80
-		return $this->inlineStyleAllowed;
81
-	}
82
-
83
-	/**
84
-	 * @param boolean $inlineStyleAllowed
85
-	 */
86
-	public function setInlineStyleAllowed(bool $inlineStyleAllowed) {
87
-		$this->inlineStyleAllowed = $inlineStyleAllowed;
88
-	}
89
-
90
-	/**
91
-	 * @return array
92
-	 */
93
-	public function getAllowedStyleDomains(): array {
94
-		return $this->allowedStyleDomains;
95
-	}
96
-
97
-	/**
98
-	 * @param array $allowedStyleDomains
99
-	 */
100
-	public function setAllowedStyleDomains(array $allowedStyleDomains) {
101
-		$this->allowedStyleDomains = $allowedStyleDomains;
102
-	}
103
-
104
-	/**
105
-	 * @return array
106
-	 */
107
-	public function getAllowedImageDomains(): array {
108
-		return $this->allowedImageDomains;
109
-	}
110
-
111
-	/**
112
-	 * @param array $allowedImageDomains
113
-	 */
114
-	public function setAllowedImageDomains(array $allowedImageDomains) {
115
-		$this->allowedImageDomains = $allowedImageDomains;
116
-	}
117
-
118
-	/**
119
-	 * @return array
120
-	 */
121
-	public function getAllowedConnectDomains(): array {
122
-		return $this->allowedConnectDomains;
123
-	}
124
-
125
-	/**
126
-	 * @param array $allowedConnectDomains
127
-	 */
128
-	public function setAllowedConnectDomains(array $allowedConnectDomains) {
129
-		$this->allowedConnectDomains = $allowedConnectDomains;
130
-	}
131
-
132
-	/**
133
-	 * @return array
134
-	 */
135
-	public function getAllowedMediaDomains(): array {
136
-		return $this->allowedMediaDomains;
137
-	}
138
-
139
-	/**
140
-	 * @param array $allowedMediaDomains
141
-	 */
142
-	public function setAllowedMediaDomains(array $allowedMediaDomains) {
143
-		$this->allowedMediaDomains = $allowedMediaDomains;
144
-	}
145
-
146
-	/**
147
-	 * @return array
148
-	 */
149
-	public function getAllowedObjectDomains(): array {
150
-		return $this->allowedObjectDomains;
151
-	}
152
-
153
-	/**
154
-	 * @param array $allowedObjectDomains
155
-	 */
156
-	public function setAllowedObjectDomains(array $allowedObjectDomains) {
157
-		$this->allowedObjectDomains = $allowedObjectDomains;
158
-	}
159
-
160
-	/**
161
-	 * @return array
162
-	 */
163
-	public function getAllowedFrameDomains(): array {
164
-		return $this->allowedFrameDomains;
165
-	}
166
-
167
-	/**
168
-	 * @param array $allowedFrameDomains
169
-	 */
170
-	public function setAllowedFrameDomains(array $allowedFrameDomains) {
171
-		$this->allowedFrameDomains = $allowedFrameDomains;
172
-	}
173
-
174
-	/**
175
-	 * @return array
176
-	 */
177
-	public function getAllowedFontDomains(): array {
178
-		return $this->allowedFontDomains;
179
-	}
180
-
181
-	/**
182
-	 * @param array $allowedFontDomains
183
-	 */
184
-	public function setAllowedFontDomains($allowedFontDomains) {
185
-		$this->allowedFontDomains = $allowedFontDomains;
186
-	}
187
-
188
-	/**
189
-	 * @return array
190
-	 * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
191
-	 */
192
-	public function getAllowedChildSrcDomains(): array {
193
-		return $this->allowedChildSrcDomains;
194
-	}
195
-
196
-	/**
197
-	 * @param array $allowedChildSrcDomains
198
-	 * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
199
-	 */
200
-	public function setAllowedChildSrcDomains($allowedChildSrcDomains) {
201
-		$this->allowedChildSrcDomains = $allowedChildSrcDomains;
202
-	}
203
-
204
-	/**
205
-	 * @return array
206
-	 */
207
-	public function getAllowedFrameAncestors(): array {
208
-		return $this->allowedFrameAncestors;
209
-	}
210
-
211
-	/**
212
-	 * @param array $allowedFrameAncestors
213
-	 */
214
-	public function setAllowedFrameAncestors($allowedFrameAncestors) {
215
-		$this->allowedFrameAncestors = $allowedFrameAncestors;
216
-	}
217
-
218
-	public function getAllowedWorkerSrcDomains(): array {
219
-		return $this->allowedWorkerSrcDomains;
220
-	}
221
-
222
-	public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains) {
223
-		$this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains;
224
-	}
34
+    /**
35
+     * @return boolean
36
+     */
37
+    public function isInlineScriptAllowed(): bool {
38
+        return $this->inlineScriptAllowed;
39
+    }
40
+
41
+    /**
42
+     * @param boolean $inlineScriptAllowed
43
+     */
44
+    public function setInlineScriptAllowed(bool $inlineScriptAllowed) {
45
+        $this->inlineScriptAllowed = $inlineScriptAllowed;
46
+    }
47
+
48
+    /**
49
+     * @return boolean
50
+     */
51
+    public function isEvalScriptAllowed(): bool {
52
+        return $this->evalScriptAllowed;
53
+    }
54
+
55
+    /**
56
+     * @param boolean $evalScriptAllowed
57
+     */
58
+    public function setEvalScriptAllowed(bool $evalScriptAllowed) {
59
+        $this->evalScriptAllowed = $evalScriptAllowed;
60
+    }
61
+
62
+    /**
63
+     * @return array
64
+     */
65
+    public function getAllowedScriptDomains(): array {
66
+        return $this->allowedScriptDomains;
67
+    }
68
+
69
+    /**
70
+     * @param array $allowedScriptDomains
71
+     */
72
+    public function setAllowedScriptDomains(array $allowedScriptDomains) {
73
+        $this->allowedScriptDomains = $allowedScriptDomains;
74
+    }
75
+
76
+    /**
77
+     * @return boolean
78
+     */
79
+    public function isInlineStyleAllowed(): bool {
80
+        return $this->inlineStyleAllowed;
81
+    }
82
+
83
+    /**
84
+     * @param boolean $inlineStyleAllowed
85
+     */
86
+    public function setInlineStyleAllowed(bool $inlineStyleAllowed) {
87
+        $this->inlineStyleAllowed = $inlineStyleAllowed;
88
+    }
89
+
90
+    /**
91
+     * @return array
92
+     */
93
+    public function getAllowedStyleDomains(): array {
94
+        return $this->allowedStyleDomains;
95
+    }
96
+
97
+    /**
98
+     * @param array $allowedStyleDomains
99
+     */
100
+    public function setAllowedStyleDomains(array $allowedStyleDomains) {
101
+        $this->allowedStyleDomains = $allowedStyleDomains;
102
+    }
103
+
104
+    /**
105
+     * @return array
106
+     */
107
+    public function getAllowedImageDomains(): array {
108
+        return $this->allowedImageDomains;
109
+    }
110
+
111
+    /**
112
+     * @param array $allowedImageDomains
113
+     */
114
+    public function setAllowedImageDomains(array $allowedImageDomains) {
115
+        $this->allowedImageDomains = $allowedImageDomains;
116
+    }
117
+
118
+    /**
119
+     * @return array
120
+     */
121
+    public function getAllowedConnectDomains(): array {
122
+        return $this->allowedConnectDomains;
123
+    }
124
+
125
+    /**
126
+     * @param array $allowedConnectDomains
127
+     */
128
+    public function setAllowedConnectDomains(array $allowedConnectDomains) {
129
+        $this->allowedConnectDomains = $allowedConnectDomains;
130
+    }
131
+
132
+    /**
133
+     * @return array
134
+     */
135
+    public function getAllowedMediaDomains(): array {
136
+        return $this->allowedMediaDomains;
137
+    }
138
+
139
+    /**
140
+     * @param array $allowedMediaDomains
141
+     */
142
+    public function setAllowedMediaDomains(array $allowedMediaDomains) {
143
+        $this->allowedMediaDomains = $allowedMediaDomains;
144
+    }
145
+
146
+    /**
147
+     * @return array
148
+     */
149
+    public function getAllowedObjectDomains(): array {
150
+        return $this->allowedObjectDomains;
151
+    }
152
+
153
+    /**
154
+     * @param array $allowedObjectDomains
155
+     */
156
+    public function setAllowedObjectDomains(array $allowedObjectDomains) {
157
+        $this->allowedObjectDomains = $allowedObjectDomains;
158
+    }
159
+
160
+    /**
161
+     * @return array
162
+     */
163
+    public function getAllowedFrameDomains(): array {
164
+        return $this->allowedFrameDomains;
165
+    }
166
+
167
+    /**
168
+     * @param array $allowedFrameDomains
169
+     */
170
+    public function setAllowedFrameDomains(array $allowedFrameDomains) {
171
+        $this->allowedFrameDomains = $allowedFrameDomains;
172
+    }
173
+
174
+    /**
175
+     * @return array
176
+     */
177
+    public function getAllowedFontDomains(): array {
178
+        return $this->allowedFontDomains;
179
+    }
180
+
181
+    /**
182
+     * @param array $allowedFontDomains
183
+     */
184
+    public function setAllowedFontDomains($allowedFontDomains) {
185
+        $this->allowedFontDomains = $allowedFontDomains;
186
+    }
187
+
188
+    /**
189
+     * @return array
190
+     * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
191
+     */
192
+    public function getAllowedChildSrcDomains(): array {
193
+        return $this->allowedChildSrcDomains;
194
+    }
195
+
196
+    /**
197
+     * @param array $allowedChildSrcDomains
198
+     * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains
199
+     */
200
+    public function setAllowedChildSrcDomains($allowedChildSrcDomains) {
201
+        $this->allowedChildSrcDomains = $allowedChildSrcDomains;
202
+    }
203
+
204
+    /**
205
+     * @return array
206
+     */
207
+    public function getAllowedFrameAncestors(): array {
208
+        return $this->allowedFrameAncestors;
209
+    }
210
+
211
+    /**
212
+     * @param array $allowedFrameAncestors
213
+     */
214
+    public function setAllowedFrameAncestors($allowedFrameAncestors) {
215
+        $this->allowedFrameAncestors = $allowedFrameAncestors;
216
+    }
217
+
218
+    public function getAllowedWorkerSrcDomains(): array {
219
+        return $this->allowedWorkerSrcDomains;
220
+    }
221
+
222
+    public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains) {
223
+        $this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains;
224
+    }
225 225
 
226 226
 }
Please login to merge, or discard this patch.