🕵️♂️ (2-in-1) Email & Username OSINT suite featuring native MCP support for deep data extraction just from a single Email/Username. Analyzes 2720+ actively maintained scan vectors (210+ email / 2510+ username) for security research, investigations, and digital footprinting.
Python cybersecuritycybersecurity-toolsemail-osintethical-hackingethical-hacking-toolsidentificationinfosecosintosint-emailosint-toolosint-toolsosint-usernamepentestingpythonredteam-toolsredteamingthreat-intelligence
fix(core): cap concurrency at 500 in the shared check and the setters (#717) (#741)
Abdelrhman Mohamed04122f95c919
diff --git a/docs/FLAGS.md b/docs/FLAGS.mdindex bea7048..f7dd14c 100644--- a/docs/FLAGS.md+++ b/docs/FLAGS.md@@ -28,7 +28,7 @@| `-s, --stop STOP` | Limit the number of permutations generated (at least 1) || `-d, --delay DELAY` | Delay (in seconds) between requests, 0 to 3600 || `-t, --timeout TIMEOUT` | Override default request timeout in seconds, above 0 and at most 3600 |-| `-C, --concurrency CONC` | Override default concurrency limit (must be at least 1) |+| `-C, --concurrency CONC` | Override default concurrency limit, 1 to 500 || `-f, --format {csv,json,pdf}`| Select output format || `--no-pdf-media` | Disable profile photo media fetching in PDF reports (conserves bandwidth on metered proxies) || `-o, --output OUTPUT` | Save results to a file (Can be used directly without `-f`) |diff --git a/tests/test_email_orchestrator.py b/tests/test_email_orchestrator.pyindex 15f7dd3..77c52fe 100644--- a/tests/test_email_orchestrator.py+++ b/tests/test_email_orchestrator.py@@ -75,3 +75,18 @@ def test_run_email_batch_multiple_categories_grouped(capsys, monkeypatch):# Site2 belongs to Cat_b and must appear AFTER Cat_b headerassert site2_pos > cat_b_pos++def test_set_concurrency_has_a_maximum():+ import pytest+ import user_scanner.core.email_orchestrator as email_orchestrator++ original = email_orchestrator.MAX_CONCURRENT_REQUESTS+ try:+ email_orchestrator.set_concurrency(500)+ assert email_orchestrator.MAX_CONCURRENT_REQUESTS == 500+ for value in [501, 10**18, True]:+ with pytest.raises(ValueError):+ email_orchestrator.set_concurrency(value)+ assert email_orchestrator.MAX_CONCURRENT_REQUESTS == 500+ finally:+ email_orchestrator.set_concurrency(original)diff --git a/tests/test_helpers.py b/tests/test_helpers.pyindex d75f700..777640a 100644--- a/tests/test_helpers.py+++ b/tests/test_helpers.py@@ -261,6 +261,8 @@ def test_cli_concurrency_positive_bound(run_main, capsys):("--cross-depth", "-2", "must be at least 1"),("--cross-sweep", "-1", "must be at least 0"),("--stop", "abc", "Invalid"),+ ("--concurrency", "501", "must be at most 500"),+ ("--concurrency", "1000000000000000000", "must be at most 500"),],)def test_cli_numeric_options_are_bounded(run_main, capsys, flag, value, message):diff --git a/tests/test_limits.py b/tests/test_limits.pyindex 8a2482e..92827d5 100644--- a/tests/test_limits.py+++ b/tests/test_limits.py@@ -12,7 +12,7 @@ INVALID_FLOATS = ["nan", "inf", "-inf", float("nan"), float("inf"), math.inf]"check, valid",[(limits.check_stop, [1, "1", 100, sys.maxsize]),- (limits.check_concurrency, [1, "1", 60, 10_000]),+ (limits.check_concurrency, [1, "1", 60, limits.MAX_CONCURRENCY]),(limits.check_cross_depth, [1, "1", 5]),(limits.check_cross_sweep, [0, "0", 3, 1_000]),],@@ -47,6 +47,12 @@ def test_int_options_reject_non_integers(check):check(value)+def test_concurrency_has_a_maximum():+ for value in [limits.MAX_CONCURRENCY + 1, 10_000, 10**18, str(10**18)]:+ with pytest.raises(ValueError, match="must be at most 500"):+ limits.check_concurrency(value)++def test_stop_rejects_values_islice_cannot_take():with pytest.raises(ValueError, match="must be at most"):limits.check_stop(sys.maxsize + 1)diff --git a/tests/test_mcp_handlers.py b/tests/test_mcp_handlers.pyindex 5ffde73..6f7cf44 100644--- a/tests/test_mcp_handlers.py+++ b/tests/test_mcp_handlers.py@@ -61,6 +61,9 @@ async def test_execute_scan_invalid_concurrency():({"cross_depth": 0}, "at least 1"),({"cross_sweep": -1}, "at least 0"),({"concurrency": True}, "Invalid concurrency value"),+ ({"concurrency": 501}, "must be at most 500"),+ ({"concurrency": 10**18}, "must be at most 500"),+ ({"concurrency": "501"}, "must be at most 500"),],)async def test_execute_scan_rejects_out_of_range_numbers(arguments, message):@@ -164,6 +167,7 @@ def test_tool_schema_concurrency_minimum():conc_prop = t.inputSchema["properties"]["concurrency"]assert conc_prop["type"] == "integer"assert conc_prop["minimum"] == 1+ assert conc_prop["maximum"] == 500props = t.inputSchema["properties"]assert props["timeout"]["exclusiveMinimum"] == 0assert props["timeout"]["maximum"] == 3600diff --git a/tests/test_orchestrator.py b/tests/test_orchestrator.pyindex 82d0a04..e4ab003 100644--- a/tests/test_orchestrator.py+++ b/tests/test_orchestrator.py@@ -112,3 +112,28 @@ def test_run_batch_multiple_categories_grouped(capsys, monkeypatch):# Site2 belongs to Cat_b and must appear AFTER Cat_b headerassert site2_pos > cat_b_pos++def test_set_concurrency_rejects_huge_values_before_building_an_executor():+ from unittest.mock import patch+ import pytest+ import user_scanner.core.orchestrator as orchestrator++ before = (orchestrator.MAX_CONCURRENT_REQUESTS, orchestrator._shared_executor)+ with patch("concurrent.futures.ThreadPoolExecutor") as pool:+ for value in [501, 10**18, True, "501"]:+ with pytest.raises(ValueError):+ orchestrator.set_concurrency(value)+ pool.assert_not_called()+ assert (orchestrator.MAX_CONCURRENT_REQUESTS, orchestrator._shared_executor) == before+++def test_set_concurrency_accepts_the_maximum():+ import user_scanner.core.orchestrator as orchestrator++ original = orchestrator.MAX_CONCURRENT_REQUESTS+ try:+ orchestrator.set_concurrency(500)+ assert orchestrator.MAX_CONCURRENT_REQUESTS == 500+ assert orchestrator._shared_executor._max_workers == 1000+ finally:+ orchestrator.set_concurrency(original)diff --git a/user_scanner/__main__.py b/user_scanner/__main__.pyindex 09f2b72..6104436 100644--- a/user_scanner/__main__.py+++ b/user_scanner/__main__.py@@ -169,7 +169,7 @@ def main():"-C","--concurrency",type=_arg_type(limits.check_concurrency),- help="Override default concurrency limit (minimum: 1, default: 60 for username, 25 for email scan)",+ help="Override default concurrency limit (1 to 500, default: 60 for username, 25 for email scan)",)parser.add_argument(diff --git a/user_scanner/core/email_orchestrator.py b/user_scanner/core/email_orchestrator.pyindex 8539df6..b93f39f 100644--- a/user_scanner/core/email_orchestrator.py+++ b/user_scanner/core/email_orchestrator.py@@ -17,6 +17,7 @@ from user_scanner.core.helpers import (load_modules,get_global_timeout,)+from user_scanner.core import limitsfrom user_scanner.core.result import Resultfrom rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, MofNCompleteColumn@@ -56,8 +57,7 @@ httpx.Client.__init__ = _patched_client_init # type: ignore[method-assign]MAX_CONCURRENT_REQUESTS = 25def set_concurrency(val: int):- if val < 1:- raise ValueError(f"Concurrency must be at least 1, got {val}")+ val = limits.check_concurrency(val)global MAX_CONCURRENT_REQUESTSMAX_CONCURRENT_REQUESTS = valdiff --git a/user_scanner/core/limits.py b/user_scanner/core/limits.pyindex 859aeea..b1d6483 100644--- a/user_scanner/core/limits.py+++ b/user_scanner/core/limits.py@@ -18,6 +18,12 @@ from typing import Any, Optional# likely a typo (milliseconds, an extra zero) than an intended hour-long wait.MAX_SECONDS = 3600.0+# Most requests allowed in flight at once. The username orchestrator builds a+# thread pool of twice this size, so an unbounded value lets one MCP call or+# CLI typo exhaust threads or memory before any scan starts (#717). The+# defaults are 60 (username) and 25 (email).+MAX_CONCURRENCY = 500+def check_int(name: str, value: Any, minimum: int, maximum: Optional[int] = None) -> int:"""Return ``value`` as an int in ``[minimum, maximum]``.@@ -78,7 +84,7 @@ def check_timeout(value: Any) -> float:def check_concurrency(value: Any) -> int:- return check_int("concurrency", value, 1)+ return check_int("concurrency", value, 1, MAX_CONCURRENCY)def check_cross_depth(value: Any) -> int:diff --git a/user_scanner/core/orchestrator.py b/user_scanner/core/orchestrator.pyindex f0d278a..16270b2 100644--- a/user_scanner/core/orchestrator.py+++ b/user_scanner/core/orchestrator.py@@ -20,6 +20,7 @@ from user_scanner.core.helpers import (load_modules,get_global_timeout,)+from user_scanner.core import limitsfrom user_scanner.core.result import Resultfrom rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, MofNCompleteColumn@@ -28,8 +29,8 @@ MAX_CONCURRENT_REQUESTS = 60_shared_executor = concurrent.futures.ThreadPoolExecutor(max_workers=max(MAX_CONCURRENT_REQUESTS * 2, 250))def set_concurrency(val: int):- if val < 1:- raise ValueError(f"Concurrency must be at least 1, got {val}")+ # Checked before the executor below is built from it+ val = limits.check_concurrency(val)global MAX_CONCURRENT_REQUESTS, _shared_executorMAX_CONCURRENT_REQUESTS = val_shared_executor = concurrent.futures.ThreadPoolExecutor(max_workers=max(val * 2, 250))diff --git a/user_scanner/mcp/schemas.py b/user_scanner/mcp/schemas.pyindex 61488ac..f272656 100644--- a/user_scanner/mcp/schemas.py+++ b/user_scanner/mcp/schemas.py@@ -110,9 +110,10 @@ def get_tool_list() -> list[types.Tool]:"concurrency": {"type": "integer","minimum": 1,+ "maximum": 500,"description": ("Override default concurrency limit (how many requests to "- "make in parallel). Must be at least 1."+ "make in parallel). Must be between 1 and 500."),},}