Files
nousresearch--hermes-agent/tests/docker/test_immutable_install_permissions.py
wehub-resource-sync b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:56:03 +08:00

68 lines
2.0 KiB
Python

"""Docker smoke tests for immutable install permissions."""
from __future__ import annotations
import subprocess
import textwrap
def test_container_sets_hosted_write_policy_env(built_image: str) -> None:
script = (
'test "$HERMES_HOME" = "/opt/data" && '
'test "$HERMES_WRITE_SAFE_ROOT" = "/opt/data" && '
'test "$HERMES_DISABLE_LAZY_INSTALLS" = "1" && '
'test "$PYTHONDONTWRITEBYTECODE" = "1"'
)
result = subprocess.run(
["docker", "run", "--rm", "--entrypoint", "sh", built_image, "-c", script],
capture_output=True,
text=True,
timeout=60,
)
assert result.returncode == 0, result.stderr[-2000:]
def test_hermes_user_cannot_modify_install_but_can_write_data(built_image: str) -> None:
script = textwrap.dedent(
r"""
set -eu
/opt/hermes/.venv/bin/python - <<'PY'
from pathlib import Path
install_file = Path("/opt/hermes/agent/message_sanitization.py")
try:
with install_file.open("a", encoding="utf-8") as handle:
handle.write("\n# unexpected hosted mutation\n")
except PermissionError:
pass
else:
raise SystemExit("install source write unexpectedly succeeded")
skill_dir = Path("/opt/data/skills/permission-smoke")
skill_dir.mkdir(parents=True, exist_ok=True)
skill_file = skill_dir / "SKILL.md"
skill_file.write_text("# Permission smoke\n", encoding="utf-8")
if skill_file.read_text(encoding="utf-8") != "# Permission smoke\n":
raise SystemExit("data write verification failed")
PY
"""
).strip()
result = subprocess.run(
[
"docker",
"run",
"--rm",
"--entrypoint",
"su",
built_image,
"hermes",
"-s",
"/bin/sh",
"-c",
script,
],
capture_output=True,
text=True,
timeout=120,
)
assert result.returncode == 0, result.stderr[-2000:]