From 5255517067a0792a687ee697044ad2a4420fe8fb Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Sat, 4 Mar 2023 02:51:44 +0530 Subject: [PATCH] Log if file tagged as malware by graph (#2700) Graph exposes a "malware" filed in the delta response. This just logs that if we fail to download an item. --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [ ] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * # #### Test Plan - [ ] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/internal/connector/onedrive/collection.go | 7 ++++++- src/internal/connector/onedrive/drive.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/internal/connector/onedrive/collection.go b/src/internal/connector/onedrive/collection.go index 1be32dbf0..16d442182 100644 --- a/src/internal/connector/onedrive/collection.go +++ b/src/internal/connector/onedrive/collection.go @@ -410,7 +410,12 @@ func (oc *Collection) populateItems(ctx context.Context, errs *fault.Bus) { // check for errors following retries if err != nil { - logger.Ctx(ctx).With("error", err.Error()).Error("downloading item") + if item.GetMalware() != nil { + logger.Ctx(ctx).With("error", err.Error(), "malware", true).Error("downloading item") + } else { + logger.Ctx(ctx).With("error", err.Error()).Error("downloading item") + } + el.AddRecoverable(clues.Stack(err).WithClues(ctx).Label(fault.LabelForceNoBackupCreation)) return nil, err } diff --git a/src/internal/connector/onedrive/drive.go b/src/internal/connector/onedrive/drive.go index bcc78b124..e6cab77fd 100644 --- a/src/internal/connector/onedrive/drive.go +++ b/src/internal/connector/onedrive/drive.go @@ -183,6 +183,7 @@ func defaultItemPager( "sharepointIds", "size", "deleted", + "malware", }, ) }