probebox 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. probebox/__init__.py +88 -0
  2. probebox/_acl.py +209 -0
  3. probebox/_filelock.py +53 -0
  4. probebox/_net.py +37 -0
  5. probebox/_safefs.py +713 -0
  6. probebox/_version.py +14 -0
  7. probebox/_win32.py +614 -0
  8. probebox/budget.py +320 -0
  9. probebox/cli.py +1042 -0
  10. probebox/compare.py +568 -0
  11. probebox/config.py +387 -0
  12. probebox/contracts.py +575 -0
  13. probebox/discover/__init__.py +1 -0
  14. probebox/discover/audit.py +937 -0
  15. probebox/discover/configs.py +267 -0
  16. probebox/discover/cross_asset.py +223 -0
  17. probebox/discover/instructions.py +139 -0
  18. probebox/discover/probe.py +464 -0
  19. probebox/discover/render.py +298 -0
  20. probebox/discover/sanitize.py +587 -0
  21. probebox/discover/servers.py +334 -0
  22. probebox/discover/sources.py +428 -0
  23. probebox/fingerprints.py +297 -0
  24. probebox/hooks.py +288 -0
  25. probebox/html_report.py +510 -0
  26. probebox/init_config.py +789 -0
  27. probebox/probes/__init__.py +1 -0
  28. probebox/probes/attack_server.py +367 -0
  29. probebox/probes/constants.py +64 -0
  30. probebox/probes/mcp/__init__.py +84 -0
  31. probebox/probes/mcp/__main__.py +6 -0
  32. probebox/probes/mcp/faults.py +380 -0
  33. probebox/probes/mcp/policy.py +155 -0
  34. probebox/probes/mcp/proxy.py +2030 -0
  35. probebox/probes/mcp/proxy_policy.py +856 -0
  36. probebox/probes/mcp/runtime.py +167 -0
  37. probebox/probes/mcp/server.py +422 -0
  38. probebox/probes/mcp/tools.py +500 -0
  39. probebox/probes/probe_state.py +719 -0
  40. probebox/probes/sandbox.py +84 -0
  41. probebox/reporting.py +673 -0
  42. probebox/runner.py +1684 -0
  43. probebox/sarif.py +318 -0
  44. probebox/scenarios/__init__.py +1 -0
  45. probebox/scenarios/evaluator.py +771 -0
  46. probebox/scenarios/schema.py +712 -0
  47. probebox/scenarios/suite.yaml +1273 -0
  48. probebox/skills/__init__.py +1 -0
  49. probebox/skills/agent_runtime.py +187 -0
  50. probebox/skills/audit.py +284 -0
  51. probebox/skills/dynamic.py +971 -0
  52. probebox/skills/fences.py +103 -0
  53. probebox/skills/inputs.py +154 -0
  54. probebox/skills/model_worker.py +54 -0
  55. probebox/skills/skill_rules.yaml +15 -0
  56. probebox/standards.py +87 -0
  57. probebox/strategies/__init__.py +21 -0
  58. probebox/strategies/candidates.py +98 -0
  59. probebox/strategies/replay.py +83 -0
  60. probebox/strategies/transforms.py +230 -0
  61. probebox/targets/__init__.py +14 -0
  62. probebox/targets/_python_worker.py +473 -0
  63. probebox/targets/base.py +192 -0
  64. probebox/targets/cli_target.py +577 -0
  65. probebox/targets/http_target.py +964 -0
  66. probebox/targets/python_target.py +210 -0
  67. probebox/telemetry.py +879 -0
  68. probebox/utils.py +340 -0
  69. probebox-1.0.0.dist-info/METADATA +437 -0
  70. probebox-1.0.0.dist-info/RECORD +73 -0
  71. probebox-1.0.0.dist-info/WHEEL +4 -0
  72. probebox-1.0.0.dist-info/entry_points.txt +2 -0
  73. probebox-1.0.0.dist-info/licenses/LICENSE +21 -0
