volumes: better hostPath validation

This commit is contained in:
Girish Ramakrishnan
2020-12-03 23:05:06 -08:00
parent 0b537fe163
commit ca17afc734
2 changed files with 11 additions and 2 deletions

View File

@@ -229,7 +229,7 @@ function removeDir(apiConfig, pathPrefix) {
function validateBackupTarget(folder) {
assert.strictEqual(typeof folder, 'string');
if (path.normalize(folder) !== folder) return new BoxError(BoxError.BAD_FIELD, 'backupFolder must contain a normalized relative path', { field: 'backupFolder' });
if (path.normalize(folder) !== folder) return new BoxError(BoxError.BAD_FIELD, 'backupFolder must contain a normalized path', { field: 'backupFolder' });
if (!path.isAbsolute(folder)) return new BoxError(BoxError.BAD_FIELD, 'backupFolder must be an absolute path', { field: 'backupFolder' });
if (folder === '/') return new BoxError(BoxError.BAD_FIELD, 'backupFolder cannot be /', { field: 'backupFolder' });