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/LogManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ module.exports = function(CLI) {

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

if (!/^[a-zA-Z0-9._-]+$/.test(user)) {
Common.printError(cst.PREFIX_MSG_ERR + 'Invalid -u/--user value: only alphanumeric, dot, underscore and dash are allowed');
return cb ? cb(Common.retErr('Invalid user value')) : that.exitCli(cst.ERROR_EXIT);
}

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

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

if (!/^[a-zA-Z0-9._-]+$/.test(user) ||
(opts.serviceName && !/^[a-zA-Z0-9._-]+$/.test(opts.serviceName))) {
Common.printError(cst.PREFIX_MSG_ERR + 'Invalid -u/--user or --service-name value: only alphanumeric, dot, underscore and dash are allowed');
return cb ? cb(new Error('Invalid user or service name')) : that.exitCli(cst.ERROR_EXIT);
}

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

if (!/^[a-zA-Z0-9._-]+$/.test(user) ||
(opts.serviceName && !/^[a-zA-Z0-9._-]+$/.test(opts.serviceName))) {
Common.printError(cst.PREFIX_MSG_ERR + 'Invalid -u/--user or --service-name value: only alphanumeric, dot, underscore and dash are allowed');
return cb ? cb(new Error('Invalid user or service name')) : that.exitCli(cst.ERROR_EXIT);
}

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