-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new and improved Notion rules for demo
- Loading branch information
1 parent
02ce284
commit a519c40
Showing
8 changed files
with
225 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from panther_notion_helpers import notion_alert_context | ||
|
||
EVENTS = ( | ||
"teamspace.settings.allow_public_page_sharing_setting_updated", | ||
"teamspace.settings.allow_guests_setting_updated", | ||
"teamspace.settings.allow_content_export_setting_updated", | ||
"workspace.settings.allow_public_page_sharing_setting_updated", | ||
"workspace.settings.allow_guests_setting_updated", | ||
"workspace.settings.allow_content_export_setting_updated", | ||
) | ||
|
||
|
||
def rule(event): | ||
return all( | ||
[ | ||
event.deep_get("event", "type", default="") in EVENTS, | ||
event.deep_get("event", "details", "state", default="") == "enabled", | ||
] | ||
) | ||
|
||
|
||
def title(event): | ||
actor = event.deep_get("event", "actor", "person", "email", default="NO_ACTOR_FOUND") | ||
action = event.deep_get("event", "type", default="NO.EVENT.FOUND").split(".")[2] | ||
teamspace = event.deep_get("event", "details", "target", "name", default=None) | ||
if teamspace: | ||
return f"[{actor}] enabled [{action}] for [{teamspace}] Teamspace" | ||
return f"[{actor}] enabled [{action}] for Workspace" | ||
|
||
|
||
def alert_context(event): | ||
return notion_alert_context(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
AnalysisType: rule | ||
Filename: notion_sharing_settings_updated.py | ||
RuleID: "Notion.SharingSettingsUpdated" | ||
DisplayName: "Notion Sharing Settings Updated" | ||
Enabled: true | ||
LogTypes: | ||
- Notion.AuditLogs | ||
Tags: | ||
- Notion | ||
- Data Exfiltration | ||
Description: A Notion User enabled sharing for a Workspace or Teamspace. | ||
Severity: Medium | ||
DedupPeriodMinutes: 60 | ||
Threshold: 1 | ||
Runbook: Possible Data Exfiltration. Follow up with the Notion User to determine if this was done for a valid business reason. | ||
Tests: | ||
- ExpectedResult: true | ||
Log: | ||
{ | ||
"event": { | ||
"actor": { | ||
"id": "c16137bb-5078-4eac-b026-5cbd2f9a027a", | ||
"object": "user", | ||
"person": { | ||
"email": "[email protected]" | ||
}, | ||
"type": "person" | ||
}, | ||
"details": { | ||
"state": "enabled", | ||
}, | ||
"id": "91b29a4b-4978-40e1-ab56-40221f801ce5", | ||
"ip_address": "11.22.33.44", | ||
"platform": "web", | ||
"timestamp": "2023-12-13 16:39:06.860000000", | ||
"type": "workspace.settings.allow_guests_setting_updated", | ||
"workspace_id": "ea65b016-6abc-4dcf-808b-e119617b55d1" | ||
}, | ||
} | ||
Name: Sharing Enabled | ||
- ExpectedResult: false | ||
Log: | ||
{ | ||
"event": { | ||
"actor": { | ||
"id": "c16137bb-5078-4eac-b026-5cbd2f9a027a", | ||
"object": "user", | ||
"person": { | ||
"email": "[email protected]" | ||
}, | ||
"type": "person" | ||
}, | ||
"details": { | ||
"state": "disabled", | ||
"target": { | ||
"id": "a70a4074-5cac-4fc5-8e59-109df81e5a93", | ||
"name": "R&D", | ||
"object": "teamspace" | ||
} | ||
}, | ||
"id": "91b29a4b-4978-40e1-ab56-40221f801ce5", | ||
"ip_address": "11.22.33.44", | ||
"platform": "web", | ||
"timestamp": "2023-12-13 16:39:06.860000000", | ||
"type": "teamspace.settings.allow_guests_setting_updated", | ||
"workspace_id": "ea65b016-6abc-4dcf-808b-e119617b55d1" | ||
}, | ||
} | ||
Name: Sharing Disabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from panther_notion_helpers import notion_alert_context | ||
|
||
|
||
def rule(event): | ||
added = ( | ||
event.deep_get("event", "type", default="") == "teamspace.permissions.member_added" | ||
and event.deep_get("event", "details", "role", default="") == "owner" | ||
) | ||
updated = ( | ||
event.deep_get("event", "type", default="") == "teamspace.permissions.member_role_updated" | ||
and event.deep_get("event", "details", "new_role", default="") == "owner" | ||
) | ||
return added or updated | ||
|
||
|
||
def title(event): | ||
actor = event.deep_get("event", "actor", "person", "email", default="NO_ACTOR_FOUND") | ||
member = event.deep_get( | ||
"event", "details", "member", "person", "email", default="NO_MEMBER_FOUND" | ||
) | ||
teamspace = event.deep_get("event", "details", "target", "name", default="NO_TEAMSPACE_FOUND") | ||
return f"[{actor}] added [{member}] as owner of [{teamspace}] Teamspace" | ||
|
||
|
||
def alert_context(event): | ||
return notion_alert_context(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
AnalysisType: rule | ||
Filename: notion_teamspace_owner_added.py | ||
RuleID: "Notion.TeamspaceOwnerAdded" | ||
DisplayName: "Notion Teamspace Owner Added" | ||
Enabled: true | ||
LogTypes: | ||
- Notion.AuditLogs | ||
Tags: | ||
- Notion | ||
- Privilege Escalation | ||
Description: A Notion User was added as a Teamspace owner. | ||
Severity: Medium | ||
DedupPeriodMinutes: 60 | ||
Threshold: 1 | ||
Runbook: Possible Privilege Escalation. Follow up with the Notion User to determine if this was done for a valid business reason. | ||
Tests: | ||
- ExpectedResult: false | ||
Log: | ||
{ | ||
"event": { | ||
"actor": { | ||
"id": "c16137bb-5078-4eac-b026-5cbd2f9a027a", | ||
"object": "user", | ||
"person": { | ||
"email": "[email protected]" | ||
}, | ||
"type": "person" | ||
}, | ||
"details": { | ||
"member": { | ||
"id": "c16137bb-5078-4eac-b026-5cbd2f9a027a", | ||
"object": "user", | ||
"person": { | ||
"email": "[email protected]" | ||
}, | ||
"type": "person" | ||
}, | ||
"role": "member", | ||
"target": { | ||
"id": "b8db234d-71eb-49e2-a5ed-7935ca764920", | ||
"name": "General", | ||
"object": "teamspace" | ||
} | ||
}, | ||
"id": "eed75a56-ca1b-453b-afd8-73789bc19398", | ||
"ip_address": "11.22.33.44", | ||
"platform": "web", | ||
"timestamp": "2023-12-13 16:20:14.966000000", | ||
"type": "teamspace.permissions.member_added", | ||
"workspace_id": "ea65b016-6abc-4dcf-808b-e119617b55d1" | ||
} | ||
} | ||
Name: Member Added | ||
- ExpectedResult: true | ||
Log: | ||
{ | ||
"event": { | ||
"actor": { | ||
"id": "c16137bb-5078-4eac-b026-5cbd2f9a027a", | ||
"object": "user", | ||
"person": { | ||
"email": "[email protected]" | ||
}, | ||
"type": "person" | ||
}, | ||
"details": { | ||
"member": { | ||
"id": "c16137bb-5078-4eac-b026-5cbd2f9a027a", | ||
"object": "user", | ||
"person": { | ||
"email": "[email protected]" | ||
}, | ||
"type": "person" | ||
}, | ||
"new_role": "owner", | ||
"target": { | ||
"id": "b8db234d-71eb-49e2-a5ed-7935ca764920", | ||
"name": "General", | ||
"object": "teamspace" | ||
} | ||
}, | ||
"id": "6019b995-0158-4430-8263-89ad7905bd1d", | ||
"ip_address": "11.22.33.44", | ||
"platform": "web", | ||
"timestamp": "2023-12-13 16:38:04.264000000", | ||
"type": "teamspace.permissions.member_role_updated", | ||
"workspace_id": "ea65b016-6abc-4dcf-808b-e119617b55d1" | ||
} | ||
} | ||
Name: Owner Added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters