train
train copied to clipboard
Insufficient credential quoting in the VMware transport
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
- Quote the
-User
and-Password
parameters toConnect-VIServer
- Composing a
PSCredential
object beforehand and pass to the-Credential
parameter
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.