storage: remove usage of secret placeholder
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user