train icon indicating copy to clipboard operation
train copied to clipboard

Insufficient credential quoting in the VMware transport

Open gsreynolds opened this issue 6 years ago • 1 comments

Description

Connecting to a vSphere instance using a password that contains an asterisk fails due to insufficient quoting of the password in the Connect-VIServer command/lack of use of a PSCredential object.

> $ inspec exec test-vcenters -t vmware://
Unable to connect to VIServer at PRODVCENTER. out-file : Cannot perform operation because the wildcard path 2@PASSWORD*e#O did not resolve to a file.
At line:1 char:40
+ ... lyContinue';Connect-VIServer PRODVCENTER -User ADMIN-USER -Password REDACTED+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (2@PASSWORD*e#O:String) [Out-File], FileNotFoundException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

Train and Platform Version

1.4.37, Windows 10

Replication Case

Use the vmware transport with a password containing special characters such as an asterisk.

Possible Solutions

  1. Quote the -User and -Password parameters to Connect-VIServer
  2. Composing a PSCredential object beforehand and pass to the -Credential parameter

gsreynolds avatar Nov 08 '18 16:11 gsreynolds

Have the same issue! Also, just want to add, as a possible workaround you should be able to embed single quotes into the password string. For example:

in .env

VISERVER_PASSWORD=\'mycomplexpassword***$$\'

export $(cat .env | xargs) echo $VISERVER_PASSWORD

'mycomplexpassword***$$'

pwsh should automatically parse that as a literal string now.

Geogboe avatar Jun 30 '20 15:06 Geogboe