add provider specific removePrivateFields to redact tokens and secrets

This commit is contained in:
Johannes Zellner
2019-02-08 11:11:49 +01:00
parent d1a1f7004b
commit 32f8a52c2b
14 changed files with 79 additions and 6 deletions
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -24,6 +25,11 @@ function getFqdn(location, domain) {
return (location === '') ? domain : location + '-' + domain;
}
function removePrivateFields(domainObject) {
domainObject.config.token = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -22,6 +23,11 @@ var assert = require('assert'),
// we are using latest v4 stable API https://api.cloudflare.com/#getting-started-endpoints
var CLOUDFLARE_ENDPOINT = 'https://api.cloudflare.com/client/v4';
function removePrivateFields(domainObject) {
domainObject.config.token = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function translateRequestError(result, callback) {
assert.strictEqual(typeof result, 'object');
assert.strictEqual(typeof callback, 'function');
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -25,6 +26,11 @@ function formatError(response) {
return util.format('DigitalOcean DNS error [%s] %j', response.statusCode, response.body);
}
function removePrivateFields(domainObject) {
domainObject.config.token = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function getInternal(dnsConfig, zoneName, name, type, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof zoneName, 'string');
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -23,6 +24,11 @@ function formatError(response) {
return util.format(`Gandi DNS error [${response.statusCode}] ${response.body.message}`);
}
function removePrivateFields(domainObject) {
domainObject.config.token = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -18,6 +19,11 @@ var assert = require('assert'),
waitForDns = require('./waitfordns.js'),
_ = require('underscore');
function removePrivateFields(domainObject) {
domainObject.config.credentials.private_key = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function getDnsCredentials(dnsConfig) {
assert.strictEqual(typeof dnsConfig, 'object');
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -29,6 +30,11 @@ function formatError(response) {
return util.format(`GoDaddy DNS error [${response.statusCode}] ${response.body.message}`);
}
function removePrivateFields(domainObject) {
domainObject.config.apiSecret = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
+6
View File
@@ -7,6 +7,7 @@
// -------------------------------------------
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -17,6 +18,11 @@ exports = module.exports = {
var assert = require('assert'),
util = require('util');
function removePrivateFields(domainObject) {
// in-place removal of tokens and api keys with domains.SECRET_PLACEHOLDER
return domainObject;
}
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
+5
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -16,6 +17,10 @@ var assert = require('assert'),
util = require('util'),
waitForDns = require('./waitfordns.js');
function removePrivateFields(domainObject) {
return domainObject;
}
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -22,6 +23,11 @@ function formatError(response) {
return util.format('NameCheap DNS error [%s] %j', response.code, response.message);
}
function removePrivateFields(domainObject) {
domainObject.config.apiKey = domains.SECRET_PLACEHOLDER;
return domainObject;
}
// Only send required fields - https://www.namecheap.com/support/api/methods/domains-dns/set-hosts.aspx
function mapHosts(hosts) {
return hosts.map(function (host) {
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -24,6 +25,11 @@ function formatError(response) {
return `Name.com DNS error [${response.statusCode}] ${response.text}`;
}
function removePrivateFields(domainObject) {
domainObject.config.token = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function addRecord(dnsConfig, zoneName, name, type, values, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof zoneName, 'string');
+5
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -12,6 +13,10 @@ var assert = require('assert'),
debug = require('debug')('box:dns/noop'),
util = require('util');
function removePrivateFields(domainObject) {
return domainObject;
}
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
+6
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -18,6 +19,11 @@ var assert = require('assert'),
waitForDns = require('./waitfordns.js'),
_ = require('underscore');
function removePrivateFields(domainObject) {
domainObject.config.secretAccessKey = domains.SECRET_PLACEHOLDER;
return domainObject;
}
function getDnsCredentials(dnsConfig) {
assert.strictEqual(typeof dnsConfig, 'object');
+5
View File
@@ -1,6 +1,7 @@
'use strict';
exports = module.exports = {
removePrivateFields: removePrivateFields,
upsert: upsert,
get: get,
del: del,
@@ -17,6 +18,10 @@ var assert = require('assert'),
util = require('util'),
waitForDns = require('./waitfordns.js');
function removePrivateFields(domainObject) {
return domainObject;
}
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');