Added space to filter regex

This commit is contained in:
iotux 2025-12-19 16:12:58 +01:00
parent 3e2f489d8b
commit 4639dc54bd

View File

@ -74,10 +74,10 @@ class SystemServiceMonitorType extends MonitorType {
async checkWindows(serviceName, heartbeat) { async checkWindows(serviceName, heartbeat) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// SECURITY: Prevent Command Injection // SECURITY: Prevent Command Injection
// Only allow alphanumeric, dots, dashes, underscores, and @. // Only allow alphanumeric, dots, dashes, underscores, @, and SPACES.
if (!serviceName || !/^[a-zA-Z0-9._\-@]+$/.test(serviceName)) { if (!serviceName || !/^[a-zA-Z0-9._\-@ ]+$/.test(serviceName)) {
heartbeat.status = DOWN; heartbeat.status = DOWN;
heartbeat.msg = "Invalid service name. Please use the internal Service Name (no spaces)."; heartbeat.msg = "Invalid service name. Only alphanumeric characters, dots, dashes, underscores, @ and spaces are allowed.";
reject(new Error(heartbeat.msg)); reject(new Error(heartbeat.msg));
return; return;
} }