probebox/__init__.py ADDED
@@ -0,0 +1,88 @@
1
+ """ProbeBox: local-first deterministic security scanner & MCP red-team probe."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ from typing import Any
7
+
8
+ from probebox._version import __version__
9
+
10
+ _LAZY_EXPORTS: dict[str, tuple[str, str]] = {
11
+ "AllowedToolRule": ("probebox.probes.mcp.proxy_policy", "AllowedToolRule"),
12
+ "DiscoverOptions": ("probebox.discover.audit", "Options"),
13
+ "DiscoveryError": ("probebox.discover.audit", "DiscoveryError"),
14
+ "InitError": ("probebox.init_config", "InitError"),
15
+ "InitOptions": ("probebox.init_config", "Options"),
16
+ "ArgConstraint": ("probebox.probes.mcp.proxy_policy", "ArgConstraint"),
17
+ "BudgetConfig": ("probebox.budget", "BudgetConfig"),
18
+ "CLITarget": ("probebox.targets", "CLITarget"),
19
+ "CLITargetSpec": ("probebox.config", "CLITargetSpec"),
20
+ "CanaryInjectionConfig": ("probebox.probes.mcp.proxy_policy", "CanaryInjectionConfig"),
21
+ "Finding": ("probebox.contracts", "Finding"),
22
+ "FindingLocation": ("probebox.contracts", "FindingLocation"),
23
+ "FixturesSpec": ("probebox.scenarios.schema", "FixturesSpec"),
24
+ "HttpPreScenarioHookSpec": ("probebox.hooks", "HttpPreScenarioHookSpec"),
25
+ "HttpTarget": ("probebox.targets", "HttpTarget"),
26
+ "HttpTargetSpec": ("probebox.config", "HttpTargetSpec"),
27
+ "IncidentalFinding": ("probebox.contracts", "IncidentalFinding"),
28
+ "InjectedToolSpec": ("probebox.scenarios.schema", "InjectedToolSpec"),
29
+ "MCPFaultSpec": ("probebox.scenarios.schema", "MCPFaultSpec"),
30
+ "MCPProxyRuntime": ("probebox.probes.mcp.proxy", "MCPProxyRuntime"),
31
+ "MCPProxyTargetSpec": ("probebox.config", "MCPProxyTargetSpec"),
32
+ "ManagedMCPProxy": ("probebox.probes.mcp.proxy", "ManagedMCPProxy"),
33
+ "OWASP_ASI_CATALOG": ("probebox.standards", "OWASP_ASI_CATALOG"),
34
+ "OpenAITargetSpec": ("probebox.config", "OpenAITargetSpec"),
35
+ "OracleSpec": ("probebox.scenarios.schema", "OracleSpec"),
36
+ "PreScenarioHookSpec": ("probebox.hooks", "PreScenarioHookSpec"),
37
+ "ProxyFaultRule": ("probebox.probes.mcp.proxy_policy", "ProxyFaultRule"),
38
+ "ProxyPolicySpec": ("probebox.probes.mcp.proxy_policy", "ProxyPolicySpec"),
39
+ "PythonTarget": ("probebox.targets", "PythonTarget"),
40
+ "PythonTargetSpec": ("probebox.config", "PythonTargetSpec"),
41
+ "REPORT_SCHEMA_VERSION": ("probebox.contracts", "REPORT_SCHEMA_VERSION"),
42
+ "SandboxFileFixture": ("probebox.scenarios.schema", "SandboxFileFixture"),
43
+ "ScanConfig": ("probebox.config", "ScanConfig"),
44
+ "ScenarioOutcome": ("probebox.scenarios.evaluator", "ScenarioOutcome"),
45
+ "ScenarioSpec": ("probebox.scenarios.schema", "ScenarioSpec"),
46
+ "ScenarioStep": ("probebox.scenarios.schema", "ScenarioStep"),
47
+ "SensitivePatternRule": ("probebox.probes.mcp.proxy_policy", "SensitivePatternRule"),
48
+ "ShellPreScenarioHookSpec": ("probebox.hooks", "ShellPreScenarioHookSpec"),
49
+ "SuiteSpec": ("probebox.scenarios.schema", "SuiteSpec"),
50
+ "TargetAdapter": ("probebox.targets", "TargetAdapter"),
51
+ "TargetResponse": ("probebox.targets", "TargetResponse"),
52
+ "TargetSpec": ("probebox.config", "TargetSpec"),
53
+ "ToolDataFixtures": ("probebox.scenarios.schema", "ToolDataFixtures"),
54
+ "TurnMetrics": ("probebox.telemetry", "TurnMetrics"),
55
+ "UpstreamServerSpec": ("probebox.probes.mcp.proxy_policy", "UpstreamServerSpec"),
56
+ "UsageMetrics": ("probebox.telemetry", "UsageMetrics"),
57
+ "WebPageFixture": ("probebox.scenarios.schema", "WebPageFixture"),
58
+ "build_compare_report": ("probebox.compare", "build_compare_report"),
59
+ "compute_proxy_policy_digest": ("probebox.probes.mcp.proxy_policy", "compute_proxy_policy_digest"),
60
+ "instantiate_target": ("probebox.config", "instantiate_target"),
61
+ "load_and_normalize_report": ("probebox.contracts", "load_and_normalize_report"),
62
+ "load_proxy_policy": ("probebox.probes.mcp.proxy_policy", "load_proxy_policy"),
63
+ "load_scan_config": ("probebox.config", "load_scan_config"),
64
+ "load_suite": ("probebox.scenarios.schema", "load_suite"),
65
+ "run_discovery": ("probebox.discover.audit", "run"),
66
+ "render_html_report": ("probebox.html_report", "render_html_report"),
67
+ "render_sarif_report": ("probebox.sarif", "render_sarif_report"),
68
+ "run_scan": ("probebox.runner", "run_scan"),
69
+ "write_html_report": ("probebox.html_report", "write_html_report"),
70
+ "write_sarif_report": ("probebox.sarif", "write_sarif_report"),
71
+ }
72
+
73
+ __all__ = ["__version__", *sorted(_LAZY_EXPORTS.keys())]
74
+
75
+
76
+ def __getattr__(name: str) -> Any:
77
+ target = _LAZY_EXPORTS.get(name)
78
+ if target is None:
79
+ raise AttributeError(f"module 'probebox' has no attribute {name!r}")
80
+ mod_name, attr_name = target
81
+ module = importlib.import_module(mod_name)
82
+ val = getattr(module, attr_name)
83
+ globals()[name] = val
84
+ return val
85
+
86
+
87
+ def __dir__() -> list[str]:
88
+ return sorted(set(globals().keys()) | set(__all__))
probebox/_acl.py ADDED
@@ -0,0 +1,209 @@
1
+ """Pure parsing of Windows security identifiers and access control lists.
2
+
3
+ No Windows calls happen here, so every rule can be tested on any platform with bytes built by
4
+ hand. ``_win32`` hands these functions the bytes it read from a security descriptor.
5
+
6
+ Layouts follow the Windows documentation. An access list is a header followed by access control
7
+ entries (ACEs); where the trustee of an ACE starts depends on the ACE's type and, for object ACEs,
8
+ on which of two optional GUIDs are present:
9
+
10
+ =========== ====== ==========================================================
11
+ ACE type Value Contents after the 4-byte header
12
+ =========== ====== ==========================================================
13
+ allowed 0x00 mask (4), SID
14
+ denied 0x01 mask (4), SID
15
+ audit 0x02 mask (4), SID
16
+ compound 0x04 mask (4), compound access type (2), reserved (2), server & client SIDs (fail-closed)
17
+ allowed + 0x05 mask (4), flags (4), [object type GUID], [inherited type GUID], SID
18
+ object
19
+ allowed + 0x09 mask (4), SID, [application data]
20
+ callback
21
+ allowed + 0x0B mask (4), flags (4), [GUIDs as above], SID, [application data]
22
+ callback
23
+ + object
24
+ mandatory 0x11 integrity label (grants no directory write access)
25
+ label
26
+ =========== ====== ==========================================================
27
+
28
+ Every other known non-allow type (denied, audit, alarm, mandatory label 0x11, resource
29
+ attribute 0x12, scoped policy 0x13, process trust label 0x14, access filter 0x15) grants
30
+ nothing to a trustee on a directory. Compound allow (0x04) and any unknown ACE type are
31
+ treated conservatively as unreadable potential write grants.
32
+ The values are those of the Windows ``ACE_TYPE`` enumeration: 0x05 is the allowed *object* ACE
33
+ and 0x09 the allowed *callback* ACE, not the other way round.
34
+
35
+ """
36
+
37
+ from __future__ import annotations
38
+
39
+ from dataclasses import dataclass
40
+
41
+ # What makes a directory writable: adding files, adding or removing entries, and changing it.
42
+ WRITE_MASK = 0x2 | 0x4 | 0x40 | 0x10000 | 0x40000 | 0x80000 | 0x40000000 | 0x10000000 | 0x2000000
43
+
44
+ SYSTEM = "S-1-5-18"
45
+ ADMINISTRATORS = "S-1-5-32-544"
46
+ CREATOR_OWNER = "S-1-3-0"
47
+ # OWNER RIGHTS: an ACE with this trustee grants what it lists to whoever owns the object. Python
48
+ # 3.13 writes one, next to SYSTEM and Administrators, into every directory it makes with mode
49
+ # 0o700 on Windows, ``tempfile.mkdtemp()`` among them. It names no other account: the owner is
50
+ # judged on its own.
51
+ OWNER_RIGHTS = "S-1-3-4"
52
+ _LOGON_SESSION = "S-1-5-5-"
53
+ # Principals that stand for "more than one account", with the names Windows shows for them.
54
+ PRINCIPAL_NAMES = {
55
+ "S-1-1-0": "Everyone",
56
+ "S-1-5-11": "Authenticated Users",
57
+ "S-1-5-32-545": "BUILTIN\\Users",
58
+ "S-1-5-4": "INTERACTIVE",
59
+ "S-1-5-7": "ANONYMOUS LOGON",
60
+ "S-1-5-3": "BATCH",
61
+ "S-1-5-2": "NETWORK",
62
+ "S-1-5-6": "SERVICE",
63
+ "S-1-15-2-1": "ALL APPLICATION PACKAGES",
64
+ "S-1-15-2-2": "ALL RESTRICTED APPLICATION PACKAGES",
65
+ "S-1-5-32-544": "BUILTIN\\Administrators",
66
+ "S-1-5-18": "SYSTEM",
67
+ "S-1-3-4": "OWNER RIGHTS",
68
+ }
69
+
70
+ # ACE types that grant access, with the offset of the SID counted from the start of the ACE.
71
+ _PLAIN_ALLOWED = {0x00: 8, 0x09: 8}
72
+ _OBJECT_ALLOWED = {0x05, 0x0B}
73
+ _COMPOUND_ALLOWED = 0x04
74
+ # ACE types known to grant nothing to anyone, or nothing on a directory (denied, audit, alarm,
75
+ # mandatory label 0x11, resource attribute 0x12, scoped policy 0x13, trust label 0x14, filter 0x15).
76
+ _INERT = {0x01, 0x02, 0x03, 0x06, 0x07, 0x08, 0x0A, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15}
77
+ _OBJECT_TYPE_PRESENT = 0x1
78
+ _INHERITED_TYPE_PRESENT = 0x2
79
+
80
+
81
+ class AclError(ValueError):
82
+ """The bytes are not a well-formed identifier or access list."""
83
+
84
+
85
+ @dataclass(frozen=True)
86
+ class Ace:
87
+ """One access control entry."""
88
+
89
+ type: int
90
+ flags: int
91
+ size: int
92
+ mask: int | None
93
+ sid: str | None
94
+ unparsed: bool # True when the entry's trustee could not be located or is malformed.
95
+
96
+ @property
97
+ def grants_write(self) -> bool:
98
+ return self.mask is not None and bool(self.mask & WRITE_MASK)
99
+
100
+
101
+ def sid_size(data: bytes, offset: int, limit: int | None = None) -> int:
102
+ """The length in bytes of the identifier at ``offset``; it must fit before ``limit``."""
103
+ end = len(data) if limit is None else min(limit, len(data))
104
+ if offset < 0 or offset + 8 > end:
105
+ raise AclError("identifier truncated")
106
+ if data[offset] != 1:
107
+ raise AclError("unsupported identifier revision")
108
+ count = data[offset + 1]
109
+ if count > 15:
110
+ raise AclError("implausible identifier")
111
+ size = 8 + 4 * count
112
+ if offset + size > end:
113
+ raise AclError("identifier truncated")
114
+ return size
115
+
116
+
117
+ def parse_sid(data: bytes, offset: int = 0, limit: int | None = None) -> str:
118
+ """The string form (``S-1-5-18``) of the identifier at ``offset``."""
119
+ sid_size(data, offset, limit)
120
+ authority = int.from_bytes(data[offset + 2:offset + 8], "big")
121
+ count = data[offset + 1]
122
+ parts = [str(int.from_bytes(data[offset + 8 + 4 * index:offset + 12 + 4 * index], "little"))
123
+ for index in range(count)]
124
+ return "-".join(["S", "1", str(authority), *parts])
125
+
126
+
127
+ def _ace_sid(ace: bytes, offset: int) -> tuple[str | None, bool]:
128
+ try:
129
+ return parse_sid(ace, offset, len(ace)), False
130
+ except AclError:
131
+ return None, True
132
+
133
+
134
+ def _parse_ace(ace: bytes) -> Ace:
135
+ ace_type, flags = ace[0], ace[1]
136
+ if ace_type in _INERT:
137
+ return Ace(ace_type, flags, len(ace), None, None, False)
138
+ if len(ace) < 8:
139
+ return Ace(ace_type, flags, len(ace), None, None, True)
140
+ mask = int.from_bytes(ace[4:8], "little")
141
+ if ace_type in _PLAIN_ALLOWED:
142
+ sid, bad = _ace_sid(ace, _PLAIN_ALLOWED[ace_type])
143
+ return Ace(ace_type, flags, len(ace), mask, sid, bad)
144
+ if ace_type in _OBJECT_ALLOWED:
145
+ if len(ace) < 12:
146
+ return Ace(ace_type, flags, len(ace), mask, None, True)
147
+ object_flags = int.from_bytes(ace[8:12], "little")
148
+ if object_flags & ~(_OBJECT_TYPE_PRESENT | _INHERITED_TYPE_PRESENT):
149
+ return Ace(ace_type, flags, len(ace), mask, None, True) # Unknown flags: unknown layout.
150
+ offset = 12
151
+ if object_flags & _OBJECT_TYPE_PRESENT:
152
+ offset += 16
153
+ if object_flags & _INHERITED_TYPE_PRESENT:
154
+ offset += 16
155
+ sid, bad = _ace_sid(ace, offset)
156
+ return Ace(ace_type, flags, len(ace), mask, sid, bad)
157
+ if ace_type == _COMPOUND_ALLOWED:
158
+ # ACCESS_ALLOWED_COMPOUND_ACE (0x04) grants access to a server/client SID pair; treat it
159
+ # fail-closed as an unreadable potential grant rather than guessing which trustee applies.
160
+ return Ace(ace_type, flags, len(ace), mask, None, True)
161
+ # A type this parser does not know. Whether it grants anything cannot be told from here.
162
+ return Ace(ace_type, flags, len(ace), None, None, True)
163
+
164
+
165
+ def parse_acl(data: bytes) -> list[Ace]:
166
+ """Every access control entry of an access list, in order."""
167
+ if len(data) < 8:
168
+ raise AclError("access list truncated")
169
+ if data[0] not in (2, 4): # ACL_REVISION (2) and ACL_REVISION_DS (4, used with object ACEs).
170
+ raise AclError("unsupported access list revision")
171
+ size = int.from_bytes(data[2:4], "little")
172
+ count = int.from_bytes(data[4:6], "little")
173
+ if size > len(data) or size < 8:
174
+ raise AclError("access list size does not match its bytes")
175
+ offset, aces = 8, []
176
+ for _ in range(count):
177
+ if offset + 4 > size:
178
+ raise AclError("access control entry runs past the end of the list")
179
+ ace_size = int.from_bytes(data[offset + 2:offset + 4], "little")
180
+ if ace_size < 4 or offset + ace_size > size:
181
+ raise AclError("access control entry size does not fit the list")
182
+ aces.append(_parse_ace(data[offset:offset + ace_size]))
183
+ offset += ace_size
184
+ # Windows ACL buffers routinely reserve free space past the last ACE inside AclSize.
185
+ return aces
186
+
187
+
188
+ def is_logon_session(sid: str) -> bool:
189
+ """True for the identifier of a logon session: only this session's processes hold it."""
190
+ return sid.startswith(_LOGON_SESSION)
191
+
192
+
193
+ def write_grants(aces: list[Ace]) -> list[str | None]:
194
+ """The trustees the list allows to write, by identifier; None for a grant that could not be read."""
195
+ grants: list[str | None] = []
196
+ for ace in aces:
197
+ if not ace.grants_write:
198
+ continue
199
+ if ace.unparsed or ace.sid is None:
200
+ if None not in grants:
201
+ grants.append(None)
202
+ elif ace.sid not in grants:
203
+ grants.append(ace.sid)
204
+ return grants
205
+
206
+
207
+ def unreadable(aces: list[Ace]) -> list[int]:
208
+ """The types of entries this parser could not interpret."""
209
+ return sorted({ace.type for ace in aces if ace.unparsed and not ace.grants_write})
probebox/_filelock.py ADDED
@@ -0,0 +1,53 @@
1
+ """Minimal cross-platform advisory file locking (POSIX flock / Windows msvcrt)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from collections.abc import Iterator
7
+ from contextlib import contextmanager
8
+ from pathlib import Path
9
+ from typing import IO, Any
10
+
11
+ if os.name == "nt":
12
+ import msvcrt # type: ignore[import-not-found]
13
+ else:
14
+ import fcntl
15
+
16
+
17
+ def acquire_file_lock(fh: IO[Any], *, non_blocking: bool = False) -> None:
18
+ """Acquire an exclusive advisory lock on an open file handle."""
19
+ if os.name == "nt":
20
+ fh.seek(0)
21
+ mode = msvcrt.LK_NBLCK if non_blocking else msvcrt.LK_LOCK # type: ignore[attr-defined]
22
+ try:
23
+ msvcrt.locking(fh.fileno(), mode, 1) # type: ignore[attr-defined]
24
+ except OSError as exc:
25
+ if non_blocking:
26
+ raise BlockingIOError(str(exc)) from exc
27
+ raise
28
+ return
29
+
30
+ flags = fcntl.LOCK_EX | (fcntl.LOCK_NB if non_blocking else 0)
31
+ fcntl.flock(fh.fileno(), flags)
32
+
33
+
34
+ def release_file_lock(fh: IO[Any]) -> None:
35
+ """Release an advisory lock held on an open file handle."""
36
+ if os.name == "nt":
37
+ fh.seek(0)
38
+ msvcrt.locking(fh.fileno(), msvcrt.LK_UNLCK, 1) # type: ignore[attr-defined]
39
+ return
40
+
41
+ fcntl.flock(fh.fileno(), fcntl.LOCK_UN)
42
+
43
+
44
+ @contextmanager
45
+ def file_lock(lock_path: Path) -> Iterator[None]:
46
+ """Context manager acquiring an exclusive advisory lock on `lock_path`."""
47
+ lock_path.parent.mkdir(parents=True, exist_ok=True)
48
+ with lock_path.open("a+", encoding="utf-8") as fh:
49
+ acquire_file_lock(fh)
50
+ try:
51
+ yield
52
+ finally:
53
+ release_file_lock(fh)
probebox/_net.py ADDED
@@ -0,0 +1,37 @@
1
+ """Which requests may take the way a proxy shows them, and which go straight to their address."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import ipaddress
6
+ from urllib.parse import urlsplit
7
+
8
+
9
+ def is_loopback(url: str) -> bool:
10
+ """Whether ``url`` names this machine itself, as it is written: ``localhost`` or a name under
11
+ it, or an address in 127.0.0.0/8 or ``::1``. Nothing is looked up to find this out."""
12
+ try:
13
+ host = (urlsplit(url).hostname or "").rstrip(".")
14
+ except ValueError:
15
+ return False
16
+ if host == "localhost" or host.endswith(".localhost"):
17
+ return True
18
+ try:
19
+ address = ipaddress.ip_address(host)
20
+ except ValueError:
21
+ return False
22
+ mapped = getattr(address, "ipv4_mapped", None)
23
+ return address.is_loopback or address.is_unspecified or (mapped is not None and mapped.is_loopback)
24
+
25
+
26
+ def uses_proxy_settings(url: str) -> bool:
27
+ """What to give an HTTP client as ``trust_env`` for requests to ``url``.
28
+
29
+ A proxy is another program, and everything sent passes through it. A request to this machine
30
+ needs none and must not go through one: the servers a scan starts are reached at 127.0.0.1,
31
+ and where a proxy is set for the whole machine, as programs that route all of its traffic do,
32
+ such a request would go out to that program and fail there, or come back through it carrying
33
+ what the scan sent. Python reports that setting on Windows but not the addresses the system
34
+ itself leaves out of it, so the usual exclusions do not save it. A request to any other
35
+ address takes the machine's proxy settings, as other clients on it do.
36
+ """
37
+ return not is_loopback(url)