Documentation
¶
Overview ¶
Package winrm provides PowerShell command reconstruction and WinRM transport.
Index ¶
- func PowerShellQuote(token string) string
- func ReconstructPowerShellCommand(pipeline *parser.Pipeline) string
- func WrapForWinRM(psCommand string) string
- type ManagedWinRMConnection
- type WinRMDialer
- type WinRMFileClient
- func (f *WinRMFileClient) Chmod(_ string, _ os.FileMode) error
- func (f *WinRMFileClient) Close() error
- func (f *WinRMFileClient) Create(path string) (io.WriteCloser, error)
- func (f *WinRMFileClient) MkdirAll(path string) error
- func (f *WinRMFileClient) Open(path string) (io.ReadCloser, error)
- func (f *WinRMFileClient) Stat(path string) (os.FileInfo, error)
- type WinRMManager
- func (m *WinRMManager) Connect(ctx context.Context, params ssh.ConnectionParams) error
- func (m *WinRMManager) Disconnect(_ context.Context, host string) error
- func (m *WinRMManager) Execute(ctx context.Context, host, command string, timeout time.Duration) (ssh.ExecResult, error)
- func (m *WinRMManager) ExecuteRaw(ctx context.Context, host, command string, timeout time.Duration) (ssh.ExecResult, error)
- func (m *WinRMManager) SFTPSession(host string) (ssh.SFTPClient, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PowerShellQuote ¶
PowerShellQuote single-quotes a token for safe use in PowerShell. Embedded single quotes are escaped by doubling (”). Flags (starting with -) and pipeline operators pass through unquoted.
func ReconstructPowerShellCommand ¶
ReconstructPowerShellCommand rebuilds a validated pipeline into a PowerShell command string with proper quoting.
func WrapForWinRM ¶
WrapForWinRM wraps a PowerShell command string for execution over WinRM. WinRM's default shell is cmd.exe, so we encode the PowerShell command as UTF-16LE base64 and pass it via -EncodedCommand to avoid quoting issues.
Types ¶
type ManagedWinRMConnection ¶
type ManagedWinRMConnection struct {
Client *winrmClient
Params ssh.ConnectionParams
}
ManagedWinRMConnection tracks a WinRM connection.
type WinRMDialer ¶
WinRMDialer creates WinRM connections.
func (*WinRMDialer) Dial ¶
func (d *WinRMDialer) Dial(_ context.Context, params ssh.ConnectionParams) (*winrmClient, error)
Dial creates a new WinRM connection.
type WinRMFileClient ¶
type WinRMFileClient struct {
// contains filtered or unexported fields
}
WinRMFileClient implements ssh.SFTPClient using PowerShell commands over WinRM.
func NewWinRMFileClient ¶
func NewWinRMFileClient(client *winrmClient) *WinRMFileClient
NewWinRMFileClient creates a new file client using an existing WinRM connection.
func (*WinRMFileClient) Chmod ¶
func (f *WinRMFileClient) Chmod(_ string, _ os.FileMode) error
Chmod is a no-op on Windows (ACLs are not managed this way).
func (*WinRMFileClient) Close ¶
func (f *WinRMFileClient) Close() error
Close is a no-op since WinRM file operations are stateless.
func (*WinRMFileClient) Create ¶
func (f *WinRMFileClient) Create(path string) (io.WriteCloser, error)
Create writes a file on the remote system via chunked base64 writes.
func (*WinRMFileClient) MkdirAll ¶
func (f *WinRMFileClient) MkdirAll(path string) error
MkdirAll creates a directory and all parents on the remote system.
func (*WinRMFileClient) Open ¶
func (f *WinRMFileClient) Open(path string) (io.ReadCloser, error)
Open reads a remote file and returns its content as a ReadCloser. Uses chunked reads for files larger than smallFileThreshold.
type WinRMManager ¶
type WinRMManager struct {
// contains filtered or unexported fields
}
WinRMManager manages WinRM connections, implementing server.Executor.
func NewWinRMManager ¶
func NewWinRMManager(dialer *WinRMDialer) *WinRMManager
NewWinRMManager creates a new WinRM connection manager.
func (*WinRMManager) Connect ¶
func (m *WinRMManager) Connect(ctx context.Context, params ssh.ConnectionParams) error
func (*WinRMManager) Disconnect ¶
func (m *WinRMManager) Disconnect(_ context.Context, host string) error
func (*WinRMManager) Execute ¶
func (m *WinRMManager) Execute(ctx context.Context, host, command string, timeout time.Duration) (ssh.ExecResult, error)
func (*WinRMManager) ExecuteRaw ¶
func (m *WinRMManager) ExecuteRaw(ctx context.Context, host, command string, timeout time.Duration) (ssh.ExecResult, error)
func (*WinRMManager) SFTPSession ¶
func (m *WinRMManager) SFTPSession(host string) (ssh.SFTPClient, error)