1 | <?php |
||
22 | class Item { |
||
23 | /** |
||
24 | * file handle, user to read from the file |
||
25 | * @var resource |
||
26 | */ |
||
27 | protected $fileHandle; |
||
28 | |||
29 | /** @var AppConfig */ |
||
30 | private $config; |
||
31 | |||
32 | /** @var ActivityManager */ |
||
33 | private $activityManager; |
||
34 | |||
35 | /** @var ItemMapper */ |
||
36 | private $itemMapper; |
||
37 | |||
38 | /** @var ILogger */ |
||
39 | private $logger; |
||
40 | |||
41 | /** @var IRootFolder */ |
||
42 | private $rootFolder; |
||
43 | |||
44 | /** @var File */ |
||
45 | private $file; |
||
46 | |||
47 | /** |
||
48 | * Item constructor. |
||
49 | * |
||
50 | * @param AppConfig $appConfig |
||
51 | * @param ActivityManager $activityManager |
||
52 | * @param ItemMapper $itemMapper |
||
53 | * @param ILogger $logger |
||
54 | * @param IRootFolder $rootFolder |
||
55 | * @param File $file |
||
56 | */ |
||
57 | public function __construct(AppConfig $appConfig, |
||
58 | ActivityManager $activityManager, |
||
59 | ItemMapper $itemMapper, |
||
60 | ILogger $logger, |
||
61 | IRootFolder $rootFolder, |
||
62 | File $file) { |
||
63 | $this->config = $appConfig; |
||
64 | $this->activityManager = $activityManager; |
||
65 | $this->itemMapper = $itemMapper; |
||
66 | $this->logger = $logger; |
||
67 | $this->rootFolder = $rootFolder; |
||
68 | $this->file = $file; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Reads a file portion by portion until the very end |
||
73 | * @return string|boolean |
||
74 | */ |
||
75 | public function fread() { |
||
89 | |||
90 | /** |
||
91 | * Action to take if this item is infected |
||
92 | */ |
||
93 | public function processInfected(Status $status) { |
||
94 | $infectedAction = $this->config->getAvInfectedAction(); |
||
95 | |||
96 | $shouldDelete = $infectedAction === 'delete'; |
||
97 | |||
98 | $message = $shouldDelete ? Provider::MESSAGE_FILE_DELETED : ''; |
||
99 | |||
100 | $userFolder = $this->rootFolder->getUserFolder($this->file->getOwner()->getUID()); |
||
101 | $path = $userFolder->getRelativePath($this->file->getPath()); |
||
102 | |||
103 | $activity = $this->activityManager->generateEvent(); |
||
104 | $activity->setApp(Application::APP_NAME) |
||
105 | ->setSubject(Provider::SUBJECT_VIRUS_DETECTED_SCAN, [$status->getDetails()]) |
||
106 | ->setMessage($message) |
||
107 | ->setObject('file', $this->file->getId(), $path) |
||
108 | ->setAffectedUser($this->file->getOwner()->getUID()) |
||
109 | ->setType(Provider::TYPE_VIRUS_DETECTED); |
||
110 | $this->activityManager->publish($activity); |
||
111 | |||
112 | if ($shouldDelete) { |
||
113 | $this->logError('Infected file deleted. ' . $status->getDetails()); |
||
114 | $this->deleteFile(); |
||
115 | } else { |
||
116 | $this->logError('File is infected. ' . $status->getDetails()); |
||
117 | } |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Action to take if this item status is unclear |
||
122 | * @param Status $status |
||
123 | */ |
||
124 | public function processUnchecked(Status $status) { |
||
128 | |||
129 | /** |
||
130 | * Action to take if this item status is not infected |
||
131 | */ |
||
132 | public function processClean() { |
||
149 | |||
150 | /** |
||
151 | * Check if the end of file is reached |
||
152 | * @return boolean |
||
153 | */ |
||
154 | private function feof() { |
||
163 | |||
164 | /** |
||
165 | * Opens a file for reading |
||
166 | * @throws \RuntimeException |
||
167 | */ |
||
168 | private function getFileHandle() { |
||
178 | |||
179 | /** |
||
180 | * Delete infected file |
||
181 | */ |
||
182 | private function deleteFile() { |
||
196 | |||
197 | private function generateExtraInfo() { |
||
212 | |||
213 | /** |
||
214 | * @param string $message |
||
215 | */ |
||
216 | public function logDebug($message) { |
||
219 | |||
220 | /** |
||
221 | * @param string $message |
||
222 | */ |
||
223 | public function logError($message) { |
||
226 | } |
||
227 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.