Skip to content

Commit f59f6f2

Browse files
committed
refactor(reach): drop redundant proxy env forwarding to coana
coana resolves HTTPS_PROXY/HTTP_PROXY itself (getProxyUrl in utils/dashboard-api/axios-aux.ts) and we already pass the full parent env to the coana subprocess, so copying HTTPS_PROXY into SOCKET_CLI_API_PROXY was a no-op. Remove the forwarding and the now-unused 'proxy' parameter. SOCKET_CLI_VERSION and SOCKET_CALLER_USER_AGENT are unaffected. SOCKET_CLI_API_PROXY (coana's highest- precedence proxy override) is left to be wired from a future explicit --proxy flag.
1 parent 9c9c6a7 commit f59f6f2

5 files changed

Lines changed: 13 additions & 19 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.4.1"
9+
version = "2.4.2"
1010
requires-python = ">= 3.11"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.4.1'
2+
__version__ = '2.4.2'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'

socketsecurity/core/tools/reachability.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def run_reachability_analysis(
126126
continue_on_no_source_files: bool = False,
127127
reach_debug: bool = False,
128128
disable_external_tool_checks: bool = False,
129-
proxy: Optional[str] = None,
130129
) -> Dict[str, Any]:
131130
"""
132131
Run reachability analysis.
@@ -251,11 +250,10 @@ def run_reachability_analysis(
251250
env["SOCKET_CLI_VERSION"] = __version__
252251
env["SOCKET_CALLER_USER_AGENT"] = _build_caller_user_agent()
253252

254-
# Forward an HTTP(S) proxy to coana if one is configured. Prefer an explicit value,
255-
# otherwise fall back to the standard proxy environment variables.
256-
proxy_url = proxy or os.environ.get("HTTPS_PROXY") or os.environ.get("HTTP_PROXY")
257-
if proxy_url:
258-
env["SOCKET_CLI_API_PROXY"] = proxy_url
253+
# NOTE: no proxy env is set here. coana already reads HTTPS_PROXY/HTTP_PROXY itself, and
254+
# we pass the full parent env above, so it inherits them. A SOCKET_CLI_API_PROXY override
255+
# should only be set from an explicit --proxy flag (not yet implemented), since seeding it
256+
# from HTTPS_PROXY would be a no-op (it's the same value coana already resolves).
259257

260258
# Optional environment variables.
261259
# NOTE: repo/branch are intentionally omitted by the caller (passed as None) when they

tests/unit/test_reachability.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,14 @@ def test_env_identifies_python_cli(analyzer, mocker):
8383
assert env["SOCKET_CLI_API_TOKEN"] == "test-api-token"
8484

8585

86-
def test_proxy_env_from_explicit_value(analyzer, mocker):
87-
"""G5: explicit proxy -> SOCKET_CLI_API_PROXY."""
88-
_, env = _run(analyzer, mocker, proxy="http://proxy.example:8080")
89-
assert env["SOCKET_CLI_API_PROXY"] == "http://proxy.example:8080"
90-
91-
92-
def test_proxy_env_from_https_proxy_fallback(analyzer, mocker, monkeypatch):
93-
"""G5: HTTPS_PROXY is forwarded when no explicit proxy is given."""
86+
def test_no_proxy_env_set_by_default(analyzer, mocker, monkeypatch):
87+
"""coana inherits HTTPS_PROXY/HTTP_PROXY from the passed env; we don't set
88+
SOCKET_CLI_API_PROXY ourselves (that's reserved for a future explicit --proxy flag)."""
89+
monkeypatch.delenv("SOCKET_CLI_API_PROXY", raising=False)
9490
monkeypatch.setenv("HTTPS_PROXY", "http://envproxy:3128")
95-
monkeypatch.delenv("HTTP_PROXY", raising=False)
9691
_, env = _run(analyzer, mocker)
97-
assert env["SOCKET_CLI_API_PROXY"] == "http://envproxy:3128"
92+
# Even with HTTPS_PROXY set, we don't copy it into SOCKET_CLI_API_PROXY (coana reads it itself).
93+
assert "SOCKET_CLI_API_PROXY" not in env
9894

9995

10096
def test_repo_branch_env_present_when_supplied(analyzer, mocker):

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)