New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@asymmetrik/yadda

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asymmetrik/yadda - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

cli/commands/secret-refresh.js

4

config/manifest.js

@@ -74,2 +74,3 @@ 'use strict';

* @property {string} region - AWS Region the key alias resides in. Does not need to be the environment's region.
* @property {string} cacheBusterKey - The secret key used for cache busting.
*/

@@ -81,3 +82,4 @@ var SecretSettingsSchema = {

kmsKeyAlias: { type: 'string' },
region: { type: 'string' }
region: { type: 'string' },
cacheBusterKey: { type: 'string' }
},

@@ -84,0 +86,0 @@ required: ['kmsKeyAlias'],

@@ -94,2 +94,34 @@ 'use strict';

/**
* Cache bust secrets
* @param {object} options - user provided options
* @param {object} options.DeploymentCenter.secret - Secret Center options
* @param {function} options.DeploymentCenter.secret._prefixKey - Secret key prefixer
* @param {string} options.DeploymentCenter.secret.cacheBusterKey - Secret key to use for cache busting
* @return {Q.Promise}
*/
exports.refreshSecrets = function(options) {
return Q.when(options)
.then(function(){
var secrets = options.DeploymentCenter.secret;
var store = secrets.secretStore();
if(!secrets.cacheBusterKey){
return logger.warn('no cache buster key set');
}
var opts = {
name: secrets._prefixKey(secrets.cacheBusterKey),
secret: Date.now()
};
return store.incrementVersion(opts).then(function(version){
opts.version = version;
return store.putSecret(opts);
})
.then(function(){
logger.info('Successfully refreshed secrets');
});
});
};
/**
* Retrieve secret from credential store

@@ -101,3 +133,3 @@ * @param {object} options - user provided options

* @param {string} options.secretParams.secret - Secret to retrieve from store
* @param {string} options.secretParams.version - (Optional) specify which version you want to retrieve. Will automatically handle padding of 0's
* @param {string} options.secretParams.version - (Optional) specify which version you want to retrieve. Defaults to the latest one. Will automatically handle padding of 0's
* @param {object} options.secretParams.context - (Optional) KMS context

@@ -115,3 +147,3 @@ * @return {Q.Promise}

name: secrets._prefixKey(params.secret),
version: _.padStart(params.version, 19, '0'),
version: params.version ? _.padStart(params.version, 19, '0') : undefined,
context: params.context,

@@ -132,5 +164,5 @@ })

* @param {object} options.secretParams - Secret parameters
* @param {string} options.secretParams.secret - Secret to retrieve from store
* @param {string} options.secretParams.secret - Secret to encrypt into store
* @param {string} options.secretParams.value - Secret value to encrypt into store
* @param {string} options.secretParams.version - (Optional) specify which version you want to retrieve. Will automatically handle padding of 0's
* @param {string} options.secretParams.version - (Optional) specify which version you want to encrypt. Will default to the next available one. Will automatically handle padding of 0's
* @param {object} options.secretParams.context - (Optional) KMS context

@@ -153,8 +185,18 @@ * @return {Q.Promise}

secret: params.value,
version: _.padStart(params.version, 19, '0'),
version: params.version ? _.padStart(params.version, 19, '0') : undefined,
context: params.context,
};
return store.putSecret(opts)
return Q.when()
.then(function(){
if(opts.version === undefined){
return store.incrementVersion(opts).then(function(version){
opts.version = version;
});
}
})
.then(function(){
return store.putSecret(opts);
})
.then(function(){
logger.info('Secret `'+opts.name+'` successfully put in store');

@@ -171,4 +213,4 @@ });

* @param {object} options.secretParams - Secret parameters
* @param {string} options.secretParams.secret - Secret to retrieve from store
* @param {string} options.secretParams.version - (Optional) specify which version you want to retrieve. Will automatically handle padding of 0's
* @param {string} options.secretParams.secret - Secret to delete from store
* @param {string} options.secretParams.version - (Optional) specify which version you want to delete. Defaults to the latest one. Will automatically handle padding of 0's
* @return {Q.Promise}

@@ -185,7 +227,17 @@ */

name: secrets._prefixKey(params.secret),
version: _.padStart(params.version, 19, '0'),
version: params.version ? _.padStart(params.version, 19, '0') : undefined,
};
return store.deleteSecret(opts)
return Q.when()
.then(function(){
if(!opts.version){
return store.getHighestVersion(opts).then(function(version) {
opts.version = version;
});
}
})
.then(function(){
return store.deleteSecret(opts);
})
.then(function(){
logger.info('Secret `'+opts.name+'` (ver: '+Number.parseInt(opts.version)+') successfully deleted');

@@ -208,10 +260,14 @@ })

.then(function(list){
list = _.filter(list, function(secret) {
return _.startsWith(secret.name, secretPrefix);
const filteredList = {};
_.each(list, function(secret){
if(!_.startsWith(secret.name, secretPrefix))
return;
if(!filteredList[secret.name] || Number(filteredList[secret.name].version) < Number(secret.version))
filteredList[secret.name] = secret;
});
if(list.length === 0)
if(Object.keys(filteredList).length === 0)
logger.warn('There are no secrets you can see.');
for(var secret in list)
logger.info(list[secret]);
_.each(filteredList, _.unary(logger.info));

@@ -276,3 +332,15 @@ return list;

return options;
// check to see if we need to create an initial timestamp for the cache busting
if(!options.DeploymentCenter.secret.cacheBusterKey)
return options;
return options.DeploymentCenter.secret.secretStore().getSecret({
name: options.DeploymentCenter.secret._prefixKey(options.DeploymentCenter.secret.cacheBusterKey)
})
.catch(function(err){
return exports.refreshSecrets(options);
})
.then(function(){
return options;
});
});

@@ -296,4 +364,5 @@ };

'__YADDA__DEPLOYMENT_SECRET_KMSALIAS__': options.DeploymentCenter.secret.kmsKeyAlias,
'__YADDA__DEPLOYMENT_SECRET_REGION__': options.DeploymentCenter.secret.region || tableDetails.region
'__YADDA__DEPLOYMENT_SECRET_REGION__': options.DeploymentCenter.secret.region || tableDetails.region,
'__YADDA__DEPLOYMENT_SECRET_CACHE_BUSTER_KEY__': options.DeploymentCenter.secret.cacheBusterKey
};
};
{
"name": "@asymmetrik/yadda",
"description": "Deployment tool for AWS ECS and ECR",
"version": "0.2.7",
"version": "0.2.8",
"main": "index.js",

@@ -24,3 +24,3 @@ "author": "Asymmetrik, Ltd",

"dependencies": {
"@asymmetrik/yadda-secret": "^0.0.8",
"@asymmetrik/yadda-secret": "^0.0.10",
"archiver": "^1.1.0",

@@ -27,0 +27,0 @@ "aws-sdk": "^2.5.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc