-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MongoDB.External.UserInvited.NoConfig rule (#1191)
Co-authored-by: Ariel Ropek <79653153+arielkr256@users.noreply.github.com>
- Loading branch information
1 parent
1a2458b
commit 207b0fc
Showing
3 changed files
with
84 additions
and
0 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
24 changes: 24 additions & 0 deletions
24
rules/mongodb_rules/mongodb_external_user_invited_no_config.py
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,24 @@ | ||
from panther_mongodb_helpers import mongodb_alert_context | ||
|
||
|
||
def rule(event): | ||
if event.deep_get("eventTypeName", default="") != "INVITED_TO_ORG": | ||
return False | ||
|
||
user_who_sent_an_invitation = event.deep_get("username", default="") | ||
user_who_was_invited = event.deep_get("targetUsername", default="") | ||
domain = user_who_sent_an_invitation.split("@")[-1] | ||
|
||
email_domains_are_different = not user_who_was_invited.endswith(domain) | ||
return email_domains_are_different | ||
|
||
|
||
def title(event): | ||
actor = event.get("username", "<USER_NOT_FOUND>") | ||
target = event.get("targetUsername", "<USER_NOT_FOUND>") | ||
org_id = event.get("orgId", "<ORG_NOT_FOUND>") | ||
return f"MongoDB Atlas: [{actor}] invited external user [{target}] to the org [{org_id}]" | ||
|
||
|
||
def alert_context(event): | ||
return mongodb_alert_context(event) |
59 changes: 59 additions & 0 deletions
59
rules/mongodb_rules/mongodb_external_user_invited_no_config.yml
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,59 @@ | ||
AnalysisType: rule | ||
Description: "An external user has been invited to a MongoDB org (no config)." | ||
DisplayName: "MongoDB External User Invited (no config)" | ||
Enabled: true | ||
Filename: mongodb_external_user_invited_no_config.py | ||
Severity: High | ||
Reference: https://www.mongodb.com/docs/v4.2/tutorial/create-users/ | ||
Tests: | ||
- ExpectedResult: false | ||
Log: | ||
created: "2023-06-07 16:57:55" | ||
currentValue: {} | ||
eventTypeName: INVITED_TO_ORG | ||
id: 6480b7139bd8a012345ABCDE | ||
isGlobalAdmin: false | ||
links: | ||
- href: https://cloud.mongodb.com/api/atlas/v1.0/orgs/12345xyzlmnce4f17d6e8e130/events/6480b7139bd8a012345ABCDE | ||
rel: self | ||
orgId: 12345xyzlmnce4f17d6e8e130 | ||
p_event_time: "2023-06-07 16:57:55" | ||
p_log_type: MongoDB.OrganizationEvent | ||
p_parse_time: "2023-06-07 17:04:42.59" | ||
p_row_id: ea276b16216684d9e198c0d0188a3d | ||
p_schema_version: 0 | ||
p_source_id: 7c3cb124-9c30-492c-99e6-46518c232d73 | ||
p_source_label: MongoDB | ||
remoteAddress: 1.2.3.4 | ||
targetUsername: insider@company.com | ||
userId: 647f654f93bebc69123abc1 | ||
username: user@company.com | ||
Name: Internal Invite | ||
- ExpectedResult: true | ||
Log: | ||
created: "2023-06-07 16:57:55" | ||
currentValue: {} | ||
eventTypeName: INVITED_TO_ORG | ||
id: 6480b7139bd8a012345ABCDE | ||
isGlobalAdmin: false | ||
links: | ||
- href: https://cloud.mongodb.com/api/atlas/v1.0/orgs/12345xyzlmnce4f17d6e8e130/events/6480b7139bd8a012345ABCDE | ||
rel: self | ||
orgId: 12345xyzlmnce4f17d6e8e130 | ||
p_event_time: "2023-06-07 16:57:55" | ||
p_log_type: MongoDB.OrganizationEvent | ||
p_parse_time: "2023-06-07 17:04:42.59" | ||
p_row_id: ea276b16216684d9e198c0d0188a3d | ||
p_schema_version: 0 | ||
p_source_id: 7c3cb124-9c30-492c-99e6-46518c232d73 | ||
p_source_label: MongoDB | ||
remoteAddress: 1.2.3.4 | ||
targetUsername: outsider@other.com | ||
userId: 647f654f93bebc69123abc1 | ||
username: user@company.com | ||
Name: External User Invite | ||
DedupPeriodMinutes: 60 | ||
LogTypes: | ||
- MongoDB.OrganizationEvent | ||
RuleID: "MongoDB.External.UserInvited.NoConfig" | ||
Threshold: 1 |