This library is no longer maintained.
This requires ClamAV to be installed the best way to do this is run the docker-clamav image. Alternatively use the manual instructions below.
If you have installed ClamAV manually or are using the Docker image with a native docker installation then add this to your /etc/hosts file.
127.0.0.1 avscan
If you are using the docker image and using Docker Machine on Mac then the host IP should be the IP of your Docker Machine IP.
DOCKER_IP avscan
brew install clamav
You can find a slightly longer explaination here but make note of the comments as the instructions contain some issues.
Make sure clamd.conf has
LocalSocket /usr/local/var/run/clamav/clamd.sock
TCPSocket 3310
Add the latest released version of the clamav-client to your app dependencies of your micro service build
e.g. "uk.gov.hmrc" %% "clamav-client" % "
version
"
Your application.conf should be configured to enable clamav scanning
clam.antivirus {
host = avscan
port = 3310
timeout = 5000
}
Wire up your microservice to load the ClamAvConfig using dependency injection by adding the following to your application.conf
play.modules.enabled += "uk.gov.hmrc.clamav.ClientModule"
For an explanation on using Guice dependency injection within your Play project, see the Play documentation.
import javax.inject.Inject
import uk.gov.hmrc.clamav._
class YourClass @Inject()(clamAntiVirusFactory: ClamAntiVirusFactory) {
...
def sendToClamAv(): Future[Try[Unit]] = {
val antivirusClient = ClamAntiVirusFactory.getClient()
antivirusClient.sendAndCheck(bytes)
//or
antivirusClient.sendAndCheck(inputStream, length)
}
}