dockerregistries: remove usage of secret placeholder
This commit is contained in:
+15
-16
@@ -1,15 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
removePrivateFields,
|
||||
|
||||
list,
|
||||
add,
|
||||
get,
|
||||
del,
|
||||
update,
|
||||
};
|
||||
|
||||
const assert = require('node:assert'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
constants = require('./constants.js'),
|
||||
@@ -26,11 +16,14 @@ const REGISTRY_FIELDS = [ 'id', 'provider', 'serverAddress', 'username', 'email'
|
||||
function removePrivateFields(registryConfig) {
|
||||
assert.strictEqual(typeof registryConfig, 'object');
|
||||
|
||||
if (registryConfig.password) registryConfig.password = constants.SECRET_PLACEHOLDER;
|
||||
|
||||
delete registryConfig.password;
|
||||
return registryConfig;
|
||||
}
|
||||
|
||||
function injectPrivateFields(newConfig, currentConfig) {
|
||||
if (!Object.hasOwn(newConfig, 'password')) newConfig.password = currentConfig.password;
|
||||
}
|
||||
|
||||
async function get(id) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
|
||||
@@ -65,10 +58,6 @@ async function testRegistryConfig(config) {
|
||||
if (error) throw new BoxError(BoxError.BAD_FIELD, `Invalid serverAddress: ${error.message}`);
|
||||
}
|
||||
|
||||
function injectPrivateFields(newConfig, currentConfig) {
|
||||
if (newConfig.password === constants.SECRET_PLACEHOLDER) newConfig.password = currentConfig.password;
|
||||
}
|
||||
|
||||
async function add(registry, auditSource) {
|
||||
assert.strictEqual(typeof registry, 'object');
|
||||
assert(auditSource && typeof auditSource === 'object');
|
||||
@@ -121,3 +110,13 @@ async function del(registry, auditSource) {
|
||||
|
||||
await eventlog.add(eventlog.ACTION_REGISTRY_DEL, auditSource, { registry: removePrivateFields(registry) });
|
||||
}
|
||||
|
||||
exports = module.exports = {
|
||||
removePrivateFields,
|
||||
|
||||
list,
|
||||
add,
|
||||
get,
|
||||
del,
|
||||
update,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user