check for whitespace in gateways and phone numbers (#477)

This commit is contained in:
Sam Machin
2025-07-01 12:16:27 +01:00
committed by GitHub
parent 5421f1421f
commit 542ccfca79
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -6,6 +6,7 @@ const decorate = require('./decorate');
const sysError = require('../error');
const net = require('net');
const hasWhitespace = (str) => /\s/.test(str);
const checkUserScope = async(req, voip_carrier_sid) => {
const {lookupCarrierBySid} = req.app.locals;
if (!voip_carrier_sid) {
@@ -60,6 +61,9 @@ const validate = async(req, sid) => {
throw new DbErrorBadRequest(
`netmask required to have value equal or greater than ${process.env.JAMBONZ_MIN_GATEWAY_NETMASK}`);
}
if (hasWhitespace(ipv4)) {
throw new DbErrorBadRequest('Gateway must not contain whitespace');
}
if (inbound && !net.isIPv4(ipv4)) {
throw new DbErrorBadRequest('Inbound gateway must be IPv4 address');
}