diff --git a/Makefile b/Makefile index 8bcf47509945028890542a63ee53f6de09484a0c..ec525f1614fcaa6da25d72721627d0ce4435cc80 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,11 @@ # erzeugt Submission-Application, die vorbereitete Verzeichnisse per Java SDK # von ExLibris an Rosetta übergibt. -# Pfad zu Java 7 -JAVAPATH=$(wildcard /usr/lib/jvm/java-8-openjdk-*/bin/) +# Pfad zu Java +JAVAPATH=$(wildcard /usr/lib/jvm/java-11-openjdk-*/bin/) # Verwendete Rosetta-Version -ROSETTAVERSION=5.5.0 +ROSETTAVERSION=6.3.0 # Pfad zum Rosetta-SDK ROSETTASDK=/exlibris/dps/d4_1/system.dir/dps-sdk-${ROSETTAVERSION}/lib/ @@ -32,7 +32,7 @@ JAR=SLUBVirusCheckPlugin.jar all: $(JAR) help: - @echo "erzeugt Storage-Plugin für Rosetta von Exlibris" + @echo "erzeugt ${JAR} für Rosetta von Exlibris" @echo "" @echo "Das Argument 'clean' löscht temporäre Dateien, 'help' gibt diese Hilfe aus und" @echo "'compile' erzeugt ein JAR-File und ein Bash-Script welches das Java-Programm" @@ -73,4 +73,3 @@ check_prerequisites: @if [ -e $(ROSETTASDK) ]; then echo "fine :)"; else echo " not found! :("; fi .PHONY: help clean distclean jarclean test - diff --git a/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml b/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml index 9a9891bda624099e4f088a79307eca6b3e6abb51..db866068f376db70d577c267f83e841e15f982e8 100644 --- a/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml +++ b/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml @@ -1,5 +1,5 @@ <pl:metadata-config xmlns:pl="http://www.exlibrisgroup.com/Plugins/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <pl:pluginTypeName>VirusCheckPlugin</pl:pluginTypeName> + <pl:pluginTypeName>VirusCheckPluginV2</pl:pluginTypeName> <pl:deployName>SLUBVirusCheckClamAVPlugin</pl:deployName> <pl:className>org.slub.rosetta.dps.repository.plugin.SLUBVirusCheckClamAVPlugin</pl:className> <pl:initParameters> @@ -49,7 +49,7 @@ </fr:x_form> </pl:initParameters> <pl:description>SLUB Virus Check Plugin using installed ClamAV daemon via tcp-sockets</pl:description> - <pl:version>1.9</pl:version> + <pl:version>2.0</pl:version> <pl:materialType>DIGITAL</pl:materialType> <pl:module>Repository</pl:module> <pl:generalType>TASK</pl:generalType> diff --git a/README b/README index 6271800f50d7ee5ec9c42abb001ed821025698db..8ec07977af440ff6a65962e048083e8ca0817ffe 100644 --- a/README +++ b/README @@ -10,6 +10,8 @@ The code is partially based on https://code.google.com/p/clamavj/source/browse/t https://github.com/vrtadmin/clamav-devel/blob/master/clamdscan/client.c and https://github.com/vrtadmin/clamav-devel/blob/master/clamdscan/proto.c + Hint: the plugin uses the VirusCheckPlugin interface version 2 now. + and therefore licenced via Apache License Version 2.0. Andreas Romeyke diff --git a/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java index 2c04872c445b19dc5eb9d4e9fe7617629503a60f..30b6d48231119dd733605d86e4012da088db7e92 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java @@ -24,7 +24,7 @@ package org.slub.rosetta.dps.repository.plugin; import com.exlibris.core.infra.common.exceptions.logging.ExLogger; -import com.exlibris.dps.repository.plugin.virusChcek.VirusCheckPlugin; +import com.exlibris.dps.repository.plugin.virusChcek.VirusCheckPluginV2; import java.io.DataOutputStream; import java.io.FileInputStream; @@ -47,9 +47,9 @@ import java.util.Map; * code could also be copied from https://code.google.com/p/clamavj/source/browse/trunk/src/main/java/com/philvarner/clamavj/ClamScan.java?r=2 * * @author andreas.romeyke@slub-dresden.de (Andreas Romeyke) - * @see com.exlibris.dps.repository.plugin.virusChcek.VirusCheckPlugin + * @see com.exlibris.dps.repository.plugin.virusChcek.VirusCheckPluginV2 */ -public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { +public class SLUBVirusCheckClamAVPlugin implements VirusCheckPluginV2 { //private static final ExLogger log = ExLogger.getExLogger(SLUBVirusCheckClamAVPlugin.class); private static final int DEFAULT_CHUNK_SIZE = 4096; private static final byte[] INSTREAM = "zINSTREAM\0".getBytes(); @@ -63,9 +63,14 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { private String host; private int port; private String response; - private Status status = Status.FAILED; + /* Status: + * @return 0 if last scan passed (means: virus free) -> PASSED + * @return 1 if last scan found a virus -> FAILED + * @return >1 if last scan result is undetermined -> UNDETERMINED + */ + private enum Status {PASSED, FAILED, UNDETERMINED}; /* order is important, because we use .ordinal() in return code */ + private Status status = Status.UNDETERMINED; private String signature = ""; - private enum Status {PASSED, FAILED}; /** constructor */ public SLUBVirusCheckClamAVPlugin() { //log.info("SLUBVirusCheckPlugin instantiated with host=" + host + " port=" + port + " timeout=" + timeout); @@ -85,6 +90,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { * @param args list of files which should be scanned */ public static void main(String[] args) { + SLUBVirusCheckClamAVPlugin plugin = new SLUBVirusCheckClamAVPlugin(); Map<String, String> initp = new HashMap<String, String>(); initp.put( "host", "127.0.0.1"); @@ -294,18 +300,26 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { setStatus(Status.PASSED); log.info("scan of file '" + fileFullPath + "' passed"); } else if (result.endsWith(FOUND_SUFFIX)) { - setStatus(Status.FAILED); + if (result.contains(".Exploit.CVE")) { // we want to ignore CVE results + setStatus(Status.UNDETERMINED); + log.info("scan of file '" + fileFullPath + "' possibly failed, check manually if should be ignored!"); + } else if (result.contains("eicar")) { // we want to ignore EICAR + setStatus(Status.UNDETERMINED); + log.info("scan of file '" + fileFullPath + "' possibly failed, because EICAR sequence detected, check manually if should be ignored!"); + } else { + setStatus(Status.FAILED); + log.info("scan of file '" + fileFullPath + "' failed"); + } setSignature(result.substring(STREAM_PREFIX.length(), result.lastIndexOf(FOUND_SUFFIX) - 1)); - log.info("scan of file '" + fileFullPath + "' failed"); } else { - setStatus(Status.FAILED); + setStatus(Status.UNDETERMINED); log.warn("clamd protocol not fully implemented, result='" + result + "'"); //System.out.println("clamd protocol not fully implemented"); } } catch (IOException e) { log.error("exception creation socket in scan(), clamd not available at host=" + host + "port=" + port, e); //System.out.println("exception creation socket, clamd not available at host=" + host + "port=" + port + " " + e); - setStatus(Status.FAILED); + setStatus(Status.UNDETERMINED); setSignature("ERROR: clamd not available"); } } @@ -341,11 +355,11 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { /** result of last scan * - * @return true if last scan passed (means: virus free) + * @return 0 if last scan passed (means: virus free) + * 1 if last scan found a virus + * >1 if last scan result is undetermined */ - public boolean isVirusFree() { - //return true; // dummy - return (Status.PASSED == getStatus()); + public int isVirusFree() { + return (getStatus().ordinal()); } } -