do not modify hostPath variable
This commit is contained in:
+4
-6
@@ -56,13 +56,11 @@ function validateHostPath(hostPath, mountType) {
|
||||
|
||||
if (hostPath === '/') return new BoxError(BoxError.BAD_FIELD, 'hostPath cannot be /');
|
||||
|
||||
if (!hostPath.endsWith('/')) hostPath = hostPath + '/'; // ensure trailing slash for the prefix matching to work
|
||||
const allowedPaths = [ '/mnt', '/media', '/srv', '/opt' ];
|
||||
if (!allowedPaths.some(p => hostPath === p || hostPath.startsWith(p + '/'))) return new BoxError(BoxError.BAD_FIELD, 'hostPath must be under /mnt, /media, /opt or /srv');
|
||||
|
||||
const allowedPaths = [ '/mnt/', '/media/', '/srv/', '/opt/' ];
|
||||
if (!allowedPaths.some(p => hostPath.startsWith(p))) return new BoxError(BoxError.BAD_FIELD, 'hostPath must be under /mnt, /media, /opt or /srv');
|
||||
|
||||
const reservedPaths = [ `${paths.VOLUMES_MOUNT_DIR}/` ];
|
||||
if (reservedPaths.some(p => hostPath.startsWith(p))) return new BoxError(BoxError.BAD_FIELD, 'hostPath is reserved');
|
||||
const reservedPaths = [ `${paths.VOLUMES_MOUNT_DIR}` ];
|
||||
if (reservedPaths.some(p => hostPath === p || hostPath.startsWith(p + '/'))) return new BoxError(BoxError.BAD_FIELD, 'hostPath is reserved');
|
||||
|
||||
if (!constants.TEST) { // we expect user to have already mounted this
|
||||
const stat = safe.fs.lstatSync(hostPath);
|
||||
|
||||
Reference in New Issue
Block a user