-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple script to query an org for members with 2fa disabled t…
…o get email addresses
- Loading branch information
1 parent
9619c4f
commit 3cc5c7e
Showing
1 changed file
with
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#! /usr/bin/env python3 | ||
|
||
from scraper.github import create_session | ||
|
||
# Looks for an environment variable `GITHUB_API_TOKEN` with a valid GitHub API token | ||
gh = create_session() | ||
|
||
|
||
def print_org_members_without_2fa(org_name="llnl"): | ||
org = gh.organization(org_name) | ||
|
||
for user in org.members(filter="2fa_disabled"): | ||
emails = { | ||
c['author']['email'] | ||
for e in user.events() | ||
if e.type == "PushEvent" | ||
for c in e.payload['commits'] | ||
} | ||
emails = {e for e in emails if "@llnl.gov" in e} | ||
if emails: | ||
print(f"{user.login}: {','.join(emails)}") | ||
|
||
|
||
if __name__ == "__main__": | ||
print_org_members_without_2fa() |