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

WinRM Check Step tries to use "${config.winrmproxy}" as a proxy when the proxy fields are not in the step config

Open skywalkw3r opened this issue 1 month ago • 0 comments

The WinRMCheck provider passes its optional settings through script-args in plugin.yaml:

... --certpath ${config.certpath} --proxy ${config.winrmproxy} --noproxy ${config.winrmnoproxy}

When the step's configuration has no entry for one of these properties, Rundeck leaves the ${config.name} reference unexpanded, so winrm-check.py receives the literal text as the value. The script treats None and empty strings as "not set", but not the unexpanded reference. The result:

  • Proxy: --proxy '${config.winrmproxy}' is taken as a real proxy URL, so every check tries to connect through a proxy host named ${config.winrmproxy} and fails with a name resolution error.
  • Certificate path: --certpath '${config.certpath}' is passed to pywinrm as ca_trust_path for https checks.

This affects:

  • jobs whose Check step was saved before the proxy fields existed (added in 9b0f72f, December 2023);
  • jobs defined through YAML or the API that leave the optional fields out.

It is currently hidden behind #136 (the step crashes with a NameError before it gets this far). Once that is fixed, it is the next failure.

Steps to reproduce

  1. Import a job with a WinRM Check Step whose configuration sets only the required fields: hostname, username, password storage path, auth type, transport and port.
  2. Run it, with #136 fixed.

Actual

[INFO   ]  Connecting to http://127.0.0.1:15985 via PROXY (${config.winrmproxy}) (common.py:134)[root]
requests.exceptions.ProxyError: HTTPConnectionPool(host='${config.winrmproxy}', port=80): Max retries exceeded ...

Expected

No proxy is used, and the check connects directly: Connecting to ... DIRECTLY (no proxy configured).

I reproduced this on a local Rundeck 6.4.0-SNAPSHOT server against a stub WinRM endpoint, not a real Windows host. When the same three fields are present in the config as empty strings, the step works.

skywalkw3r avatar Oct 18 '26 20:10 skywalkw3r