Skip to content

Small tool bugs: guard rejects 'poweroff' searches, certRenew always forces, inventorySync ignores node env #121

Closed

Description

@TMHSDigital

Summary

Three small, independent tool bugs found during the audit, grouped into one issue.

Related: #106

Checklist

  • Command guard refuses harmless searches for "halt" or "poweroff" -- mcp-server/src/utils/ssh-api.ts:21. The pattern /\b(shutdown\s+-h|halt|poweroff)\b/i is tested against the whole command, including user search text that homelab_logSearch puts in the command (logSearch.ts:45). homelab_logSearch {pattern: "poweroff"} returns UnsafeCommandError. Fix: only match these words in command position (start of command, or after ;, &&, ||, |, sudo), and add a test that a logSearch for "poweroff" is allowed.
  • homelab_certRenew with domain always forces renewal -- mcp-server/src/tools/certRenew.ts:44 runs certbot renew --cert-name <domain> --force-renewal. An agent that retries reissues the certificate each time and can hit Let's Encrypt's duplicate-certificate limit (5 per week). Fix: drop --force-renewal by default and add an explicit force boolean (default false) with the rate-limit warning in its description.
  • homelab_inventorySync ignores per-node HOMELAB_ANSIBLE_INVENTORY -- mcp-server/src/tools/inventorySync.ts:22 reads process.env directly, while every other setting goes through nodeSetting() so HOMELAB_NODES env overrides apply (Per-service config ignores the node param; sshTest reports the wrong host #106). Fix: setting(args.node, "HOMELAB_ANSIBLE_INVENTORY", "/etc/ansible/hosts").

Acceptance criteria

  • Each item fixed with a unit test.

Getting started

  • Relevant files: listed per item
  • How to run tests: cd mcp-server && npm install && npm test

Filed by repo-audit/full-audit at a59395f. Severity: low. Effort: S. audit-key: bug|mcp-server/src/tools|small-tool-bugs-a59395f

Activity

  1. added
    bug
    good first issue
    severity: low
    on Nov 18, 2026
  2. TMHSDigital commented on Nov 18, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in e7e2db1. logSearch now sends the pattern base64-encoded and decodes it on the node, so searches for "poweroff"/"halt" pass the guard (guard unchanged); certRenew only adds --force-renewal with the new force: true; inventorySync reads HOMELAB_ANSIBLE_INVENTORY via nodeSetting(). Each has a unit test (417 passing), and the base64/grep transport was checked in a shell with quote, leading-dash and $(...) patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuemcp-serverseverity: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions