Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The app offers a variety of settings to customize the behavior of the antivirus.

- **Authentication Method:** If you have created your own account on https://vaas.gdata.de/login, select 'Resource Owner Password Flow' here. If you have received access data from your provider (Client ID and Secret), select 'Client Credentials Flow'.
- **Scan only this:** Equivalent to an allowlist. If the values here are separated by commas, e.g. "Documents, .exe, Scan", only those containing the corresponding values in the path are scanned. In this example, *.exe files and the contents of the Documents/ and Scan/ folders would be scanned.
- **Do not scan this:** Equivalent to a blocklist. If there are values separated by commas, e.g. "Documents, .exe, Scan", these are not scanned.time until all files are scanned. Recommended are values between 10 and 100.
- **Do not scan this:** Equivalent to a blocklist. If there are values separated by commas, e.g. "Documents, .exe, Scan", these are not scanned.
- **Quarantine folder:** If an existing file is found to be malicious, it is moved to this folder in the user's home directory. If the folder does not exist, it is created automatically. If you do not want to use a quarantine folder, leave this field empty.
- **Notify mails:** If an email address is entered here (or multiple comma seperated), a notification is sent to this address when a user uploads a file that is found to be malicious.
- **Maximum scan size:** Files larger than this size (in MB) are not scanned and tagged as "Won't Scan". Recommended values are between 10 and 300 MB.
Expand Down
6 changes: 0 additions & 6 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
['name' => 'settings#setadvancedconfig', 'url' => '/setadvancedconfig', 'verb' => 'POST'],
['name' => 'settings#setAutoScan', 'url' => '/setAutoScan', 'verb' => 'POST'],
['name' => 'settings#getAutoScan', 'url' => '/getAutoScan', 'verb' => 'GET'],
['name' => 'settings#setScanOnlyNewFiles', 'url' => '/setScanOnlyNewFiles', 'verb' => 'POST'],
['name' => 'settings#getScanOnlyNewFiles', 'url' => '/getScanOnlyNewFiles', 'verb' => 'GET'],
['name' => 'settings#setPrefixMalicious', 'url' => '/setPrefixMalicious', 'verb' => 'POST'],
['name' => 'settings#getPrefixMalicious', 'url' => '/getPrefixMalicious', 'verb' => 'GET'],
['name' => 'settings#getAuthMethod', 'url' => '/getAuthMethod', 'verb' => 'GET'],
Expand All @@ -23,10 +21,6 @@
['name' => 'settings#getCounters', 'url' => '/getCounters', 'verb' => 'GET'],
['name' => 'settings#getSendMailOnVirusUpload', 'url' => '/getSendMailOnVirusUpload', 'verb' => 'GET'],
['name' => 'settings#setSendMailOnVirusUpload', 'url' => '/setSendMailOnVirusUpload', 'verb' => 'POST'],
['name' => 'settings#getSendMailSummaryOfMaliciousFiles', 'url'
=> '/getSendMailSummaryOfMaliciousFiles', 'verb' => 'GET'],
['name' => 'settings#setSendMailSummaryOfMaliciousFiles', 'url'
=> '/setSendMailSummaryOfMaliciousFiles', 'verb' => 'POST'],
['name' => 'settings#testsettings', 'url' => '/testsettings', 'verb' => 'POST'],
['name' => 'settings#getCache', 'url' => '/getCache', 'verb' => 'GET'],
['name' => 'settings#getHashlookup', 'url' => '/getHashlookup', 'verb' => 'GET']
Expand Down
106 changes: 0 additions & 106 deletions lib/BackgroundJobs/NotifyAdminJob.php

This file was deleted.

18 changes: 0 additions & 18 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@ public function getAutoScan(): JSONResponse {
return new JSONResponse(['status' => $this->config->getValueBool($this->appName, 'autoScanFiles')]);
}

public function setScanOnlyNewFiles(bool $scanOnlyNewFiles): JSONResponse {
$this->config->setValueBool($this->appName, 'scanOnlyNewFiles', $scanOnlyNewFiles);
return new JSONResponse(['status' => 'success']);
}

public function getScanOnlyNewFiles(): JSONResponse {
return new JSONResponse(['status' => $this->config->getValueBool($this->appName, 'scanOnlyNewFiles')]);
}

public function setPrefixMalicious(bool $prefixMalicious): JSONResponse {
$this->config->setValueBool($this->appName, 'prefixMalicious', $prefixMalicious);
return new JSONResponse(['status' => 'success']);
Expand Down Expand Up @@ -163,15 +154,6 @@ public function setSendMailOnVirusUpload(bool $sendMailOnVirusUpload): JSONRespo
return new JSONResponse(['status' => 'success']);
}

public function getSendMailSummaryOfMaliciousFiles(): JSONResponse {
return new JSONResponse(['status' => $this->config->getValueBool($this->appName, 'notifyAdminEnabled')]);
}

public function setSendMailSummaryOfMaliciousFiles(bool $sendMailSummaryOfMaliciousFiles): JSONResponse {
$this->config->setValueBool($this->appName, 'notifyAdminEnabled', $sendMailSummaryOfMaliciousFiles);
return new JSONResponse(['status' => 'success']);
}

public function testSettings(string $tokenEndpoint, string $vaasUrl): JSONResponse {
try {
$authenticator = $this->verdictService->getAuthenticator($this->verdictService->authMethod, $tokenEndpoint);
Expand Down
99 changes: 0 additions & 99 deletions lib/Service/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use Coduo\PHPHumanizer\NumberHumanizer;
use Exception;
use OCA\GDataVaas\AppInfo\Application;
use OCP\Files\File;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\IAppConfig;
use OCP\Mail\IMailer;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -76,100 +73,4 @@ private function getNotifyMails(): array {
}
return explode(',', $notifyMails);
}

/**
* @param array $maliciousFiles
* @return void
* @throws Exception
*/
public function notifyWeeklySummary(array $maliciousFiles): void {
$msg = $this->mailer->createMessage();
$msg->setSubject('Summary: Malicious files in your Nextcloud instance');
$msg->setHtmlBody($this->createSummaryHtml($maliciousFiles));
$msg->setPlainBody($this->createSummaryPlain($maliciousFiles));
$receiver = $this->getNotifyMails();
$msg->setTo($receiver);

$this->mailer->send($msg);
$this->logger->debug('Mail sent to ' . implode(', ', $receiver));
}

/**
* @param array $maliciousFiles
* @return string
*/
private function createSummaryHtml(array $maliciousFiles): string {
$htmlMessage = '<p>This is your weekly summary of the malicious files found in your Nextcloud instance:</p>';
$htmlMessage .= '<p>Found ' . count($maliciousFiles) . ' malicious files:</p>';
$htmlMessage .= '<table>';
$htmlMessage .= '<tr>';
$htmlMessage .= '<td> <strong>Name</strong> </td>';
$htmlMessage .= '<td> <strong>Path</strong> </td>';
$htmlMessage .= '<td> <strong>Owner</strong> </td>';
$htmlMessage .= '<td> <strong>Upload time</strong> </td>';
$htmlMessage .= '<td> <strong>Mimetype</strong> </td>';
$htmlMessage .= '<td> <strong>Size</strong> </td>';
$htmlMessage .= '</tr>';
foreach ($maliciousFiles as $file) {
if ($file instanceof File) {
try {
$size = $file->getSize();
} catch (InvalidPathException|NotFoundException) {
$size = 0;
}
$uploadTime = $file->getCreationTime() ?: $file->getUploadTime();
if ($uploadTime === 0) {
$uploadTime = 'Unknown';
}
$htmlMessage .= '<tr>';
$htmlMessage .= '<td>' . $file->getName() . '</td>';
$htmlMessage .= '<td>' . $file->getInternalPath() . '</td>';
$htmlMessage .= '<td>' . $file->getOwner()->getDisplayName() . '</td>';
$htmlMessage .= '<td>' . $uploadTime . '</td>';
$htmlMessage .= '<td>' . $file->getMimeType() . '</td>';
if ($size !== 0) {
$htmlMessage .= '<td>' . NumberHumanizer::binarySuffix($size, 'de') . '</td>';
} else {
$htmlMessage .= '<td>Unknown</td>';
}
$htmlMessage .= '</tr>';
}
}
$htmlMessage .= '</table>';
return $htmlMessage;
}

/**
* @param array $maliciousFiles
* @return string
*/
private function createSummaryPlain(array $maliciousFiles): string {
$plainMessage = "This is your weekly summary of the malicious files found in your Nextcloud instance:\n";
$plainMessage .= 'Found ' . count($maliciousFiles) . " malicious files:\n";
foreach ($maliciousFiles as $file) {
if ($file instanceof File) {
$plainMessage .= "\n";
try {
$size = $file->getSize();
} catch (InvalidPathException|NotFoundException) {
$size = 0;
}
$uploadTime = $file->getCreationTime() ?: $file->getUploadTime();
if ($uploadTime === 0) {
$uploadTime = 'Unknown';
}
$plainMessage .= 'Name: ' . $file->getName() . "\n";
$plainMessage .= 'Path: ' . $file->getPath() . "\n";
$plainMessage .= 'Owner: ' . $file->getOwner()->getDisplayName() . "\n";
$plainMessage .= 'Time: ' . $uploadTime . "\n";
$plainMessage .= 'Mimetype: ' . $file->getMimeType() . "\n";
if ($size !== 0) {
$plainMessage .= 'Size: ' . NumberHumanizer::binarySuffix($size, 'de') . "\n";
} else {
$plainMessage .= "Size: Unknown\n";
}
}
}
return $plainMessage;
}
}
3 changes: 0 additions & 3 deletions lib/Settings/VaasAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function getForm(): TemplateResponse {
'quarantineFolder'
=> $this->config->getValueString(Application::APP_ID, 'quarantineFolder', 'Quarantine'),
'autoScanFiles' => $this->config->getValueBool(Application::APP_ID, 'autoScanFiles'),
'scanOnlyNewFiles'
=> $this->config->getValueBool(Application::APP_ID, 'scanOnlyNewFiles', true),
'prefixMalicious'
=> $this->config->getValueBool(Application::APP_ID, 'prefixMalicious', true),
'disableUnscannedTag' => $this->config->getValueBool(Application::APP_ID, 'disableUnscannedTag'),
Expand All @@ -55,7 +53,6 @@ public function getForm(): TemplateResponse {
'notifyMail' => $this->config->getValueString(Application::APP_ID, 'notifyMails'),
'sendMailOnVirusUpload'
=> $this->config->getValueBool(Application::APP_ID, 'sendMailOnVirusUpload'),
'notifyAdminEnabled' => $this->config->getValueBool(Application::APP_ID, 'notifyAdminEnabled'),
'maxScanSizeInMB'
=> $this->config->getValueInt(Application::APP_ID, 'maxScanSizeInMB', 256),
'timeout' => $this->config->getValueInt(Application::APP_ID, 'timeout', 300),
Expand Down
11 changes: 0 additions & 11 deletions src/admin-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ document.addEventListener('DOMContentLoaded', async () => {
const disableUnscannedTag = document.querySelector('#disable_tag_unscanned');
const scanCounter = document.querySelector('#scan_counter');
const sendMailOnVirusUpload = document.querySelector('#send_mail_on_virus_upload');
const sendMailSummaryOfMaliciousFiles =
document.querySelector('#send_summary_mail_for_malicious_files');

hideUnneccessaryFields(authMethod.value);

Expand Down Expand Up @@ -171,13 +169,6 @@ document.addEventListener('DOMContentLoaded', async () => {
);
});

sendMailSummaryOfMaliciousFiles.addEventListener('click', async () => {
await postData(
OC.generateUrl('apps/gdatavaas/setSendMailSummaryOfMaliciousFiles'),
{sendMailSummaryOfMaliciousFiles: sendMailSummaryOfMaliciousFiles.checked}
);
});

// Activate or deactivate automatic file scanning
const toggleAutoScan = async (enable) => {
autoScanFiles.checked = enable;
Expand All @@ -199,8 +190,6 @@ document.addEventListener('DOMContentLoaded', async () => {
prefixMalicious.checked = (await getData(OC.generateUrl('apps/gdatavaas/getPrefixMalicious'))).status;
disableUnscannedTag.checked = (await getData(OC.generateUrl('apps/gdatavaas/getDisableUnscannedTag'))).status;
sendMailOnVirusUpload.checked = (await getData(OC.generateUrl('apps/gdatavaas/getSendMailOnVirusUpload'))).status;
sendMailSummaryOfMaliciousFiles.checked =
(await getData(OC.generateUrl('apps/gdatavaas/getSendMailSummaryOfMaliciousFiles'))).status;

let filesCounter = await getData(OC.generateUrl('apps/gdatavaas/getCounters'));
if (filesCounter['status'] === 'success') {
Expand Down
7 changes: 0 additions & 7 deletions templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@
</td>
<td><div title="<?php p($l->t('If a user tries to upload an infected file an email is send to all \'Notify Mails\' receiver'));?>" class="visible"><label><?php p($l->t('Send mails on infected file upload'));?></label></div></td>
</tr>
<tr>
<td>
<input id="send_summary_mail_for_malicious_files" class="toggle-round" type="checkbox">
<label for="send_summary_mail_for_malicious_files"></label>
</td>
<td><div title="<?php p($l->t('Send a summary of found malicious files to all \'Notify Mails\' receiver'));?>" class="visible"><label><?php p($l->t('Send weekly mails with a summary of malicious files'));?></label></div></td>
</tr>
</table>
<h3>
<label><?php p($l->t('Files scanned: '));?></label>
Expand Down