How to set up the latest Clam Antivirus with the Liferay platform on Windows. The goal is to scan documents for viruses when they are being uploaded.
Environment
- Windows 10
- Liferay 6.2
- ClamAV version 0.103.0
Resolution
- Download the latest version of ClamAV https://www.clamav.net/downloads/production/ClamAV-0.103.0.exe
-
Right-click on ClamAV-0.103.0.exe and select Run as administrator.
You may receive a warning message along the lines of “Windows protected your PC”. Select More info and then select Run anyway. -
Select I accept the agreement and click Next.
-
Click Next again. If you’ve removed a previous installation of ClamAV, you may receive the prompt “The folder .already exists.” If you do, select Yes.
-
Click Install.
-
Click Finish.
-
Need to update its path in an environment variable. For example: C:\Program Files\ClamAV
-
Press the Windows key and type PowerShell but DO NOT press Enter.
-
Right-click on Windows PowerShell at the top of the menu and select Run as administrator. Your computer may warn you Do you want to allow this app to make changes to your device? Click Yes.
-
Verify that the prompt in the PowerShell window looks like this: PS C:\WINDOWS\system32>
In the Administrator PowerShell window, enter the following to navigate to the ClamAV install directory: cd "c:\program files\clamav" -
First Time Set-UP
In the PowerShell window, perform the following tasks:
Run:
copy .\conf_examples\freshclam.conf.sample .\freshclam.conf
copy .\conf_examples\clamd.conf.sample .\clamd.conf
Run: write.exe .\freshclam.conf
WordPad will pop up. Delete the line that says “Example”. You may also wish to set additional options to enable features or alter default behaviour, such as the receive-timeout. Save the file and close WordPad.
Run: write.exe .\clamd.conf
WordPad will pop up. Delete the line that says “Example”. You may also wish to set additional options to enable features or alter default behaviour, such as enabling logging. Save the file and close WordPad. -
Download the signature database.
Continuing in the PowerShell window:
Run: .\freshclam.exe
Steps to Perform Basic Scanning
Run this to scan the files in the current directory: .\clamscan.exe.
This will scan the current directory. At the end of the scan, it will display a summary. - Add the required properties on 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
- Delete all temp folders.
- Restart the server
- Start the platform and login as the admin.
- Upload document
Expected Result
The upload has been successfully uploaded.
The documents and media portlet says "Your request failed to complete" if a virus would be detected in the file.