[exim-cvs] Testsuite: testcase for ClamAV over TCP

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Exim Git Commits Mailing List
Ημερομηνία:  
Προς: exim-cvs
Αντικείμενο: [exim-cvs] Testsuite: testcase for ClamAV over TCP
Gitweb: https://git.exim.org/exim.git/commitdiff/0cedb352e62898761b701af0c400df8ae1989383
Commit:     0cedb352e62898761b701af0c400df8ae1989383
Parent:     e40f75b25322c11065dbade34e32ca177b10768c
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sun Jan 17 19:59:51 2021 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Jan 17 20:01:49 2021 +0000


    Testsuite: testcase for ClamAV over TCP
---
 test/README                       |  9 ++++--
 test/confs/4006                   |  4 +--
 test/log/4006                     |  3 ++
 test/scripts/4006_scan_clamd/4006 | 62 ++++++++++++++++++++++++++++++++-------
 test/stdout/4006                  | 38 +++++++++++++++++++++---
 5 files changed, 97 insertions(+), 19 deletions(-)


diff --git a/test/README b/test/README
index c0f5482..bca17eb 100644
--- a/test/README
+++ b/test/README
@@ -1119,13 +1119,16 @@ are of the following kinds:
 (2) A line that starts with "*sleep" specifies a number of seconds to wait
     before proceeding.


-(3) A line containing "*eof" specifies that the client is expected to close
+(3) A line containing "*data" and a number specifies that the client is
+    expected to send that many byte; the server discards them
+
+(4) A line containing "*eof" specifies that the client is expected to close
     the connection at this point.


-(4) A line containing just '.' specifies that the client is expected to send
+(5) A line containing just '.' specifies that the client is expected to send
     many lines, terminated by one that contains just a dot.


-(5) Otherwise, the line defines the start of an input line that the client
+(6) Otherwise, the line defines the start of an input line that the client
     is expected to send. To allow for lines that start with digits, the line
     may start with '<', which is not taken as part of the input data. If the
     lines starts with '<<' then only the characters are expected; no return-
diff --git a/test/confs/4006 b/test/confs/4006
index 4c7059f..f8b216b 100644
--- a/test/confs/4006
+++ b/test/confs/4006
@@ -2,6 +2,7 @@
 # Content-scan: clamav interface


OPT=
+SRV=unset
CONTROL=

.include DIR/aux-var/std_conf_prefix
@@ -9,8 +10,7 @@ CONTROL=
log_selector = +subject
primary_hostname = myhost.test.ex

-#XXX we need an additional test for tcp-connected clamd
-av_scanner = clamd : DIR/eximdir/clam_sock CONTROL
+av_scanner = clamd : SRV CONTROL

# ----- Main settings -----

diff --git a/test/log/4006 b/test/log/4006
index 33f47f9..1b71968 100644
--- a/test/log/4006
+++ b/test/log/4006
@@ -14,3 +14,6 @@
1999-03-02 09:44:33 10HmbC-0005vi-00 <= CALLER@??? U=CALLER P=local-esmtp S=sss T="message should be accepted after a retry"
1999-03-02 09:44:33 10HmbC-0005vi-00 => :blackhole: <userx@???> R=r
1999-03-02 09:44:33 10HmbC-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbD-0005vi-00 <= CALLER@??? U=CALLER P=local-esmtp S=sss T="message should be accepted"
+1999-03-02 09:44:33 10HmbD-0005vi-00 => :blackhole: <userx@???> R=r
+1999-03-02 09:44:33 10HmbD-0005vi-00 Completed
diff --git a/test/scripts/4006_scan_clamd/4006 b/test/scripts/4006_scan_clamd/4006
index d251c1a..91d08bd 100644
--- a/test/scripts/4006_scan_clamd/4006
+++ b/test/scripts/4006_scan_clamd/4006
@@ -2,15 +2,16 @@
#
# SCAN command interface, on a unix socket, only. No ExtendedDetectionInfo.
#
+# Pass
server DIR/eximdir/clam_sock
<SCAN
>LF>scanned_file_name: OK

-<*eof
+*eof
****
#
#
#
-exim -odi -bs -DOPT=
+exim -odi -bs -DSRV=DIR/eximdir/clam_sock -DOPT=
ehlo test.ex
mail from:<>
rcpt to:<userx@???>
@@ -24,15 +25,16 @@ quit
#
#
#
+# fail/error
server DIR/eximdir/clam_sock
<SCAN
>LF>scanned_file_name: 666 ERROR

-<*eof
+*eof
****
#
#
#
-exim -odi -bs -DOPT=
+exim -odi -bs -DSRV=DIR/eximdir/clam_sock -DOPT=
ehlo test.ex
mail from:<>
rcpt to:<userx@???>
@@ -46,15 +48,16 @@ quit
#
#
#
+# fail/virus-found
server DIR/eximdir/clam_sock
<SCAN
>LF>scanned_file_name: VNAME FOUND

