0.9.3.8 hotfix: declare runtime service API-key environment values

Fix Nini startup expansion for simulator service API keys, document optional runtime secret requirements, and add CI coverage for undeclared Environment references.
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-10-07 00:27:46 +02:00
1 parent fca0a1bf97
commit 4d491d7919
5 files changed
+101 -1

No files matched your search

+4
View File
@@ -61,6 +61,10 @@ jobs:
shell: bash
run: python3 tools/ci/verify_no_plaintext_runtime_secrets.py
- name: Verify runtime environment expansion declarations
shell: bash
run: python3 tools/ci/verify_environment_expansions.py
- name: Verify OSSL policy coverage
shell: bash
run: python3 tools/ci/verify_ossl_policy.py
+5
View File
@@ -22,6 +22,11 @@
; * such use is providing a base path for setting locations that Robust
; * uses to write data.
; *
[Environment]
; Runtime secrets are supplied through process environment,
; /etc/nexverse/nexverse.env or bin/nexverse.local.env.
NEXVERSE_NATIVE_TOKEN_SIGNING_KEY = ""
[Const]
; The domain or IP of the Robust server.
BaseHostname = "127.0.0.1"
+7 -1
View File
@@ -1,7 +1,13 @@
[Environment]
; Database credentials are loaded from process environment, /etc/nexverse/nexverse.env,
; Runtime secrets are loaded from process environment, /etc/nexverse/nexverse.env,
; or bin/nexverse.local.env and must never be committed.
;
; Every ${Environment|...} reference used by the simulator must be declared
; here so Nini can expand the configuration even while the related module is
; disabled. The actual secret value remains outside version control.
NEXVERSE_DB_PASSWORD = ""
NEXVERSE_ECONOMY_API_KEY = ""
NEXVERSE_EXPERIENCES_API_KEY = ""
; This is the main configuration file for an instance of OpenSim running in grid mode
+7
View File
@@ -19,6 +19,13 @@ For the current grid configuration:
- `NEXVERSE_ROBUST_CERT_PASSWORD` — password for the Robust TLS certificate container when that certificate is enabled.
- `NEXVERSE_NATIVE_TOKEN_SIGNING_KEY` — HMAC signing key for NexVerse native access tokens; generate at least 32 random bytes (for example `openssl rand -hex 64`).
Simulator service variables are also declared in `bin/config-include/GridCommon.ini` so Nini can resolve every `${Environment|...}` expression during startup:
- `NEXVERSE_ECONOMY_API_KEY` — required only when `[NexEconomyViewer] Enabled = true`; use a restricted machine key with `economy:read` and `economy:transfer`.
- `NEXVERSE_EXPERIENCES_API_KEY` — required only when `[NexExperiencesViewer] Enabled = true`; use a restricted machine key with `experiences:script`.
The declarations themselves stay empty in the tracked INI. When the corresponding module is disabled, the empty declaration is sufficient for configuration expansion. When the module is enabled, provide the real value through a protected runtime secret source.
## Recommended production setup
Create the directory and file once:
+78
View File
@@ -0,0 +1,78 @@
#!/usr/bin/env python3
"""Ensure runtime ${Environment|KEY} references are declared before Nini expansion."""
from pathlib import Path
import re
ROOT = Path(__file__).resolve().parents[2]
REF = re.compile(r"\$\{Environment\|([A-Z][A-Z0-9_]*)\}")
SECTION = re.compile(r"^\s*\[([^]]+)\]\s*$")
ASSIGN = re.compile(r"^\s*([A-Z0-9_]+)\s*=")
def read(rel):
return (ROOT / rel).read_text(encoding="utf-8", errors="replace")
def refs(paths):
found = set()
for rel in paths:
found.update(REF.findall(read(rel)))
return found
def declarations(paths):
found = set()
for rel in paths:
section = ""
for raw in read(rel).splitlines():
m = SECTION.match(raw)
if m:
section = m.group(1)
continue
if section != "Environment":
continue
m = ASSIGN.match(raw)
if m:
found.add(m.group(1))
return found
profiles = [
(
"simulator",
["bin/OpenSim.ini", "bin/config-include/GridCommon.ini"],
["bin/OpenSim.ini", "bin/config-include/GridCommon.ini"],
),
(
"simulator-example",
["bin/OpenSim.ini.example", "bin/config-include/GridCommon.ini"],
["bin/OpenSim.ini.example", "bin/config-include/GridCommon.ini"],
),
(
"robust-hg",
["bin/Robust.HG.ini"],
["bin/Robust.HG.ini"],
),
(
"robust-hg-example",
["bin/Robust.HG.ini.example"],
["bin/Robust.HG.ini.example"],
),
]
violations = []
for name, reference_paths, declaration_paths in profiles:
required = refs(reference_paths)
declared = declarations(declaration_paths)
missing = sorted(required - declared)
if missing:
violations.append((name, missing))
if violations:
print("[NX-SECRET-0002] Environment expansion declarations are incomplete:")
for profile, missing in violations:
print(f" - {profile}: missing {', '.join(missing)}")
raise SystemExit(1)
print("NexVerse environment expansion declaration guard: OK")