No description, website, or topics provided.
Scala Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
project
src
.gitignore
.scalafmt.conf
.travis.yml
LICENSE
README.md
clamav-travis.sh
scalastyle-config.xml
scalastyle-test-config.xml

README.md

clamav-client

Build Status Download

Local Installation

This requires ClamAV to be installed the best way to do this is run the docker-clamav image. Alternatively use the manual instructions below.

Configuring hosts file

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

Manual installation on Mac OS with Brew

brew install clamav

You can find a slightly longer explaination here but make note of the comments as the instructions contain some issues.

Configuring your MicroService

Make sure clamd.conf has

LocalSocket /usr/local/var/run/clamav/clamd.sock TCPSocket 3310

To use clamav-client

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.

Use ClamAntiVirus

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)
  }
}