This article documents how to set up Clam Antivirus with the Liferay platform on Windows for testing purposes. The goal is to scan documents for viruses when they are being uploaded.
Resolution
- Download ClamWin for Windows. You can update to a more recent version after installation. For other operating systems, try http://www.clamav.net/
- Run the ClamWin installer with default settings.
- Once installation completes and the database updates, copy the directory
C:\ProgramData\.clamwin\db into C:\Program Files (x86)\ClamWin\bin\
. - Update the PATH variable to include
C:\Program Files (x86)\ClamWin\bin\
. - Verify that ClamAV is functioning properly by scanning a file. Download a test eicar file and run:
clamscan --stdout --no-summary [path to test file]
. You will likely need to modify your machine's antivirus to allow the file to be downloaded.You should see this output:
C:\Users\liferay>clamscan --stdout --no-summary C:\Users\liferay\Downloads\eicar.com.txt Loading virus signature database, please wait... done C:\Users\liferay\Downloads\eicar.com.txt: Eicar-Test-Signature FOUND
- Now, configure the Liferay platform's implementation of ClamAV. Add the following properties to the portal-ext.properties file:
# Set this property to true to enable execution of antivirus check when # files are submitted into a store. Setting this value to true will prevent # any potential virus files from entering the store but will not allow for # file quarantines. # dl.store.antivirus.enabled=true # # Set the name of a class that implements # com.liferay.portlet.documentlibrary.antivirus.AntivirusScanner. The # document library server will use this to scan documents for viruses. # #dl.store.antivirus.impl=com.liferay.portlet.documentlibrary.antivirus.DummyAntivirusScannerImpl dl.store.antivirus.impl=com.liferay.portlet.documentlibrary.antivirus.ClamAntivirusScannerImpl
- Start the platform and login as the admin.
- Add a documents and media portlet to a page and upload the eicar file.
Expected Result
The documents and media portlet says Your request failed to complete and A virus was detected in the file.
The upload has been successfully blocked.