views:

63

answers:

1

I'm writing a Java-based web app that allows users to upload and submit content to the site. Before it is made available, though, I'd like to perform a virus scan to ensure that no malicious content gets posted. Does anyone know of an anti-virus scanner that can be accessed via Java? The app will be hosted on Linux (CentOS 5.5 x64) and run on Tomcat 6.x. Any advice or recommendations would be appreciated!

+1  A: 

Check out Clam AV. It seems to only come in shared library form so you would have to make a JNI wrapper for it. I haven't tried it but it looks kind of neat.

Kristoffer E
Just what I was going to suggest. Pretty sure there's packages to allow use from command line, so worst case, could just run a system command from inside Java and parse the output, but only if you can't find/make a wrapper for it instead.
Slokun
You could exec a process and run "clamscan" on the uploaded file. Also make sure that you're updating the virus definitions with "freshclam". Be careful with JNI in an app server. Segfault will take down the entire JVM. A forked process, while not as efficient, won't.
basszero
Good points, invoking the command line version is definitely an option as well.
Kristoffer E