File tree 2 files changed +38
-5
lines changed
2 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 1
1
import panther_event_type_helpers as event_type
2
2
3
+ ADMIN_EVENTS = {
4
+ "business.add_admin" ,
5
+ "business.invite_admin" ,
6
+ "team.promote_maintainer" ,
7
+ }
3
8
4
- def get_admin_role (_ ):
5
- # github doesn't record the admin role in the event
6
- return "<UNKNOWN_ROLE>"
9
+
10
+ def get_admin_role (event ):
11
+ action = event .get ("action" , "" )
12
+ return action if action in ADMIN_EVENTS else "<UNKNOWN_ADMIN_ROLE>"
7
13
8
14
9
15
def get_event_type (event ):
10
- if event .get ("action" ) == "team.promote_maintainer" :
16
+ if event .get ("action" , "" ) in ADMIN_EVENTS :
11
17
return event_type .ADMIN_ROLE_ASSIGNED
12
- if event .get ("action" ) == "org.disable_two_factor_requirement" :
18
+ if event .get ("action" , "" ) == "org.disable_two_factor_requirement" :
13
19
return event_type .MFA_DISABLED
14
20
return None
Original file line number Diff line number Diff line change @@ -166,6 +166,33 @@ Tests:
166
166
" p_log_type " : " GitHub.Audit" ,
167
167
" user " : " bob"
168
168
}
169
+ - Name : Github - Admin Added
170
+ ExpectedResult : true
171
+ Log :
172
+ {
173
+ " actor " : " cat" ,
174
+ " action " : " business.add_admin" ,
175
+ " p_log_type " : " GitHub.Audit" ,
176
+ " user " : " bob"
177
+ }
178
+ - Name : Github - Admin Invited
179
+ ExpectedResult : true
180
+ Log :
181
+ {
182
+ " actor " : " cat" ,
183
+ " action " : " business.invite_admin" ,
184
+ " p_log_type " : " GitHub.Audit" ,
185
+ " user " : " bob"
186
+ }
187
+ - Name : Github - Unknown Admin Role
188
+ ExpectedResult : false
189
+ Log :
190
+ {
191
+ " actor " : " cat" ,
192
+ " action " : " unknown.admin_role" ,
193
+ " p_log_type " : " GitHub.Audit" ,
194
+ " user " : " bob"
195
+ }
169
196
-
170
197
Name : Zendesk - Admin Role Downgraded
171
198
ExpectedResult : false
You can’t perform that action at this time.
0 commit comments