MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / _github_osgint_enrich

Method _github_osgint_enrich

IntelOSINT.py:17326–17440  ·  view source on GitHub ↗
(self, username, user_data=None)

Source from the content-addressed store, hash-verified

17324 return out
17325
17326 def _github_osgint_enrich(self, username, user_data=None):
17327 info = {"OSGINT": "Arricchimento GitHub attivo"}
17328 emails = set()
17329 repos_checked = []
17330 try:
17331 headers = {"User-Agent": "IntelOSINT-OSGINT"}
17332 token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN")
17333 if token:
17334 headers["Authorization"] = f"Bearer {token}"
17335
17336 if isinstance(user_data, dict) and user_data.get("email"):
17337 emails.add(str(user_data.get("email")))
17338
17339 try:
17340 events_url = f"https://api.github.com/users/{urllib.parse.quote(username)}/events/public?per_page=100"
17341 er = requests.get(events_url, headers=headers, timeout=10)
17342 events = er.json() if er.status_code == 200 else []
17343 if isinstance(events, list):
17344 for ev in events:
17345 payload = (ev or {}).get("payload") or {}
17346 commits = payload.get("commits") or []
17347 if not isinstance(commits, list):
17348 continue
17349 for c in commits:
17350 author = (c or {}).get("author") or {}
17351 em = str(author.get("email") or "").strip()
17352 if em and "@" in em and "noreply.github.com" not in em:
17353 emails.add(em)
17354 except Exception:
17355 pass
17356
17357 repos_url = f"https://api.github.com/users/{urllib.parse.quote(username)}/repos?per_page=30&sort=pushed&type=owner"
17358 repos_r = requests.get(repos_url, headers=headers, timeout=10)
17359 repos = repos_r.json() if repos_r.status_code == 200 else []
17360 if isinstance(repos, list):
17361 for repo in repos:
17362 if len(repos_checked) >= 10:
17363 break
17364 if not isinstance(repo, dict) or repo.get("fork"):
17365 continue
17366 name = repo.get("name")
17367 if not name:
17368 continue
17369 repos_checked.append(str(name))
17370 try:
17371 commits_url = f"https://api.github.com/repos/{urllib.parse.quote(username)}/{urllib.parse.quote(str(name))}/commits?author={urllib.parse.quote(username)}&per_page=3"
17372 cr = requests.get(commits_url, headers=headers, timeout=8)
17373 if cr.status_code != 200:
17374 continue
17375 commits = cr.json()
17376 if not isinstance(commits, list):
17377 continue
17378 for commit in commits[:3]:
17379 c = (commit or {}).get("commit") or {}
17380 for who in ("author", "committer"):
17381 em = ((c.get(who) or {}).get("email") or "").strip()
17382 if em and "@" in em and "noreply.github.com" not in em:
17383 emails.add(em)

Callers 1

analyze_social_githubMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected