mirror of
https://github.com/appium/appium.git
synced 2026-02-10 11:59:45 -06:00
Merge pull request #3240 from jlipps/master
add validation for port values to server (fix #3227)
This commit is contained in:
@@ -47,7 +47,7 @@ module.exports.catchAllHandler = function (e, req, res, next) {
|
||||
next(e);
|
||||
};
|
||||
|
||||
module.exports.checkArgs = function (args) {
|
||||
module.exports.checkArgs = function (parser, args) {
|
||||
var exclusives = [
|
||||
['noReset', 'fullReset']
|
||||
, ['ipa', 'safari']
|
||||
@@ -69,6 +69,34 @@ module.exports.checkArgs = function (args) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
var checkValidPort = function (port) {
|
||||
if (port > 0 && port < 65536) return true;
|
||||
console.error("Port must be greater than 0 and less than 65536");
|
||||
return false;
|
||||
};
|
||||
|
||||
var validations = {
|
||||
port: checkValidPort
|
||||
, callbackPort: checkValidPort
|
||||
, bootstrapPort: checkValidPort
|
||||
, selendroidPort: checkValidPort
|
||||
, chromedriverPort: checkValidPort
|
||||
, robotPort: checkValidPort
|
||||
, backendRetries: function (r) { return r >= 0; }
|
||||
};
|
||||
|
||||
var nonDefaultArgs = getNonDefaultArgs(parser, args);
|
||||
|
||||
_.each(validations, function (validator, arg) {
|
||||
if (_.has(nonDefaultArgs, arg)) {
|
||||
if (!validator(args[arg])) {
|
||||
console.error("Invalid argument for param " + arg + ": " + args[arg]);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
module.exports.noColorLogger = function (tokens, req, res) {
|
||||
|
||||
@@ -81,7 +81,7 @@ var main = function (args, readyCb, doneCb) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
checkArgs(args);
|
||||
checkArgs(parser, args);
|
||||
if (typeof doneCb === "undefined") {
|
||||
doneCb = function () {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user