Skip to content

Commit

Permalink
A new exception to exclude from logging
Browse files Browse the repository at this point in the history
The already logs when the file is detected
with virus. So we don't have to log it as
an exception in the server. Hence added a
new exception.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
  • Loading branch information
sharidas committed Mar 23, 2018
1 parent d0f8dc3 commit 8a23688
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ More information is available in the Anti-Virus documentation.
<use-migrations>true</use-migrations>
<namespace>Files_Antivirus</namespace>
<dependencies>
<owncloud min-version="10.0.3" max-version="10.0" />
<owncloud min-version="10.0.3" max-version="10.1" />
</dependencies>
<ocsid>157439</ocsid>
<settings>
Expand Down
7 changes: 4 additions & 3 deletions lib/AvirWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCA\Files_Antivirus\Scanner\AbstractScanner;
use OCA\Files_Antivirus\Scanner\InitException;
use OCP\App;
use OCP\Files\ExcludeForbiddenException;
use OCP\IL10N;
use OCP\ILogger;
use OCP\Files\InvalidContentException;
Expand Down Expand Up @@ -138,7 +139,7 @@ function () use ($scanner, $path) {
* @param AbstractScanner $scanner
* @param string $path
* @param bool $shouldDelete
* @throws InvalidContentException
* @throws ExcludeForbiddenException
*/
private function onScanComplete($scanner, $path, $shouldDelete){
$status = $scanner->completeAsyncScan();
Expand Down Expand Up @@ -178,11 +179,11 @@ private function onScanComplete($scanner, $path, $shouldDelete){
}
}

throw new InvalidContentException(
throw new ExcludeForbiddenException(
$this->l10n->t(
'Virus %s is detected in the file. Upload cannot be completed.',
$status->getDetails()
)
), true
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/AvirWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function setUp() {
}

/**
* @expectedException \OCP\Files\InvalidContentException
* @expectedException \OCP\Files\ExcludeForbiddenException
*/
public function testInfectedFwrite(){
$wrapper = $this->getWrapper();
Expand All @@ -67,7 +67,7 @@ public function testInfectedFwrite(){
}

/**
* @expectedException \OCP\Files\InvalidContentException
* @expectedException \OCP\Files\ExcludeForbiddenException
*/
public function testBigInfectedFwrite(){
$wrapper = $this->getWrapper();
Expand Down

0 comments on commit 8a23688

Please sign in to comment.