From: Jeremy Harris Date: Sun, 17 Jan 2021 19:59:51 +0000 (+0000) Subject: Testsuite: testcase for ClamAV over TCP X-Git-Url: https://git.exim.org/users/heiko/exim.git/commitdiff_plain/0cedb352e62898761b701af0c400df8ae1989383 Testsuite: testcase for ClamAV over TCP --- diff --git a/test/README b/test/README index c0f548292..bca17eb18 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 4c7059fdf..f8b216b99 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 33f47f90e..1b7196869 100644 --- a/test/log/4006 +++ b/test/log/4006 @@ -14,3 +14,6 @@ 1999-03-02 09:44:33 10HmbC-0005vi-00 <= CALLER@myhost.test.ex 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: R=r 1999-03-02 09:44:33 10HmbC-0005vi-00 Completed +1999-03-02 09:44:33 10HmbD-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss T="message should be accepted" +1999-03-02 09:44:33 10HmbD-0005vi-00 => :blackhole: 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 d251c1a1f..91d08bd68 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 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: @@ -24,15 +25,16 @@ quit # # # +# fail/error server DIR/eximdir/clam_sock 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: @@ -46,15 +48,16 @@ quit # # # +# fail/virus-found server DIR/eximdir/clam_sock 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: @@ -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: @@ -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: @@ -109,13 +114,14 @@ quit # # # +# connect-fail (server not initially listenting), retry server -i 2 DIR/eximdir/clam_sock 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: @@ -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 +LF>scanned_file_name: OK +*eof +**** +# +exim -odi -bs -DSRV="127.0.0.1 PORT_D" -DOPT= +ehlo test.ex +mail from:<> +rcpt to: +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 4d858c5b1..b4a72b826 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 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 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 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 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] + +) +< id 10HmbD-0005vi-00 +< for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 + + +< +< +>LF>scanned_file_name: OK +Expected EOF read from client End of script