Plugins You can find out about all the publicly available Grails plugins.

ClamAV Plugin

  • Tags: security
  • Latest: 0.2
  • Last Updated: 29 July 2009
  • Grails version: *
  • Authors: Marc Palmer
1 vote
compile "org.grails.plugins:clamav:0.2"



Grails ClamAV Plugin

This is a plugin to simply use the open source antivirus ClamAVâ„¢ from Grails.

Latest plugin version is 0.2.

Install & configure ClamAVâ„¢

The plugin relies on a running daemon of ClamAVâ„¢ listening on a TCP port.


See on ClamAVâ„¢ website for installation instructions for your system (packages exists for different Linux versions).


Configure the TCPSocket option (normally in clamd.conf). This is the port on which ClamAV will be listening for commands from the plugin. If you set it to the default value of 9321, you won't need to configure the plugin.

# The port on which ClamAV listens for commands
TCPSocket  9321

Install & configure the plugin


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/


In grails-app/conf/Config.groovy you can add following entries:

  • (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).

!Grails-ClamAv-Plugin status.png!



The plugin registers a new validato{}r named freeOfVirus that you can use in validation like any other constraint. For example like:

class Foo
  byte[] binaryData
  static constraints = {
    binaryData(freeOfVirus: true)


The plugin provides a service named clamAVService that implements the simple AntiVirusService interface. You can uses in your controllers like any other service.


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


  • extend validator to work on InputStream, File, ...


The sources of the plugin are available under SVN in Grails plugin repository:

Version History

v. 0.2 (29.07.2009)

  • plugin works now with Grails 1.1.1
v. 0.1 (10.03.2007)
  • initial version