Use full portBindings object internally also for validation
This commit is contained in:
+8
-8
@@ -246,7 +246,7 @@ function validatePortBindings(portBindings, manifest) {
|
||||
for (const portName in portBindings) {
|
||||
if (!/^[A-Z0-9_]+$/.test(portName)) return new BoxError(BoxError.BAD_FIELD, `${portName} is not a valid environment variable in portBindings`);
|
||||
|
||||
const hostPort = portBindings[portName];
|
||||
const hostPort = portBindings[portName].hostPort;
|
||||
if (!Number.isInteger(hostPort)) return new BoxError(BoxError.BAD_FIELD, `${hostPort} is not an integer in ${portName} portBindings`);
|
||||
if (RESERVED_PORTS.indexOf(hostPort) !== -1) return new BoxError(BoxError.BAD_FIELD, `Port ${hostPort} for ${portName} is reserved in portBindings`);
|
||||
if (RESERVED_PORT_RANGES.find(range => (hostPort >= range[0] && hostPort <= range[1]))) return new BoxError(BoxError.BAD_FIELD, `Port ${hostPort} for ${portName} is reserved in portBindings`);
|
||||
@@ -1286,7 +1286,7 @@ async function install(data, auditSource) {
|
||||
|
||||
const subdomain = data.subdomain.toLowerCase(),
|
||||
domain = data.domain.toLowerCase(),
|
||||
portBindings = data.portBindings || null,
|
||||
portBindings = translatePortBindings(data.portBindings || null, manifest),
|
||||
accessRestriction = data.accessRestriction || null,
|
||||
memoryLimit = data.memoryLimit || 0,
|
||||
debugMode = data.debugMode || null,
|
||||
@@ -1394,7 +1394,7 @@ async function install(data, auditSource) {
|
||||
installationState: exports.ISTATE_PENDING_INSTALL
|
||||
};
|
||||
|
||||
const [addError] = await safe(add(appId, appStoreId, manifest, subdomain, domain, translatePortBindings(portBindings, manifest), app));
|
||||
const [addError] = await safe(add(appId, appStoreId, manifest, subdomain, domain, portBindings, app));
|
||||
if (addError && addError.reason === BoxError.ALREADY_EXISTS) throw getDuplicateErrorDetails(addError.message, locations, portBindings);
|
||||
if (addError) throw addError;
|
||||
|
||||
@@ -1850,10 +1850,10 @@ async function setLocation(app, data, auditSource) {
|
||||
};
|
||||
|
||||
if ('portBindings' in data) {
|
||||
error = validatePortBindings(data.portBindings, app.manifest);
|
||||
if (error) throw error;
|
||||
|
||||
values.portBindings = translatePortBindings(data.portBindings || null, app.manifest);
|
||||
|
||||
error = validatePortBindings(values.portBindings, app.manifest);
|
||||
if (error) throw error;
|
||||
}
|
||||
|
||||
// rename the auto-created mailbox to match the new location
|
||||
@@ -2256,7 +2256,7 @@ async function clone(app, data, user, auditSource) {
|
||||
|
||||
const subdomain = data.subdomain.toLowerCase(),
|
||||
domain = data.domain.toLowerCase(),
|
||||
portBindings = data.portBindings || null,
|
||||
portBindings = translatePortBindings(data.portBindings, manifest),
|
||||
backupId = data.backupId,
|
||||
overwriteDns = 'overwriteDns' in data ? data.overwriteDns : false,
|
||||
skipDnsSetup = 'skipDnsSetup' in data ? data.skipDnsSetup : false,
|
||||
@@ -2324,7 +2324,7 @@ async function clone(app, data, user, auditSource) {
|
||||
mailboxDisplayName: app.mailboxDisplayName
|
||||
};
|
||||
|
||||
const [addError] = await safe(add(newAppId, appStoreId, manifest, subdomain, domain, translatePortBindings(portBindings, manifest), obj));
|
||||
const [addError] = await safe(add(newAppId, appStoreId, manifest, subdomain, domain, portBindings, obj));
|
||||
if (addError && addError.reason === BoxError.ALREADY_EXISTS) throw getDuplicateErrorDetails(addError.message, locations, portBindings);
|
||||
if (addError) throw addError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user