Skip to content

Commit fc44cb6

Browse files
authored
removed special EICAR result case to maintain API consistency (#1)
* removed special EICAR result case to maintain API consistency * remove EICAR error
1 parent 4230c1b commit fc44cb6

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

clamd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ const (
3333
cmdScan = "SCAN"
3434
cmdContscan = "CONTSCAN"
3535
resOk = "OK"
36+
resFound = "FOUND"
3637
resPong = "PONG"
3738
resReloading = "RELOADING"
3839
resNoSuchFile = "No such file or directory. ERROR"
3940
resPermissionDenied = "Permission denied. ERROR"
4041
resCantOpenFile = "Can't open file or directory ERROR"
41-
resEICAR = "Win.Test.EICAR_HDB-1 FOUND"
4242
)
4343

4444
// NewClamd returns a Clamd client with default options.
@@ -238,8 +238,8 @@ func parseErr(res string, err error) (bool, error) {
238238
if strings.HasSuffix(res, resOk) {
239239
return true, nil
240240
}
241-
if strings.HasSuffix(res, resEICAR) {
242-
return false, errors.Join(ErrEICARFound, fmt.Errorf("%s", res))
241+
if strings.HasSuffix(res, resFound) {
242+
return false, nil
243243
}
244244
if strings.HasSuffix(res, resNoSuchFile) {
245245
return false, errors.Join(ErrNoSuchFileOrDir, fmt.Errorf("%s", res))

clamd_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package clamd
22

33
import (
44
"context"
5-
"errors"
65
"log"
76
"os"
87
"path"
@@ -76,7 +75,7 @@ func TestScan(t *testing.T) {
7675
defer os.Remove(tf)
7776

7877
got, err := clamd.Scan(context.Background(), tf)
79-
if err != nil && !errors.Is(err, ErrEICARFound) {
78+
if err != nil {
8079
t.Errorf("%v", err)
8180
}
8281
if got {
@@ -96,7 +95,7 @@ func TestStream(t *testing.T) {
9695
}
9796

9897
got, err := clamd.ScanStream(context.Background(), f)
99-
if err != nil && !errors.Is(err, ErrEICARFound) {
98+
if err != nil {
10099
t.Errorf("%v", err)
101100
}
102101
if got {
@@ -111,7 +110,7 @@ func TestScanAll(t *testing.T) {
111110
defer os.Remove(tf)
112111

113112
got, err := clamd.ScanAll(context.Background(), tf)
114-
if err != nil && !errors.Is(err, ErrEICARFound) {
113+
if err != nil {
115114
t.Errorf("%v", err)
116115
}
117116
if got {

errors.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ var (
1414
ErrCantOpenFile = errors.New("clamd can't open file or dir")
1515
ErrSreamLimitExceeded = errors.New("clamd's INSTREAM size limit exceeded")
1616
ErrUnknown = errors.New("unknown error")
17-
ErrEICARFound = errors.New("Win.Test.EICAR_HDB-1 FOUND")
1817
)

0 commit comments

Comments
 (0)