Hi there Tom! Hope you're doing great.
Upon creating your same rule in the /var/ossec/etc/rules/local_rules.xml file (this file is not lost during the upgrade process so please be aware of it) I found the same issue as you had.
I then tried this:
1. Change the SID to rule 91537 and not 91531, as that's the specific rule that matched and the rule we want to "fork" from.
2. Change the regex type, using PCRE2 which is newer and allows for better handling of regex.
3. Add an escape character for the forward slash
4. I also changed the field name from "data.office365.SourceRelativeUrl" to just "office365.SourceRelativeUrl". At least my logtest utility wasn't including the "data." part, not sure why. We might have different versions so check for that part in your end.
Finally, this is what the rule would look like (I changed the ID but that's not needed, it's just because I already had a custom rule with your ID)
<group name="office365,">
<rule id="100111" level="13">
<if_sid>91537</if_sid>
<field name="office365.SourceRelativeUrl" type="pcre2">^Documents\/Confidential$</field>
<description>Office 365: Access to confidential file.</description>
<options>no_full_log</options>
<group>SharePointFileOperation,hipaa_164.312.b,hipaa_164.312.c.1,pci_dss_10.6.2,pci_dss_11.5</group>
<mitre>
<id>T1078</id>
</mitre>
</rule>
</group>
And upon running the wauzh-logtest utility, I see that it's working as expected:
root@wazuh:/# /var/ossec/bin/wazuh-logtest
Starting wazuh-logtest v4.4.5
Type one log per line
{"integration":"office365","office365":{"AppAccessContext":{"AADSessionId":"6a9e6789-#######-9be7-8538d52cbf85","ClientAppName":"Unknown","CorrelationId":"402933a1-60a3-9000-35ac-0c25ec1f91a1","TokenIssuedAtTime":"2024-06-15T20:33:02","UniqueTokenId":"-#######"},"CreationTime":"2024-06-16T09:35:52","Id":"354ee104--#######ae0a-08dc8de7b6d3","Operation":"FilePreviewed","OrganizationId":"2d78dcf1--#######-92fd004d07b1","RecordType":6,"UserKey":"i:0h.f|membership|-#######@live.com","UserType":0,"Version":1,"Workload":"OneDrive","ClientIP":"85.195.241.213","UserId":"tom.-#######.onmicrosoft.com","AuthenticationType":"OAuth","BrowserName":"Chrome","BrowserVersion":"126.0.0.0","CorrelationId":"402933a1--#######-35ac-0c25ec1f91a1","EventSource":"SharePoint","IsManagedDevice":false,"ItemType":"File","ListId":"e4cf29f6-1b0e-41af-9a65-03c4cb805909","ListItemUniqueId":"156c935e-053c-459e-8212-8de4137f62aa","Platform":"MacOSX","Site":"50834d26-afd3-4959-a311-aa87aac3e382","UserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36","WebId":"4bdf3a3f-5b82-427d-8653-9ef52126f9d0","DeviceDisplayName":"2a01:111:2056:200:41ac:4d1:5daa:33ed","HighPriorityMediaProcessing":false,"ListBaseType":1,"ListServerTemplate":700,"SourceFileExtension":"docx","SiteUrl":"https://-#######-my.sharepoint.com/personal/-#######_onmicrosoft_com/","SourceRelativeUrl":"Documents/Confidential","SourceFileName":"CanaryToken-SuperSecret.docx","ApplicationDisplayName":"Unknown","ObjectId":"https://-#######-my.sharepoint.com/personal/-#######_onmicrosoft_com/Documents/Confidential/CanaryToken-SuperSecret.docx","Subscription":"Audit.SharePoint"}}
**Phase 1: Completed pre-decoding.
**Phase 2: Completed decoding.
name: 'json'
integration: 'office365'
office365.AppAccessContext.AADSessionId: '6a9e6789-#######-9be7-8538d52cbf85'
office365.AppAccessContext.ClientAppName: 'Unknown'
office365.AppAccessContext.CorrelationId: '402933a1-60a3-9000-35ac-0c25ec1f91a1'
office365.AppAccessContext.TokenIssuedAtTime: '2024-06-15T20:33:02'
office365.AppAccessContext.UniqueTokenId: '-#######'
office365.ApplicationDisplayName: 'Unknown'
office365.AuthenticationType: 'OAuth'
office365.BrowserName: 'Chrome'
office365.BrowserVersion: '126.0.0.0'
office365.ClientIP: '85.195.241.213'
office365.CorrelationId: '402933a1--#######-35ac-0c25ec1f91a1'
office365.CreationTime: '2024-06-16T09:35:52'
office365.DeviceDisplayName: '2a01:111:2056:200:41ac:4d1:5daa:33ed'
office365.EventSource: 'SharePoint'
office365.HighPriorityMediaProcessing: 'false'
office365.Id: '354ee104--#######ae0a-08dc8de7b6d3'
office365.IsManagedDevice: 'false'
office365.ItemType: 'File'
office365.ListBaseType: '1'
office365.ListId: 'e4cf29f6-1b0e-41af-9a65-03c4cb805909'
office365.ListItemUniqueId: '156c935e-053c-459e-8212-8de4137f62aa'
office365.ListServerTemplate: '700'
office365.ObjectId: 'https://-#######-my.sharepoint.com/personal/-#######_onmicrosoft_com/Documents/Confidential/CanaryToken-SuperSecret.docx'
office365.Operation: 'FilePreviewed'
office365.OrganizationId: '2d78dcf1--#######-92fd004d07b1'
office365.Platform: 'MacOSX'
office365.RecordType: '6'
office365.Site: '50834d26-afd3-4959-a311-aa87aac3e382'
office365.SiteUrl: 'https://-#######-my.sharepoint.com/personal/-#######_onmicrosoft_com/'
office365.SourceFileExtension: 'docx'
office365.SourceFileName: 'CanaryToken-SuperSecret.docx'
office365.SourceRelativeUrl: 'Documents/Confidential'
office365.Subscription: 'Audit.SharePoint'
office365.UserAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
office365.UserId: 'tom.-#######.onmicrosoft.com'
office365.UserKey: 'i:0h.f|membership|-#######@live.com'
office365.UserType: '0'
office365.Version: '1'
office365.WebId: '4bdf3a3f-5b82-427d-8653-9ef52126f9d0'
office365.Workload: 'OneDrive'
**Phase 3: Completed filtering (rules).
id: '100111'
level: '13'
description: ' Office 365: Access to confidential file.
'
groups: '['office365', 'SharePointFileOperation']'
firedtimes: '1'
hipaa: '['164.312.b', '164.312.c.1']'
mail: 'True'
mitre.id: '['T1078']'
mitre.tactic: '['Defense Evasion', 'Persistence', 'Privilege Escalation', 'Initial Access']'
mitre.technique: '['Valid Accounts']'
pci_dss: '['10.6.2', '11.5']'
**Alert to be generated.
Related docs I used to check your answer:
Let me know if that helps.
Eric