1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
5
|
|
|
* |
6
|
|
|
* @author Lukas Reschke <[email protected]> |
7
|
|
|
* @author Thomas Citharel <[email protected]> |
8
|
|
|
* |
9
|
|
|
* @license AGPL-3.0 |
10
|
|
|
* |
11
|
|
|
* This code is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
13
|
|
|
* as published by the Free Software Foundation. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU Affero General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
namespace OC\Security\CSP; |
25
|
|
|
|
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
|
|
|
/** |
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
|
|
|
* @deprecated 17.0.0 Unsafe eval should not be used anymore. |
59
|
|
|
*/ |
60
|
|
|
public function setEvalScriptAllowed(bool $evalScriptAllowed) { |
61
|
|
|
$this->evalScriptAllowed = $evalScriptAllowed; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return array |
66
|
|
|
*/ |
67
|
|
|
public function getAllowedScriptDomains(): array { |
68
|
|
|
return $this->allowedScriptDomains; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param array $allowedScriptDomains |
73
|
|
|
*/ |
74
|
|
|
public function setAllowedScriptDomains(array $allowedScriptDomains) { |
75
|
|
|
$this->allowedScriptDomains = $allowedScriptDomains; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return boolean |
80
|
|
|
*/ |
81
|
|
|
public function isInlineStyleAllowed(): bool { |
82
|
|
|
return $this->inlineStyleAllowed; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param boolean $inlineStyleAllowed |
87
|
|
|
*/ |
88
|
|
|
public function setInlineStyleAllowed(bool $inlineStyleAllowed) { |
89
|
|
|
$this->inlineStyleAllowed = $inlineStyleAllowed; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return array |
94
|
|
|
*/ |
95
|
|
|
public function getAllowedStyleDomains(): array { |
96
|
|
|
return $this->allowedStyleDomains; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param array $allowedStyleDomains |
101
|
|
|
*/ |
102
|
|
|
public function setAllowedStyleDomains(array $allowedStyleDomains) { |
103
|
|
|
$this->allowedStyleDomains = $allowedStyleDomains; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return array |
108
|
|
|
*/ |
109
|
|
|
public function getAllowedImageDomains(): array { |
110
|
|
|
return $this->allowedImageDomains; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param array $allowedImageDomains |
115
|
|
|
*/ |
116
|
|
|
public function setAllowedImageDomains(array $allowedImageDomains) { |
117
|
|
|
$this->allowedImageDomains = $allowedImageDomains; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return array |
122
|
|
|
*/ |
123
|
|
|
public function getAllowedConnectDomains(): array { |
124
|
|
|
return $this->allowedConnectDomains; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param array $allowedConnectDomains |
129
|
|
|
*/ |
130
|
|
|
public function setAllowedConnectDomains(array $allowedConnectDomains) { |
131
|
|
|
$this->allowedConnectDomains = $allowedConnectDomains; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return array |
136
|
|
|
*/ |
137
|
|
|
public function getAllowedMediaDomains(): array { |
138
|
|
|
return $this->allowedMediaDomains; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param array $allowedMediaDomains |
143
|
|
|
*/ |
144
|
|
|
public function setAllowedMediaDomains(array $allowedMediaDomains) { |
145
|
|
|
$this->allowedMediaDomains = $allowedMediaDomains; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return array |
150
|
|
|
*/ |
151
|
|
|
public function getAllowedObjectDomains(): array { |
152
|
|
|
return $this->allowedObjectDomains; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param array $allowedObjectDomains |
157
|
|
|
*/ |
158
|
|
|
public function setAllowedObjectDomains(array $allowedObjectDomains) { |
159
|
|
|
$this->allowedObjectDomains = $allowedObjectDomains; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return array |
164
|
|
|
*/ |
165
|
|
|
public function getAllowedFrameDomains(): array { |
166
|
|
|
return $this->allowedFrameDomains; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @param array $allowedFrameDomains |
171
|
|
|
*/ |
172
|
|
|
public function setAllowedFrameDomains(array $allowedFrameDomains) { |
173
|
|
|
$this->allowedFrameDomains = $allowedFrameDomains; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return array |
178
|
|
|
*/ |
179
|
|
|
public function getAllowedFontDomains(): array { |
180
|
|
|
return $this->allowedFontDomains; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param array $allowedFontDomains |
185
|
|
|
*/ |
186
|
|
|
public function setAllowedFontDomains($allowedFontDomains) { |
187
|
|
|
$this->allowedFontDomains = $allowedFontDomains; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return array |
192
|
|
|
* @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains |
193
|
|
|
*/ |
194
|
|
|
public function getAllowedChildSrcDomains(): array { |
195
|
|
|
return $this->allowedChildSrcDomains; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param array $allowedChildSrcDomains |
200
|
|
|
* @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains |
201
|
|
|
*/ |
202
|
|
|
public function setAllowedChildSrcDomains($allowedChildSrcDomains) { |
203
|
|
|
$this->allowedChildSrcDomains = $allowedChildSrcDomains; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return array |
208
|
|
|
*/ |
209
|
|
|
public function getAllowedFrameAncestors(): array { |
210
|
|
|
return $this->allowedFrameAncestors; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @param array $allowedFrameAncestors |
215
|
|
|
*/ |
216
|
|
|
public function setAllowedFrameAncestors($allowedFrameAncestors) { |
217
|
|
|
$this->allowedFrameAncestors = $allowedFrameAncestors; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function getAllowedWorkerSrcDomains(): array { |
221
|
|
|
return $this->allowedWorkerSrcDomains; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains) { |
225
|
|
|
$this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function getAllowedFormActionDomains(): array { |
229
|
|
|
return $this->allowedFormActionDomains; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public function setAllowedFormActionDomains(array $allowedFormActionDomains): void { |
233
|
|
|
$this->allowedFormActionDomains = $allowedFormActionDomains; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
|
237
|
|
|
public function getReportTo(): array { |
238
|
|
|
return $this->reportTo; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
public function setReportTo(array $reportTo) { |
242
|
|
|
$this->reportTo = $reportTo; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
} |
246
|
|
|
|