diff --git a/Tasks/CopyFilesOverSSHV0/ThirdPartyNotice.txt b/Tasks/CopyFilesOverSSHV0/ThirdPartyNotice.txt index b98535f5e04b..4eba1e4e41c0 100644 --- a/Tasks/CopyFilesOverSSHV0/ThirdPartyNotice.txt +++ b/Tasks/CopyFilesOverSSHV0/ThirdPartyNotice.txt @@ -24,7 +24,7 @@ This Azure DevOps extension (CopyFilesOverSSHV0) is based on or incorporates mat 18. path-is-absolute (git+https://github.com/sindresorhus/path-is-absolute.git) 19. q (git://github.com/kriskowal/q.git) 20. readable-stream (git://github.com/isaacs/readable-stream.git) -21. ssh2-sftp-client (git+https://https://github.com/theophilusx/ssh2-sftp-client.git) +21. ssh2-sftp-client (git+https://github.com/theophilusx/ssh2-sftp-client.git) 22. semver (git+https://github.com/npm/node-semver.git) 23. shelljs (git://github.com/arturadib/shelljs.git) 24. ssh2 (git+ssh://git@github.com/mscdex/ssh2.git) diff --git a/Tasks/CopyFilesOverSSHV0/copyfilesoverssh.ts b/Tasks/CopyFilesOverSSHV0/copyfilesoverssh.ts index 7e81ea14c403..03d065fa2d7c 100644 --- a/Tasks/CopyFilesOverSSHV0/copyfilesoverssh.ts +++ b/Tasks/CopyFilesOverSSHV0/copyfilesoverssh.ts @@ -222,7 +222,7 @@ async function run() { let targetPath = path.posix.join(targetFolder, relativePath); if (!path.isAbsolute(targetPath)) { - targetPath = './' + targetPath + targetPath = `./${targetPath}`; } console.log(tl.loc('StartedFileCopy', fileToCopy, targetPath)); diff --git a/Tasks/CopyFilesOverSSHV0/package-lock.json b/Tasks/CopyFilesOverSSHV0/package-lock.json index 96d8b150b0df..18722f77b877 100644 --- a/Tasks/CopyFilesOverSSHV0/package-lock.json +++ b/Tasks/CopyFilesOverSSHV0/package-lock.json @@ -9,11 +9,6 @@ "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" }, - "async": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" - }, "azure-pipelines-task-lib": { "version": "2.9.3", "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-2.9.3.tgz", @@ -56,41 +51,45 @@ "concat-map": "0.0.1" } }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "glob": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", - "integrity": "sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=", + "concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.2", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + } } }, "inherits": { @@ -98,20 +97,10 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "lodash": { - "version": "4.11.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.11.2.tgz", - "integrity": "sha1-1rQzixEKWOIdrlzrz9u/0rxM2zs=" - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "requires": { "brace-expansion": "^1.1.7" } @@ -121,56 +110,20 @@ "resolved": "https://registry.npmjs.org/mockery/-/mockery-1.7.0.tgz", "integrity": "sha1-9O3g2HUMHJcnwnLqLGBiniyaHE8=" }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } + "retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" }, - "scp2": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/scp2/-/scp2-0.5.0.tgz", - "integrity": "sha1-ZO50vDaF86TGKQ8tqMHjtO75Lo0=", - "requires": { - "async": "~0.9.0", - "glob": "~7.0.3", - "lodash": "~4.11.1", - "ssh2": "~0.4.10" - }, - "dependencies": { - "ssh2": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/ssh2/-/ssh2-0.4.15.tgz", - "integrity": "sha1-B8b0EG2fe26m5N9jbGxT8fmBf/g=", - "requires": { - "readable-stream": "~1.0.0", - "ssh2-streams": "~0.0.22" - } - } - } + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, "semver": { "version": "5.5.0", @@ -202,14 +155,34 @@ } } }, - "ssh2-streams": { - "version": "0.0.23", - "resolved": "https://registry.npmjs.org/ssh2-streams/-/ssh2-streams-0.0.23.tgz", - "integrity": "sha1-ru8wgxu1/Er2qj9tCiYaQTUxYSs=", + "ssh2-sftp-client": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ssh2-sftp-client/-/ssh2-sftp-client-5.2.1.tgz", + "integrity": "sha512-/xRyPOp42re6dHZ9zGGfTucPG/XNLjrZjeKsCcu65334uMrBwHRPkCjcWdnrWu/AxPrCUSXn6/Mc57MaVI4mKQ==", "requires": { - "asn1": "~0.2.0", - "readable-stream": "~1.0.0", - "streamsearch": "~0.1.2" + "concat-stream": "^2.0.0", + "retry": "^0.12.0", + "ssh2": "^0.8.9" + }, + "dependencies": { + "ssh2": { + "version": "0.8.9", + "resolved": "https://registry.npmjs.org/ssh2/-/ssh2-0.8.9.tgz", + "integrity": "sha512-GmoNPxWDMkVpMFa9LVVzQZHF6EW3WKmBwL+4/GeILf2hFmix5Isxm7Amamo8o7bHiU0tC+wXsGcUXOxp8ChPaw==", + "requires": { + "ssh2-streams": "~0.4.10" + } + }, + "ssh2-streams": { + "version": "0.4.10", + "resolved": "https://registry.npmjs.org/ssh2-streams/-/ssh2-streams-0.4.10.tgz", + "integrity": "sha512-8pnlMjvnIZJvmTzUIIA5nT4jr2ZWNNVHwyXfMGdRJbug9TpI3kd99ffglgfSWqujVv/0gxwMsDn9j9RVst8yhQ==", + "requires": { + "asn1": "~0.2.0", + "bcrypt-pbkdf": "^1.0.2", + "streamsearch": "~0.1.2" + } + } } }, "streamsearch": { @@ -217,20 +190,20 @@ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, - "wrappy": { + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "util-deprecate": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" } } } diff --git a/Tasks/CopyFilesOverSSHV0/sshhelper.ts b/Tasks/CopyFilesOverSSHV0/sshhelper.ts index ae1dbda42bbb..916fd86a8ba8 100644 --- a/Tasks/CopyFilesOverSSHV0/sshhelper.ts +++ b/Tasks/CopyFilesOverSSHV0/sshhelper.ts @@ -53,6 +53,19 @@ export class SshHelper { await defer.promise; } + /** + * Change path separator for Windows-based platforms + * See https://github.com/spmjs/node-scp2/blob/master/lib/client.js#L319 + * + * @param filePath + */ + private unixyPath(filePath) { + if (process.platform === 'win32') { + return filePath.replace(/\\/g, '/'); + } + return filePath; + } + /** * Sets up the SSH connection */ @@ -72,6 +85,9 @@ export class SshHelper { async closeConnection() { try { if (this.sftpClient) { + this.sftpClient.on('error', (err) => { + tl.debug('sftpClient: Ignoring error diconnecting: ' + err); + }); // ignore logout errors; see: https://github.com/mscdex/node-imap/issues/695 await this.sftpClient.end(); this.sftpClient = null; } @@ -98,9 +114,7 @@ export class SshHelper { * @returns {Promise} */ async uploadFile(sourceFile: string, dest: string) : Promise { - if (process.platform === 'win32') { - dest = dest.replace(/\\/g, '/'); - } + dest = this.unixyPath(dest); tl.debug('Upload ' + sourceFile + ' to ' + dest + ' on remote machine.'); @@ -142,7 +156,7 @@ export class SshHelper { if(!this.sftpClient) { defer.reject(tl.loc('ConnectionNotSetup')); } - if (await this.sftpClient.stat(path)) { + if (await this.sftpClient.exists(path)) { //path exists defer.resolve(true); } else { diff --git a/Tasks/CopyFilesOverSSHV0/task.json b/Tasks/CopyFilesOverSSHV0/task.json index 89cac2b42203..65a93b7ae544 100644 --- a/Tasks/CopyFilesOverSSHV0/task.json +++ b/Tasks/CopyFilesOverSSHV0/task.json @@ -17,7 +17,7 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 173, + "Minor": 174, "Patch": 0 }, "demands": [], diff --git a/Tasks/CopyFilesOverSSHV0/task.loc.json b/Tasks/CopyFilesOverSSHV0/task.loc.json index 22e150d908e0..78eae77b683f 100644 --- a/Tasks/CopyFilesOverSSHV0/task.loc.json +++ b/Tasks/CopyFilesOverSSHV0/task.loc.json @@ -17,7 +17,7 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 173, + "Minor": 174, "Patch": 0 }, "demands": [],