Skip to content

Commit

Permalink
Merge pull request #299 from manifoldco/fix-value-ref-in-cred-set
Browse files Browse the repository at this point in the history
Fix bug copying same value for each cred
  • Loading branch information
ianlivingstone committed Oct 28, 2017
2 parents a23f4cd + 0500955 commit 97654b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ func importCmd(ctx *cli.Context) error {

makers := valueMakers{}
for _, secret := range secrets {
makers[secret.key] = func() *apitypes.CredentialValue {
return apitypes.NewStringCredentialValue(secret.value)
}
makers[secret.key] = func(value string) valueMaker {
return func() *apitypes.CredentialValue {
return apitypes.NewStringCredentialValue(value)
}
}(secret.value)
}

creds, err := setCredentials(ctx, path, makers)
Expand Down
3 changes: 2 additions & 1 deletion cmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ func determinePathFromFlags(ctx *cli.Context) (*pathexp.PathExp, error) {
)
}

type valueMakers map[string](func() *apitypes.CredentialValue)
type valueMaker func() *apitypes.CredentialValue
type valueMakers map[string]valueMaker

func setCredentials(ctx *cli.Context, pe *pathexp.PathExp, makers valueMakers) ([]apitypes.CredentialEnvelope, error) {
cfg, err := config.LoadConfig()
Expand Down
2 changes: 1 addition & 1 deletion daemon/logic/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (e *Engine) AppendCredentials(ctx context.Context, notifier *observer.Notif
// Derive a key for the credential using the keyring master key
// and use the derived key to encrypt the credential
cekNonce, ctNonce, ct, err := e.crypto.BoxCredential(
ctx, []byte(cred.Body.Value), *mekshare.Key.Value, *mekshare.Key.Nonce,
ctx, []byte(c.Body.Value), *mekshare.Key.Value, *mekshare.Key.Nonce,
&kp.Encryption, *encryptingKey.Key.Value)
if err != nil {
log.Printf("Error encrypting credential: %s", err)
Expand Down

0 comments on commit 97654b2

Please sign in to comment.