Security Fixes

This commit is contained in:
Andy Dixon
2026-06-16 09:41:51 +01:00
parent 9bbd9ceccf
commit fcb19c96c8
22 changed files with 1578 additions and 134 deletions
+15
View File
@@ -267,6 +267,21 @@ func (c *Client) UploadBytes(remotePath string, data []byte, onProgress func(Tra
return c.copyWithProgress(reader, remote, int64(len(data)), remotePath, onProgress)
}
// CreateWriter creates or truncates a remote file and returns a streaming
// writer for callers that already manage progress and chunking.
func (c *Client) CreateWriter(remotePath string) (io.WriteCloser, error) {
c.mu.Lock()
defer c.mu.Unlock()
if c.closed || c.sftp == nil {
return nil, fmt.Errorf("sftpclient: client is closed")
}
remote, err := c.sftp.Create(remotePath)
if err != nil {
return nil, fmt.Errorf("sftpclient: failed to create remote file: %w", err)
}
return remote, nil
}
// Pwd returns the current working directory on the remote host.
func (c *Client) Pwd() (string, error) {
c.mu.Lock()