Verdict-as-a-Service
Example: Nextcloud Plugin
This example demonstrates how to utilize Verdict-as-a-Service to protect a Nextcloud installation against malware. It is meant to scan the files uploaded to the Nextcloud installation.
Simple implementation
The main lines of code utilizing Verdict-as-a-Service in this example are the following.
$this->vaas->Connect($this->authenticator->getToken());
$verdict = $this->vaas->ForFile($filePath);
switch ($verdict->Verdict->value) {
case TagService::CLEAN:
$this->tagService->setTag($fileId, TagService::CLEAN);
break;
case TagService::MALICIOUS:
$this->tagService->setTag($fileId, TagService::MALICIOUS);
try {
$this->fileService->setMaliciousPrefixIfActivated($fileId);
$this->fileService->moveFileToQuarantineFolderIfDefined($fileId);
} catch (Exception) {
}
break;
default:
$this->tagService->setTag($fileId, TagService::UNSCANNED);
break;
}
Automatic file scanning
We implemented an automatic file scan, that scans all files that are already uploaded to the Nextcloud instance. This scan option can also be configured to only scan new files for malware.
Found items will get moved into the quarantine folder and tagged with the "Malicious"-Tag.
How to get the plugin?
The plugin is currently not published and therefore not available in the Nextcloud Apps directory. You can get in contact with us and have a chat about your use case. Have a look at the contact page for that.