Skip to content

Commit b35f8c7

Browse files
committed
fix(python): address PR #4084 review feedback
- server.py: drop unused log_swallowed_exception import / _LOGGER (caught by pylint W0611, surfaced via Codacy UnusedCode finding) - server.py: extend host whitelist to IPv6 "::" so Studio URL is rewritten to localhost when bound on either IPv4 or IPv6 all-interfaces address - server.py: document default-host change in ArcadeDBServer.__init__ docstring (no CHANGELOG.md exists in this repo) - test_server.py: drop _config private-state assertion; rely on the publicly-observable get_studio_url() composition instead - test-python-bindings.yml: SHA-pin actions/setup-python to match the rest of the workflow's pinning convention; pin bandit==1.9.4 for reproducible scans
1 parent fdfda61 commit b35f8c7

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/test-python-bindings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ jobs:
4141
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4242

4343
- name: Set up Python
44-
uses: actions/setup-python@v5
44+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
4545
with:
4646
python-version: "3.12"
4747

4848
- name: Install Bandit
49-
run: python -m pip install "bandit>=1.9.0"
49+
run: python -m pip install "bandit==1.9.4"
5050

5151
- name: Run Bandit on src and tests (must be clean)
5252
working-directory: bindings/python

bindings/python/src/arcadedb_embedded/server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
import os
88
from typing import Any, Dict, Optional
99

10-
from ._logging import get_logger, log_swallowed_exception
1110
from .core import Database
1211
from .exceptions import ArcadeDBError
1312
from .jvm import start_jvm
1413

15-
_LOGGER = get_logger(__name__)
16-
1714

1815
class ArcadeDBServer:
1916
"""ArcadeDB Server wrapper for enabling HTTP API and Studio access."""
@@ -35,7 +32,11 @@ def __init__(
3532
config: Optional configuration dictionary with keys like:
3633
- http_port: HTTP API port (default: 2480)
3734
- binary_port: Binary protocol port (default: 2424)
38-
- host: Host to bind to (default: 0.0.0.0)
35+
- host: Host to bind to (default: "localhost"). Pass "0.0.0.0"
36+
explicitly to expose the server on all IPv4 interfaces, or
37+
"::" for all IPv6 interfaces. Earlier versions defaulted to
38+
"0.0.0.0"; the default was tightened to loopback in the
39+
Python bindings v0.x security cleanup.
3940
- mode: Server mode (default: development)
4041
jvm_kwargs: Optional JVM args passed to start_jvm()
4142
Example: {"heap_size": "8g"}
@@ -170,7 +171,7 @@ def get_http_port(self) -> int:
170171
def get_studio_url(self) -> str:
171172
"""Get the URL for the Studio web interface."""
172173
host = self._config.get("host", "localhost")
173-
if host == "0.0.0.0": # nosec B104 - equality comparison, not a bind
174+
if host in ("0.0.0.0", "::"): # nosec B104 - equality comparison, not a bind
174175
host = "localhost"
175176
port = self.get_http_port()
176177
return f"http://{host}:{port}/"

bindings/python/tests/test_server.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,17 @@ def test_server_context_manager(temp_server_root):
119119

120120

121121
def test_default_host_is_localhost(temp_server_root):
122-
"""Default host should be localhost; binding to all interfaces must be opt-in."""
122+
"""Default host should be localhost; binding to all interfaces must be opt-in.
123+
124+
Asserts on the publicly-observable Studio URL composition; we do not
125+
start the server here because that requires a real JVM. The same default
126+
host feeds both ``get_studio_url()`` and the underlying ContextConfiguration,
127+
so the URL is a faithful proxy for the configured host.
128+
"""
123129
from arcadedb_embedded.server import ArcadeDBServer
124130

125131
server = ArcadeDBServer(
126132
root_path=temp_server_root,
127133
root_password=TEST_PASSWORD,
128134
)
129-
assert server._config.get("host", "localhost") == "localhost"
130135
assert server.get_studio_url().startswith("http://localhost:")

0 commit comments

Comments
 (0)