From be983bb96bfe5bdbce6271513dc5f7df7b06dc09 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 24 Apr 2024 11:48:33 +0200 Subject: [PATCH] feat(storage-users): add scandata to upload command Signed-off-by: jkoberg --- services/antivirus/pkg/service/service.go | 3 +-- services/storage-users/pkg/command/uploads.go | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/services/antivirus/pkg/service/service.go b/services/antivirus/pkg/service/service.go index 21ab9a7745..a1d41c651c 100644 --- a/services/antivirus/pkg/service/service.go +++ b/services/antivirus/pkg/service/service.go @@ -146,7 +146,7 @@ func (av Antivirus) processEvent(e events.Event, s events.Publisher) error { } if av.c.DebugScanOutcome != "" { - av.l.Warn().Str("antivir, clamav", ">>>>>>> ANTIVIRUS_DEBUG_SCAN_OUTCOME IS SET NO ACTUAL VIRUS SCAN IS PERFORMED!") + av.l.Warn().Str("antivir, clamav", ">>>>>>> ANTIVIRUS_DEBUG_SCAN_OUTCOME IS SET NO ACTUAL VIRUS SCAN IS PERFORMED!").Send() if err := events.Publish(ctx, s, events.PostprocessingStepFinished{ FinishedStep: events.PPStepAntivirus, Outcome: events.PostprocessingOutcome(av.c.DebugScanOutcome), @@ -158,7 +158,6 @@ func (av Antivirus) processEvent(e events.Event, s events.Publisher) error { Description: "DEBUG: forced outcome", Scandate: time.Now(), ResourceID: ev.ResourceID, - ErrorMsg: "DEBUG: forced outcome", }, }); err != nil { av.l.Fatal().Err(err).Str("uploadid", ev.UploadID).Interface("resourceID", ev.ResourceID).Msg("cannot publish events - exiting") diff --git a/services/storage-users/pkg/command/uploads.go b/services/storage-users/pkg/command/uploads.go index e5ae4f2561..433773637c 100644 --- a/services/storage-users/pkg/command/uploads.go +++ b/services/storage-users/pkg/command/uploads.go @@ -191,6 +191,7 @@ func ListUploadSessions(cfg *config.Config) *cli.Command { if c.Bool("json") { for _, u := range uploads { ref := u.Reference() + sr, sd := u.ScanData() s := struct { ID string `json:"id"` Space string `json:"space"` @@ -201,6 +202,8 @@ func ListUploadSessions(cfg *config.Config) *cli.Command { SpaceOwner *userpb.UserId `json:"spaceowner,omitempty"` Expires time.Time `json:"expires"` Processing bool `json:"processing"` + ScanDate time.Time `json:"virus_scan_date"` + ScanResult string `json:"virus_scan_result"` }{ Space: ref.GetResourceId().GetSpaceId(), ID: u.ID(), @@ -211,6 +214,8 @@ func ListUploadSessions(cfg *config.Config) *cli.Command { SpaceOwner: u.SpaceOwner(), Expires: u.Expires(), Processing: u.IsProcessing(), + ScanDate: sd, + ScanResult: sr, } j, err := json.Marshal(s) if err != nil { @@ -236,10 +241,11 @@ func ListUploadSessions(cfg *config.Config) *cli.Command { // start a table table = tw.NewWriter(os.Stdout) - table.SetHeader([]string{"Space", "Upload Id", "Name", "Offset", "Size", "Executant", "Owner", "Expires", "Processing"}) + table.SetHeader([]string{"Space", "Upload Id", "Name", "Offset", "Size", "Executant", "Owner", "Expires", "Processing", "Scan Date", "Scan Result"}) table.SetAutoFormatHeaders(false) for _, u := range uploads { + sr, sd := u.ScanData() table.Append([]string{ u.Reference().ResourceId.GetSpaceId(), u.ID(), @@ -250,6 +256,8 @@ func ListUploadSessions(cfg *config.Config) *cli.Command { u.SpaceOwner().GetOpaqueId(), u.Expires().Format(time.RFC3339), strconv.FormatBool(u.IsProcessing()), + sd.Format(time.RFC3339), + sr, }) if c.Bool("restart") {