Grails ClamAV Plugin
This is a plugin to simply use the open source antivirus ClamAV™ from Grails.
Latest plugin version is 0.1.
Install & configure ClamAV™
The plugin relies on a running daemon of ClamAV™ listening on a TCP port.
Installation
See on ClamAV™ website for installation instructions for your system (packages exists for different Linux versions).
Install & configure the plugin
Installation
Type this command in your Grail application directory
$> grails install-plugin clamav
or if you have a plugin archive locally.
$> grails install-plugin /path/to/grails-clamav-0.1.zip
Configuration
In grails-app/conf/Config.groovy you can add following entries:
- clamav.host=xxx (the host on which the ClamAV daemon runs. Default is localhost)
- clamav.port=xxx (the port on which ClamAV daemon is listening. Must match the TCPSocket configuration option of ClamAV daemon. Default is 9321)
Status page
The plugin contains a controller that displays a status page and allows to quickly test an uploaded file. The default location is "/clamAv" within your app (adapt if you use url mappings).

Usage
Validator
The plugin registers a new validator named freeOfVirus that you can use in validation like any other constraint. For example like:
class Foo
{
...
byte[] binaryData
...
static constraints = {
binaryData(freeOfVirus: true)
}
}
Service
The plugin provides a service named clamAVService that implements the simple AntiVirusService interface. You can uses in your controllers like any other service.
Example:
class TestController
{
def clamAVService // will be injected
def test = {
def f = new File(...)
def virus
f.withInputStream {
virus = clamAVService.scan(it)
}
render(text: (virus ? "Virus found: $virus" : "Ok"))
}
}
Sources
The sources of the plugin are available under SVN in Grails plugin repository: http://svn.codehaus.org/grails-plugins/grails-clamav/trunk/.

