Skip to content

Commit

Permalink
Added a simple script to query an org for members with 2fa disabled t…
Browse files Browse the repository at this point in the history
…o get email addresses
  • Loading branch information
IanLee1521 committed Feb 2, 2021
1 parent 9619c4f commit 3cc5c7e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/org_to_emails.py
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()

0 comments on commit 3cc5c7e

Please sign in to comment.