-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secrets encryption from CLI #141
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few changes
src/commands/api-mesh/create.js
Outdated
const publicKey = await getPublicEncryptionKey(imsOrgCode); | ||
const secretsData = await interpolateSecrets(secretsFilePath, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const publicKey = await getPublicEncryptionKey(imsOrgCode); | |
const secretsData = await interpolateSecrets(secretsFilePath, this); | |
const secretsData = await interpolateSecrets(secretsFilePath, this); | |
const publicKey = await getPublicEncryptionKey(imsOrgCode); |
I woluld switch them because if interpolateSecrets
failed due to any error, there wont be any use for the publicKey. Lets avoid unnecessary fetches where possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, addressed in latest commit
src/commands/api-mesh/update.js
Outdated
const publicKey = await getPublicEncryptionKey(imsOrgCode); | ||
const secretsData = await interpolateSecrets(secretsFilePath, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const publicKey = await getPublicEncryptionKey(imsOrgCode); | |
const secretsData = await interpolateSecrets(secretsFilePath, this); | |
const secretsData = await interpolateSecrets(secretsFilePath, this); | |
const publicKey = await getPublicEncryptionKey(imsOrgCode); |
Same as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, addressed in latest commit
src/utils.js
Outdated
* @param publicKey Public key for (AES + RSA) encryption | ||
* @param secrets Secrets Data that needs encryption | ||
*/ | ||
async function encryptSecret(publicKey, secrets) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async function encryptSecret(publicKey, secrets) { | |
async function encryptSecrets(publicKey, secrets) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, addressed in latest commit
src/utils.js
Outdated
async function encryptSecret(publicKey, secrets) { | ||
if (!publicKey || typeof publicKey !== 'string' || !publicKey.trim()) { | ||
throw new Error( | ||
chalk.red('Something went wrong in secerts encryption. Invalid publicKey provided.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chalk.red('Something went wrong in secerts encryption. Invalid publicKey provided.'), | |
chalk.red('Unable to encrypt secerts. Invalid Public Key.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, addressed in latest commit
src/utils.js
Outdated
logger.error('Error generating AES key, IV OR encryption package:', error.message); | ||
throw new Error(chalk.red(`Failed to generate encryption parameters. Please try again.`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.error('Error generating AES key, IV OR encryption package:', error.message); | |
throw new Error(chalk.red(`Failed to generate encryption parameters. Please try again.`)); | |
logger.error('Unable to encrypt secrets. Please try again. :', error.message); | |
throw new Error(`Unable to encrypt secerts. ${error.message}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, addressed in latest commit
src/lib/devConsole.js
Outdated
let errorMessage = `Failed to load encryption keys. Please contact support.`; | ||
logger.error(`${errorMessage}. Received ${response.status} response instead of 200`); | ||
throw new Error(chalk.red(errorMessage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let errorMessage = `Failed to load encryption keys. Please contact support.`; | |
logger.error(`${errorMessage}. Received ${response.status} response instead of 200`); | |
throw new Error(chalk.red(errorMessage)); | |
let errorMessage = `Failed to load encryption keys. Please contact support.`; | |
logger.error(`${errorMessage}. Received ${response.status}, expected 200`); | |
throw new Error(chalk.red(errorMessage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, addressed in latest commit
src/lib/devConsole.js
Outdated
throw new Error(chalk.red(errorMessage)); | ||
} | ||
} catch (error) { | ||
let errorMessage = `Something went wrong in secerts encryption. Please try after some time.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let errorMessage = `Something went wrong in secerts encryption. Please try after some time.`; | |
let errorMessage = `Something went wrong while encrypting secrets. Please try again.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, addressed in latest commit
Description
This PR is to encrypt secrets data from CLI. Whenever a
create
ORupdate
command will be executed with--secrets
followed by a secrets yaml file, we need to encrypt the secrets data before sending it over.Related Issue
https://jira.corp.adobe.com/browse/CEXT-3188
(point 3)
Motivation and Context
This change is required for secrets encryption.
How Has This Been Tested?
aio plugins link . in this PR branch, make sure the endpoint returns the public key
aio api-mesh create mesh.json --secrets mysecrets.yaml
aio api-mesh update mesh.json --secrets mysecrets.yaml
Screenshots (if appropriate):
Types of changes
Checklist: