Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /scripts /github_log_detail.py
| #!/usr/bin/env python3 | |
| """ | |
| GitHub Workflow Log Downloader | |
| """ | |
| 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", | |
| } | |
| # Spezifische fehlgeschlagene Runs | |
| failed_runs = [ | |
| (23078068287, "API v1 Routes Tests"), | |
| (23078068284, "CI Enhanced"), | |
| (23078068281, "Memory Check"), | |
| ] | |
| for run_id, name in failed_runs: | |
| print(f"\n{'=' * 60}") | |
| print(f"📋 {name} (Run #{run_id})") | |
| print("=" * 60) | |
| # Versuche Logs zu holen | |
| resp = requests.get( | |
| f"https://api.github.com/repos/{CONFIG['owner']}/{CONFIG['repo']}/actions/runs/{run_id}/logs", | |
| headers=headers, | |
| timeout=30, | |
| ) | |
| if resp.status_code == 200: | |
| # Logs sind ein ZIP | |
| print("✅ Logs verfügbar (ZIP)") | |
| # Wir können das ZIP nicht direkt anzeigen, aber wir können die Jobs prüfen | |
| else: | |
| print(f"⚠️ Logs nicht verfügbar: {resp.status_code}") | |
| # Hole Job Details mit Fehlern | |
| jobs_resp = requests.get( | |
| f"https://api.github.com/repos/{CONFIG['owner']}/{CONFIG['repo']}/actions/runs/{run_id}/jobs", | |
| headers=headers, | |
| timeout=30, | |
| ) | |
| if jobs_resp.status_code == 200: | |
| jobs = jobs_resp.json()["jobs"] | |
| for job in jobs: | |
| if job["conclusion"] == "failure": | |
| print(f"\n❌ FAILED JOB: {job['name']}") | |
| for step in job["steps"]: | |
| if step["conclusion"] == "failure": | |
| print(f" 📌 Step: {step['name']}") | |
| print(f" 🔗 Log: {job['html_url']}") | |
Xet Storage Details
- Size:
- 3.06 kB
- Xet hash:
- ed1f3b434fc97ad2f42288d4923cf96d000d786c3289e1273e7b820100eb1a89
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.