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-09-20 14:14:12 +0300
committerMatthias <ilovemilk@wusa.io>2020-09-20 14:14:12 +0300
commitbee8d9351abd3a75a56ce45e98a51511e874ab83 (patch)
tree9be6a181721d08bd5ed6b2f0b55e952c8a45a498
parent95575d7688e50dfaddc34f9353f87556d61b82e4 (diff)
fix recovery and history
-rw-r--r--lib/Controller/RecoveredFileOperationController.php27
-rw-r--r--lib/Service/DetectionService.php4
-rw-r--r--package-lock.json122
-rw-r--r--package.json1
-rw-r--r--src/components/ProtectionStatus.vue1
-rw-r--r--src/views/History.vue10
-rw-r--r--src/views/Recover.vue4
7 files changed, 27 insertions, 142 deletions
diff --git a/lib/Controller/RecoveredFileOperationController.php b/lib/Controller/RecoveredFileOperationController.php
index 95a7cf1..e17d3c3 100644
--- a/lib/Controller/RecoveredFileOperationController.php
+++ b/lib/Controller/RecoveredFileOperationController.php
@@ -152,7 +152,7 @@ class RecoveredFileOperationController extends Controller
try {
$file = $this->service->find($id);
switch ($file->getCommand()) {
- case Monitor::WRITE:
+ case Monitor::DELETE:
// Recover new created files by deleting them
$filePath = $file->getPath().'/'.$file->getOriginalName();
if ($this->deleteFromStorage($filePath)) {
@@ -165,7 +165,7 @@ class RecoveredFileOperationController extends Controller
$error = true;
}
break;
- case Monitor::DELETE:
+ case Monitor::WRITE:
// Recover deleted files by restoring them from the trashbin
// It's not necessary to use the real path
$dir = '/';
@@ -192,16 +192,23 @@ class RecoveredFileOperationController extends Controller
array_push($filesRecovered, $id);
break;
case Monitor::CREATE:
- // Recover new created files/folders
- $filePath = $file->getPath().'/'.$file->getOriginalName();
- if ($this->deleteFromStorage($filePath)) {
- $this->service->deleteById($id);
+ // Recover deleted files by restoring them from the trashbin
+ // It's not necessary to use the real path
+ $dir = '/';
+ $candidate = $this->findCandidateToRestore($dir, $file->getOriginalName());
+ if ($candidate !== null) {
+ $path = $dir.'/'.$candidate['name'].'.d'.$candidate['mtime'];
+ if (Trashbin::restore($path, $candidate['name'], $candidate['mtime']) !== false) {
+ $this->service->deleteById($id);
- $deleted++;
- array_push($filesRecovered, $id);
+ $recovered++;
+ array_push($filesRecovered, $id);
+ }
+ // File does not exist
+ $badRequest = false;
} else {
- // File cannot be deleted
- $error = true;
+ // No candidate found
+ $badRequest = false;
}
break;
default:
diff --git a/lib/Service/DetectionService.php b/lib/Service/DetectionService.php
index 125761b..1675f8a 100644
--- a/lib/Service/DetectionService.php
+++ b/lib/Service/DetectionService.php
@@ -100,7 +100,9 @@ class DetectionService {
}
}
}
-
+ usort($detectionObjects, function ($a, $b) {
+ return $b->getId() - $a->getId();
+ });
return $detectionObjects;
}
diff --git a/package-lock.json b/package-lock.json
index 8eba1cf..49946b7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1011,24 +1011,11 @@
"@types/yargs": "^12.0.9"
}
},
- "@mdi/font": {
- "version": "5.6.55",
- "resolved": "https://registry.npmjs.org/@mdi/font/-/font-5.6.55.tgz",
- "integrity": "sha512-6wWrpTXiv2wBtoCL+EJ9Xxfy6Tv6Q1KxmrX54/M23tBNmdGmh417y1tn327oXQxO1nq7BiHGAKkWQZ/GQPLTCA=="
- },
"@polymer/font-roboto": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@polymer/font-roboto/-/font-roboto-3.0.2.tgz",
"integrity": "sha512-tx5TauYSmzsIvmSqepUPDYbs4/Ejz2XbZ1IkD7JEGqkdNUJlh+9KU85G56Tfdk/xjEZ8zorFfN09OSwiMrIQWA=="
},
- "@polymer/iron-a11y-announcer": {
- "version": "3.0.2",
- "resolved": "https://registry.npmjs.org/@polymer/iron-a11y-announcer/-/iron-a11y-announcer-3.0.2.tgz",
- "integrity": "sha512-LqnMF39mXyxSSRbTHRzGbcJS8nU0NVTo2raBOgOlpxw5yfGJUVcwaTJ/qy5NtWCZLRfa4suycf0oAkuUjHTXHQ==",
- "requires": {
- "@polymer/polymer": "^3.0.0"
- }
- },
"@polymer/iron-a11y-keys-behavior": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@polymer/iron-a11y-keys-behavior/-/iron-a11y-keys-behavior-3.0.1.tgz",
@@ -1135,14 +1122,6 @@
"@polymer/polymer": "^3.0.0"
}
},
- "@polymer/iron-scroll-target-behavior": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/@polymer/iron-scroll-target-behavior/-/iron-scroll-target-behavior-3.0.1.tgz",
- "integrity": "sha512-xg1WanG25BIkQE8rhuReqY9zx1K5M7F+YAIYpswEp5eyDIaZ1Y3vUmVeQ3KG+hiSugzI1M752azXN7kvyhOBcQ==",
- "requires": {
- "@polymer/polymer": "^3.0.0"
- }
- },
"@polymer/iron-selector": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@polymer/iron-selector/-/iron-selector-3.0.1.tgz",
@@ -1329,107 +1308,6 @@
"integrity": "sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw==",
"dev": true
},
- "@vaadin/vaadin-checkbox": {
- "version": "2.2.9",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-checkbox/-/vaadin-checkbox-2.2.9.tgz",
- "integrity": "sha512-SUXgc7nbs/5zqw8tchLxZLPd0bwyjIXPU3K6hUj4CT9dWhJmIbgDpTzfuDJ8JOyPZOG+pxBvyWv4h3gicRWLow==",
- "requires": {
- "@polymer/polymer": "^3.0.0",
- "@vaadin/vaadin-control-state-mixin": "^2.1.1",
- "@vaadin/vaadin-element-mixin": "^2.0.0",
- "@vaadin/vaadin-lumo-styles": "^1.2.0",
- "@vaadin/vaadin-material-styles": "^1.2.0",
- "@vaadin/vaadin-themable-mixin": "^1.2.1"
- }
- },
- "@vaadin/vaadin-control-state-mixin": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-control-state-mixin/-/vaadin-control-state-mixin-2.1.3.tgz",
- "integrity": "sha512-EtLfMN9i/gwToAEuW6E1OA2Q2i/4a+Il6tKkqE/0i7bgu3Xr1IITMcagQn9QSsp1Xkpr/nLtWWKRq7yZZkbHVg==",
- "requires": {
- "@polymer/polymer": "^3.0.0"
- }
- },
- "@vaadin/vaadin-development-mode-detector": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-development-mode-detector/-/vaadin-development-mode-detector-2.0.2.tgz",
- "integrity": "sha512-B6P8sppzubOkcoO0uKgybEWQAsBkRPCL1CnDLgdelGZrRqmUBwLi9dYIG1AJY5i9i+hqa8Sn/O0B/Be0T39k7w=="
- },
- "@vaadin/vaadin-element-mixin": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-element-mixin/-/vaadin-element-mixin-2.1.3.tgz",
- "integrity": "sha512-tCEdrS5JMIl9ZsyjnV28XI2AFLC35RUWRF6XPrvm/MpKAxWLk1MlYrkwR26avOuSqvNwCBO56NIDN2k1yYC4eA==",
- "requires": {
- "@polymer/polymer": "^3.0.0",
- "@vaadin/vaadin-development-mode-detector": "^2.0.0",
- "@vaadin/vaadin-usage-statistics": "^2.0.2"
- }
- },
- "@vaadin/vaadin-grid": {
- "version": "5.4.3",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-grid/-/vaadin-grid-5.4.3.tgz",
- "integrity": "sha512-KQSRVmNKK35FtZLHVDhFUzUyLc4kuV4Qm3ZxdjEPCkWr68p4vxORB+SnmLvN8vBR8MnKJHgOyCCOGVGB96a10w==",
- "requires": {
- "@polymer/iron-a11y-announcer": "^3.0.0",
- "@polymer/iron-a11y-keys-behavior": "^3.0.0",
- "@polymer/iron-resizable-behavior": "^3.0.0",
- "@polymer/iron-scroll-target-behavior": "^3.0.0",
- "@polymer/polymer": "^3.0.0",
- "@vaadin/vaadin-checkbox": "^2.2.1",
- "@vaadin/vaadin-element-mixin": "^2.1.1",
- "@vaadin/vaadin-lumo-styles": "^1.1.1",
- "@vaadin/vaadin-material-styles": "^1.1.1",
- "@vaadin/vaadin-text-field": "^2.1.1",
- "@vaadin/vaadin-themable-mixin": "^1.2.1"
- }
- },
- "@vaadin/vaadin-lumo-styles": {
- "version": "1.5.0",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-lumo-styles/-/vaadin-lumo-styles-1.5.0.tgz",
- "integrity": "sha512-9e9n7rH5IlzsAhRWvBt6C8roXbdNILKyKMJPwbN9I6zsPwzFhG5y2y5IY59Q5Ijj8aXvHuLV+Icjogc+2KU5fg==",
- "requires": {
- "@polymer/iron-icon": "^3.0.0",
- "@polymer/iron-iconset-svg": "^3.0.0",
- "@polymer/polymer": "^3.0.0"
- }
- },
- "@vaadin/vaadin-material-styles": {
- "version": "1.2.3",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-material-styles/-/vaadin-material-styles-1.2.3.tgz",
- "integrity": "sha512-hWtnfNPANPU3UJmyIXuu2pH8R60LtnUzTZ0o2lupvxyc5IR0qFZMnB1m0xQBdBTje44xxCRaHeJATrwpzsOeMQ==",
- "requires": {
- "@polymer/polymer": "^3.0.0"
- }
- },
- "@vaadin/vaadin-text-field": {
- "version": "2.4.4",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-text-field/-/vaadin-text-field-2.4.4.tgz",
- "integrity": "sha512-w1CjkZh0P9sR8L5m4YMQgmg7hImp/YfWv3C8JIn/H+fK8QTmKIwhBvysO/TkZa1TL5T2PTY5ZgFicG4M52rRHQ==",
- "requires": {
- "@polymer/polymer": "^3.0.0",
- "@vaadin/vaadin-control-state-mixin": "^2.1.1",
- "@vaadin/vaadin-element-mixin": "^2.0.0",
- "@vaadin/vaadin-lumo-styles": "^1.2.0",
- "@vaadin/vaadin-material-styles": "^1.2.0",
- "@vaadin/vaadin-themable-mixin": "^1.2.1"
- }
- },
- "@vaadin/vaadin-themable-mixin": {
- "version": "1.4.4",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-themable-mixin/-/vaadin-themable-mixin-1.4.4.tgz",
- "integrity": "sha512-S/zN0DvSQ3cy1PdH0Dfa2yQirIFQKWCC3o0YdBzrKVCGvi5QW8+IqBTDFKnIaOfWjYoHsw2eunWcg9pu2jlI1Q==",
- "requires": {
- "@polymer/polymer": "^3.0.0"
- }
- },
- "@vaadin/vaadin-usage-statistics": {
- "version": "2.0.4",
- "resolved": "https://registry.npmjs.org/@vaadin/vaadin-usage-statistics/-/vaadin-usage-statistics-2.0.4.tgz",
- "integrity": "sha512-W954k2x0cy7YSNgvm6g3DukjPUCf6z2V0BsMMPz2masVP34MCi8p9JUvf8FsxABx34U6TCMouxCnNXQaFxX8Og==",
- "requires": {
- "@vaadin/vaadin-development-mode-detector": "^2.0.0"
- }
- },
"@vue/component-compiler-utils": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@vue/component-compiler-utils/-/component-compiler-utils-2.6.0.tgz",
diff --git a/package.json b/package.json
index df1c685..4f7b9b9 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,6 @@
"@polymer/paper-button": "^3.0.1",
"@polymer/paper-card": "^3.0.1",
"@polymer/paper-spinner": "^3.0.2",
- "@vaadin/vaadin-grid": "^5.4.3",
"core-js": "^3.0.1",
"moment": "^2.24.0",
"nextcloud-axios": "^0.2.0",
diff --git a/src/components/ProtectionStatus.vue b/src/components/ProtectionStatus.vue
index 79258e7..b2524ca 100644
--- a/src/components/ProtectionStatus.vue
+++ b/src/components/ProtectionStatus.vue
@@ -88,6 +88,7 @@ export default {
.recover-button {
display: flex;
border: 1px solid #fff;
+ padding: 0.7em 0.57em;
}
.recover-button:hover {
diff --git a/src/views/History.vue b/src/views/History.vue
index 8603567..635ec48 100644
--- a/src/views/History.vue
+++ b/src/views/History.vue
@@ -119,7 +119,7 @@ export default {
notificationText = deleted + " files deleted, " + recovered + " files recovered from backup."
}
if (recovered > 0 && deleted == 0) {
- notificationText = deleted + " files recovered from backup."
+ notificationText = recovered + " files recovered from backup."
}
if (deleted > 0 && recovered == 0) {
notificationText = deleted + " files deleted."
@@ -141,12 +141,10 @@ export default {
.catch( error => { console.error(error); });
},
onRecover() {
- console.log(this.selected);
- },
- itemsToRecover(e) {
var itemsToRecover = [];
- for (var i = 0; i < e.length; i++) {
- itemsToRecover.push(e[i].id);
+ var items = this.selected
+ for (var i = 0; i < items.length; i++) {
+ itemsToRecover.push(items[i]['id']);
}
this.recover(itemsToRecover);
},
diff --git a/src/views/Recover.vue b/src/views/Recover.vue
index 776a6eb..a00b5d9 100644
--- a/src/views/Recover.vue
+++ b/src/views/Recover.vue
@@ -119,7 +119,7 @@ export default {
notificationText = deleted + " files deleted, " + recovered + " files recovered from backup."
}
if (recovered > 0 && deleted == 0) {
- notificationText = deleted + " files recovered from backup."
+ notificationText = recovered + " files recovered from backup."
}
if (deleted > 0 && recovered == 0) {
notificationText = deleted + " files deleted."
@@ -157,7 +157,7 @@ export default {
onRecover(id) {
var itemsToRecover = [];
const detectionTable = this.$refs['detection' + id];
- var items = detectionTable[0].$refs.grid.items;
+ var items = detectionTable[0].items;
for (var i = 0; i < items.length; i++) {
itemsToRecover.push(items[i].id);
}