Personal AI, On Personal Devices
Python
feat: secure server defaults — loopback binding, redact mode, rate limiting
Jon Saad-Falcon63a32d20d6c7
diff --git a/src/openjarvis/core/config.py b/src/openjarvis/core/config.pyindex bce70fa3..290906c6 100644--- a/src/openjarvis/core/config.py+++ b/src/openjarvis/core/config.py@@ -760,11 +760,20 @@ class AgentConfig:class ServerConfig:"""API server settings."""- host: str = "0.0.0.0"+ host: str = "127.0.0.1"port: int = 8000agent: str = "orchestrator"model: str = ""workers: int = 1+ cors_origins: list = field(+ default_factory=lambda: [+ "http://localhost:3000",+ "http://localhost:5173",+ "http://127.0.0.1:3000",+ "http://127.0.0.1:5173",+ "tauri://localhost",+ ]+ )@dataclass(slots=True)@@ -972,7 +981,7 @@ class SecurityConfig:enabled: bool = Truescan_input: bool = Truescan_output: bool = True- mode: str = "warn" # "redact" | "warn" | "block"+ mode: str = "redact" # "redact" | "warn" | "block"secret_scanner: bool = Truepii_scanner: bool = Trueaudit_log_path: str = str(DEFAULT_CONFIG_DIR / "audit.db")@@ -980,9 +989,13 @@ class SecurityConfig:merkle_audit: bool = Truesigning_key_path: str = ""ssrf_protection: bool = True- rate_limit_enabled: bool = False+ rate_limit_enabled: bool = Truerate_limit_rpm: int = 60rate_limit_burst: int = 10+ local_engine_bypass: bool = False+ local_tool_bypass: bool = False+ profile: str = ""+ vault_key_path: str = str(DEFAULT_CONFIG_DIR / ".vault_key")capabilities: CapabilitiesConfig = field(default_factory=CapabilitiesConfig)diff --git a/tests/security/test_network_defaults.py b/tests/security/test_network_defaults.pynew file mode 100644index 00000000..4655b8ed--- /dev/null+++ b/tests/security/test_network_defaults.py@@ -0,0 +1,58 @@+"""Tests for secure network defaults (Section 1 of security hardening)."""++from __future__ import annotations+++class TestServerConfigDefaults:+ """ServerConfig should bind to loopback by default."""++ def test_default_host_is_loopback(self) -> None:+ from openjarvis.core.config import ServerConfig++ cfg = ServerConfig()+ assert cfg.host == "127.0.0.1"++ def test_default_port_unchanged(self) -> None:+ from openjarvis.core.config import ServerConfig++ cfg = ServerConfig()+ assert cfg.port == 8000++ def test_cors_origins_default(self) -> None:+ from openjarvis.core.config import ServerConfig++ cfg = ServerConfig()+ assert isinstance(cfg.cors_origins, list)+ assert "http://localhost:3000" in cfg.cors_origins+ assert "http://localhost:5173" in cfg.cors_origins+ assert "tauri://localhost" in cfg.cors_origins+ assert "*" not in cfg.cors_origins+++class TestSecurityConfigDefaults:+ """SecurityConfig should default to redact mode with rate limiting."""++ def test_default_mode_is_redact(self) -> None:+ from openjarvis.core.config import SecurityConfig++ cfg = SecurityConfig()+ assert cfg.mode == "redact"++ def test_rate_limiting_enabled_by_default(self) -> None:+ from openjarvis.core.config import SecurityConfig++ cfg = SecurityConfig()+ assert cfg.rate_limit_enabled is True++ def test_bypass_defaults_conservative(self) -> None:+ from openjarvis.core.config import SecurityConfig++ cfg = SecurityConfig()+ assert cfg.local_engine_bypass is False+ assert cfg.local_tool_bypass is False++ def test_profile_default_empty(self) -> None:+ from openjarvis.core.config import SecurityConfig++ cfg = SecurityConfig()+ assert cfg.profile == ""