Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub Data Model to display admin-add events instead of UNKNOWN_ROLE #979

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions data_models/github_data_model.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import panther_event_type_helpers as event_type

ADMIN_EVENTS = {
"business.add_admin",
"business.invite_admin",
"team.promote_maintainer",
}

def get_admin_role(_):
# github doesn't record the admin role in the event
return "<UNKNOWN_ROLE>"

def get_admin_role(event):
action = event.get("action", "")
return action if action in ADMIN_EVENTS else "<UNKNOWN_ADMIN_ROLE>"


def get_event_type(event):
if event.get("action") == "team.promote_maintainer":
if event.get("action", "") in ADMIN_EVENTS:
return event_type.ADMIN_ROLE_ASSIGNED
if event.get("action") == "org.disable_two_factor_requirement":
if event.get("action", "") == "org.disable_two_factor_requirement":
return event_type.MFA_DISABLED
return None
27 changes: 27 additions & 0 deletions rules/standard_rules/admin_assigned.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,33 @@ Tests:
"p_log_type": "GitHub.Audit",
"user": "bob"
}
- Name: Github - Admin Added
ExpectedResult: true
Log:
{
"actor": "cat",
"action": "business.add_admin",
"p_log_type": "GitHub.Audit",
"user": "bob"
}
- Name: Github - Admin Invited
ExpectedResult: true
Log:
{
"actor": "cat",
"action": "business.invite_admin",
"p_log_type": "GitHub.Audit",
"user": "bob"
}
- Name: Github - Unknown Admin Role
ExpectedResult: false
Log:
{
"actor": "cat",
"action": "unknown.admin_role",
"p_log_type": "GitHub.Audit",
"user": "bob"
}
-
Name: Zendesk - Admin Role Downgraded
ExpectedResult: false
Expand Down