escape params

This commit is contained in:
Eugene Mirotin 2017-05-19 01:25:01 +03:00
parent 880fb43fd9
commit b88f7a993c
4 changed files with 46 additions and 18 deletions

View File

@ -15,7 +15,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var getSubShellCommand;
var _, bash, getSubShellCommand;
_ = require('lodash');
bash = require('bash');
getSubShellCommand = require('../utils/helpers').getSubShellCommand;
@ -36,6 +40,11 @@ module.exports = {
boolean: true,
description: 'increase verbosity',
alias: 'v'
}, {
signature: 'noproxy',
parameter: 'noproxy',
boolean: true,
description: "don't use the proxy configuration for this connection. Only makes sense if you've configured proxy globally."
}
],
action: function(params, options, done) {
@ -77,15 +86,26 @@ module.exports = {
throw new Error('Did not find running application container');
}
return Promise["try"](function() {
var command, proxyAuth, proxyConfig, proxyHost, proxytunnelCommand, sshProxyCommand, subShellCommand;
var command, i, proxyAuth, proxyCommand, proxyConfig, sshProxyCommand, subShellCommand, tunnelOptions;
sshProxyCommand = '';
proxyConfig = global.PROXY_CONFIG;
if (proxyConfig) {
if (proxyConfig && !options.noproxy) {
proxyAuth = proxyConfig.proxyAuth;
proxyHost = "-p " + proxyConfig.host + ":" + proxyConfig.port;
proxyAuth = proxyAuth ? "-P " + proxyAuth : '';
proxytunnelCommand = "proxytunnel " + proxyHost + " " + proxyAuth + " -d %h:%p";
sshProxyCommand = "-o ProxyCommand='" + proxytunnelCommand + "'";
tunnelOptions = {
proxy: proxyConfig.host + ":" + proxyConfig.port,
dest: '%h:%p'
};
if (proxyAuth) {
i = proxyAuth.indexOf(':');
_.assign(tunnelOptions, {
user: proxyAuth.substring(0, i),
pass: proxyAuth.substring(i + 1)
});
}
proxyCommand = "proxytunnel " + (bash.args(tunnelOptions, '--', '='));
sshProxyCommand = "-o " + (bash.args({
ProxyCommand: proxyCommand
}, '', '='));
}
command = "ssh " + verbose + " -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlMaster=no " + sshProxyCommand + " -p " + options.port + " " + username + "@ssh." + proxyUrl + " enter " + uuid + " " + containerId;
subShellCommand = getSubShellCommand(command);

View File

@ -786,6 +786,10 @@ ssh gateway port
increase verbosity
#### --noproxy <noproxy>
don't use the proxy configuration for this connection. Only makes sense if you've configured proxy globally.
# Notes
## note <|note>

View File

@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
###
_ = require('lodash')
bash = require('bash')
{ getSubShellCommand } = require('../utils/helpers')
module.exports =
@ -50,7 +52,8 @@ module.exports =
signature: 'noproxy'
parameter: 'noproxy'
boolean: true
description: "don't use the proxy configuration for this connection. Only makes sense if you've configured proxy globally."
description: "don't use the proxy configuration for this connection.
Only makes sense if you've configured proxy globally."
]
action: (params, options, done) ->
child_process = require('child_process')
@ -88,16 +91,16 @@ module.exports =
proxyConfig = global.PROXY_CONFIG
if proxyConfig and not options.noproxy
{ proxyAuth } = proxyConfig
proxyHost = "#{proxyConfig.host}:#{proxyConfig.port}"
tunnelOptions =
proxy: "#{proxyConfig.host}:#{proxyConfig.port}"
dest: '%h:%p'
if proxyAuth
i = proxyAuth.indexOf(':')
proxyUser = proxyAuth.substring(0, i)
proxyPassword = proxyAuth.substring(i + 1)
proxyAuth = "--user=#{proxyUser} --pass=#{proxyPassword}"
else
proxyAuth = ''
proxytunnelCommand = "proxytunnel --proxy=#{proxyHost} #{proxyAuth} --dest=%h:%p"
sshProxyCommand = "-o ProxyCommand='#{proxytunnelCommand}'"
_.assign tunnelOptions,
user: proxyAuth.substring(0, i)
pass: proxyAuth.substring(i + 1)
proxyCommand = "proxytunnel #{bash.args(tunnelOptions, '--', '=')}"
sshProxyCommand = "-o #{bash.args({ ProxyCommand: proxyCommand }, '', '=')}"
command = "ssh #{verbose} -t \
-o LogLevel=ERROR \

View File

@ -33,10 +33,12 @@
"gulp-shell": "^0.5.2"
},
"dependencies": {
"@resin.io/valid-email": "^0.1.0",
"ansi-escapes": "^2.0.0",
"any-promise": "^1.3.0",
"babel-preset-es2015": "^6.16.0",
"babel-register": "^6.16.3",
"bash": "0.0.1",
"bluebird": "^3.3.3",
"capitano": "^1.7.0",
"chalk": "^1.1.3",
@ -85,8 +87,7 @@
"umount": "^1.1.5",
"underscore.string": "^3.1.1",
"unzip2": "^0.2.5",
"update-notifier": "^0.6.1",
"valid-email": "^0.0.2"
"update-notifier": "^0.6.1"
},
"optionalDependencies": {
"removedrive": "^1.0.0"