Add parent path information to malware detected items (#3221)
This allows identifying the file location when an item is detected with malware --- #### Does this PR need a docs update or release note? - [x] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #3112 #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
559ad37a7e
commit
6395dcbe39
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Permissions backup for OneDrive is now out of experimental (By default, only newly backed up items will have their permissions backed up. You will have to run a full backup to ensure all items have their permissions backed up.)
|
||||
- LocationRef is now populated for all services and data types. It should be used in place of RepoRef if a location for an item is required.
|
||||
- User selection for Exchange and OneDrive can accept either a user PrincipalName or the user's canonical ID.
|
||||
- Add path information to items that were skipped during backup because they were flagged as malware.
|
||||
|
||||
### Fixed
|
||||
- Fixed permissions restore in latest backup version.
|
||||
|
||||
@ -317,6 +317,15 @@ func ItemInfo(item models.DriveItemable) map[string]any {
|
||||
if parent != nil {
|
||||
m[fault.AddtlContainerID] = ptr.Val(parent.GetId())
|
||||
m[fault.AddtlContainerName] = ptr.Val(parent.GetName())
|
||||
containerPath := ""
|
||||
|
||||
// Remove the "/drives/b!vF-sdsdsds-sdsdsa-sdsd/root:" prefix
|
||||
splitPath := strings.SplitN(ptr.Val(parent.GetPath()), ":", 2)
|
||||
if len(splitPath) > 1 {
|
||||
containerPath = splitPath[1]
|
||||
}
|
||||
|
||||
m[fault.AddtlContainerPath] = containerPath
|
||||
}
|
||||
|
||||
malware := item.GetMalware()
|
||||
|
||||
@ -269,6 +269,8 @@ func (suite *GraphErrorsUnitSuite) TestMalwareInfo() {
|
||||
ref = models.ItemReference{}
|
||||
refCID = "container-id"
|
||||
refCN = "container-name"
|
||||
refCP = "/drives/b!vF-sdsdsds-sdsdsa-sdsd/root:/Folder/container-name"
|
||||
refCPexp = "/Folder/container-name"
|
||||
mal = models.Malware{}
|
||||
malDesc = "malware-description"
|
||||
)
|
||||
@ -281,6 +283,7 @@ func (suite *GraphErrorsUnitSuite) TestMalwareInfo() {
|
||||
|
||||
ref.SetId(&refCID)
|
||||
ref.SetName(&refCN)
|
||||
ref.SetPath(&refCP)
|
||||
i.SetParentReference(&ref)
|
||||
|
||||
mal.SetDescription(&malDesc)
|
||||
@ -291,6 +294,7 @@ func (suite *GraphErrorsUnitSuite) TestMalwareInfo() {
|
||||
fault.AddtlLastModBy: lmID,
|
||||
fault.AddtlContainerID: refCID,
|
||||
fault.AddtlContainerName: refCN,
|
||||
fault.AddtlContainerPath: refCPexp,
|
||||
fault.AddtlMalwareDesc: malDesc,
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ const (
|
||||
AddtlLastModBy = "last_modified_by"
|
||||
AddtlContainerID = "container_id"
|
||||
AddtlContainerName = "container_name"
|
||||
AddtlContainerPath = "container_path"
|
||||
AddtlMalwareDesc = "malware_description"
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user