Skip to content
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

Keep-142 AWS GO SDK Develop #3

Open
wants to merge 13 commits into
base: KEEP-142-aws-go-review
Choose a base branch
from

Conversation

ayusha-metron
Copy link
Collaborator

No description provided.

@ayusha-metron ayusha-metron self-assigned this Feb 17, 2025
@ayusha-metron ayusha-metron changed the title Initial commit Keep-142 AWS GO SDK Feb 17, 2025
@ayusha-metron ayusha-metron marked this pull request as ready for review February 18, 2025 06:33
@satish-metron
Copy link
Collaborator

Hey, A general observation i noticed is that we are not providing logs when a certain checkpoint is met.

For example,

  1. log when we load the encrypted config into memory.
  2. log when we start decrypting and call the decrypt API etc

We are providing great error logs for all errors but we do not have debug logs and such much. maybe check and add those if you think they make sense since we can use logs for decryption.


* Supports the Go-Lang Secrets Manager SDK.
* Requires AWS packages: aws, config, credentials, kms, kms-types
* Works with just AES/RSA key types with `Encrypt` and `Decrypt` permissions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work with both Symmetric and Asymmetric(RSA) right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Works with both of the types.

}
convertedConfig := make(map[string]interface{})
for k, v := range a.config {
convertedConfig[string(k)] = v
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a.config is a map[string]interface{} then k should already be a string, Do we really need to convert it string again here string(k)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a.config is type of map[core.ConfigKey]interface{}, We need to convert it to map[string]interface{}.

func (a *AWSKeyVaultStorage) Delete(key core.ConfigKey) map[string]interface{} {
if _, found := a.config[key]; found {
delete(a.config, key)
logger.Debugf("%s", "Removed key: "+string(key))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.Debugf("Removed key: %s", key) will work if key is already string

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key is core.Config present in Keeper-golang repository, so converting it into a string.


func decryptSymmetric(client *kms.Client, keyId string, cipherText []byte) ([]byte, error) {
if keyId == "" {
return nil, fmt.Errorf("keyId is empty")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should validate cipherText also if it is null or empty

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the condition.

}

func (a *AWSKeyVaultStorage) saveConfig(updatedConfig map[core.ConfigKey]interface{}) error {
configJson, err := json.Marshal(a.config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the comment in code wherever needed like what the method do see here
https://github.com/Keeper-Security/secrets-manager-go/blob/master/core/core.go

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the comments.

// createHash creates an MD5 hash of the provided config data.
func (a *AWSKeyVaultStorage) createHash(config []byte) string {
hash := md5.Sum(config)
return hex.EncodeToString(hash[:])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we do return hex.EncodeToString(hash)?

@ayusha-metron ayusha-metron changed the title Keep-142 AWS GO SDK Keep-142 AWS GO SDK Develop Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants