fix(appctl): lock HOMELAB_DOMAIN at startup to prevent application
Core Architecture & Invariant CI / validate (push) Successful in 40s

domain leaks during sync
This commit is contained in:
kiskaadee committed 2026-10-14 13:41:17 -05:00
1 parent 298ae728e1
commit 6052019f2c
3 files changed
+34 -1

No files matched your search

+3
View File
@@ -35,6 +35,9 @@ if [ -f "$ENV_FILE" ]; then
set +a
fi
# Lock the homelab root domain before setup_app_env can mutate $DOMAIN
export HOMELAB_DOMAIN="${HOMELAB_DOMAIN:-${DOMAIN_SUFFIX:-${DOMAIN:-roadtotech.me}}}"
# Show help usage
show_help() {
echo "🚀 appctl - Homelab Container Orchestrator"
+5 -1
View File
@@ -37,7 +37,11 @@ SITES_DIR = os.environ.get(
else os.path.expanduser("~/Sites"),
)
HOMELAB_DOMAIN = os.environ.get("HOMELAB_DOMAIN") or os.environ.get("DOMAIN", "")
HOMELAB_DOMAIN = (
os.environ.get("HOMELAB_DOMAIN")
or os.environ.get("DOMAIN_SUFFIX")
or os.environ.get("DOMAIN", "")
)
def validate_environment() -> None:
+26
View File
@@ -336,3 +336,29 @@ def test_homepage_sync_groups_and_sorts_correctly(
content = output_file.read_text()
assert content.find("- Group A") < content.find("- Group B") # Group A should appear before Group B
assert "App2" in content # App 2 is in the file
def test_homepage_sync_core_services_domain_isolation(
mock_core_dir: Path,
monkeypatch,
):
"""
Ensure Core Infrastructure services use HOMELAB_DOMAIN and do not leak
an application's domain if DOMAIN is overridden by appctl.
"""
hp_config_dir = mock_core_dir / "config" / "homepage"
hp_config_dir.mkdir(parents=True, exist_ok=True)
monkeypatch.setattr(engine, "HOMELAB_DOMAIN", "roadtotech.me")
monkeypatch.setenv("DOMAIN", "mermaid.roadtotech.me")
engine.cmd_sync_homepage(["--homepage-dir=" + str(hp_config_dir)])
output_file = hp_config_dir / "services.yaml"
assert output_file.exists()
content = output_file.read_text()
assert "https://dashboard.roadtotech.me" in content
assert "https://traefik.roadtotech.me" in content
assert "https://auth.roadtotech.me" in content
assert "mermaid.roadtotech.me" not in content