diff options
author | Christian Cleberg <hello@cleberg.net> | 2025-04-05 13:43:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-05 13:43:01 -0500 |
commit | bee22b97b652cd04fa470d7f31c3b917e44f3ab9 (patch) | |
tree | e1ec29a3388b94a8d41e3b28ca1f2357f3efaec7 /applications/github/github_audit_log.py | |
parent | 3041472781997ff66c5f9fa80a7f5ffbd284a438 (diff) | |
download | audit-tools-bee22b97b652cd04fa470d7f31c3b917e44f3ab9.tar.gz audit-tools-bee22b97b652cd04fa470d7f31c3b917e44f3ab9.tar.bz2 audit-tools-bee22b97b652cd04fa470d7f31c3b917e44f3ab9.zip |
migrate from pylint to ruff (#1)
* migrate from pylint to ruff
* Commit from GitHub Actions (Pylint)
* rename pylint.yml to ruff.yml
* only run ruff-action when python files change
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'applications/github/github_audit_log.py')
-rw-r--r-- | applications/github/github_audit_log.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/applications/github/github_audit_log.py b/applications/github/github_audit_log.py index 0937764..dd00535 100644 --- a/applications/github/github_audit_log.py +++ b/applications/github/github_audit_log.py @@ -6,16 +6,17 @@ NOTE: REQUIRES A GITHUB ENTERPRISE SUBSCRIPTION TO ACCESS THE API. import requests -GITHUB_TOKEN = 'your_personal_access_token' -ORGANIZATION = 'your_organization' +GITHUB_TOKEN = "your_personal_access_token" +ORGANIZATION = "your_organization" TIMEOUT = 30 # Headers for authentication headers = { - 'Authorization': f'token {GITHUB_TOKEN}', - 'Accept': 'application/vnd.github.v3+json' + "Authorization": f"token {GITHUB_TOKEN}", + "Accept": "application/vnd.github.v3+json", } + def get_audit_log_events(org, actions): """ Get audit log events for specific actions @@ -23,8 +24,10 @@ def get_audit_log_events(org, actions): events = [] page = 1 while True: - url = (f'https://api.github.com/orgs/{org}/audit-log?page={page}&per_page=100' - f'&action={",".join(actions)}') + url = ( + f"https://api.github.com/orgs/{org}/audit-log?page={page}&per_page=100" + f"&action={','.join(actions)}" + ) response = requests.get(url, headers=headers, timeout=TIMEOUT) response.raise_for_status() page_events = response.json() @@ -34,12 +37,15 @@ def get_audit_log_events(org, actions): page += 1 return events -if __name__ == '__main__': + +if __name__ == "__main__": try: # Define the actions to filter - action_filters = ['protected_branch', - 'repository_branch_protection_evaluation', - 'repository_ruleset'] + action_filters = [ + "protected_branch", + "repository_branch_protection_evaluation", + "repository_ruleset", + ] # Get audit log events for the specified actions audit_log_events = get_audit_log_events(ORGANIZATION, action_filters) |