Skip to content

Commit

Permalink
removed special EICAR result case to maintain API consistency (#1)
Browse files Browse the repository at this point in the history
* removed special EICAR result case to maintain API consistency

* remove EICAR error
  • Loading branch information
bsomes authored Mar 20, 2024
1 parent 4230c1b commit fc44cb6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions clamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ const (
cmdScan = "SCAN"
cmdContscan = "CONTSCAN"
resOk = "OK"
resFound = "FOUND"
resPong = "PONG"
resReloading = "RELOADING"
resNoSuchFile = "No such file or directory. ERROR"
resPermissionDenied = "Permission denied. ERROR"
resCantOpenFile = "Can't open file or directory ERROR"
resEICAR = "Win.Test.EICAR_HDB-1 FOUND"
)

// NewClamd returns a Clamd client with default options.
Expand Down Expand Up @@ -238,8 +238,8 @@ func parseErr(res string, err error) (bool, error) {
if strings.HasSuffix(res, resOk) {
return true, nil
}
if strings.HasSuffix(res, resEICAR) {
return false, errors.Join(ErrEICARFound, fmt.Errorf("%s", res))
if strings.HasSuffix(res, resFound) {
return false, nil
}
if strings.HasSuffix(res, resNoSuchFile) {
return false, errors.Join(ErrNoSuchFileOrDir, fmt.Errorf("%s", res))
Expand Down
7 changes: 3 additions & 4 deletions clamd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clamd

import (
"context"
"errors"
"log"
"os"
"path"
Expand Down Expand Up @@ -76,7 +75,7 @@ func TestScan(t *testing.T) {
defer os.Remove(tf)

got, err := clamd.Scan(context.Background(), tf)
if err != nil && !errors.Is(err, ErrEICARFound) {
if err != nil {
t.Errorf("%v", err)
}
if got {
Expand All @@ -96,7 +95,7 @@ func TestStream(t *testing.T) {
}

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

got, err := clamd.ScanAll(context.Background(), tf)
if err != nil && !errors.Is(err, ErrEICARFound) {
if err != nil {
t.Errorf("%v", err)
}
if got {
Expand Down
1 change: 0 additions & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ var (
ErrCantOpenFile = errors.New("clamd can't open file or dir")
ErrSreamLimitExceeded = errors.New("clamd's INSTREAM size limit exceeded")
ErrUnknown = errors.New("unknown error")
ErrEICARFound = errors.New("Win.Test.EICAR_HDB-1 FOUND")
)

0 comments on commit fc44cb6

Please sign in to comment.