@@ -32,61 +32,61 @@ |
||
32 | 32 | use Psr\Log\LoggerInterface; |
33 | 33 | |
34 | 34 | class Action { |
35 | - /** @var LoggerInterface */ |
|
36 | - private $logger; |
|
35 | + /** @var LoggerInterface */ |
|
36 | + private $logger; |
|
37 | 37 | |
38 | - public function __construct(LoggerInterface $logger) { |
|
39 | - $this->logger = $logger; |
|
40 | - } |
|
38 | + public function __construct(LoggerInterface $logger) { |
|
39 | + $this->logger = $logger; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Log a single action with a log level of info |
|
44 | - * |
|
45 | - * @param string $text |
|
46 | - * @param array $params |
|
47 | - * @param array $elements |
|
48 | - * @param bool $obfuscateParameters |
|
49 | - */ |
|
50 | - public function log(string $text, |
|
51 | - array $params, |
|
52 | - array $elements, |
|
53 | - bool $obfuscateParameters = false): void { |
|
54 | - foreach ($elements as $element) { |
|
55 | - if (!isset($params[$element])) { |
|
56 | - if ($obfuscateParameters) { |
|
57 | - $this->logger->critical( |
|
58 | - '$params["'.$element.'"] was missing.', |
|
59 | - ['app' => 'admin_audit'] |
|
60 | - ); |
|
61 | - } else { |
|
62 | - $this->logger->critical( |
|
63 | - sprintf( |
|
64 | - '$params["'.$element.'"] was missing. Transferred value: %s', |
|
65 | - print_r($params, true) |
|
66 | - ), |
|
67 | - ['app' => 'admin_audit'] |
|
68 | - ); |
|
69 | - } |
|
70 | - return; |
|
71 | - } |
|
72 | - } |
|
42 | + /** |
|
43 | + * Log a single action with a log level of info |
|
44 | + * |
|
45 | + * @param string $text |
|
46 | + * @param array $params |
|
47 | + * @param array $elements |
|
48 | + * @param bool $obfuscateParameters |
|
49 | + */ |
|
50 | + public function log(string $text, |
|
51 | + array $params, |
|
52 | + array $elements, |
|
53 | + bool $obfuscateParameters = false): void { |
|
54 | + foreach ($elements as $element) { |
|
55 | + if (!isset($params[$element])) { |
|
56 | + if ($obfuscateParameters) { |
|
57 | + $this->logger->critical( |
|
58 | + '$params["'.$element.'"] was missing.', |
|
59 | + ['app' => 'admin_audit'] |
|
60 | + ); |
|
61 | + } else { |
|
62 | + $this->logger->critical( |
|
63 | + sprintf( |
|
64 | + '$params["'.$element.'"] was missing. Transferred value: %s', |
|
65 | + print_r($params, true) |
|
66 | + ), |
|
67 | + ['app' => 'admin_audit'] |
|
68 | + ); |
|
69 | + } |
|
70 | + return; |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - $replaceArray = []; |
|
75 | - foreach ($elements as $element) { |
|
76 | - if ($params[$element] instanceof \DateTime) { |
|
77 | - $params[$element] = $params[$element]->format('Y-m-d H:i:s'); |
|
78 | - } |
|
79 | - $replaceArray[] = $params[$element]; |
|
80 | - } |
|
74 | + $replaceArray = []; |
|
75 | + foreach ($elements as $element) { |
|
76 | + if ($params[$element] instanceof \DateTime) { |
|
77 | + $params[$element] = $params[$element]->format('Y-m-d H:i:s'); |
|
78 | + } |
|
79 | + $replaceArray[] = $params[$element]; |
|
80 | + } |
|
81 | 81 | |
82 | - $this->logger->info( |
|
83 | - vsprintf( |
|
84 | - $text, |
|
85 | - $replaceArray |
|
86 | - ), |
|
87 | - [ |
|
88 | - 'app' => 'admin_audit' |
|
89 | - ] |
|
90 | - ); |
|
91 | - } |
|
82 | + $this->logger->info( |
|
83 | + vsprintf( |
|
84 | + $text, |
|
85 | + $replaceArray |
|
86 | + ), |
|
87 | + [ |
|
88 | + 'app' => 'admin_audit' |
|
89 | + ] |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | } |
@@ -33,33 +33,33 @@ |
||
33 | 33 | * @package OCA\AdminAudit\Actions |
34 | 34 | */ |
35 | 35 | class Auth extends Action { |
36 | - public function loginAttempt(array $params): void { |
|
37 | - $this->log( |
|
38 | - 'Login attempt: "%s"', |
|
39 | - $params, |
|
40 | - [ |
|
41 | - 'uid', |
|
42 | - ], |
|
43 | - true |
|
44 | - ); |
|
45 | - } |
|
36 | + public function loginAttempt(array $params): void { |
|
37 | + $this->log( |
|
38 | + 'Login attempt: "%s"', |
|
39 | + $params, |
|
40 | + [ |
|
41 | + 'uid', |
|
42 | + ], |
|
43 | + true |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | - public function loginSuccessful(array $params): void { |
|
48 | - $this->log( |
|
49 | - 'Login successful: "%s"', |
|
50 | - $params, |
|
51 | - [ |
|
52 | - 'uid', |
|
53 | - ], |
|
54 | - true |
|
55 | - ); |
|
56 | - } |
|
47 | + public function loginSuccessful(array $params): void { |
|
48 | + $this->log( |
|
49 | + 'Login successful: "%s"', |
|
50 | + $params, |
|
51 | + [ |
|
52 | + 'uid', |
|
53 | + ], |
|
54 | + true |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - public function logout(array $params): void { |
|
59 | - $this->log( |
|
60 | - 'Logout occurred', |
|
61 | - [], |
|
62 | - [] |
|
63 | - ); |
|
64 | - } |
|
58 | + public function logout(array $params): void { |
|
59 | + $this->log( |
|
60 | + 'Logout occurred', |
|
61 | + [], |
|
62 | + [] |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | } |
@@ -38,313 +38,313 @@ |
||
38 | 38 | * @package OCA\AdminAudit\Actions |
39 | 39 | */ |
40 | 40 | class Sharing extends Action { |
41 | - /** |
|
42 | - * Logs sharing of data |
|
43 | - * |
|
44 | - * @param array $params |
|
45 | - */ |
|
46 | - public function shared(array $params): void { |
|
47 | - if ($params['shareType'] === IShare::TYPE_LINK) { |
|
48 | - $this->log( |
|
49 | - 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
|
50 | - $params, |
|
51 | - [ |
|
52 | - 'itemType', |
|
53 | - 'itemTarget', |
|
54 | - 'itemSource', |
|
55 | - 'permissions', |
|
56 | - 'id', |
|
57 | - ] |
|
58 | - ); |
|
59 | - } elseif ($params['shareType'] === IShare::TYPE_USER) { |
|
60 | - $this->log( |
|
61 | - 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
|
62 | - $params, |
|
63 | - [ |
|
64 | - 'itemType', |
|
65 | - 'itemTarget', |
|
66 | - 'itemSource', |
|
67 | - 'shareWith', |
|
68 | - 'permissions', |
|
69 | - 'id', |
|
70 | - ] |
|
71 | - ); |
|
72 | - } elseif ($params['shareType'] === IShare::TYPE_GROUP) { |
|
73 | - $this->log( |
|
74 | - 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
|
75 | - $params, |
|
76 | - [ |
|
77 | - 'itemType', |
|
78 | - 'itemTarget', |
|
79 | - 'itemSource', |
|
80 | - 'shareWith', |
|
81 | - 'permissions', |
|
82 | - 'id', |
|
83 | - ] |
|
84 | - ); |
|
85 | - } elseif ($params['shareType'] === IShare::TYPE_ROOM) { |
|
86 | - $this->log( |
|
87 | - 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)', |
|
88 | - $params, |
|
89 | - [ |
|
90 | - 'itemType', |
|
91 | - 'itemTarget', |
|
92 | - 'itemSource', |
|
93 | - 'shareWith', |
|
94 | - 'permissions', |
|
95 | - 'id', |
|
96 | - ] |
|
97 | - ); |
|
98 | - } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { |
|
99 | - $this->log( |
|
100 | - 'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)', |
|
101 | - $params, |
|
102 | - [ |
|
103 | - 'itemType', |
|
104 | - 'itemTarget', |
|
105 | - 'itemSource', |
|
106 | - 'shareWith', |
|
107 | - 'permissions', |
|
108 | - 'id', |
|
109 | - ] |
|
110 | - ); |
|
111 | - } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { |
|
112 | - $this->log( |
|
113 | - 'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)', |
|
114 | - $params, |
|
115 | - [ |
|
116 | - 'itemType', |
|
117 | - 'itemTarget', |
|
118 | - 'itemSource', |
|
119 | - 'shareWith', |
|
120 | - 'permissions', |
|
121 | - 'id', |
|
122 | - ] |
|
123 | - ); |
|
124 | - } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { |
|
125 | - $this->log( |
|
126 | - 'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)', |
|
127 | - $params, |
|
128 | - [ |
|
129 | - 'itemType', |
|
130 | - 'itemTarget', |
|
131 | - 'itemSource', |
|
132 | - 'shareWith', |
|
133 | - 'permissions', |
|
134 | - 'id', |
|
135 | - ] |
|
136 | - ); |
|
137 | - } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { |
|
138 | - $this->log( |
|
139 | - 'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)', |
|
140 | - $params, |
|
141 | - [ |
|
142 | - 'itemType', |
|
143 | - 'itemTarget', |
|
144 | - 'itemSource', |
|
145 | - 'shareWith', |
|
146 | - 'permissions', |
|
147 | - 'id', |
|
148 | - ] |
|
149 | - ); |
|
150 | - } elseif ($params['shareType'] === IShare::TYPE_DECK) { |
|
151 | - $this->log( |
|
152 | - 'The %s "%s" with ID "%s" has been shared to the deck card "%s" with permissions "%s" (Share ID: %s)', |
|
153 | - $params, |
|
154 | - [ |
|
155 | - 'itemType', |
|
156 | - 'itemTarget', |
|
157 | - 'itemSource', |
|
158 | - 'shareWith', |
|
159 | - 'permissions', |
|
160 | - 'id', |
|
161 | - ] |
|
162 | - ); |
|
163 | - } |
|
164 | - } |
|
41 | + /** |
|
42 | + * Logs sharing of data |
|
43 | + * |
|
44 | + * @param array $params |
|
45 | + */ |
|
46 | + public function shared(array $params): void { |
|
47 | + if ($params['shareType'] === IShare::TYPE_LINK) { |
|
48 | + $this->log( |
|
49 | + 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
|
50 | + $params, |
|
51 | + [ |
|
52 | + 'itemType', |
|
53 | + 'itemTarget', |
|
54 | + 'itemSource', |
|
55 | + 'permissions', |
|
56 | + 'id', |
|
57 | + ] |
|
58 | + ); |
|
59 | + } elseif ($params['shareType'] === IShare::TYPE_USER) { |
|
60 | + $this->log( |
|
61 | + 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
|
62 | + $params, |
|
63 | + [ |
|
64 | + 'itemType', |
|
65 | + 'itemTarget', |
|
66 | + 'itemSource', |
|
67 | + 'shareWith', |
|
68 | + 'permissions', |
|
69 | + 'id', |
|
70 | + ] |
|
71 | + ); |
|
72 | + } elseif ($params['shareType'] === IShare::TYPE_GROUP) { |
|
73 | + $this->log( |
|
74 | + 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
|
75 | + $params, |
|
76 | + [ |
|
77 | + 'itemType', |
|
78 | + 'itemTarget', |
|
79 | + 'itemSource', |
|
80 | + 'shareWith', |
|
81 | + 'permissions', |
|
82 | + 'id', |
|
83 | + ] |
|
84 | + ); |
|
85 | + } elseif ($params['shareType'] === IShare::TYPE_ROOM) { |
|
86 | + $this->log( |
|
87 | + 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)', |
|
88 | + $params, |
|
89 | + [ |
|
90 | + 'itemType', |
|
91 | + 'itemTarget', |
|
92 | + 'itemSource', |
|
93 | + 'shareWith', |
|
94 | + 'permissions', |
|
95 | + 'id', |
|
96 | + ] |
|
97 | + ); |
|
98 | + } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { |
|
99 | + $this->log( |
|
100 | + 'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)', |
|
101 | + $params, |
|
102 | + [ |
|
103 | + 'itemType', |
|
104 | + 'itemTarget', |
|
105 | + 'itemSource', |
|
106 | + 'shareWith', |
|
107 | + 'permissions', |
|
108 | + 'id', |
|
109 | + ] |
|
110 | + ); |
|
111 | + } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { |
|
112 | + $this->log( |
|
113 | + 'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)', |
|
114 | + $params, |
|
115 | + [ |
|
116 | + 'itemType', |
|
117 | + 'itemTarget', |
|
118 | + 'itemSource', |
|
119 | + 'shareWith', |
|
120 | + 'permissions', |
|
121 | + 'id', |
|
122 | + ] |
|
123 | + ); |
|
124 | + } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { |
|
125 | + $this->log( |
|
126 | + 'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)', |
|
127 | + $params, |
|
128 | + [ |
|
129 | + 'itemType', |
|
130 | + 'itemTarget', |
|
131 | + 'itemSource', |
|
132 | + 'shareWith', |
|
133 | + 'permissions', |
|
134 | + 'id', |
|
135 | + ] |
|
136 | + ); |
|
137 | + } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { |
|
138 | + $this->log( |
|
139 | + 'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)', |
|
140 | + $params, |
|
141 | + [ |
|
142 | + 'itemType', |
|
143 | + 'itemTarget', |
|
144 | + 'itemSource', |
|
145 | + 'shareWith', |
|
146 | + 'permissions', |
|
147 | + 'id', |
|
148 | + ] |
|
149 | + ); |
|
150 | + } elseif ($params['shareType'] === IShare::TYPE_DECK) { |
|
151 | + $this->log( |
|
152 | + 'The %s "%s" with ID "%s" has been shared to the deck card "%s" with permissions "%s" (Share ID: %s)', |
|
153 | + $params, |
|
154 | + [ |
|
155 | + 'itemType', |
|
156 | + 'itemTarget', |
|
157 | + 'itemSource', |
|
158 | + 'shareWith', |
|
159 | + 'permissions', |
|
160 | + 'id', |
|
161 | + ] |
|
162 | + ); |
|
163 | + } |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * Logs unsharing of data |
|
168 | - * |
|
169 | - * @param array $params |
|
170 | - */ |
|
171 | - public function unshare(array $params): void { |
|
172 | - if ($params['shareType'] === IShare::TYPE_LINK) { |
|
173 | - $this->log( |
|
174 | - 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
|
175 | - $params, |
|
176 | - [ |
|
177 | - 'itemType', |
|
178 | - 'fileTarget', |
|
179 | - 'itemSource', |
|
180 | - 'id', |
|
181 | - ] |
|
182 | - ); |
|
183 | - } elseif ($params['shareType'] === IShare::TYPE_USER) { |
|
184 | - $this->log( |
|
185 | - 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
|
186 | - $params, |
|
187 | - [ |
|
188 | - 'itemType', |
|
189 | - 'fileTarget', |
|
190 | - 'itemSource', |
|
191 | - 'shareWith', |
|
192 | - 'id', |
|
193 | - ] |
|
194 | - ); |
|
195 | - } elseif ($params['shareType'] === IShare::TYPE_GROUP) { |
|
196 | - $this->log( |
|
197 | - 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
|
198 | - $params, |
|
199 | - [ |
|
200 | - 'itemType', |
|
201 | - 'fileTarget', |
|
202 | - 'itemSource', |
|
203 | - 'shareWith', |
|
204 | - 'id', |
|
205 | - ] |
|
206 | - ); |
|
207 | - } elseif ($params['shareType'] === IShare::TYPE_ROOM) { |
|
208 | - $this->log( |
|
209 | - 'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)', |
|
210 | - $params, |
|
211 | - [ |
|
212 | - 'itemType', |
|
213 | - 'fileTarget', |
|
214 | - 'itemSource', |
|
215 | - 'shareWith', |
|
216 | - 'id', |
|
217 | - ] |
|
218 | - ); |
|
219 | - } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { |
|
220 | - $this->log( |
|
221 | - 'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)', |
|
222 | - $params, |
|
223 | - [ |
|
224 | - 'itemType', |
|
225 | - 'fileTarget', |
|
226 | - 'itemSource', |
|
227 | - 'shareWith', |
|
228 | - 'id', |
|
229 | - ] |
|
230 | - ); |
|
231 | - } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { |
|
232 | - $this->log( |
|
233 | - 'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)', |
|
234 | - $params, |
|
235 | - [ |
|
236 | - 'itemType', |
|
237 | - 'fileTarget', |
|
238 | - 'itemSource', |
|
239 | - 'shareWith', |
|
240 | - 'id', |
|
241 | - ] |
|
242 | - ); |
|
243 | - } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { |
|
244 | - $this->log( |
|
245 | - 'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)', |
|
246 | - $params, |
|
247 | - [ |
|
248 | - 'itemType', |
|
249 | - 'fileTarget', |
|
250 | - 'itemSource', |
|
251 | - 'shareWith', |
|
252 | - 'id', |
|
253 | - ] |
|
254 | - ); |
|
255 | - } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { |
|
256 | - $this->log( |
|
257 | - 'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)', |
|
258 | - $params, |
|
259 | - [ |
|
260 | - 'itemType', |
|
261 | - 'fileTarget', |
|
262 | - 'itemSource', |
|
263 | - 'shareWith', |
|
264 | - 'id', |
|
265 | - ] |
|
266 | - ); |
|
267 | - } elseif ($params['shareType'] === IShare::TYPE_DECK) { |
|
268 | - $this->log( |
|
269 | - 'The %s "%s" with ID "%s" has been unshared from the deck card "%s" (Share ID: %s)', |
|
270 | - $params, |
|
271 | - [ |
|
272 | - 'itemType', |
|
273 | - 'fileTarget', |
|
274 | - 'itemSource', |
|
275 | - 'shareWith', |
|
276 | - 'id', |
|
277 | - ] |
|
278 | - ); |
|
279 | - } |
|
280 | - } |
|
166 | + /** |
|
167 | + * Logs unsharing of data |
|
168 | + * |
|
169 | + * @param array $params |
|
170 | + */ |
|
171 | + public function unshare(array $params): void { |
|
172 | + if ($params['shareType'] === IShare::TYPE_LINK) { |
|
173 | + $this->log( |
|
174 | + 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
|
175 | + $params, |
|
176 | + [ |
|
177 | + 'itemType', |
|
178 | + 'fileTarget', |
|
179 | + 'itemSource', |
|
180 | + 'id', |
|
181 | + ] |
|
182 | + ); |
|
183 | + } elseif ($params['shareType'] === IShare::TYPE_USER) { |
|
184 | + $this->log( |
|
185 | + 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
|
186 | + $params, |
|
187 | + [ |
|
188 | + 'itemType', |
|
189 | + 'fileTarget', |
|
190 | + 'itemSource', |
|
191 | + 'shareWith', |
|
192 | + 'id', |
|
193 | + ] |
|
194 | + ); |
|
195 | + } elseif ($params['shareType'] === IShare::TYPE_GROUP) { |
|
196 | + $this->log( |
|
197 | + 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
|
198 | + $params, |
|
199 | + [ |
|
200 | + 'itemType', |
|
201 | + 'fileTarget', |
|
202 | + 'itemSource', |
|
203 | + 'shareWith', |
|
204 | + 'id', |
|
205 | + ] |
|
206 | + ); |
|
207 | + } elseif ($params['shareType'] === IShare::TYPE_ROOM) { |
|
208 | + $this->log( |
|
209 | + 'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)', |
|
210 | + $params, |
|
211 | + [ |
|
212 | + 'itemType', |
|
213 | + 'fileTarget', |
|
214 | + 'itemSource', |
|
215 | + 'shareWith', |
|
216 | + 'id', |
|
217 | + ] |
|
218 | + ); |
|
219 | + } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { |
|
220 | + $this->log( |
|
221 | + 'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)', |
|
222 | + $params, |
|
223 | + [ |
|
224 | + 'itemType', |
|
225 | + 'fileTarget', |
|
226 | + 'itemSource', |
|
227 | + 'shareWith', |
|
228 | + 'id', |
|
229 | + ] |
|
230 | + ); |
|
231 | + } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { |
|
232 | + $this->log( |
|
233 | + 'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)', |
|
234 | + $params, |
|
235 | + [ |
|
236 | + 'itemType', |
|
237 | + 'fileTarget', |
|
238 | + 'itemSource', |
|
239 | + 'shareWith', |
|
240 | + 'id', |
|
241 | + ] |
|
242 | + ); |
|
243 | + } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { |
|
244 | + $this->log( |
|
245 | + 'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)', |
|
246 | + $params, |
|
247 | + [ |
|
248 | + 'itemType', |
|
249 | + 'fileTarget', |
|
250 | + 'itemSource', |
|
251 | + 'shareWith', |
|
252 | + 'id', |
|
253 | + ] |
|
254 | + ); |
|
255 | + } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { |
|
256 | + $this->log( |
|
257 | + 'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)', |
|
258 | + $params, |
|
259 | + [ |
|
260 | + 'itemType', |
|
261 | + 'fileTarget', |
|
262 | + 'itemSource', |
|
263 | + 'shareWith', |
|
264 | + 'id', |
|
265 | + ] |
|
266 | + ); |
|
267 | + } elseif ($params['shareType'] === IShare::TYPE_DECK) { |
|
268 | + $this->log( |
|
269 | + 'The %s "%s" with ID "%s" has been unshared from the deck card "%s" (Share ID: %s)', |
|
270 | + $params, |
|
271 | + [ |
|
272 | + 'itemType', |
|
273 | + 'fileTarget', |
|
274 | + 'itemSource', |
|
275 | + 'shareWith', |
|
276 | + 'id', |
|
277 | + ] |
|
278 | + ); |
|
279 | + } |
|
280 | + } |
|
281 | 281 | |
282 | - /** |
|
283 | - * Logs the updating of permission changes for shares |
|
284 | - * |
|
285 | - * @param array $params |
|
286 | - */ |
|
287 | - public function updatePermissions(array $params): void { |
|
288 | - $this->log( |
|
289 | - 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"', |
|
290 | - $params, |
|
291 | - [ |
|
292 | - 'itemType', |
|
293 | - 'path', |
|
294 | - 'itemSource', |
|
295 | - 'permissions', |
|
296 | - ] |
|
297 | - ); |
|
298 | - } |
|
282 | + /** |
|
283 | + * Logs the updating of permission changes for shares |
|
284 | + * |
|
285 | + * @param array $params |
|
286 | + */ |
|
287 | + public function updatePermissions(array $params): void { |
|
288 | + $this->log( |
|
289 | + 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"', |
|
290 | + $params, |
|
291 | + [ |
|
292 | + 'itemType', |
|
293 | + 'path', |
|
294 | + 'itemSource', |
|
295 | + 'permissions', |
|
296 | + ] |
|
297 | + ); |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * Logs the password changes for a share |
|
302 | - * |
|
303 | - * @param array $params |
|
304 | - */ |
|
305 | - public function updatePassword(array $params): void { |
|
306 | - $this->log( |
|
307 | - 'The password of the publicly shared %s "%s" with ID "%s" has been changed', |
|
308 | - $params, |
|
309 | - [ |
|
310 | - 'itemType', |
|
311 | - 'token', |
|
312 | - 'itemSource', |
|
313 | - ] |
|
314 | - ); |
|
315 | - } |
|
300 | + /** |
|
301 | + * Logs the password changes for a share |
|
302 | + * |
|
303 | + * @param array $params |
|
304 | + */ |
|
305 | + public function updatePassword(array $params): void { |
|
306 | + $this->log( |
|
307 | + 'The password of the publicly shared %s "%s" with ID "%s" has been changed', |
|
308 | + $params, |
|
309 | + [ |
|
310 | + 'itemType', |
|
311 | + 'token', |
|
312 | + 'itemSource', |
|
313 | + ] |
|
314 | + ); |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * Logs the expiration date changes for a share |
|
319 | - * |
|
320 | - * @param array $params |
|
321 | - */ |
|
322 | - public function updateExpirationDate(array $params): void { |
|
323 | - $this->log( |
|
324 | - 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"', |
|
325 | - $params, |
|
326 | - [ |
|
327 | - 'itemType', |
|
328 | - 'itemSource', |
|
329 | - 'date', |
|
330 | - ] |
|
331 | - ); |
|
332 | - } |
|
317 | + /** |
|
318 | + * Logs the expiration date changes for a share |
|
319 | + * |
|
320 | + * @param array $params |
|
321 | + */ |
|
322 | + public function updateExpirationDate(array $params): void { |
|
323 | + $this->log( |
|
324 | + 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"', |
|
325 | + $params, |
|
326 | + [ |
|
327 | + 'itemType', |
|
328 | + 'itemSource', |
|
329 | + 'date', |
|
330 | + ] |
|
331 | + ); |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Logs access of shared files |
|
336 | - * |
|
337 | - * @param array $params |
|
338 | - */ |
|
339 | - public function shareAccessed(array $params): void { |
|
340 | - $this->log( |
|
341 | - 'The shared %s with the token "%s" by "%s" has been accessed.', |
|
342 | - $params, |
|
343 | - [ |
|
344 | - 'itemType', |
|
345 | - 'token', |
|
346 | - 'uidOwner', |
|
347 | - ] |
|
348 | - ); |
|
349 | - } |
|
334 | + /** |
|
335 | + * Logs access of shared files |
|
336 | + * |
|
337 | + * @param array $params |
|
338 | + */ |
|
339 | + public function shareAccessed(array $params): void { |
|
340 | + $this->log( |
|
341 | + 'The shared %s with the token "%s" by "%s" has been accessed.', |
|
342 | + $params, |
|
343 | + [ |
|
344 | + 'itemType', |
|
345 | + 'token', |
|
346 | + 'uidOwner', |
|
347 | + ] |
|
348 | + ); |
|
349 | + } |
|
350 | 350 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | namespace OCA\AdminAudit\Actions; |
30 | 30 | |
31 | 31 | class Console extends Action { |
32 | - /** |
|
33 | - * @param $arguments |
|
34 | - */ |
|
35 | - public function runCommand(array $arguments): void { |
|
36 | - if (!isset($arguments[1]) || $arguments[1] === '_completion') { |
|
37 | - // Don't log autocompletion |
|
38 | - return; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param $arguments |
|
34 | + */ |
|
35 | + public function runCommand(array $arguments): void { |
|
36 | + if (!isset($arguments[1]) || $arguments[1] === '_completion') { |
|
37 | + // Don't log autocompletion |
|
38 | + return; |
|
39 | + } |
|
40 | 40 | |
41 | - // Remove `./occ` |
|
42 | - array_shift($arguments); |
|
41 | + // Remove `./occ` |
|
42 | + array_shift($arguments); |
|
43 | 43 | |
44 | - $this->log('Console command executed: %s', |
|
45 | - ['arguments' => implode(' ', $arguments)], |
|
46 | - ['arguments'] |
|
47 | - ); |
|
48 | - } |
|
44 | + $this->log('Console command executed: %s', |
|
45 | + ['arguments' => implode(' ', $arguments)], |
|
46 | + ['arguments'] |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | } |
@@ -29,20 +29,20 @@ |
||
29 | 29 | namespace OCA\AdminAudit\Actions; |
30 | 30 | |
31 | 31 | class Versions extends Action { |
32 | - public function rollback(array $params): void { |
|
33 | - $this->log('Version "%s" of "%s" was restored.', |
|
34 | - [ |
|
35 | - 'version' => $params['revision'], |
|
36 | - 'path' => $params['path'] |
|
37 | - ], |
|
38 | - ['version', 'path'] |
|
39 | - ); |
|
40 | - } |
|
32 | + public function rollback(array $params): void { |
|
33 | + $this->log('Version "%s" of "%s" was restored.', |
|
34 | + [ |
|
35 | + 'version' => $params['revision'], |
|
36 | + 'path' => $params['path'] |
|
37 | + ], |
|
38 | + ['version', 'path'] |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | - public function delete(array $params): void { |
|
43 | - $this->log('Version "%s" was deleted.', |
|
44 | - ['path' => $params['path']], |
|
45 | - ['path'] |
|
46 | - ); |
|
47 | - } |
|
42 | + public function delete(array $params): void { |
|
43 | + $this->log('Version "%s" was deleted.', |
|
44 | + ['path' => $params['path']], |
|
45 | + ['path'] |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | } |
@@ -29,15 +29,15 @@ |
||
29 | 29 | namespace OCA\AdminAudit\Actions; |
30 | 30 | |
31 | 31 | class Trashbin extends Action { |
32 | - public function delete(array $params): void { |
|
33 | - $this->log('File "%s" deleted from trash bin.', |
|
34 | - ['path' => $params['path']], ['path'] |
|
35 | - ); |
|
36 | - } |
|
32 | + public function delete(array $params): void { |
|
33 | + $this->log('File "%s" deleted from trash bin.', |
|
34 | + ['path' => $params['path']], ['path'] |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | - public function restore(array $params): void { |
|
39 | - $this->log('File "%s" restored from trash bin.', |
|
40 | - ['path' => $params['filePath']], ['path'] |
|
41 | - ); |
|
42 | - } |
|
38 | + public function restore(array $params): void { |
|
39 | + $this->log('File "%s" restored from trash bin.', |
|
40 | + ['path' => $params['filePath']], ['path'] |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | } |
@@ -29,34 +29,34 @@ |
||
29 | 29 | |
30 | 30 | class AppManagement extends Action { |
31 | 31 | |
32 | - /** |
|
33 | - * @param string $appName |
|
34 | - */ |
|
35 | - public function enableApp(string $appName): void { |
|
36 | - $this->log('App "%s" enabled', |
|
37 | - ['app' => $appName], |
|
38 | - ['app'] |
|
39 | - ); |
|
40 | - } |
|
32 | + /** |
|
33 | + * @param string $appName |
|
34 | + */ |
|
35 | + public function enableApp(string $appName): void { |
|
36 | + $this->log('App "%s" enabled', |
|
37 | + ['app' => $appName], |
|
38 | + ['app'] |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string $appName |
|
44 | - * @param string[] $groups |
|
45 | - */ |
|
46 | - public function enableAppForGroups(string $appName, array $groups): void { |
|
47 | - $this->log('App "%1$s" enabled for groups: %2$s', |
|
48 | - ['app' => $appName, 'groups' => implode(', ', $groups)], |
|
49 | - ['app', 'groups'] |
|
50 | - ); |
|
51 | - } |
|
42 | + /** |
|
43 | + * @param string $appName |
|
44 | + * @param string[] $groups |
|
45 | + */ |
|
46 | + public function enableAppForGroups(string $appName, array $groups): void { |
|
47 | + $this->log('App "%1$s" enabled for groups: %2$s', |
|
48 | + ['app' => $appName, 'groups' => implode(', ', $groups)], |
|
49 | + ['app', 'groups'] |
|
50 | + ); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param string $appName |
|
55 | - */ |
|
56 | - public function disableApp(string $appName): void { |
|
57 | - $this->log('App "%s" disabled', |
|
58 | - ['app' => $appName], |
|
59 | - ['app'] |
|
60 | - ); |
|
61 | - } |
|
53 | + /** |
|
54 | + * @param string $appName |
|
55 | + */ |
|
56 | + public function disableApp(string $appName): void { |
|
57 | + $this->log('App "%s" disabled', |
|
58 | + ['app' => $appName], |
|
59 | + ['app'] |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | } |
@@ -39,108 +39,108 @@ |
||
39 | 39 | * @package OCA\AdminAudit\Actions |
40 | 40 | */ |
41 | 41 | class UserManagement extends Action { |
42 | - /** |
|
43 | - * Log creation of users |
|
44 | - * |
|
45 | - * @param array $params |
|
46 | - */ |
|
47 | - public function create(array $params): void { |
|
48 | - $this->log( |
|
49 | - 'User created: "%s"', |
|
50 | - $params, |
|
51 | - [ |
|
52 | - 'uid', |
|
53 | - ] |
|
54 | - ); |
|
55 | - } |
|
42 | + /** |
|
43 | + * Log creation of users |
|
44 | + * |
|
45 | + * @param array $params |
|
46 | + */ |
|
47 | + public function create(array $params): void { |
|
48 | + $this->log( |
|
49 | + 'User created: "%s"', |
|
50 | + $params, |
|
51 | + [ |
|
52 | + 'uid', |
|
53 | + ] |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Log assignments of users (typically user backends) |
|
59 | - * |
|
60 | - * @param string $uid |
|
61 | - */ |
|
62 | - public function assign(string $uid): void { |
|
63 | - $this->log( |
|
64 | - 'UserID assigned: "%s"', |
|
65 | - [ 'uid' => $uid ], |
|
66 | - [ 'uid' ] |
|
67 | - ); |
|
68 | - } |
|
57 | + /** |
|
58 | + * Log assignments of users (typically user backends) |
|
59 | + * |
|
60 | + * @param string $uid |
|
61 | + */ |
|
62 | + public function assign(string $uid): void { |
|
63 | + $this->log( |
|
64 | + 'UserID assigned: "%s"', |
|
65 | + [ 'uid' => $uid ], |
|
66 | + [ 'uid' ] |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Log deletion of users |
|
72 | - * |
|
73 | - * @param array $params |
|
74 | - */ |
|
75 | - public function delete(array $params): void { |
|
76 | - $this->log( |
|
77 | - 'User deleted: "%s"', |
|
78 | - $params, |
|
79 | - [ |
|
80 | - 'uid', |
|
81 | - ] |
|
82 | - ); |
|
83 | - } |
|
70 | + /** |
|
71 | + * Log deletion of users |
|
72 | + * |
|
73 | + * @param array $params |
|
74 | + */ |
|
75 | + public function delete(array $params): void { |
|
76 | + $this->log( |
|
77 | + 'User deleted: "%s"', |
|
78 | + $params, |
|
79 | + [ |
|
80 | + 'uid', |
|
81 | + ] |
|
82 | + ); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Log unassignments of users (typically user backends, no data removed) |
|
87 | - * |
|
88 | - * @param string $uid |
|
89 | - */ |
|
90 | - public function unassign(string $uid): void { |
|
91 | - $this->log( |
|
92 | - 'UserID unassigned: "%s"', |
|
93 | - [ 'uid' => $uid ], |
|
94 | - [ 'uid' ] |
|
95 | - ); |
|
96 | - } |
|
85 | + /** |
|
86 | + * Log unassignments of users (typically user backends, no data removed) |
|
87 | + * |
|
88 | + * @param string $uid |
|
89 | + */ |
|
90 | + public function unassign(string $uid): void { |
|
91 | + $this->log( |
|
92 | + 'UserID unassigned: "%s"', |
|
93 | + [ 'uid' => $uid ], |
|
94 | + [ 'uid' ] |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Log enabling of users |
|
100 | - * |
|
101 | - * @param array $params |
|
102 | - */ |
|
103 | - public function change(array $params): void { |
|
104 | - switch ($params['feature']) { |
|
105 | - case 'enabled': |
|
106 | - $this->log( |
|
107 | - $params['value'] === true |
|
108 | - ? 'User enabled: "%s"' |
|
109 | - : 'User disabled: "%s"', |
|
110 | - ['user' => $params['user']->getUID()], |
|
111 | - [ |
|
112 | - 'user', |
|
113 | - ] |
|
114 | - ); |
|
115 | - break; |
|
116 | - case 'eMailAddress': |
|
117 | - $this->log( |
|
118 | - 'Email address changed for user %s', |
|
119 | - ['user' => $params['user']->getUID()], |
|
120 | - [ |
|
121 | - 'user', |
|
122 | - ] |
|
123 | - ); |
|
124 | - break; |
|
125 | - } |
|
126 | - } |
|
98 | + /** |
|
99 | + * Log enabling of users |
|
100 | + * |
|
101 | + * @param array $params |
|
102 | + */ |
|
103 | + public function change(array $params): void { |
|
104 | + switch ($params['feature']) { |
|
105 | + case 'enabled': |
|
106 | + $this->log( |
|
107 | + $params['value'] === true |
|
108 | + ? 'User enabled: "%s"' |
|
109 | + : 'User disabled: "%s"', |
|
110 | + ['user' => $params['user']->getUID()], |
|
111 | + [ |
|
112 | + 'user', |
|
113 | + ] |
|
114 | + ); |
|
115 | + break; |
|
116 | + case 'eMailAddress': |
|
117 | + $this->log( |
|
118 | + 'Email address changed for user %s', |
|
119 | + ['user' => $params['user']->getUID()], |
|
120 | + [ |
|
121 | + 'user', |
|
122 | + ] |
|
123 | + ); |
|
124 | + break; |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Logs changing of the user scope |
|
130 | - * |
|
131 | - * @param IUser $user |
|
132 | - */ |
|
133 | - public function setPassword(IUser $user): void { |
|
134 | - if ($user->getBackendClassName() === 'Database') { |
|
135 | - $this->log( |
|
136 | - 'Password of user "%s" has been changed', |
|
137 | - [ |
|
138 | - 'user' => $user->getUID(), |
|
139 | - ], |
|
140 | - [ |
|
141 | - 'user', |
|
142 | - ] |
|
143 | - ); |
|
144 | - } |
|
145 | - } |
|
128 | + /** |
|
129 | + * Logs changing of the user scope |
|
130 | + * |
|
131 | + * @param IUser $user |
|
132 | + */ |
|
133 | + public function setPassword(IUser $user): void { |
|
134 | + if ($user->getBackendClassName() === 'Database') { |
|
135 | + $this->log( |
|
136 | + 'Password of user "%s" has been changed', |
|
137 | + [ |
|
138 | + 'user' => $user->getUID(), |
|
139 | + ], |
|
140 | + [ |
|
141 | + 'user', |
|
142 | + ] |
|
143 | + ); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | public function assign(string $uid): void { |
63 | 63 | $this->log( |
64 | 64 | 'UserID assigned: "%s"', |
65 | - [ 'uid' => $uid ], |
|
66 | - [ 'uid' ] |
|
65 | + ['uid' => $uid], |
|
66 | + ['uid'] |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | public function unassign(string $uid): void { |
91 | 91 | $this->log( |
92 | 92 | 'UserID unassigned: "%s"', |
93 | - [ 'uid' => $uid ], |
|
94 | - [ 'uid' ] |
|
93 | + ['uid' => $uid], |
|
94 | + ['uid'] |
|
95 | 95 | ); |
96 | 96 | } |
97 | 97 |
@@ -35,45 +35,45 @@ |
||
35 | 35 | * @package OCA\AdminAudit\Actions |
36 | 36 | */ |
37 | 37 | class Security extends Action { |
38 | - /** |
|
39 | - * Log twofactor auth enabled |
|
40 | - * |
|
41 | - * @param IUser $user |
|
42 | - * @param array $params |
|
43 | - */ |
|
44 | - public function twofactorFailed(IUser $user, array $params): void { |
|
45 | - $params['uid'] = $user->getUID(); |
|
46 | - $params['displayName'] = $user->getDisplayName(); |
|
38 | + /** |
|
39 | + * Log twofactor auth enabled |
|
40 | + * |
|
41 | + * @param IUser $user |
|
42 | + * @param array $params |
|
43 | + */ |
|
44 | + public function twofactorFailed(IUser $user, array $params): void { |
|
45 | + $params['uid'] = $user->getUID(); |
|
46 | + $params['displayName'] = $user->getDisplayName(); |
|
47 | 47 | |
48 | - $this->log( |
|
49 | - 'Failed two factor attempt by user %s (%s) with provider %s', |
|
50 | - $params, |
|
51 | - [ |
|
52 | - 'displayName', |
|
53 | - 'uid', |
|
54 | - 'provider', |
|
55 | - ] |
|
56 | - ); |
|
57 | - } |
|
48 | + $this->log( |
|
49 | + 'Failed two factor attempt by user %s (%s) with provider %s', |
|
50 | + $params, |
|
51 | + [ |
|
52 | + 'displayName', |
|
53 | + 'uid', |
|
54 | + 'provider', |
|
55 | + ] |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Logs unsharing of data |
|
61 | - * |
|
62 | - * @param IUser $user |
|
63 | - * @param array $params |
|
64 | - */ |
|
65 | - public function twofactorSuccess(IUser $user, array $params): void { |
|
66 | - $params['uid'] = $user->getUID(); |
|
67 | - $params['displayName'] = $user->getDisplayName(); |
|
59 | + /** |
|
60 | + * Logs unsharing of data |
|
61 | + * |
|
62 | + * @param IUser $user |
|
63 | + * @param array $params |
|
64 | + */ |
|
65 | + public function twofactorSuccess(IUser $user, array $params): void { |
|
66 | + $params['uid'] = $user->getUID(); |
|
67 | + $params['displayName'] = $user->getDisplayName(); |
|
68 | 68 | |
69 | - $this->log( |
|
70 | - 'Successful two factor attempt by user %s (%s) with provider %s', |
|
71 | - $params, |
|
72 | - [ |
|
73 | - 'displayName', |
|
74 | - 'uid', |
|
75 | - 'provider', |
|
76 | - ] |
|
77 | - ); |
|
78 | - } |
|
69 | + $this->log( |
|
70 | + 'Successful two factor attempt by user %s (%s) with provider %s', |
|
71 | + $params, |
|
72 | + [ |
|
73 | + 'displayName', |
|
74 | + 'uid', |
|
75 | + 'provider', |
|
76 | + ] |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | } |