Skip to content

Commit 22c4aa1

Browse files
Remove unused settings
- Malicious file notifications summary - Scan only new files
1 parent f029274 commit 22c4aa1

File tree

8 files changed

+1
-251
lines changed

8 files changed

+1
-251
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The app offers a variety of settings to customize the behavior of the antivirus.
5959

6060
- **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'.
6161
- **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.
62-
- **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.
62+
- **Do not scan this:** Equivalent to a blocklist. If there are values separated by commas, e.g. "Documents, .exe, Scan", these are not scanned.
6363
- **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.
6464
- **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.
6565
- **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.

appinfo/routes.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
['name' => 'settings#setadvancedconfig', 'url' => '/setadvancedconfig', 'verb' => 'POST'],
1313
['name' => 'settings#setAutoScan', 'url' => '/setAutoScan', 'verb' => 'POST'],
1414
['name' => 'settings#getAutoScan', 'url' => '/getAutoScan', 'verb' => 'GET'],
15-
['name' => 'settings#setScanOnlyNewFiles', 'url' => '/setScanOnlyNewFiles', 'verb' => 'POST'],
16-
['name' => 'settings#getScanOnlyNewFiles', 'url' => '/getScanOnlyNewFiles', 'verb' => 'GET'],
1715
['name' => 'settings#setPrefixMalicious', 'url' => '/setPrefixMalicious', 'verb' => 'POST'],
1816
['name' => 'settings#getPrefixMalicious', 'url' => '/getPrefixMalicious', 'verb' => 'GET'],
1917
['name' => 'settings#getAuthMethod', 'url' => '/getAuthMethod', 'verb' => 'GET'],
@@ -23,10 +21,6 @@
2321
['name' => 'settings#getCounters', 'url' => '/getCounters', 'verb' => 'GET'],
2422
['name' => 'settings#getSendMailOnVirusUpload', 'url' => '/getSendMailOnVirusUpload', 'verb' => 'GET'],
2523
['name' => 'settings#setSendMailOnVirusUpload', 'url' => '/setSendMailOnVirusUpload', 'verb' => 'POST'],
26-
['name' => 'settings#getSendMailSummaryOfMaliciousFiles', 'url'
27-
=> '/getSendMailSummaryOfMaliciousFiles', 'verb' => 'GET'],
28-
['name' => 'settings#setSendMailSummaryOfMaliciousFiles', 'url'
29-
=> '/setSendMailSummaryOfMaliciousFiles', 'verb' => 'POST'],
3024
['name' => 'settings#testsettings', 'url' => '/testsettings', 'verb' => 'POST'],
3125
['name' => 'settings#getCache', 'url' => '/getCache', 'verb' => 'GET'],
3226
['name' => 'settings#getHashlookup', 'url' => '/getHashlookup', 'verb' => 'GET']

lib/BackgroundJobs/NotifyAdminJob.php

Lines changed: 0 additions & 106 deletions
This file was deleted.

lib/Controller/SettingsController.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ public function getAutoScan(): JSONResponse {
100100
return new JSONResponse(['status' => $this->config->getValueBool($this->appName, 'autoScanFiles')]);
101101
}
102102

103-
public function setScanOnlyNewFiles(bool $scanOnlyNewFiles): JSONResponse {
104-
$this->config->setValueBool($this->appName, 'scanOnlyNewFiles', $scanOnlyNewFiles);
105-
return new JSONResponse(['status' => 'success']);
106-
}
107-
108-
public function getScanOnlyNewFiles(): JSONResponse {
109-
return new JSONResponse(['status' => $this->config->getValueBool($this->appName, 'scanOnlyNewFiles')]);
110-
}
111-
112103
public function setPrefixMalicious(bool $prefixMalicious): JSONResponse {
113104
$this->config->setValueBool($this->appName, 'prefixMalicious', $prefixMalicious);
114105
return new JSONResponse(['status' => 'success']);
@@ -163,15 +154,6 @@ public function setSendMailOnVirusUpload(bool $sendMailOnVirusUpload): JSONRespo
163154
return new JSONResponse(['status' => 'success']);
164155
}
165156

166-
public function getSendMailSummaryOfMaliciousFiles(): JSONResponse {
167-
return new JSONResponse(['status' => $this->config->getValueBool($this->appName, 'notifyAdminEnabled')]);
168-
}
169-
170-
public function setSendMailSummaryOfMaliciousFiles(bool $sendMailSummaryOfMaliciousFiles): JSONResponse {
171-
$this->config->setValueBool($this->appName, 'notifyAdminEnabled', $sendMailSummaryOfMaliciousFiles);
172-
return new JSONResponse(['status' => 'success']);
173-
}
174-
175157
public function testSettings(string $tokenEndpoint, string $vaasUrl): JSONResponse {
176158
try {
177159
$authenticator = $this->verdictService->getAuthenticator($this->verdictService->authMethod, $tokenEndpoint);

lib/Service/MailService.php

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
use Coduo\PHPHumanizer\NumberHumanizer;
1010
use Exception;
1111
use OCA\GDataVaas\AppInfo\Application;
12-
use OCP\Files\File;
13-
use OCP\Files\InvalidPathException;
14-
use OCP\Files\NotFoundException;
1512
use OCP\IAppConfig;
1613
use OCP\Mail\IMailer;
1714
use Psr\Log\LoggerInterface;
@@ -76,100 +73,4 @@ private function getNotifyMails(): array {
7673
}
7774
return explode(',', $notifyMails);
7875
}
79-
80-
/**
81-
* @param array $maliciousFiles
82-
* @return void
83-
* @throws Exception
84-
*/
85-
public function notifyWeeklySummary(array $maliciousFiles): void {
86-
$msg = $this->mailer->createMessage();
87-
$msg->setSubject('Summary: Malicious files in your Nextcloud instance');
88-
$msg->setHtmlBody($this->createSummaryHtml($maliciousFiles));
89-
$msg->setPlainBody($this->createSummaryPlain($maliciousFiles));
90-
$receiver = $this->getNotifyMails();
91-
$msg->setTo($receiver);
92-
93-
$this->mailer->send($msg);
94-
$this->logger->debug('Mail sent to ' . implode(', ', $receiver));
95-
}
96-
97-
/**
98-
* @param array $maliciousFiles
99-
* @return string
100-
*/
101-
private function createSummaryHtml(array $maliciousFiles): string {
102-
$htmlMessage = '<p>This is your weekly summary of the malicious files found in your Nextcloud instance:</p>';
103-
$htmlMessage .= '<p>Found ' . count($maliciousFiles) . ' malicious files:</p>';
104-
$htmlMessage .= '<table>';
105-
$htmlMessage .= '<tr>';
106-
$htmlMessage .= '<td> <strong>Name</strong> </td>';
107-
$htmlMessage .= '<td> <strong>Path</strong> </td>';
108-
$htmlMessage .= '<td> <strong>Owner</strong> </td>';
109-
$htmlMessage .= '<td> <strong>Upload time</strong> </td>';
110-
$htmlMessage .= '<td> <strong>Mimetype</strong> </td>';
111-
$htmlMessage .= '<td> <strong>Size</strong> </td>';
112-
$htmlMessage .= '</tr>';
113-
foreach ($maliciousFiles as $file) {
114-
if ($file instanceof File) {
115-
try {
116-
$size = $file->getSize();
117-
} catch (InvalidPathException|NotFoundException) {
118-
$size = 0;
119-
}
120-
$uploadTime = $file->getCreationTime() ?: $file->getUploadTime();
121-
if ($uploadTime === 0) {
122-
$uploadTime = 'Unknown';
123-
}
124-
$htmlMessage .= '<tr>';
125-
$htmlMessage .= '<td>' . $file->getName() . '</td>';
126-
$htmlMessage .= '<td>' . $file->getInternalPath() . '</td>';
127-
$htmlMessage .= '<td>' . $file->getOwner()->getDisplayName() . '</td>';
128-
$htmlMessage .= '<td>' . $uploadTime . '</td>';
129-
$htmlMessage .= '<td>' . $file->getMimeType() . '</td>';
130-
if ($size !== 0) {
131-
$htmlMessage .= '<td>' . NumberHumanizer::binarySuffix($size, 'de') . '</td>';
132-
} else {
133-
$htmlMessage .= '<td>Unknown</td>';
134-
}
135-
$htmlMessage .= '</tr>';
136-
}
137-
}
138-
$htmlMessage .= '</table>';
139-
return $htmlMessage;
140-
}
141-
142-
/**
143-
* @param array $maliciousFiles
144-
* @return string
145-
*/
146-
private function createSummaryPlain(array $maliciousFiles): string {
147-
$plainMessage = "This is your weekly summary of the malicious files found in your Nextcloud instance:\n";
148-
$plainMessage .= 'Found ' . count($maliciousFiles) . " malicious files:\n";
149-
foreach ($maliciousFiles as $file) {
150-
if ($file instanceof File) {
151-
$plainMessage .= "\n";
152-
try {
153-
$size = $file->getSize();
154-
} catch (InvalidPathException|NotFoundException) {
155-
$size = 0;
156-
}
157-
$uploadTime = $file->getCreationTime() ?: $file->getUploadTime();
158-
if ($uploadTime === 0) {
159-
$uploadTime = 'Unknown';
160-
}
161-
$plainMessage .= 'Name: ' . $file->getName() . "\n";
162-
$plainMessage .= 'Path: ' . $file->getPath() . "\n";
163-
$plainMessage .= 'Owner: ' . $file->getOwner()->getDisplayName() . "\n";
164-
$plainMessage .= 'Time: ' . $uploadTime . "\n";
165-
$plainMessage .= 'Mimetype: ' . $file->getMimeType() . "\n";
166-
if ($size !== 0) {
167-
$plainMessage .= 'Size: ' . NumberHumanizer::binarySuffix($size, 'de') . "\n";
168-
} else {
169-
$plainMessage .= "Size: Unknown\n";
170-
}
171-
}
172-
}
173-
return $plainMessage;
174-
}
17576
}

lib/Settings/VaasAdmin.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public function getForm(): TemplateResponse {
4545
'quarantineFolder'
4646
=> $this->config->getValueString(Application::APP_ID, 'quarantineFolder', 'Quarantine'),
4747
'autoScanFiles' => $this->config->getValueBool(Application::APP_ID, 'autoScanFiles'),
48-
'scanOnlyNewFiles'
49-
=> $this->config->getValueBool(Application::APP_ID, 'scanOnlyNewFiles', true),
5048
'prefixMalicious'
5149
=> $this->config->getValueBool(Application::APP_ID, 'prefixMalicious', true),
5250
'disableUnscannedTag' => $this->config->getValueBool(Application::APP_ID, 'disableUnscannedTag'),
@@ -55,7 +53,6 @@ public function getForm(): TemplateResponse {
5553
'notifyMail' => $this->config->getValueString(Application::APP_ID, 'notifyMails'),
5654
'sendMailOnVirusUpload'
5755
=> $this->config->getValueBool(Application::APP_ID, 'sendMailOnVirusUpload'),
58-
'notifyAdminEnabled' => $this->config->getValueBool(Application::APP_ID, 'notifyAdminEnabled'),
5956
'maxScanSizeInMB'
6057
=> $this->config->getValueInt(Application::APP_ID, 'maxScanSizeInMB', 256),
6158
'timeout' => $this->config->getValueInt(Application::APP_ID, 'timeout', 300),

src/admin-settings.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ document.addEventListener('DOMContentLoaded', async () => {
4646
const disableUnscannedTag = document.querySelector('#disable_tag_unscanned');
4747
const scanCounter = document.querySelector('#scan_counter');
4848
const sendMailOnVirusUpload = document.querySelector('#send_mail_on_virus_upload');
49-
const sendMailSummaryOfMaliciousFiles =
50-
document.querySelector('#send_summary_mail_for_malicious_files');
5149

5250
hideUnneccessaryFields(authMethod.value);
5351

@@ -171,13 +169,6 @@ document.addEventListener('DOMContentLoaded', async () => {
171169
);
172170
});
173171

174-
sendMailSummaryOfMaliciousFiles.addEventListener('click', async () => {
175-
await postData(
176-
OC.generateUrl('apps/gdatavaas/setSendMailSummaryOfMaliciousFiles'),
177-
{sendMailSummaryOfMaliciousFiles: sendMailSummaryOfMaliciousFiles.checked}
178-
);
179-
});
180-
181172
// Activate or deactivate automatic file scanning
182173
const toggleAutoScan = async (enable) => {
183174
autoScanFiles.checked = enable;
@@ -199,8 +190,6 @@ document.addEventListener('DOMContentLoaded', async () => {
199190
prefixMalicious.checked = (await getData(OC.generateUrl('apps/gdatavaas/getPrefixMalicious'))).status;
200191
disableUnscannedTag.checked = (await getData(OC.generateUrl('apps/gdatavaas/getDisableUnscannedTag'))).status;
201192
sendMailOnVirusUpload.checked = (await getData(OC.generateUrl('apps/gdatavaas/getSendMailOnVirusUpload'))).status;
202-
sendMailSummaryOfMaliciousFiles.checked =
203-
(await getData(OC.generateUrl('apps/gdatavaas/getSendMailSummaryOfMaliciousFiles'))).status;
204193

205194
let filesCounter = await getData(OC.generateUrl('apps/gdatavaas/getCounters'));
206195
if (filesCounter['status'] === 'success') {

templates/admin.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@
142142
</td>
143143
<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>
144144
</tr>
145-
<tr>
146-
<td>
147-
<input id="send_summary_mail_for_malicious_files" class="toggle-round" type="checkbox">
148-
<label for="send_summary_mail_for_malicious_files"></label>
149-
</td>
150-
<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>
151-
</tr>
152145
</table>
153146
<h3>
154147
<label><?php p($l->t('Files scanned: '));?></label>

0 commit comments

Comments
 (0)