Repository navigation
fix(hermes): validate config lifecycle writes - #8845
Conversation
Signed-off-by: Yimo Jiang <[email protected]>
📝 WalkthroughWalkthroughHermes configuration writes now undergo schema validation before mutation. Sandbox URL validation supports explicit private-URL opt-in while retaining public DNS pinning. Hermes restart failures include sanitized gateway-log tails. Documentation and tests cover validation, recovery, diagnostics, and configuration effects. ChangesHermes configuration safety
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in commit 17f2e6c in the TypeScript / code-coverage/cliThe overall coverage in commit 17f2e6c in the Show a code coverage summary of the most impacted files.
Updated |
| import importlib.util | ||
| import os | ||
| import sys | ||
| import tempfile |
| import importlib.util | ||
| import os | ||
| import sys | ||
| import tempfile |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/lib/actions/sandbox/gateway-restart.test.ts (1)
195-218: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winCover failed Hermes log-tail retrieval.
The new
nulland non-zero result paths inhermesGatewayLogTailare not exercised. Add Hermes cases whereexecuteSandboxExecCommandreturnsnulland a non-zero status. Assert that the restart remains alaunch failureand does not print the log-tail header.As per path instructions: “Review tests for behavioral confidence rather than implementation lock-in.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/actions/sandbox/gateway-restart.test.ts` around lines 195 - 218, Add Hermes-specific test cases near the existing gateway restart coverage for hermesGatewayLogTail when executeSandboxExecCommand returns null and when it returns a non-zero status. For both cases, assert the restart reports a launch failure and the gateway log-tail header is not printed, while keeping assertions focused on observable behavior rather than implementation details.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@agents/hermes/plugin/__init__.py`:
- Line 332: In the browser tool initialization flow, replace the setattr call
assigning _allow_private_urls_resolved with direct attribute assignment on
browser_tool, preserving the existing allow_private_urls value.
In `@agents/hermes/plugin/test_private_url_opt_in.py`:
- Line 10: Remove the unused tempfile import from test_private_url_opt_in.py,
leaving the rest of the test file unchanged.
In `@src/lib/actions/sandbox/gateway-restart.test.ts`:
- Around line 155-187: Update the fixture in the restartSandboxGateway test so
the sk-proj token is assigned to logLines[13], which is included by the captured
tail. Keep the existing sanitized-output assertion and ensure it verifies the
token value is absent while the expected redaction behavior remains covered.
---
Nitpick comments:
In `@src/lib/actions/sandbox/gateway-restart.test.ts`:
- Around line 195-218: Add Hermes-specific test cases near the existing gateway
restart coverage for hermesGatewayLogTail when executeSandboxExecCommand returns
null and when it returns a non-zero status. For both cases, assert the restart
reports a launch failure and the gateway log-tail header is not printed, while
keeping assertions focused on observable behavior rather than implementation
details.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 4bd7a157-bd41-4715-a068-974f6a411de3
📒 Files selected for processing (14)
agents/hermes/plugin/__init__.pyagents/hermes/plugin/test_private_url_opt_in.pyagents/hermes/runtime-config-guard.pydocs/reference/commands.mdxhandoff-issue-contract.mdsrc/lib/actions/sandbox/gateway-restart.test.tssrc/lib/actions/sandbox/gateway-restart.tssrc/lib/sandbox/compose-sandbox-config-body.test.tssrc/lib/sandbox/config.tstest/config-set.test.tstest/helpers/hermes-restart-config-seal-fixture.tstest/hermes-nonroot-strict-hash-reconciliation.test.tstest/hermes-restart-config-seal-transition.test.tstest/hermes-runtime-config-guard.test.ts
| if isinstance(security, dict) | ||
| else False | ||
| ) | ||
| setattr(browser_tool, "_allow_private_urls_resolved", allow_private_urls) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use direct attribute assignment.
Replace setattr(browser_tool, "_allow_private_urls_resolved", allow_private_urls) with direct assignment. Ruff reports B010 for this changed line.
🧰 Tools
🪛 Ruff (0.16.1)
[warning] 332-332: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@agents/hermes/plugin/__init__.py` at line 332, In the browser tool
initialization flow, replace the setattr call assigning
_allow_private_urls_resolved with direct attribute assignment on browser_tool,
preserving the existing allow_private_urls value.
Source: Linters/SAST tools
| import importlib.util | ||
| import os | ||
| import sys | ||
| import tempfile |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the unused import.
tempfile has no use in this file. Remove the import.
🧰 Tools
🪛 GitHub Check: CodeQL
[notice] 10-10: Unused import
Import of 'tempfile' is not used.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@agents/hermes/plugin/test_private_url_opt_in.py` at line 10, Remove the
unused tempfile import from test_private_url_opt_in.py, leaving the rest of the
test file unchanged.
Source: Linters/SAST tools
| const logLines = Array.from({ length: 15 }, (_, index) => `line-${index}`); | ||
| logLines[1] = "token=sk-proj-abcdefghijklmnopqrstuvwxyz0123456789"; | ||
| logLines[14] = "Bearer super-secret-token-value"; | ||
| const executeSandboxExecCommand = vi.fn(() => ({ | ||
| status: 0, | ||
| stdout: logLines.join("\n"), | ||
| stderr: "", | ||
| })); | ||
| const deps = baseDeps({ | ||
| getSessionAgent: () => ({ name: "hermes" }), | ||
| getSandbox: () => ({ name: "triage-8614", agent: "hermes" }), | ||
| requestGatewaySupervisorAction: vi.fn(() => ({ | ||
| status: 1, | ||
| stdout: "GATEWAY_FAILED", | ||
| stderr: "", | ||
| })), | ||
| executeSandboxExecCommand, | ||
| }); | ||
|
|
||
| const result = restartSandboxGateway("triage-8614", { quiet: true, deps }); | ||
| const output = (console.error as ReturnType<typeof vi.fn>).mock.calls.flat().join("\n"); | ||
|
|
||
| expect(result).toMatchObject({ ok: false, failureLayer: "launch failure" }); | ||
| expect(executeSandboxExecCommand).toHaveBeenCalledWith( | ||
| "triage-8614", | ||
| "tail -n 12 /tmp/gateway.log 2>/dev/null || true", | ||
| ); | ||
| expect(output).toContain("Hermes gateway log tail (sanitized):"); | ||
| expect(output).toContain("line-3"); | ||
| expect(output).toContain("Bearer <REDACTED>"); | ||
| expect(output).not.toContain("line-2"); | ||
| expect(output).not.toContain("sk-proj-abcdefghijklmnopqrstuvwxyz0123456789"); | ||
| expect(output).not.toContain("super-secret-token-value"); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Place the token fixture inside the captured tail.
tail -n 12 keeps indexes 3 through 14 from these 15 lines. logLines[1] is removed before sanitization, so the assertion at Line 186 passes even if the sk-proj... value is leaked. Move the fixture to logLines[13] and assert the sanitized result.
Proposed test fix
- logLines[1] = "token=sk-proj-abcdefghijklmnopqrstuvwxyz0123456789";
+ logLines[13] = "token=sk-proj-abcdefghijklmnopqrstuvwxyz0123456789";As per path instructions: “Review tests for behavioral confidence rather than implementation lock-in.”
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const logLines = Array.from({ length: 15 }, (_, index) => `line-${index}`); | |
| logLines[1] = "token=sk-proj-abcdefghijklmnopqrstuvwxyz0123456789"; | |
| logLines[14] = "Bearer super-secret-token-value"; | |
| const executeSandboxExecCommand = vi.fn(() => ({ | |
| status: 0, | |
| stdout: logLines.join("\n"), | |
| stderr: "", | |
| })); | |
| const deps = baseDeps({ | |
| getSessionAgent: () => ({ name: "hermes" }), | |
| getSandbox: () => ({ name: "triage-8614", agent: "hermes" }), | |
| requestGatewaySupervisorAction: vi.fn(() => ({ | |
| status: 1, | |
| stdout: "GATEWAY_FAILED", | |
| stderr: "", | |
| })), | |
| executeSandboxExecCommand, | |
| }); | |
| const result = restartSandboxGateway("triage-8614", { quiet: true, deps }); | |
| const output = (console.error as ReturnType<typeof vi.fn>).mock.calls.flat().join("\n"); | |
| expect(result).toMatchObject({ ok: false, failureLayer: "launch failure" }); | |
| expect(executeSandboxExecCommand).toHaveBeenCalledWith( | |
| "triage-8614", | |
| "tail -n 12 /tmp/gateway.log 2>/dev/null || true", | |
| ); | |
| expect(output).toContain("Hermes gateway log tail (sanitized):"); | |
| expect(output).toContain("line-3"); | |
| expect(output).toContain("Bearer <REDACTED>"); | |
| expect(output).not.toContain("line-2"); | |
| expect(output).not.toContain("sk-proj-abcdefghijklmnopqrstuvwxyz0123456789"); | |
| expect(output).not.toContain("super-secret-token-value"); | |
| const logLines = Array.from({ length: 15 }, (_, index) => `line-${index}`); | |
| logLines[13] = "token=sk-proj-abcdefghijklmnopqrstuvwxyz0123456789"; | |
| logLines[14] = "Bearer super-secret-token-value"; | |
| const executeSandboxExecCommand = vi.fn(() => ({ | |
| status: 0, | |
| stdout: logLines.join("\n"), | |
| stderr: "", | |
| })); | |
| const deps = baseDeps({ | |
| getSessionAgent: () => ({ name: "hermes" }), | |
| getSandbox: () => ({ name: "triage-8614", agent: "hermes" }), | |
| requestGatewaySupervisorAction: vi.fn(() => ({ | |
| status: 1, | |
| stdout: "GATEWAY_FAILED", | |
| stderr: "", | |
| })), | |
| executeSandboxExecCommand, | |
| }); | |
| const result = restartSandboxGateway("triage-8614", { quiet: true, deps }); | |
| const output = (console.error as ReturnType<typeof vi.fn>).mock.calls.flat().join("\n"); | |
| expect(result).toMatchObject({ ok: false, failureLayer: "launch failure" }); | |
| expect(executeSandboxExecCommand).toHaveBeenCalledWith( | |
| "triage-8614", | |
| "tail -n 12 /tmp/gateway.log 2>/dev/null || true", | |
| ); | |
| expect(output).toContain("Hermes gateway log tail (sanitized):"); | |
| expect(output).toContain("line-3"); | |
| expect(output).toContain("Bearer <REDACTED>"); | |
| expect(output).not.toContain("line-2"); | |
| expect(output).not.toContain("sk-proj-abcdefghijklmnopqrstuvwxyz0123456789"); | |
| expect(output).not.toContain("super-secret-token-value"); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/actions/sandbox/gateway-restart.test.ts` around lines 155 - 187,
Update the fixture in the restartSandboxGateway test so the sk-proj token is
assigned to logLines[13], which is included by the captured tail. Keep the
existing sanitized-output assertion and ensure it verifies the token value is
absent while the expected redaction behavior remains covered.
Source: Path instructions
PR Review Advisor — No blocking findings reportedAdvisor assessment: No blocking advisor findings reported Model lanes
4 terminology differences from the second opinionAdvisory only. These are normalized differences from the primary terminology receipt.
1 additional E2E selection from the second opinionAdvisory only. The primary lane did not select these E2E jobs or targets.
Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests. 3 semantic terminology decisionsTerminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.
E2E guidanceAdvisory only. A maintainer can dispatch the default E2E suite for the commit under review. Recommended E2E: None Manual-only E2E: 2 optional E2E recommendations
This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge. |
prekshivyas
left a comment
There was a problem hiding this comment.
Reviewed latest PR commit 17f2e6cbe. I found no blocking correctness or security issue. Candidate configuration is schema-validated before the sealed mutation, private URLs require the existing explicit boolean opt-in while public hosts retain DNS validation and pinning, and restart diagnostics are bounded and redacted. The atomic-write, opt-in, recovery, and diagnostic tests cover the affected lifecycle.
Security rubric: 1 PASS (credential-shaped diagnostics are redacted); 2 PASS (schema, URL, DNS, and boolean validation precede use); 3 PASS (the explicit opt-in is read from the authoritative config); 4 PASS (no new dependency); 5 PASS (targeted recovery and bounded diagnostics); 6 PASS (no cryptography change); 7 PASS (private access remains denied by default); 8 PASS (positive and negative lifecycle coverage); 9 PASS (validation precedes configuration and integrity mutation). Files reviewed: the complete 14-file diff.
prekshivyas
left a comment
There was a problem hiding this comment.
Blocking test-integrity finding on commit 17f2e6c.
The restart diagnostic test creates 15 log lines and production captures only tail -n 12, but the sk-proj fixture is assigned to line index 1. That line is excluded before sanitization, so the assertion that the token is absent passes even if the sanitizer leaks this credential shape. Move the token into the captured tail and assert the emitted value is redacted. Also clear the current static-check failures from the unused tempfile import and constant-name setattr call.
|
Main CI now exposes one all-files formatter drift from this merged change: Biome rewrites only |
Summary
Hermes configuration writes now validate the complete candidate before changing configuration or integrity metadata. The lifecycle also reports truthful restart effects, bounded redacted restart diagnostics, targeted recovery guidance, and an explicit private-URL opt-in while retaining public-host DNS validation and pinning.
Related Issue
Fixes #8614
Changes
security.allow_private_urlsboolean as the explicit opt-in required by the CLI and plugin. Public hosts continue through DNS validation and pinning; private URLs remain denied by default.--restartverification accurately, and direct pre-write compatibility-hash failures tonemoclaw '<sandbox>' recover./tmp/gateway.logwhen Hermes supervisor restart fails, without exposing credential-shaped values..env, recovery, and private-URL behavior.Type of Change
Quality Gates
Documentation Writer Review
docs-updateddocs/reference/commands.mdx; changed code comments, diagnostics, and behavior-oriented test titlesDGX Station Hardware Evidence
scripts/prepare-dgx-station-host.shis unchanged.Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run validate:prpassed after refreshingorigin/mainwhen hooks were skipped or unavailablepython3 -m unittest agents.hermes.plugin.test_private_url_opt_inpassed; CLI typecheck and plugin build passed. Real CLI E2E verified atomic rejection with unchanged hashes, a valid write, post-rebuild write recovery, bounded restart diagnostics, default private-URL denial, and explicit opt-in acceptance.npm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — command/result: Localnpm testdid not pass because the handoff hook leaked into temporary Git fixtures and unrelated environment-dependent baseline tests failed. The issue-focused suites passed; CI remains authoritative for the broad gate.npm run docsbuilds without warnings (doc changes only)Signed-off-by: Yimo Jiang [email protected]
Summary by CodeRabbit
New Features
Bug Fixes
Documentation