(self, email, module_timeout=4.0, total_timeout=18, max_results=80)
| 12612 | return {"domain": domain, "ips": ips, "nodes": list(nodes_dict.values()), "edges": edges} |
| 12613 | |
| 12614 | def holehe_scan(self, email, module_timeout=4.0, total_timeout=18, max_results=80): |
| 12615 | email = (email or "").strip() |
| 12616 | if not email or "@" not in email: |
| 12617 | return [{"username": email, "type": "Holehe", "info": {"Status": " Email non valida"}, "main_img": "https://cdn-icons-png.flaticon.com/512/732/732200.png", "status_code": 400, "url": ""}] |
| 12618 | |
| 12619 | try: |
| 12620 | import trio |
| 12621 | import httpx |
| 12622 | import pkgutil |
| 12623 | import importlib |
| 12624 | import inspect |
| 12625 | import holehe.modules |
| 12626 | except Exception as e: |
| 12627 | return [{"username": email, "type": "Holehe", "info": {"Status": f" Holehe non disponibile: {e}"}, "main_img": "https://cdn-icons-png.flaticon.com/512/732/732200.png", "status_code": 500, "url": ""}] |
| 12628 | |
| 12629 | async def _run(): |
| 12630 | out = [] |
| 12631 | checked = 0 |
| 12632 | failed = 0 |
| 12633 | timed_out = 0 |
| 12634 | started = time.monotonic() |
| 12635 | async with httpx.AsyncClient( |
| 12636 | timeout=httpx.Timeout(max(5, module_timeout + 2)), |
| 12637 | follow_redirects=True, |
| 12638 | headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"} |
| 12639 | ) as client: |
| 12640 | for m in pkgutil.walk_packages(holehe.modules.__path__, holehe.modules.__name__ + "."): |
| 12641 | if time.monotonic() - started > total_timeout: |
| 12642 | break |
| 12643 | modname = m.name |
| 12644 | basename = modname.split(".")[-1] |
| 12645 | try: |
| 12646 | mod = importlib.import_module(modname) |
| 12647 | except Exception: |
| 12648 | continue |
| 12649 | |
| 12650 | fn = getattr(mod, basename, None) |
| 12651 | if fn and inspect.iscoroutinefunction(fn): |
| 12652 | try: |
| 12653 | before = len(out) |
| 12654 | with trio.move_on_after(module_timeout) as scope: |
| 12655 | await fn(email, client, out) |
| 12656 | checked += 1 |
| 12657 | if scope.cancelled_caught and len(out) == before: |
| 12658 | timed_out += 1 |
| 12659 | except Exception: |
| 12660 | failed += 1 |
| 12661 | continue |
| 12662 | return out, checked, failed, timed_out, round(time.monotonic() - started, 2) |
| 12663 | |
| 12664 | try: |
| 12665 | raw, checked, failed, timed_out, elapsed = trio.run(_run) |
| 12666 | except Exception as e: |
| 12667 | return [{"username": email, "type": "Holehe", "info": {"Status": f" Errore esecuzione: {e}"}, "main_img": "https://cdn-icons-png.flaticon.com/512/732/732200.png", "status_code": 500, "url": ""}] |
| 12668 | |
| 12669 | positives = [] |
| 12670 | uncertain = [] |
| 12671 | for r in (raw or []): |
no outgoing calls
no test coverage detected