Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/undo-ransomware/ransomware_detection.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias <ilovemilk@wusa.io>2020-03-29 18:12:41 +0300
committerMatthias <ilovemilk@wusa.io>2020-03-29 18:12:41 +0300
commit892cf6bd9200e36aa89c2f3e4333d2601f5da268 (patch)
tree50e0ee35006a4c15c8cf83478a3b930a54a01313
parentf1dcc36d1a7d6d6e4ac1f7cc57818c877357d32c (diff)
fix dependency injecting the monitor
-rw-r--r--lib/Events/FilesEvents.php19
-rw-r--r--lib/Monitor.php9
2 files changed, 19 insertions, 9 deletions
diff --git a/lib/Events/FilesEvents.php b/lib/Events/FilesEvents.php
index b1ba0c1..a996e61 100644
--- a/lib/Events/FilesEvents.php
+++ b/lib/Events/FilesEvents.php
@@ -56,7 +56,7 @@ class FilesEvents {
*/
public function __construct(
ILogger $logger,
- $monitor,
+ Monitor $monitor,
$userId
) {
@@ -72,8 +72,8 @@ class FilesEvents {
* @throws NotFoundException
*/
public function onFileUpdate(array $params) {
+ $this->logger->error("Updating ".$params['path'], ['app' => Application::APP_ID]);
$this->analyze([$params['path']], Monitor::WRITE);
- $this->logger->error("Updating ".$params['path'], ['app' => Application::APP_ID]);
}
@@ -89,23 +89,28 @@ class FilesEvents {
}
public function onFileCreate(array $params) {
- $this->logger->error("Creating ".$params['path'], ['app' => Application::APP_ID]);
+ $this->logger->error("Creating ".$params['path'], ['app' => Application::APP_ID]);
+ $this->analyze([$params['path']], Monitor::CREATE);
}
public function onFileWrite(array $params) {
- $this->logger->error("Writing ".$params['path'], ['app' => Application::APP_ID]);
+ $this->logger->error("Writing ".$params['path'], ['app' => Application::APP_ID]);
+ $this->analyze([$params['path']], Monitor::WRITE);
}
public function onFileDelete(array $params) {
- $this->logger->error("Deleting ".$params['path'], ['app' => Application::APP_ID]);
+ $this->logger->error("Deleting ".$params['path'], ['app' => Application::APP_ID]);
+ $this->analyze([$params['path']], Monitor::DELETE);
}
public function onFileCopy(array $params) {
- $this->logger->error("Copying ".$params['path'], ['app' => Application::APP_ID]);
+ $this->logger->error("Copying ".$params['oldpath']." to ".$params['newpath'], ['app' => Application::APP_ID]);
+ $this->analyze([$params['oldpath'], $params['newpath']], Monitor::RENAME);
}
public function onFileTouch(array $params) {
- $this->logger->error("Touching ".$params['path'], ['app' => Application::APP_ID]);
+ $this->logger->error("Touching ".$params['path'], ['app' => Application::APP_ID]);
+ $this->analyze([$params['path']], Monitor::WRITE);
}
/**
diff --git a/lib/Monitor.php b/lib/Monitor.php
index 955d854..e77ba09 100644
--- a/lib/Monitor.php
+++ b/lib/Monitor.php
@@ -136,7 +136,8 @@ class Monitor
public function analyze($paths, $mode)
{
$path = $paths[0];
- $storage = $this->rootFolder->get(dirname($path))->getStorage();
+
+ $storage = $this->rootFolder->getUserFolder($this->userId)->get(dirname($path))->getStorage();
if ($this->userId === null || $this->nestingLevel !== 0 || !$this->isUploadedFile($storage, $path) || $this->isCreatingSkeletonFiles()) {
// check only cloud files and no system files
return;
@@ -353,7 +354,11 @@ class Monitor
$fullPath = $path;
if (property_exists($storage, 'mountPoint')) {
/* @var StorageWrapper $storage */
- $fullPath = $storage->mountPoint.$path;
+ try {
+ $fullPath = $storage->mountPoint.$path;
+ } catch (\Exception $ex) {
+ return false;
+ }
}
// ignore transfer files