nextcloud / files_antivirus

👾 Antivirus app for Nextcloud Files
https://apps.nextcloud.com/apps/files_antivirus
GNU Affero General Public License v3.0
81 stars 33 forks source link

unspecific message "An unknown error has occurred" on virus upload detection #212

Open level420 opened 2 years ago

level420 commented 2 years ago

Note that the antivirus files app is working as expected, besides the unspecific message. The message which I'd like to see is logged correctly in the nextcloud log file, like this:

Error: Virus Win.Test.EICAR_HDB-1 is detected in the file. Upload cannot be completed.

but it does not reach the user in the browser frontend. It is even translated correctly e.g. to german if the users language is german!

Steps to reproduce

  1. configure nextcloud with the current antivirus app via
  2. try upload an eicar virus testfile via drag and drop in the browser
  3. see that uploading is inhibited with the message "An unknown error has occured"

Expected behaviour

I'm expecting to get a message like "unable to upload file xxx because it contains a virus", of course even better also including the viruses name

Actual behaviour

There is only a unspecific "An unknown error has occured" message, leaving the user alone without knowing what went wrong.

Server configuration

Operating system: centos 7 running docker with docker-compose

Web server: apache 2.4.51

Database: mariadb 10.6 official docker image from docker hub

PHP version: 8.0.12 official nextcloud fpm docker image from docker hub

Nextcloud version: (see Nextcloud admin page) 22.2.3 official nextcloud fpm docker image from docker hub

Where did you install Nextcloud from: official nextcloud fpm docker image from docker hub image nextcloud:22-fpm

clamAV version: official clamav docker latest image from https://hub.docker.com/r/clamav/clamav version 0.104.1

List of activated apps:

Enabled:

Nextcloud configuration:

relevant part of the configuration in Security -> Antivirus for files

Mode: ClamAV Daemon (Socket)
Socket: /run/clamav/clamd.sock
Stream Length: 26214400
File size limit for periodic background scans ...: -1
When infected files are found ...: Only log

Client configuration

Browser: irrelevant

Operating system: irrelevant

Logs

Nextcloud log (data/owncloud.log)

{"reqId":"YZTnUNxJpbDfhrut6YsDNwAAJAs","level":3,"time":"2021-11-17T11:28:16+00:00","remoteAddr":"91.16.153.169","user":"dietrich","app":"no app in context","method":"PUT","url":"/remote.php/webdav/ReaReg/eicarcom2.zip","message":"Virus Win.Test.EICAR_HDB-1 is detected in the file. Upload cannot be completed.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36","version":"22.2.3.0","exception":{"Exception":"OCP\\Files\\InvalidContentException","Message":"Virus Win.Test.EICAR_HDB-1 is detected in the file. Upload cannot be completed.","Code":0,"Trace":[{"function":"OCA\\Files_Antivirus\\{closure}","class":"OCA\\Files_Antivirus\\AvirWrapper","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/3rdparty/icewind/streams/src/CallbackWrapper.php","line":119,"function":"call_user_func","args":[{"__class__":"Closure"}]},{"function":"stream_close","class":"Icewind\\Streams\\CallbackWrapper","type":"->","args":[]},{"file":"/var/www/html/lib/private/Files/Storage/Local.php","line":575,"function":"fclose","args":[null]},{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php","line":628,"function":"writeStream","class":"OC\\Files\\Storage\\Local","type":"->","args":["files/ReaReg/eicarcom2.zip.ocTransferId398789552.part",null,null]},{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php","line":628,"function":"writeStream","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["files/ReaReg/eicarcom2.zip.ocTransferId398789552.part",null,null]},{"file":"/var/www/html/custom_apps/files_antivirus/lib/AvirWrapper.php","line":94,"function":"writeStream","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["files/ReaReg/eicarcom2.zip.ocTransferId398789552.part",null,null]},{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php","line":628,"function":"writeStream","class":"OCA\\Files_Antivirus\\AvirWrapper","type":"->","args":["files/ReaReg/eicarcom2.zip.ocTransferId398789552.part",null,null]},{"file":"/var/www/html/custom_apps/files_accesscontrol/lib/StorageWrapper.php","line":320,"function":"writeStream","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["files/ReaReg/eicarcom2.zip.ocTransferId398789552.part",null,null]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/File.php","line":206,"function":"writeStream","class":"OCA\\FilesAccessControl\\StorageWrapper","type":"->","args":["files/ReaReg/eicarcom2.zip.ocTransferId398789552.part",null]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php","line":155,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":[null]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["eicarcom2.zip",null]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["ReaReg/eicarcom2.zip",null,null]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PUT",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v1/webdav.php","line":83,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":166,"args":["/var/www/html/apps/dav/appinfo/v1/webdav.php"],"function":"require_once"}],"File":"/var/www/html/custom_apps/files_antivirus/lib/AvirWrapper.php","Line":154,"CustomMessage":"--"},"id":"6194e75ddf5ac"}