bln-squrl-tool
Advanced tools
Comparing version 1.0.11 to 1.1.0
@@ -141,3 +141,5 @@ #!/usr/bin/env node | ||
if (value === undefined) { | ||
throw new Error(`"${secretKey}" not found in "${vault}"`); | ||
process.stdout.write(`"${secretKey}" not found in "${vault}"\n`); | ||
set(contentObj, objPath, ''.toString(encoding)); | ||
continue; | ||
} | ||
@@ -144,0 +146,0 @@ set(contentObj, objPath, value.toString(encoding)); |
@@ -36,2 +36,3 @@ 'use strict'; | ||
region: options.region, | ||
hashEncodingType: options.store === 'ssm' ? 'base64urlencoded' : 'base64', | ||
}; | ||
@@ -38,0 +39,0 @@ }, |
@@ -11,5 +11,6 @@ 'use strict'; | ||
hashSecretKeyName: 'HASH_SECRET_KEY', | ||
hashEncodingType: 'base64', | ||
// eslint-disable-next-line security/detect-non-literal-regexp | ||
secretKeyRegex: new RegExp(`^[^:]{1,100}:${secretKeyPrefix}[A-Za-z0-9+/=]{44}$`, 'u'), // /^[^:]{1,100}:SECRET_[A-Za-z0-9+/=]{44}$/u, | ||
secretKeyRegex: new RegExp(`^[^:]{1,100}:${secretKeyPrefix}[A-Za-z0-9+/_-]{43}=?`, 'u'), | ||
vault: 'vault', | ||
}; |
{ | ||
"name": "bln-squrl-tool", | ||
"version": "1.0.11", | ||
"version": "1.1.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -14,2 +14,3 @@ 'use strict'; | ||
this.encoding = options.encoding || defaults.encoding; | ||
this.hashEncodingType = options.hashEncodingType || defaults.hashEncodingType; | ||
} | ||
@@ -23,3 +24,3 @@ | ||
const hashSecret = await this.secretStore.get(this.hashSecretKeyName, this.vault, true); | ||
const key = genKey(genHash(value, hashSecret)); | ||
const key = genKey(genHash(value, hashSecret, this.hashEncodingType)); | ||
await this.secretStore.set(key, Buffer.from(value), this.vault); | ||
@@ -26,0 +27,0 @@ return genReferenceKey(key, this.vault); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const op = require('./op'); | ||
const ssm = require('./ssm'); | ||
@@ -10,2 +11,3 @@ module.exports = { | ||
aws, | ||
ssm, | ||
}; |
@@ -5,4 +5,4 @@ 'use strict'; | ||
module.exports = (value, hashSecret) => { | ||
return crypto | ||
module.exports = (value, hashSecret, hashEncodingType = 'base64') => { | ||
const hashedKey = crypto | ||
.createHash('sha256') | ||
@@ -12,2 +12,6 @@ .update(Buffer.from(hashSecret)) | ||
.digest('base64'); | ||
return hashEncodingType === 'base64urlencoded' | ||
? hashedKey.replace(/\+/ug, '-').replace(/\//ug, '_').replace(/[=]/ug, '') | ||
: hashedKey; | ||
}; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
const revealFromReferenceKey = async (options = {}) => { | ||
const {encoding, referenceKey, Squrl} = options; | ||
const {encoding, referenceKey, Squrl, hashEncodingType} = options; | ||
@@ -16,5 +16,4 @@ const {key: secretKey, vault} = parseReferenceKey(referenceKey); | ||
const storeList = options.store ? [options.store] : Object.keys(stores); | ||
for (const store of storeList) { | ||
const squrl = new Squrl({...options, store, vault, encoding}); | ||
const squrl = new Squrl({...options, store, vault, encoding, hashEncodingType}); | ||
const value = await squrl.retrieve({key: secretKey, vault}); | ||
@@ -21,0 +20,0 @@ if (value) { |
Sorry, the diff of this file is too big to display
214061
45
5693