Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /scripts /github_check_suites.py
| #!/usr/bin/env python3 | |
| """ | |
| GitHub Check Suites Status | |
| """ | |
| import time | |
| import jwt | |
| import requests | |
| CONFIG = { | |
| "app_id": "2872904", | |
| "key_path": "/root/.ssh/github-app-zenai.pem", | |
| "owner": "SHAdd0WTAka", | |
| "repo": "Zen-Ai-Pentest", | |
| } | |
| def generate_jwt(app_id, key_path): | |
| with open(key_path, "r") as f: | |
| private_key = f.read() | |
| payload = { | |
| "iat": int(time.time()), | |
| "exp": int(time.time()) + 600, | |
| "iss": app_id, | |
| } | |
| return jwt.encode(payload, private_key, algorithm="RS256") | |
| def get_installation_token(jwt_token, owner, repo): | |
| headers = { | |
| "Authorization": f"Bearer {jwt_token}", | |
| "Accept": "application/vnd.github.v3+json", | |
| } | |
| resp = requests.get(f"https://api.github.com/repos/{owner}/{repo}/installation", headers=headers, timeout=30) | |
| if resp.status_code != 200: | |
| return None | |
| installation_id = resp.json()["id"] | |
| resp = requests.post( | |
| f"https://api.github.com/app/installations/{installation_id}/access_tokens", headers=headers, timeout=30 | |
| ) | |
| return resp.json()["token"] if resp.status_code == 201 else None | |
| if __name__ == "__main__": | |
| jwt_token = generate_jwt(CONFIG["app_id"], CONFIG["key_path"]) | |
| token = get_installation_token(jwt_token, CONFIG["owner"], CONFIG["repo"]) | |
| if not token: | |
| print("❌ Kein Token") | |
| exit(1) | |
| headers = { | |
| "Authorization": f"token {token}", | |
| "Accept": "application/vnd.github.v3+json", | |
| } | |
| # Hol den neuesten Commit auf main | |
| resp = requests.get( | |
| f"https://api.github.com/repos/{CONFIG['owner']}/{CONFIG['repo']}/commits/main", headers=headers, timeout=30 | |
| ) | |
| if resp.status_code == 200: | |
| commit = resp.json() | |
| sha = commit["sha"] | |
| print(f"📍 Letzter Commit: {sha[:7]}") | |
| print(f" Message: {commit['commit']['message'][:50]}") | |
| # Check Suites für diesen Commit | |
| resp = requests.get( | |
| f"https://api.github.com/repos/{CONFIG['owner']}/{CONFIG['repo']}/commits/{sha}/check-suites", | |
| headers=headers, | |
| timeout=30, | |
| ) | |
| if resp.status_code == 200: | |
| suites = resp.json() | |
| print(f"\n📊 Check Suites: {suites['total_count']}") | |
| status_counts = {} | |
| for suite in suites["check_suites"]: | |
| status = suite["conclusion"] if suite["conclusion"] else suite["status"] | |
| if status not in status_counts: | |
| status_counts[status] = 0 | |
| status_counts[status] += 1 | |
| if status in ["failure", "action_required"]: | |
| print(f"\n❌ FAILED: {suite['app']['name']} ({suite['status']})") | |
| # Hole Check Runs für diese Suite | |
| runs_resp = requests.get( | |
| f"https://api.github.com/repos/{CONFIG['owner']}/{CONFIG['repo']}/check-suites/{suite['id']}/check-runs", | |
| headers=headers, | |
| timeout=30, | |
| ) | |
| if runs_resp.status_code == 200: | |
| for run in runs_resp.json()["check_runs"]: | |
| if run["conclusion"] == "failure": | |
| print(f" • {run['name']}: {run['conclusion']}") | |
| if run.get("details_url"): | |
| print(f" Details: {run['details_url']}") | |
| print("\n📈 Zusammenfassung:") | |
| for status, count in status_counts.items(): | |
| print(f" {status}: {count}") | |
| else: | |
| print(f"❌ Check Suites Fehler: {resp.text}") | |
| else: | |
| print(f"❌ Commit Fehler: {resp.text}") | |
Xet Storage Details
- Size:
- 3.73 kB
- Xet hash:
- 19ea00fa08b975cfc709fdc8d3c371408e5405c7872d515b901fde615abac682
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.