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

[sync] GitHub Data Model Admin Actions update (#79) #1104

Merged
merged 2 commits into from
Feb 13, 2024
Merged
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
13 changes: 12 additions & 1 deletion data_models/github_data_model.py
Original file line number Diff line number Diff line change
@@ -6,14 +6,25 @@
"team.promote_maintainer",
}

CONDITIONAL_ADMIN_EVENTS = {
"team.add_repository",
}


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


def get_event_type(event):
if event.get("action", "") in ADMIN_EVENTS:
action = event.get("action", "")
permission = event.get("permission", "")
if action in ADMIN_EVENTS:
return event_type.ADMIN_ROLE_ASSIGNED
if action in CONDITIONAL_ADMIN_EVENTS and permission == "admin":
return event_type.ADMIN_ROLE_ASSIGNED
if event.get("action", "") == "org.disable_two_factor_requirement":
return event_type.MFA_DISABLED