diff --git a/motor/vault/config.go b/motor/vault/config.go index a27f28129e..1bdce95e04 100644 --- a/motor/vault/config.go +++ b/motor/vault/config.go @@ -34,6 +34,7 @@ var vaultMarshalNameMap = map[VaultType]string{ VaultType_AWSSecretsManager: "aws-secrets-manager", VaultType_AWSParameterStore: "aws-parameter-store", VaultType_GCPBerglas: "gcp-berglas", + VaultType_Memory: "memory", } func (t *VaultType) Value() string { diff --git a/motor/vault/config/vaultconfigstore.go b/motor/vault/config/vaultconfigstore.go index 3d5336a364..242ff3ca59 100644 --- a/motor/vault/config/vaultconfigstore.go +++ b/motor/vault/config/vaultconfigstore.go @@ -14,6 +14,7 @@ import ( "go.mondoo.com/cnquery/motor/vault/gcpberglas" "go.mondoo.com/cnquery/motor/vault/gcpsecretmanager" "go.mondoo.com/cnquery/motor/vault/hashivault" + "go.mondoo.com/cnquery/motor/vault/inmemory" "go.mondoo.com/cnquery/motor/vault/keyring" ) @@ -29,6 +30,8 @@ func New(vCfg *vault.VaultConfiguration) (vault.Vault, error) { log.Debug().Str("vault-name", vCfg.Name).Str("vault-type", vCfg.Type.String()).Msg("initialize new vault") var v vault.Vault switch vCfg.Type { + case vault.VaultType_Memory: + v = inmemory.New() case vault.VaultType_HashiCorp: serverUrl := vCfg.Options["url"] token := vCfg.Options["token"] diff --git a/motor/vault/inmemory/inmemory.go b/motor/vault/inmemory/inmemory.go index 5ca41b0507..0237db597e 100644 --- a/motor/vault/inmemory/inmemory.go +++ b/motor/vault/inmemory/inmemory.go @@ -40,10 +40,6 @@ func (v *inmemoryVault) Set(ctx context.Context, secret *vault.Secret) (*vault.S return nil, errors.New("secret is empty") } - if secret.Encoding != vault.SecretEncoding_encoding_undefined && secret.Encoding != vault.SecretEncoding_encoding_proto { - return nil, errors.New("only proto encoding is supported") - } - v.secrets[secret.Key] = secret return &vault.SecretID{ Key: secret.Key, @@ -59,6 +55,5 @@ func (v *inmemoryVault) Get(ctx context.Context, id *vault.SecretID) (*vault.Sec if !ok { return nil, vault.NotFoundError } - s.Encoding = vault.SecretEncoding_encoding_proto return s, nil } diff --git a/motor/vault/vault.pb.go b/motor/vault/vault.pb.go index 7a09a10001..0b7607f7fd 100644 --- a/motor/vault/vault.pb.go +++ b/motor/vault/vault.pb.go @@ -154,6 +154,7 @@ const ( VaultType_AWSSecretsManager VaultType = 6 VaultType_AWSParameterStore VaultType = 7 VaultType_GCPBerglas VaultType = 8 + VaultType_Memory VaultType = 9 ) // Enum value maps for VaultType. @@ -168,6 +169,7 @@ var ( 6: "AWSSecretsManager", 7: "AWSParameterStore", 8: "GCPBerglas", + 9: "Memory", } VaultType_value = map[string]int32{ "None": 0, @@ -179,6 +181,7 @@ var ( "AWSSecretsManager": 6, "AWSParameterStore": 7, "GCPBerglas": 8, + "Memory": 9, } ) @@ -657,7 +660,7 @@ var file_vault_proto_rawDesc = []byte{ 0x11, 0x0a, 0x0d, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, - 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x10, 0x03, 0x2a, 0xb1, 0x01, 0x0a, 0x09, + 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x10, 0x03, 0x2a, 0xbd, 0x01, 0x0a, 0x09, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x52, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x4b, 0x65, 0x72, 0x6e, 0x65, 0x6c, 0x4b, @@ -668,25 +671,25 @@ var file_vault_proto_rawDesc = []byte{ 0x05, 0x12, 0x15, 0x0a, 0x11, 0x41, 0x57, 0x53, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x73, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11, 0x41, 0x57, 0x53, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x10, 0x07, 0x12, - 0x0e, 0x0a, 0x0a, 0x47, 0x43, 0x50, 0x42, 0x65, 0x72, 0x67, 0x6c, 0x61, 0x73, 0x10, 0x08, 0x32, - 0xe4, 0x01, 0x0a, 0x05, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x49, 0x0a, 0x05, 0x41, 0x62, 0x6f, - 0x75, 0x74, 0x12, 0x1d, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, - 0x6f, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x21, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, - 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x75, 0x6c, 0x74, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x47, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x20, 0x2e, 0x63, 0x6e, - 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, - 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x49, 0x44, 0x1a, 0x1e, 0x2e, + 0x0e, 0x0a, 0x0a, 0x47, 0x43, 0x50, 0x42, 0x65, 0x72, 0x67, 0x6c, 0x61, 0x73, 0x10, 0x08, 0x12, + 0x0a, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x10, 0x09, 0x32, 0xe4, 0x01, 0x0a, 0x05, + 0x56, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x49, 0x0a, 0x05, 0x41, 0x62, 0x6f, 0x75, 0x74, 0x12, 0x1d, + 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, 0x72, 0x2e, 0x76, + 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x21, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x61, - 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x47, 0x0a, - 0x03, 0x53, 0x65, 0x74, 0x12, 0x1e, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, - 0x6f, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, - 0x63, 0x72, 0x65, 0x74, 0x1a, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, - 0x6f, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, - 0x63, 0x72, 0x65, 0x74, 0x49, 0x44, 0x42, 0x23, 0x5a, 0x21, 0x67, 0x6f, 0x2e, 0x6d, 0x6f, 0x6e, - 0x64, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, - 0x6d, 0x6f, 0x74, 0x6f, 0x72, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x47, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, + 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x49, 0x44, 0x1a, 0x1e, 0x2e, 0x63, 0x6e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x47, 0x0a, 0x03, 0x53, 0x65, 0x74, + 0x12, 0x1e, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, 0x72, + 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, + 0x1a, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x74, 0x6f, 0x72, + 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, + 0x49, 0x44, 0x42, 0x23, 0x5a, 0x21, 0x67, 0x6f, 0x2e, 0x6d, 0x6f, 0x6e, 0x64, 0x6f, 0x6f, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x6d, 0x6f, 0x74, 0x6f, + 0x72, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/motor/vault/vault.proto b/motor/vault/vault.proto index bd41bbd4b0..f82954c66e 100644 --- a/motor/vault/vault.proto +++ b/motor/vault/vault.proto @@ -77,6 +77,7 @@ enum VaultType { AWSSecretsManager = 6; AWSParameterStore = 7; GCPBerglas = 8; + Memory = 9; } message VaultConfiguration {