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

@soluto-asurion/kamus-cli

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soluto-asurion/kamus-cli - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

46

lib/actions/encrypt.js

@@ -6,3 +6,3 @@ const bluebird = require('bluebird');

const fs = require('fs');
const Confirm = require('prompt-confirm');
const { Confirm } = require('enquirer');
const request = require('request');

@@ -14,2 +14,3 @@ const { promisify } = require('util');

const pjson = require('../../package.json');
const urljoin = require('url-join');

@@ -19,3 +20,3 @@ const DEFAULT_ENCODING = 'utf8';

module.exports = async (args, options, logger) => {
const { serviceAccount, namespace } = options;

@@ -27,2 +28,3 @@ logger.info('Encryption started...');

try {
logger.debug('Validating Arguments');
validateArguments(options);

@@ -35,5 +37,8 @@

else {
logger.debug('Acquiring authentication token');
token = await acquireToken(options, logger);
}
const encryptedSecret = await encrypt(options, token);
logger.debug('Starting secret encryption');
const encryptedSecret = await encrypt(options, logger, token);
logger.debug('Secret encryption finished');

@@ -50,11 +55,15 @@ logger.info(`Successfully encrypted data to ${serviceAccount} service account in ${namespace} namespace`);

const checkForNewlines = async (secret) => {
const checkForNewlines = async (secret, logger) => {
const eolIndex = secret.indexOf(os.EOL);
if (eolIndex !== -1) {
const newlinesDetectedPrompt = new Confirm(`Secret contains newlines at index ${eolIndex}. Continue encrypting this secret?`);
const newlinesDetectedPrompt = new Confirm({
name: 'question',
message: `Secret contains newlines at index ${eolIndex}. Continue encrypting this secret?`
});
const response = await newlinesDetectedPrompt.run();
if (!response) {
throw new Error('Aborted secret encryption');
logger.info('Aborting - secrets contains newline');
process.exit(0);
}

@@ -64,6 +73,15 @@ }

const encrypt = async ({ secret, secretFile, serviceAccount, namespace, kamusUrl, certFingerprint, fileEncoding }, token = null) => {
// eslint-disable-next-line security/detect-non-literal-fs-filename
const data = secretFile ? fs.readFileSync(secretFile, { encoding: fileEncoding || DEFAULT_ENCODING }) : secret;
await checkForNewlines(data);
const encrypt = async ({ secret, secretFile, serviceAccount, namespace, kamusUrl, certFingerprint, fileEncoding }, logger, token = null) => {
let data;
if (secretFile) {
logger.debug(`Reading secret file ${secretFile}`);
// eslint-disable-next-line security/detect-non-literal-fs-filename
data = fs.readFileSync(secretFile, { encoding: fileEncoding || DEFAULT_ENCODING });
} else {
data = secret;
}
await checkForNewlines(data, logger);
logger.debug(`starting request to encrypt api at ${kamusUrl}`);
const response = await performEncryptRequestAsync(data, serviceAccount, namespace, kamusUrl, certFingerprint, token);

@@ -73,2 +91,3 @@ if (response && response.statusCode >= 300) {

}
logger.debug('Request to encrypt api finished successfully');
return response.body;

@@ -110,3 +129,3 @@ };

if (isDocker()) {
logger.info(`Login to https://microsoft.com/devicelogin Enter this code to authenticate: ${userCodeResult.userCode}`);
logger.info(`Open "https://microsoft.com/devicelogin" in browser and login to Azure with the following code: ${userCodeResult.userCode}`);
} else {

@@ -139,3 +158,3 @@ opn(userCodeResult.verificationUrl);

const options = {
url: url.resolve(kamusUrl, '/api/v1/encrypt'),
url: urljoin(kamusUrl, '/api/v1/encrypt'),
headers,

@@ -172,2 +191,3 @@ // Certificate validation

if (outputFile) {
logger.debug(`Starting to write encrypted data to ${outputFile}`);
// eslint-disable-next-line security/detect-non-literal-fs-filename

@@ -183,2 +203,2 @@ fs.writeFileSync(outputFile, encryptedSecret, {

}
};
};

@@ -8,10 +8,14 @@ #!/usr/bin/env node

const { ColorfulChalkLogger, DEBUG } = require('colorful-chalk-logger');
const { ColorfulChalkLogger, INFO } = require('colorful-chalk-logger');
const isVerboseLogging = (args) => args.indexOf('--verbose') > -1 || args.indexOf('-v') > -1;
const logger = new ColorfulChalkLogger('kamus-cli', {
level: DEBUG, // the default value is INFO
date: false, // the default value is false.
colorful: true, // the default value is true.
}, process.argv);
level: INFO,
date: false,
colorful: true,
}, isVerboseLogging(process.argv) ? process.argv.concat(['--log-level', 'debug']) : process.argv); // translate to ColorfulChalkLogger log level
process.argv = process.argv.filter(x => x != '--verbose' && x != '-v' ); // ColorfulChalkLogger got the verbose, don't pass it to caporal
prog

@@ -35,3 +39,2 @@ .logger(logger)

.option('-O, --overwrite', 'Overwrites file if it already exists', prog.BOOL)
.option('--log-level <debug|verbose|info|warn|error|fatal>', 'log level', prog.STRING)
.option('--log-flag <date|inline|colorful|no-date|no-inline|no-colorful>', 'log format', prog.STRING)

@@ -38,0 +41,0 @@ .option('--log-output <filepath>', 'output log to file', prog.STRING)

{
"name": "@soluto-asurion/kamus-cli",
"version": "0.2.3",
"version": "0.3.0",
"description": "CLI Tool to encrypt secrets for kamus",

@@ -8,3 +8,5 @@ "main": "index.js",

"test": "node_modules/.bin/mocha ./test/*.spec.js --exit",
"eslint": "eslint . --ignore-pattern node_modules/"
"eslint": "eslint . --ignore-pattern node_modules/",
"snyk-protect": "snyk protect",
"prepublish": "npm run snyk-protect"
},

@@ -31,21 +33,23 @@ "repository": {

"dependencies": {
"adal-node": "^0.1.28",
"adal-node": "^0.2.0",
"bluebird": "^3.5.3",
"caporal": "^1.1.0",
"colorful-chalk-logger": "^0.3.2",
"colorful-chalk-logger": "^0.4.0",
"enquirer": "^2.3.0",
"node-fetch": "^2.3.0",
"opn": "^5.4.0",
"prompt-confirm": "^2.0.4",
"request": "^2.88.0"
"request": "^2.88.0",
"snyk": "^1.198.0",
"url-join": "^4.0.1"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.12.0",
"eslint-plugin-security": "^1.4.0",
"husky": "^1.3.1",
"lint-staged": "^8.1.0",
"mocha": "^5.2.0",
"mock-fs": "^4.7.0",
"nock": "^10.0.5",
"sinon": "^7.2.2"
"chai": "4.2.0",
"eslint": "6.5.1",
"eslint-plugin-security": "1.4.0",
"husky": "3.0.8",
"lint-staged": "9.4.1",
"mocha": "6.2.1",
"mock-fs": "4.10.1",
"nock": "11.3.5",
"sinon": "7.5.0"
},

@@ -69,3 +73,4 @@ "files": [

}
}
},
"snyk": true
}

Sorry, the diff of this file is not supported yet

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