1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2020 Matthias Held <[email protected]> |
5
|
|
|
* @author Matthias Held <[email protected]> |
6
|
|
|
* @license GNU AGPL version 3 or any later version |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
11
|
|
|
* License, or (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\RansomwareDetection; |
23
|
|
|
|
24
|
|
|
use OCA\RansomwareDetection\AppInfo\Application; |
25
|
|
|
use OCA\RansomwareDetection\Events\FilesEvents; |
26
|
|
|
|
27
|
|
|
class FilesHooks { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Retrieve the FilesEvents' Controller. |
31
|
|
|
* |
32
|
|
|
* @return FilesEvents |
33
|
|
|
*/ |
34
|
|
|
protected static function getController(): FilesEvents { |
35
|
|
|
$app = new Application(); |
36
|
|
|
|
37
|
|
|
return $app->getContainer() |
38
|
|
|
->query(FilesEvents::class); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Hook events: file is updated. |
43
|
|
|
* |
44
|
|
|
* @param array $params |
45
|
|
|
*/ |
46
|
|
|
public static function onFileUpdate(array $params) { |
47
|
|
|
self::getController() |
48
|
|
|
->onFileUpdate($params); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Hook events: file is renamed. |
54
|
|
|
* |
55
|
|
|
* @param array $params |
56
|
|
|
*/ |
57
|
|
|
public static function onFileRename(array $params) { |
58
|
|
|
self::getController() |
59
|
|
|
->onFileRename($params); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Hook events: file is created. |
64
|
|
|
* |
65
|
|
|
* @param array $params |
66
|
|
|
*/ |
67
|
|
|
public static function onFileCreate(array $params) { |
68
|
|
|
self::getController() |
69
|
|
|
->onFileCreate($params); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Hook events: file is written. |
74
|
|
|
* |
75
|
|
|
* @param array $params |
76
|
|
|
*/ |
77
|
|
|
public static function onFileWrite(array $params) { |
78
|
|
|
self::getController() |
79
|
|
|
->onFileWrite($params); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Hook events: file is deleted. |
84
|
|
|
* |
85
|
|
|
* @param array $params |
86
|
|
|
*/ |
87
|
|
|
public static function onFileDelete(array $params) { |
88
|
|
|
self::getController() |
89
|
|
|
->onFileDelete($params); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Hook events: file is touched. |
94
|
|
|
* |
95
|
|
|
* @param array $params |
96
|
|
|
*/ |
97
|
|
|
public static function onFileTouch(array $params) { |
98
|
|
|
self::getController() |
99
|
|
|
->onFileTouch($params); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Hook events: file is copied. |
104
|
|
|
* |
105
|
|
|
* @param array $params |
106
|
|
|
*/ |
107
|
|
|
public static function onFileCopy(array $params) { |
108
|
|
|
self::getController() |
109
|
|
|
->onFileCopy($params); |
110
|
|
|
} |
111
|
|
|
} |