py-winrm-plugin icon indicating copy to clipboard operation
py-winrm-plugin copied to clipboard

Unsupported `winrm-shell` value runs nothing and the step is reported as successful

Open skywalkw3r opened this issue 1 month ago • 0 comments

The shell can be overridden per node with the winrm-shell attribute (instance-scope-node-attribute on the shell property in plugin.yaml). Node attributes are free text, so a value like PowerShell, pwsh, or powershell (trailing space) can reach the plugin.

RunCommand.get_response() in contents/winrm_session.py only handles "cmd" and "powershell". For any other value it runs nothing and leaves stat and e_std as None. winrm-exec.py then calls sys.exit(tsk.stat), i.e. sys.exit(None), which exits 0.

Steps to reproduce

  1. Define a node using the WinRM node executor with the attribute winrm-shell=PowerShell.
  2. Run any command on that node, e.g. whoami.

Actual

  • No command is sent to the node.
  • The step exits 0 and is shown as successful, with no output.
  • With exitbehaviour=console: nothing is logged.
  • With exitbehaviour=exitcode: it logs Execution finished with the following exit code: None, then still exits 0.

Expected

The step fails with a clear error naming the bad value and the allowed values (cmd, powershell).

Notes

I found this by reading the code and confirmed it locally by running contents/winrm-exec.py directly with RD_CONFIG_SHELL=PowerShell against a closed local port (no WinRM listener): it exits 0 in both exit behaviour modes, because nothing ever tries to connect. I also reproduced it on a local Rundeck 6.4.0-SNAPSHOT server (against a stub WinRM endpoint, not a real Windows host): the winrm-shell=PowerShell node attribute is passed straight through to the plugin, and the job is reported as succeeded with no output.

skywalkw3r avatar Oct 18 '26 20:10 skywalkw3r