feat(storage-users): add scandata to upload command

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2024-04-26 09:17:45 +02:00
parent dcdf314b8c
commit c80ee6e844
2 changed files with 10 additions and 3 deletions
+1 -2
View File
@@ -146,7 +146,7 @@ func (av Antivirus) processEvent(e events.Event, s events.Publisher) error {
} }
if av.c.DebugScanOutcome != "" { 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{ if err := events.Publish(ctx, s, events.PostprocessingStepFinished{
FinishedStep: events.PPStepAntivirus, FinishedStep: events.PPStepAntivirus,
Outcome: events.PostprocessingOutcome(av.c.DebugScanOutcome), 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", Description: "DEBUG: forced outcome",
Scandate: time.Now(), Scandate: time.Now(),
ResourceID: ev.ResourceID, ResourceID: ev.ResourceID,
ErrorMsg: "DEBUG: forced outcome",
}, },
}); err != nil { }); err != nil {
av.l.Fatal().Err(err).Str("uploadid", ev.UploadID).Interface("resourceID", ev.ResourceID).Msg("cannot publish events - exiting") av.l.Fatal().Err(err).Str("uploadid", ev.UploadID).Interface("resourceID", ev.ResourceID).Msg("cannot publish events - exiting")
@@ -191,6 +191,7 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
if c.Bool("json") { if c.Bool("json") {
for _, u := range uploads { for _, u := range uploads {
ref := u.Reference() ref := u.Reference()
sr, sd := u.ScanData()
s := struct { s := struct {
ID string `json:"id"` ID string `json:"id"`
Space string `json:"space"` Space string `json:"space"`
@@ -201,6 +202,8 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
SpaceOwner *userpb.UserId `json:"spaceowner,omitempty"` SpaceOwner *userpb.UserId `json:"spaceowner,omitempty"`
Expires time.Time `json:"expires"` Expires time.Time `json:"expires"`
Processing bool `json:"processing"` Processing bool `json:"processing"`
ScanDate time.Time `json:"virus_scan_date"`
ScanResult string `json:"virus_scan_result"`
}{ }{
Space: ref.GetResourceId().GetSpaceId(), Space: ref.GetResourceId().GetSpaceId(),
ID: u.ID(), ID: u.ID(),
@@ -211,6 +214,8 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
SpaceOwner: u.SpaceOwner(), SpaceOwner: u.SpaceOwner(),
Expires: u.Expires(), Expires: u.Expires(),
Processing: u.IsProcessing(), Processing: u.IsProcessing(),
ScanDate: sd,
ScanResult: sr,
} }
j, err := json.Marshal(s) j, err := json.Marshal(s)
if err != nil { if err != nil {
@@ -236,10 +241,11 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
// start a table // start a table
table = tw.NewWriter(os.Stdout) 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) table.SetAutoFormatHeaders(false)
for _, u := range uploads { for _, u := range uploads {
sr, sd := u.ScanData()
table.Append([]string{ table.Append([]string{
u.Reference().ResourceId.GetSpaceId(), u.Reference().ResourceId.GetSpaceId(),
u.ID(), u.ID(),
@@ -250,6 +256,8 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
u.SpaceOwner().GetOpaqueId(), u.SpaceOwner().GetOpaqueId(),
u.Expires().Format(time.RFC3339), u.Expires().Format(time.RFC3339),
strconv.FormatBool(u.IsProcessing()), strconv.FormatBool(u.IsProcessing()),
sd.Format(time.RFC3339),
sr,
}) })
if c.Bool("restart") { if c.Bool("restart") {