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).
Configuration
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
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).
!Grails-ClamAv-Plugin status.png!
Usage
Validator
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)
}
}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"))
}
}TODOs
- TESTS
- extend validator to work on InputStream, File, ...
Sources
The sources of the plugin are available under SVN in Grails plugin repository:
http://svn.codehaus.org/grails-plugins/grails-clamav/trunk/.
Version History
v. 0.1 (10.03.2007)