-<*eof
+*eof
****
#
#
#
-exim -odi -bs -DOPT=/defer_ok
+exim -odi -bs -DSRV=DIR/eximdir/clam_sock -DOPT=/defer_ok
ehlo test.ex
mail from:<>
rcpt to:<userx@???>
@@ -68,13 +71,14 @@ quit
#
#
#
+# times out
server DIR/eximdir/clam_sock
*sleep 3
****
#
#
#
-exim -odi -bs -DOPT="/ tmo=2s"
+exim -odi -bs -DSRV=DIR/eximdir/clam_sock -DOPT="/ tmo=2s"
ehlo test.ex
mail from:<>
rcpt to:<userx@???>
@@ -88,13 +92,14 @@ quit
#
#
#
+# times out
server DIR/eximdir/clam_sock
*sleep 3
****
#
#
#
-exim -odi -bs -DOPT="/ tmo=2s / defer_ok"
+exim -odi -bs -DSRV=DIR/eximdir/clam_sock -DOPT="/ tmo=2s / defer_ok"
ehlo test.ex
mail from:<>
rcpt to:<userx@???>
@@ -109,13 +114,14 @@ quit
#
#
#
+# connect-fail (server not initially listenting), retry
server -i 2 DIR/eximdir/clam_sock
<SCAN
>LF>scanned_file_name: OK

-<*eof
+*eof
****
#
-exim -odi -bs -DCONTROL="retry=4s"
+exim -odi -bs -DSRV=DIR/eximdir/clam_sock -DCONTROL="retry=4s"
ehlo test.ex
mail from:<>
rcpt to:<userx@???>
@@ -127,3 +133,39 @@ Subject: message should be accepted after a retry
quit
****
#
+################################################################################
+#
+# TCP clamd server connection, default protocol
+# only checks the protocol header, filesize element and start of eml file lines;
+# not the post-file protocol mark
+# Pass
+server PORT_D
+<zINSTREAM\x00\x00\x00\x01\xe5From MAILER-DAEMON
+<X-Envelope-From: <
+<X-Envelope-To: userx@???
+<Received: from
+<\x09by myhost.test.ex with local-esmtp
+<\x09(envelope-from <
+<\x09id
+<\x09for userx@???;
+<Date:
+<Subject: message should be accepted
+<Message-Id: <
+<From:
+<
+<
+>LF>scanned_file_name: OK
+*eof
+****
+#
+exim -odi -bs -DSRV="127.0.0.1 PORT_D" -DOPT=
+ehlo test.ex
+mail from:<>
+rcpt to:<userx@???>
+data
+Date: Fri, 17 Dec 2004 14:35:01 +0100
+Subject: message should be accepted
+
+.
+quit
+****
diff --git a/test/stdout/4006 b/test/stdout/4006
index 4d858c5..b4a72b8 100644
--- a/test/stdout/4006
+++ b/test/stdout/4006
@@ -64,25 +64,36 @@
354 Enter message, ending with "." on a line by itself
250 OK id=10HmbC-0005vi-00
221 myhost.test.ex closing connection
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250-myhost.test.ex Hello CALLER at test.ex
+250-SIZE 52428800
+250-8BITMIME
+250-PIPELINING
+250 HELP
+250 OK
+250 Accepted
+354 Enter message, ending with "." on a line by itself
+250 OK id=10HmbD-0005vi-00
+221 myhost.test.ex closing connection

******** SERVER ********
Listening on TESTSUITE/eximdir/clam_sock ...
Connection request
<SCAN TESTSUITE/spool/scan/10HmbB-0005vi-00/10HmbB-0005vi-00.eml
>LF>scanned_file_name: OK

-Unexpected EOF read from client
+Expected EOF read from client
End of script
Listening on TESTSUITE/eximdir/clam_sock ...
Connection request
<SCAN TESTSUITE/spool/scan/10HmaX-0005vi-00/10HmaX-0005vi-00.eml
>LF>scanned_file_name: 666 ERROR

-Unexpected EOF read from client
+Expected EOF read from client
End of script
Listening on TESTSUITE/eximdir/clam_sock ...
Connection request
<SCAN TESTSUITE/spool/scan/10HmbA-0005vi-00/10HmbA-0005vi-00.eml
>LF>scanned_file_name: VNAME FOUND

-Unexpected EOF read from client
+Expected EOF read from client
End of script
Listening on TESTSUITE/eximdir/clam_sock ...
Connection request
@@ -97,5 +108,24 @@ Listening on TESTSUITE/eximdir/clam_sock ...
Connection request
<SCAN TESTSUITE/spool/scan/10HmbC-0005vi-00/10HmbC-0005vi-00.eml
>LF>scanned_file_name: OK

-Unexpected EOF read from client
+Expected EOF read from client
+End of script
+Listening on port 1225 ... 
+Connection request from [127.0.0.1]
+<zINSTREAM
+<X-Envelope-From: <CALLER@???>
+<X-Envelope-To: userx@???
+<Received: from CALLER (helo=test.ex)
+<    by myhost.test.ex with local-esmtp (Exim x.yz)
+<    (envelope-from <CALLER@???>)
+<    id 10HmbD-0005vi-00
+<    for userx@???; Tue, 2 Mar 1999 09:44:33 +0000
+<Date: Tue, 2 Mar 1999 09:44:33 +0000
+<Subject: message should be accepted
+<Message-Id: <E10HmbD-0005vi-00@???>
+<From: CALLER_NAME <CALLER@???>
+<
+<
+>LF>scanned_file_name: OK
+Expected EOF read from client
 End of script