Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/API/Deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ module.exports = function(CLI) {
return cb ? cb() : that.exitCli(cst.SUCCESS_EXIT);
}

if (!/^[a-zA-Z0-9._-]+$/.test(env)) {
Common.printError('Invalid environment name: ' + env);
return cb ? cb(new Error('Invalid environment name')) : that.exitCli(cst.ERROR_EXIT);
}

if (!json_conf.deploy || !json_conf.deploy[env]) {
Common.printError('%s environment is not defined in %s file', env, file);
return cb ? cb('%s environment is not defined in %s file') : that.exitCli(cst.ERROR_EXIT);
Expand Down
15 changes: 15 additions & 0 deletions lib/API/Extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,21 @@ module.exports = function(CLI) {
CLI.prototype.remoteV2 = function(command, opts, cb) {
var that = this;

var ALLOWED_COMMANDS = [
'start', 'stop', 'restart', 'reload', 'delete', 'list', 'describe',
'logs', 'flush', 'reloadLogs', 'sendDataToProcessId', 'trigger',
'gracefulReload', 'killDaemon', 'ping', 'launchBus', 'attach',
'getVersion', 'infoVizion', 'monit', 'dashboard', 'update',
'install', 'uninstall', 'publish', 'save', 'resurrect', 'reset',
'scale', 'env', 'show', 'id', 'deepUpdate', 'startup', 'unstartup',
'prettyList', 'jlist', 'streamLogs', 'flushLogs', 'pullAndRestart',
'pullAndReload', 'forward', 'backward', 'gc', 'getMonitorData',
'getSystemData', 'infoVizion'
];

if (ALLOWED_COMMANDS.indexOf(command) === -1)
return cb(new Error('Command not allowed: ' + command));

if (that[command].length == 1)
return that[command](cb);

Expand Down
2 changes: 2 additions & 0 deletions lib/API/LogManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ module.exports = function(CLI) {

var user = opts.user || 'root';

if (!/^[a-zA-Z0-9_-]+$/.test(user)) return cb ? cb(Common.retErr('Invalid user')) : that.exitCli(cst.ERROR_EXIT);

script = script.replace(/%HOME_PATH%/g, cst.PM2_ROOT_PATH)
.replace(/%USER%/g, user);

Expand Down
4 changes: 4 additions & 0 deletions lib/API/Startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ module.exports = function(CLI) {
var openrc_service_name = 'pm2';
var launchd_service_name = (opts.serviceName || 'pm2.' + user);

if (!/^[a-zA-Z0-9._-]+$/.test(service_name)) return cb(new Error('Invalid service name'));

if (!platform)
platform = actual_platform;
else if (actual_platform && actual_platform !== platform) {
Expand Down Expand Up @@ -203,6 +205,8 @@ module.exports = function(CLI) {
var openrc_service_name = 'pm2';
var launchd_service_name = (opts.serviceName || 'pm2.' + user);

if (!/^[a-zA-Z0-9._-]+$/.test(service_name)) return cb(new Error('Invalid service name'));

if (!platform)
platform = actual_platform;
else if (actual_platform && actual_platform !== platform) {
Expand Down