diff --git a/dashboard/src/components/BackupSiteEditDialog.vue b/dashboard/src/components/BackupSiteEditDialog.vue index 4453b4e5f..8b644c20e 100644 --- a/dashboard/src/components/BackupSiteEditDialog.vue +++ b/dashboard/src/components/BackupSiteEditDialog.vue @@ -95,6 +95,7 @@ async function getMemory() { defineExpose({ async open(t) { + t = JSON.parse(JSON.stringify(t)); // make a copy formError.value = {}; busy.value = false; site.value = t; diff --git a/src/dns/interface.js b/src/dns/interface.js index d33f2ebbb..99014ffb0 100644 --- a/src/dns/interface.js +++ b/src/dns/interface.js @@ -20,13 +20,13 @@ const assert = require('node:assert'), BoxError = require('../boxerror.js'); function removePrivateFields(domainObject) { - // in-place removal of tokens and api keys with constants.SECRET_PLACEHOLDER + // in-place removal of tokens and api keys return domainObject; } // eslint-disable-next-line no-unused-vars function injectPrivateFields(newConfig, currentConfig) { - // in-place injection of tokens and api keys which came in with constants.SECRET_PLACEHOLDER + // in-place injection of tokens and api keys } // replaces any existing records or creates new records of subdomain+type with values diff --git a/src/storage/filesystem.js b/src/storage/filesystem.js index 0ec94b580..e4e05691b 100644 --- a/src/storage/filesystem.js +++ b/src/storage/filesystem.js @@ -1,33 +1,7 @@ 'use strict'; -exports = module.exports = { - setup, - teardown, - cleanup, - - verifyConfig, - removePrivateFields, - injectPrivateFields, - - getAvailableSize, - getStatus, - - upload, - download, - - copy, - copyDir, - - exists, - listDir, - - remove, - removeDir, -}; - const assert = require('node:assert'), BoxError = require('../boxerror.js'), - constants = require('../constants.js'), debug = require('debug')('box:storage/filesystem'), df = require('../df.js'), fs = require('node:fs'), @@ -401,8 +375,8 @@ async function verifyConfig({ id, provider, config }) { } function removePrivateFields(config) { - if (config.mountOptions && config.mountOptions.password) config.mountOptions.password = constants.SECRET_PLACEHOLDER; - if (config.mountOptions && config.mountOptions.privateKey) config.mountOptions.privateKey = constants.SECRET_PLACEHOLDER; + delete config.mountOptions?.password; + delete config.mountOptions?.privateKey; delete config._provider; delete config._managedMountPath; @@ -411,9 +385,36 @@ function removePrivateFields(config) { } function injectPrivateFields(newConfig, currentConfig) { - if (newConfig.mountOptions && currentConfig.mountOptions && newConfig.mountOptions.password === constants.SECRET_PLACEHOLDER) newConfig.mountOptions.password = currentConfig.mountOptions.password; - if (newConfig.mountOptions && currentConfig.mountOptions && newConfig.mountOptions.privateKey === constants.SECRET_PLACEHOLDER) newConfig.mountOptions.privateKey = currentConfig.mountOptions.privateKey; + if (newConfig.mountOptions && currentConfig.mountOptions) { + if (!Object.hasOwn(newConfig.mountOptions, 'password')) newConfig.mountOptions.password = currentConfig.mountOptions.password; + if (!Object.hasOwn(newConfig.mountOptions, 'privateKey')) newConfig.mountOptions.privateKey = currentConfig.mountOptions.privateKey; + } newConfig._provider = currentConfig._provider; if (currentConfig._managedMountPath) newConfig._managedMountPath = currentConfig._managedMountPath; } + +exports = module.exports = { + setup, + teardown, + cleanup, + + verifyConfig, + removePrivateFields, + injectPrivateFields, + + getAvailableSize, + getStatus, + + upload, + download, + + copy, + copyDir, + + exists, + listDir, + + remove, + removeDir, +}; diff --git a/src/storage/gcs.js b/src/storage/gcs.js index d39687f88..43d0a36c9 100644 --- a/src/storage/gcs.js +++ b/src/storage/gcs.js @@ -1,30 +1,5 @@ 'use strict'; -exports = module.exports = { - getAvailableSize, - getStatus, - - upload, - exists, - download, - - copy, - copyDir, - - listDir, - - remove, - removeDir, - - setup, - teardown, - cleanup, - - verifyConfig, - removePrivateFields, - injectPrivateFields, -}; - const assert = require('node:assert'), async = require('async'), BoxError = require('../boxerror.js'), @@ -275,10 +250,35 @@ async function teardown(apiConfig) { } function removePrivateFields(apiConfig) { - apiConfig.credentials.private_key = constants.SECRET_PLACEHOLDER; + delete apiConfig.credentials.private_key; return apiConfig; } function injectPrivateFields(newConfig, currentConfig) { - if (newConfig.credentials.private_key === constants.SECRET_PLACEHOLDER && currentConfig.credentials) newConfig.credentials.private_key = currentConfig.credentials.private_key; + if (!Object.hasOwn(newConfig.credentials, 'private_key') && currentConfig.credentials) newConfig.credentials.private_key = currentConfig.credentials.private_key; } + +exports = module.exports = { + getAvailableSize, + getStatus, + + upload, + exists, + download, + + copy, + copyDir, + + listDir, + + remove, + removeDir, + + setup, + teardown, + cleanup, + + verifyConfig, + removePrivateFields, + injectPrivateFields, +}; diff --git a/src/storage/interface.js b/src/storage/interface.js index 7153c7478..934874b7d 100644 --- a/src/storage/interface.js +++ b/src/storage/interface.js @@ -40,13 +40,13 @@ const assert = require('node:assert'), BoxError = require('../boxerror.js'); function removePrivateFields(apiConfig) { - // in-place removal of tokens and api keys with constants.SECRET_PLACEHOLDER + // in-place removal of tokens and api keys return apiConfig; } // eslint-disable-next-line no-unused-vars function injectPrivateFields(newConfig, currentConfig) { - // in-place injection of tokens and api keys which came in with constants.SECRET_PLACEHOLDER + // in-place injection of tokens and api keys } async function getAvailableSize(apiConfig) { diff --git a/src/storage/s3.js b/src/storage/s3.js index dcf1ad362..b6f37536c 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -1,32 +1,5 @@ 'use strict'; -exports = module.exports = { - setup, - teardown, - cleanup, - - verifyConfig, - removePrivateFields, - injectPrivateFields, - - getAvailableSize, - getStatus, - - upload, - exists, - download, - copy, - copyDir, - - listDir, - - remove, - removeDir, - - // Used to mock AWS - _chunk: chunk -}; - const assert = require('node:assert'), async = require('async'), BoxError = require('../boxerror.js'), @@ -679,12 +652,39 @@ async function teardown(apiConfig) { } function removePrivateFields(apiConfig) { - apiConfig.secretAccessKey = constants.SECRET_PLACEHOLDER; + delete apiConfig.secretAccessKey; delete apiConfig._provider; return apiConfig; } function injectPrivateFields(newConfig, currentConfig) { - if (newConfig.secretAccessKey === constants.SECRET_PLACEHOLDER) newConfig.secretAccessKey = currentConfig.secretAccessKey; + if (!Object.hasOwn(newConfig, 'secretAccessKey')) newConfig.secretAccessKey = currentConfig.secretAccessKey; newConfig._provider = currentConfig._provider; } + +exports = module.exports = { + setup, + teardown, + cleanup, + + verifyConfig, + removePrivateFields, + injectPrivateFields, + + getAvailableSize, + getStatus, + + upload, + exists, + download, + copy, + copyDir, + + listDir, + + remove, + removeDir, + + // Used to mock AWS + _chunk: chunk +};