From 6dde3f6ef6cd113073dfea7ad9b62e98f99756d7 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 30 Mar 2023 18:16:43 +0200 Subject: [PATCH 1/2] add more logging to antivirus --- changelog/unreleased/av-more-logging.md | 5 +++++ services/antivirus/pkg/service/service.go | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 changelog/unreleased/av-more-logging.md diff --git a/changelog/unreleased/av-more-logging.md b/changelog/unreleased/av-more-logging.md new file mode 100644 index 0000000000..f9887b8bd2 --- /dev/null +++ b/changelog/unreleased/av-more-logging.md @@ -0,0 +1,5 @@ +Enhancement: Add more logging to av service + +We need more debug logging in some situations to understand the state of a virus scan. + +https://github.com/owncloud/ocis/pull/5973 diff --git a/services/antivirus/pkg/service/service.go b/services/antivirus/pkg/service/service.go index 1cc427720a..15ce0c48e9 100644 --- a/services/antivirus/pkg/service/service.go +++ b/services/antivirus/pkg/service/service.go @@ -102,6 +102,7 @@ func (av Antivirus) Run() error { continue } + av.l.Info().Str("uploadid", ev.UploadID).Str("filename", ev.Filename).Msg("Starting virus scan.") var errmsg string res, err := av.process(ev) if err != nil { @@ -144,6 +145,7 @@ func (av Antivirus) Run() error { // process the scan func (av Antivirus) process(ev events.StartPostprocessingStep) (scanners.ScanResult, error) { if ev.Filesize == 0 || (0 < av.m && av.m < ev.Filesize) { + av.l.Debug().Str("uploadid", ev.UploadID).Uint64("limit", av.m).Uint64("filesize", ev.Filesize).Msg("Skipping file because file size is higher than the limit.") return scanners.ScanResult{ Scantime: time.Now(), }, nil @@ -163,6 +165,7 @@ func (av Antivirus) process(ev events.StartPostprocessingStep) (scanners.ScanRes return scanners.ScanResult{}, err } defer rrc.Close() + av.l.Debug().Str("uploadid", ev.UploadID).Msg("Downloaded file successfully.") res, err := av.s.Scan(rrc) if err != nil { From 16d97d5393d9bc9580db718b35481a8ec9ed5479 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Tue, 4 Apr 2023 11:10:36 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: kobergj --- services/antivirus/pkg/service/service.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/antivirus/pkg/service/service.go b/services/antivirus/pkg/service/service.go index 15ce0c48e9..cc29e6c517 100644 --- a/services/antivirus/pkg/service/service.go +++ b/services/antivirus/pkg/service/service.go @@ -102,7 +102,7 @@ func (av Antivirus) Run() error { continue } - av.l.Info().Str("uploadid", ev.UploadID).Str("filename", ev.Filename).Msg("Starting virus scan.") + av.l.Debug().Str("uploadid", ev.UploadID).Str("filename", ev.Filename).Msg("Starting virus scan.") var errmsg string res, err := av.process(ev) if err != nil { @@ -145,7 +145,7 @@ func (av Antivirus) Run() error { // process the scan func (av Antivirus) process(ev events.StartPostprocessingStep) (scanners.ScanResult, error) { if ev.Filesize == 0 || (0 < av.m && av.m < ev.Filesize) { - av.l.Debug().Str("uploadid", ev.UploadID).Uint64("limit", av.m).Uint64("filesize", ev.Filesize).Msg("Skipping file because file size is higher than the limit.") + av.l.Info().Str("uploadid", ev.UploadID).Uint64("limit", av.m).Uint64("filesize", ev.Filesize).Msg("Skipping file to be virus scanned because its file size is higher than the defined limit.") return scanners.ScanResult{ Scantime: time.Now(), }, nil @@ -165,7 +165,7 @@ func (av Antivirus) process(ev events.StartPostprocessingStep) (scanners.ScanRes return scanners.ScanResult{}, err } defer rrc.Close() - av.l.Debug().Str("uploadid", ev.UploadID).Msg("Downloaded file successfully.") + av.l.Debug().Str("uploadid", ev.UploadID).Msg("Downloaded file successfully, starting virusscan") res, err := av.s.Scan(rrc) if err != nil {