From a424f921bdbd79dbd954ef954d5ad757006821b4 Mon Sep 17 00:00:00 2001 From: Gregory Jansen Date: Fri, 8 Mar 2013 12:03:57 -0500 Subject: [PATCH 01/13] Update pom.xml --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 1beb96f..c00c910 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,11 @@ - clamavj + ClamAV Daemon Java API 4.0.0 - com.philvarner.clamavj + edu.unc.lib.cdr clamavj - 0.2 - A library to interact with clamd for virus scanning. + 0.3 + A fork or the Phil Varner library to interact with clamd for virus scanning. http://philvarner.com/clamavj/ @@ -62,4 +62,4 @@ test - \ No newline at end of file + From bc1905180168d6a81db85df29fae722c9b5ccc1d Mon Sep 17 00:00:00 2001 From: Gregory Jansen Date: Fri, 8 Mar 2013 12:10:01 -0500 Subject: [PATCH 02/13] added file path scanning support changed group id and version --- pom.xml | 138 ++++++++++-------- .../java/com/philvarner/clamavj/ClamScan.java | 89 ++++++++++- 2 files changed, 162 insertions(+), 65 deletions(-) diff --git a/pom.xml b/pom.xml index c00c910..77db961 100644 --- a/pom.xml +++ b/pom.xml @@ -1,65 +1,79 @@ - ClamAV Daemon Java API - 4.0.0 - edu.unc.lib.cdr - clamavj - 0.3 - A fork or the Phil Varner library to interact with clamd for virus scanning. - http://philvarner.com/clamavj/ - - - Apache Software License, 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - - - - dependencies - license - scm - project-team - index - - - - - - - - - - - maven-compiler-plugin - - 1.6 - 1.6 - - - - maven-javadoc-plugin - - - - - - - commons-logging - commons-logging - 1.1 - provided - - - junit - junit - 4.10 - test - - + ClamAV Daemon Java API + 4.0.0 + edu.unc.lib.cdr + clamavj + 0.3 + A fork or the Phil Varner library to interact with clamd for virus scanning. + http://philvarner.com/clamavj/ + + + Apache Software License, 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + + dlbuild.libint.unc.edu + dlbuild.libint.unc.edu-releases + http://dlbuild.libint.unc.edu:8080/artifactory/libs-release-local + + + dlbuild.libint.unc.edu + dlbuild.libint.unc.edu-snapshots + http://dlbuild.libint.unc.edu:8080/artifactory/libs-snapshot-local + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + + dependencies + license + scm + project-team + index + + + + + + + + + + + maven-compiler-plugin + + 1.6 + 1.6 + + + + maven-javadoc-plugin + + + + + + + commons-logging + commons-logging + 1.1 + provided + + + junit + junit + 4.10 + test + + diff --git a/src/main/java/com/philvarner/clamavj/ClamScan.java b/src/main/java/com/philvarner/clamavj/ClamScan.java index dd8fc4d..0ae87ac 100644 --- a/src/main/java/com/philvarner/clamavj/ClamScan.java +++ b/src/main/java/com/philvarner/clamavj/ClamScan.java @@ -1,22 +1,24 @@ package com.philvarner.clamavj; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.io.ByteArrayInputStream; import java.io.DataOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + public class ClamScan { private static Log log = LogFactory.getLog(ClamScan.class); public static final int CHUNK_SIZE = 2048; private static final byte[] INSTREAM = "zINSTREAM\0".getBytes(); + private static final byte[] SCAN = "zSCAN\0".getBytes(); private static final byte[] PING = "zPING\0".getBytes(); private static final byte[] STATS = "nSTATS\n".getBytes(); // TODO: IDSESSION, END @@ -147,6 +149,87 @@ public String cmd(byte[] cmd) { public ScanResult scan(byte[] in) throws IOException { return scan(new ByteArrayInputStream(in)); } + + /** + * The method to call if you have the content in a file. + * + * @param in the file to scan + * @return the result of the scan + * @throws IOException + */ + public ScanResult scan(File in) throws IOException { + Socket socket = new Socket(); + try { + socket.connect(new InetSocketAddress(getHost(), getPort())); + } catch (IOException e) { + log.error("could not connect to clamd server", e); + return new ScanResult(e); + } + + try { + socket.setSoTimeout(getTimeout()); + } catch (SocketException e) { + log.error("Could not set socket timeout to " + getTimeout() + "ms", e); + } + + DataOutputStream dos = null; + String response = ""; + try { // finally to close resources + + try { + dos = new DataOutputStream(socket.getOutputStream()); + } catch (IOException e) { + log.error("could not open socket OutputStream", e); + return new ScanResult(e); + } + + try { + dos.write(SCAN); + } catch (IOException e) { + log.debug("error writing SCAN command", e); + return new ScanResult(e); + } + + try { + dos.write(in.getAbsolutePath().getBytes()); + } catch (IOException e) { + log.debug("error writing file path", e); + return new ScanResult(e); + } + + try { + dos.writeInt(0); + dos.flush(); + } catch (IOException e) { + log.debug("error writing zero-length chunk to socket", e); + } + + int read = CHUNK_SIZE; + byte[] buffer = new byte[CHUNK_SIZE]; + try { + read = socket.getInputStream().read(buffer); + } catch (IOException e) { + log.debug("error reading result from socket", e); + read = 0; + } + + if (read > 0) response = new String(buffer, 0, read); + + } finally { + if (dos != null) try { + dos.close(); + } catch (IOException e) { + log.debug("exception closing DOS", e); + } + try { + socket.close(); + } catch (IOException e) { + log.debug("exception closing socket", e); + } + } + if (log.isDebugEnabled()) log.debug("Response: " + response); + return new ScanResult(response.trim()); + } /** * The preferred method to call. This streams the contents of the InputStream to clamd, so From 77ce70b11277646cab481434687a8c381933c345 Mon Sep 17 00:00:00 2001 From: Gregory Jansen Date: Fri, 8 Mar 2013 12:19:32 -0500 Subject: [PATCH 03/13] removing exception throwing --- src/main/java/com/philvarner/clamavj/ClamScan.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/philvarner/clamavj/ClamScan.java b/src/main/java/com/philvarner/clamavj/ClamScan.java index 0ae87ac..35f0e18 100644 --- a/src/main/java/com/philvarner/clamavj/ClamScan.java +++ b/src/main/java/com/philvarner/clamavj/ClamScan.java @@ -157,7 +157,7 @@ public ScanResult scan(byte[] in) throws IOException { * @return the result of the scan * @throws IOException */ - public ScanResult scan(File in) throws IOException { + public ScanResult scan(File in) { Socket socket = new Socket(); try { socket.connect(new InetSocketAddress(getHost(), getPort())); From 1ac0b657197982ca0468b2bc9d7167f887e6b1f3 Mon Sep 17 00:00:00 2001 From: Gregory Jansen Date: Fri, 8 Mar 2013 14:02:15 -0500 Subject: [PATCH 04/13] adding eclipse project artifacts to git ignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 365cbde..0315e20 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ target *.war *.ear .idea +/.classpath +/.project +/.settings +/.settings/** From dec346cb7014ab618effcfdd119af795a22fb106 Mon Sep 17 00:00:00 2001 From: Mike Daines Date: Fri, 8 Mar 2013 14:32:05 -0500 Subject: [PATCH 05/13] Send the SCAN command all in one go and interpret responses correctly. Add a test case for file scans. --- .../java/com/philvarner/clamavj/ClamScan.java | 27 +++------ .../com/philvarner/clamavj/ScanResult.java | 17 +++--- .../clamavj/test/ClamScanTestCase.java | 7 ++- .../clamavj/test/ScanFileTestCase.java | 56 +++++++++++++++++++ 4 files changed, 78 insertions(+), 29 deletions(-) create mode 100644 src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java diff --git a/src/main/java/com/philvarner/clamavj/ClamScan.java b/src/main/java/com/philvarner/clamavj/ClamScan.java index 35f0e18..750b13a 100644 --- a/src/main/java/com/philvarner/clamavj/ClamScan.java +++ b/src/main/java/com/philvarner/clamavj/ClamScan.java @@ -12,13 +12,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import static com.philvarner.clamavj.ScanResult.STREAM_PATH; + public class ClamScan { private static Log log = LogFactory.getLog(ClamScan.class); public static final int CHUNK_SIZE = 2048; private static final byte[] INSTREAM = "zINSTREAM\0".getBytes(); - private static final byte[] SCAN = "zSCAN\0".getBytes(); private static final byte[] PING = "zPING\0".getBytes(); private static final byte[] STATS = "nSTATS\n".getBytes(); // TODO: IDSESSION, END @@ -155,10 +156,11 @@ public ScanResult scan(byte[] in) throws IOException { * * @param in the file to scan * @return the result of the scan - * @throws IOException */ public ScanResult scan(File in) { + Socket socket = new Socket(); + try { socket.connect(new InetSocketAddress(getHost(), getPort())); } catch (IOException e) { @@ -184,26 +186,13 @@ public ScanResult scan(File in) { } try { - dos.write(SCAN); + dos.write(("SCAN " + in.getAbsolutePath() + "\n").getBytes()); + dos.flush(); } catch (IOException e) { log.debug("error writing SCAN command", e); return new ScanResult(e); } - try { - dos.write(in.getAbsolutePath().getBytes()); - } catch (IOException e) { - log.debug("error writing file path", e); - return new ScanResult(e); - } - - try { - dos.writeInt(0); - dos.flush(); - } catch (IOException e) { - log.debug("error writing zero-length chunk to socket", e); - } - int read = CHUNK_SIZE; byte[] buffer = new byte[CHUNK_SIZE]; try { @@ -228,7 +217,7 @@ public ScanResult scan(File in) { } } if (log.isDebugEnabled()) log.debug("Response: " + response); - return new ScanResult(response.trim()); + return new ScanResult(response.trim(), in.getAbsolutePath()); } /** @@ -325,7 +314,7 @@ public ScanResult scan(InputStream in) { if (log.isDebugEnabled()) log.debug("Response: " + response); - return new ScanResult(response.trim()); + return new ScanResult(response.trim(), STREAM_PATH); } public String getHost() { diff --git a/src/main/java/com/philvarner/clamavj/ScanResult.java b/src/main/java/com/philvarner/clamavj/ScanResult.java index e3a6fe8..186e039 100644 --- a/src/main/java/com/philvarner/clamavj/ScanResult.java +++ b/src/main/java/com/philvarner/clamavj/ScanResult.java @@ -9,15 +9,15 @@ public class ScanResult { public enum Status {PASSED, FAILED, ERROR} - public static final String STREAM_PREFIX = "stream: "; - public static final String RESPONSE_OK = "stream: OK"; + public static final String STREAM_PATH = "stream"; + public static final String OK_SUFFIX = "OK"; public static final String FOUND_SUFFIX = "FOUND"; public static final String RESPONSE_SIZE_EXCEEDED = "INSTREAM size limit exceeded. ERROR"; public static final String RESPONSE_ERROR_WRITING_FILE = "Error writing to temporary file. ERROR"; - public ScanResult(String result) { - setResult(result); + public ScanResult(String result, String path) { + setResult(result, path); } public ScanResult(Exception ex) { @@ -37,15 +37,18 @@ public String getResult() { return result; } - public void setResult(String result) { + public void setResult(String result, String path) { + this.result = result; + + String prefix = path + ": "; if (result == null) { setStatus(Status.ERROR); - } else if (RESPONSE_OK.equals(result)) { + } else if (result.equals(prefix + OK_SUFFIX)) { setStatus(Status.PASSED); } else if (result.endsWith(FOUND_SUFFIX)) { - setSignature(result.substring(STREAM_PREFIX.length(), result.lastIndexOf(FOUND_SUFFIX) - 1)); + setSignature(result.substring(prefix.length(), result.lastIndexOf(FOUND_SUFFIX) - 1)); } else if (RESPONSE_SIZE_EXCEEDED.equals(result)) { setStatus(Status.ERROR); } else if (RESPONSE_ERROR_WRITING_FILE.equals(result)) { diff --git a/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java b/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java index a842a12..0a3d8b4 100644 --- a/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java +++ b/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java @@ -8,7 +8,8 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import static com.philvarner.clamavj.ScanResult.RESPONSE_OK; +import static com.philvarner.clamavj.ScanResult.OK_SUFFIX; +import static com.philvarner.clamavj.ScanResult.STREAM_PATH; public class ClamScanTestCase extends TestCase { @@ -29,7 +30,7 @@ public void testSuccess() throws Exception { assertNotNull(is); ScanResult result = scanner.scan(is); assertEquals(Status.PASSED, result.getStatus()); - assertEquals(RESPONSE_OK, result.getResult()); + assertEquals(STREAM_PATH + ": " + OK_SUFFIX, result.getResult()); } public void testVirus() throws Exception { @@ -67,7 +68,7 @@ public void testMultipleOfChunkSize() throws Exception { assertNotNull(is); ScanResult result = scanner.scan(is); assertEquals(Status.PASSED, result.getStatus()); - assertEquals(RESPONSE_OK, result.getResult()); + assertEquals(STREAM_PATH + ": " + OK_SUFFIX, result.getResult()); } public void testTooLarge() throws Exception { diff --git a/src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java b/src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java new file mode 100644 index 0000000..949f6b7 --- /dev/null +++ b/src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java @@ -0,0 +1,56 @@ +package com.philvarner.clamavj.test; + +import com.philvarner.clamavj.ClamScan; +import com.philvarner.clamavj.ScanResult; +import com.philvarner.clamavj.ScanResult.Status; +import junit.framework.TestCase; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.net.URL; + +import static com.philvarner.clamavj.ScanResult.OK_SUFFIX; + +public class ScanFileTestCase extends TestCase { + + ClamScan scanner; + + public void setUp() { + scanner = new ClamScan("localhost", 3310, 60000); + } + + public void testSuccess() throws Exception { + + File f = File.createTempFile("clean", ".txt"); + f.deleteOnExit(); + + FileOutputStream s = new FileOutputStream(f); + s.write("test".getBytes()); + s.close(); + + ScanResult result = scanner.scan(f); + + assertEquals(f.getAbsolutePath() + ": " + OK_SUFFIX, result.getResult()); + assertEquals(Status.PASSED, result.getStatus()); + + } + + public void testVirus() throws Exception { + + File f = File.createTempFile("eicar", ".com"); + f.deleteOnExit(); + + FileOutputStream s = new FileOutputStream(f); + s.write("X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*".getBytes()); + s.close(); + + ScanResult result = scanner.scan(f); + + assertEquals(f.getAbsolutePath() + ": Eicar-Test-Signature FOUND", result.getResult()); + assertEquals("Eicar-Test-Signature", result.getSignature()); + assertEquals(Status.FAILED, result.getStatus()); + + } + +} From efbb90db9f67a4205000332e285b7a003a9f5db4 Mon Sep 17 00:00:00 2001 From: Mike Daines Date: Mon, 11 Mar 2013 10:07:48 -0400 Subject: [PATCH 06/13] Centralize prefix stuff --- src/main/java/com/philvarner/clamavj/ScanResult.java | 6 +++++- .../com/philvarner/clamavj/test/ClamScanTestCase.java | 10 +++++----- .../com/philvarner/clamavj/test/ScanFileTestCase.java | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/philvarner/clamavj/ScanResult.java b/src/main/java/com/philvarner/clamavj/ScanResult.java index 186e039..abe68ef 100644 --- a/src/main/java/com/philvarner/clamavj/ScanResult.java +++ b/src/main/java/com/philvarner/clamavj/ScanResult.java @@ -15,6 +15,10 @@ public enum Status {PASSED, FAILED, ERROR} public static final String RESPONSE_SIZE_EXCEEDED = "INSTREAM size limit exceeded. ERROR"; public static final String RESPONSE_ERROR_WRITING_FILE = "Error writing to temporary file. ERROR"; + + public static String getPrefix(String path) { + return path + ": "; + } public ScanResult(String result, String path) { setResult(result, path); @@ -41,7 +45,7 @@ public void setResult(String result, String path) { this.result = result; - String prefix = path + ": "; + String prefix = getPrefix(path); if (result == null) { setStatus(Status.ERROR); diff --git a/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java b/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java index 0a3d8b4..ef0e886 100644 --- a/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java +++ b/src/test/java/com/philvarner/clamavj/test/ClamScanTestCase.java @@ -30,7 +30,7 @@ public void testSuccess() throws Exception { assertNotNull(is); ScanResult result = scanner.scan(is); assertEquals(Status.PASSED, result.getStatus()); - assertEquals(STREAM_PATH + ": " + OK_SUFFIX, result.getResult()); + assertEquals(ScanResult.getPrefix(STREAM_PATH) + OK_SUFFIX, result.getResult()); } public void testVirus() throws Exception { @@ -38,7 +38,7 @@ public void testVirus() throws Exception { assertNotNull(is); ScanResult result = scanner.scan(is); assertEquals(Status.FAILED, result.getStatus()); - assertEquals("stream: Eicar-Test-Signature FOUND", result.getResult()); + assertEquals(ScanResult.getPrefix(STREAM_PATH) + "Eicar-Test-Signature FOUND", result.getResult()); assertEquals("Eicar-Test-Signature", result.getSignature()); } @@ -46,7 +46,7 @@ public void testVirusAsByteArray() throws Exception { byte[] bytes = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*".getBytes(); ScanResult result = scanner.scan(bytes); assertEquals(Status.FAILED, result.getStatus()); - assertEquals("stream: Eicar-Test-Signature FOUND", result.getResult()); + assertEquals(ScanResult.getPrefix(STREAM_PATH) + "Eicar-Test-Signature FOUND", result.getResult()); assertEquals("Eicar-Test-Signature", result.getSignature()); } @@ -59,7 +59,7 @@ public void testNoArgConstructor() throws Exception { byte[] bytes = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*".getBytes(); ScanResult result = scanner.scan(bytes); assertEquals(Status.FAILED, result.getStatus()); - assertEquals("stream: Eicar-Test-Signature FOUND", result.getResult()); + assertEquals(ScanResult.getPrefix(STREAM_PATH) + "Eicar-Test-Signature FOUND", result.getResult()); assertEquals("Eicar-Test-Signature", result.getSignature()); } @@ -68,7 +68,7 @@ public void testMultipleOfChunkSize() throws Exception { assertNotNull(is); ScanResult result = scanner.scan(is); assertEquals(Status.PASSED, result.getStatus()); - assertEquals(STREAM_PATH + ": " + OK_SUFFIX, result.getResult()); + assertEquals(ScanResult.getPrefix(STREAM_PATH) + OK_SUFFIX, result.getResult()); } public void testTooLarge() throws Exception { diff --git a/src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java b/src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java index 949f6b7..31a19ee 100644 --- a/src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java +++ b/src/test/java/com/philvarner/clamavj/test/ScanFileTestCase.java @@ -31,7 +31,7 @@ public void testSuccess() throws Exception { ScanResult result = scanner.scan(f); - assertEquals(f.getAbsolutePath() + ": " + OK_SUFFIX, result.getResult()); + assertEquals(ScanResult.getPrefix(f.getAbsolutePath()) + OK_SUFFIX, result.getResult()); assertEquals(Status.PASSED, result.getStatus()); } @@ -47,7 +47,7 @@ public void testVirus() throws Exception { ScanResult result = scanner.scan(f); - assertEquals(f.getAbsolutePath() + ": Eicar-Test-Signature FOUND", result.getResult()); + assertEquals(ScanResult.getPrefix(f.getAbsolutePath()) + "Eicar-Test-Signature FOUND", result.getResult()); assertEquals("Eicar-Test-Signature", result.getSignature()); assertEquals(Status.FAILED, result.getStatus()); From eecd44db1ab253cc91d7e539399d0dad09d26de1 Mon Sep 17 00:00:00 2001 From: Mike Daines Date: Mon, 4 May 2015 10:35:43 -0400 Subject: [PATCH 07/13] When reading command output, don't assume we always read CHUNK_SIZE bytes --- src/main/java/com/philvarner/clamavj/ClamScan.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/philvarner/clamavj/ClamScan.java b/src/main/java/com/philvarner/clamavj/ClamScan.java index 750b13a..f546595 100644 --- a/src/main/java/com/philvarner/clamavj/ClamScan.java +++ b/src/main/java/com/philvarner/clamavj/ClamScan.java @@ -112,14 +112,16 @@ public String cmd(byte[] cmd) { int read = CHUNK_SIZE; byte[] buffer = new byte[CHUNK_SIZE]; - while (read == CHUNK_SIZE) { + while (read != -1) { try { read = is.read(buffer); } catch (IOException e) { log.error("error reading result from socket", e); break; } - response.append(new String(buffer, 0, read)); + if (read > 0) { + response.append(new String(buffer, 0, read)); + } } } finally { From 45eba3ee54ad51dc23de4a7389e018ea65f6247e Mon Sep 17 00:00:00 2001 From: Mike Daines Date: Mon, 4 May 2015 16:41:07 -0400 Subject: [PATCH 08/13] Add Travis CI config --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..757db4a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +--- +language: java +before_install: + - sudo apt-get install clamav-daemon From ef90981dfeac85acc653fea2f8ded7fd5f88ffb0 Mon Sep 17 00:00:00 2001 From: Mike Daines Date: Fri, 8 May 2015 15:15:47 -0400 Subject: [PATCH 09/13] Run freshclam and launch clamd --- .travis.yml | 4 +++- clamd.conf | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 clamd.conf diff --git a/.travis.yml b/.travis.yml index 757db4a..adc4821 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ --- language: java before_install: - - sudo apt-get install clamav-daemon + - sudo apt-get install -y clamav-daemon + - sudo freshclam + - sudo clamd --config-file $TRAVIS_BUILD_DIR/clamd.conf diff --git a/clamd.conf b/clamd.conf new file mode 100644 index 0000000..84da4a2 --- /dev/null +++ b/clamd.conf @@ -0,0 +1,2 @@ +TCPSocket 3310 +TCPAddr 127.0.0.1 From 6a8f0c35e8d7bb074a6c88f13c870d93a58d17ed Mon Sep 17 00:00:00 2001 From: bbpennel Date: Tue, 2 Jan 2018 12:20:51 -0500 Subject: [PATCH 10/13] Added profile that disables tests unless explicitely asked to perform --- pom.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pom.xml b/pom.xml index 52a137b..105339f 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,28 @@ + + + skip-clamavj-tests + + + !testClamavj + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + true + + + + + + From a143d97de655dbb5bbf8adc3cc58988a1537c36b Mon Sep 17 00:00:00 2001 From: bbpennel Date: Tue, 2 Jan 2018 14:13:49 -0500 Subject: [PATCH 11/13] Performing apt-get update and using -qq --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index adc4821..ae1a7fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ --- language: java before_install: - - sudo apt-get install -y clamav-daemon + - "sudo apt-get update -qq" + - sudo apt-get install clamav-daemon -qq - sudo freshclam - sudo clamd --config-file $TRAVIS_BUILD_DIR/clamd.conf From 6a768aa526be29021085b7197b15a9ee271268ff Mon Sep 17 00:00:00 2001 From: bbpennel Date: Tue, 2 Jan 2018 14:19:24 -0500 Subject: [PATCH 12/13] Specifying that travis use flag to enable tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ae1a7fc..b118eae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,4 @@ before_install: - sudo apt-get install clamav-daemon -qq - sudo freshclam - sudo clamd --config-file $TRAVIS_BUILD_DIR/clamd.conf +script: mvn test -B -DtestClamavj \ No newline at end of file From 4c98cd5b772a64f7a108cfdef4abdbcd6e43cb7c Mon Sep 17 00:00:00 2001 From: bbpennel Date: Thu, 4 Jan 2018 11:41:42 -0500 Subject: [PATCH 13/13] Removed no longer used constant --- src/main/java/com/philvarner/clamavj/ScanResult.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/philvarner/clamavj/ScanResult.java b/src/main/java/com/philvarner/clamavj/ScanResult.java index 28679ea..f3f3aee 100644 --- a/src/main/java/com/philvarner/clamavj/ScanResult.java +++ b/src/main/java/com/philvarner/clamavj/ScanResult.java @@ -15,7 +15,6 @@ public enum Status {PASSED, FAILED, ERROR} public static final String ERROR_SUFFIX = "ERROR"; public static final String RESPONSE_SIZE_EXCEEDED = "INSTREAM size limit exceeded. ERROR"; - public static final String RESPONSE_ERROR_WRITING_FILE = "Error writing to temporary file. ERROR"; public static String getPrefix(String path) { return path + ": ";