From 31e1ed2417733c27c54d50833618d8d49a4f8a6b Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 7 May 2016 20:03:56 -0400 Subject: [PATCH] Implement WrapInfo audit logging --- audit/hashstructure.go | 13 +++++++++++++ logical/response.go | 12 ++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/audit/hashstructure.go b/audit/hashstructure.go index 8ab9951c5..8e78c0ce2 100644 --- a/audit/hashstructure.go +++ b/audit/hashstructure.go @@ -67,12 +67,25 @@ func Hash(salter *salt.Salt, raw interface{}) error { } } + if s.WrapInfo != nil { + if err := Hash(salter, s.WrapInfo); err != nil { + return err + } + } + data, err := HashStructure(s.Data, fn) if err != nil { return err } s.Data = data.(map[string]interface{}) + + case *logical.WrapInfo: + if s == nil { + return nil + } + + s.Token = fn(s.Token) } return nil diff --git a/logical/response.go b/logical/response.go index 88dd9934a..b59a5bb6e 100644 --- a/logical/response.go +++ b/logical/response.go @@ -87,7 +87,7 @@ func init() { if input.Auth != nil { retAuth, err := copystructure.Copy(input.Auth) if err != nil { - return nil, fmt.Errorf("error copying Secret: %v", err) + return nil, fmt.Errorf("error copying Auth: %v", err) } ret.Auth = retAuth.(*Auth) } @@ -95,7 +95,7 @@ func init() { if input.Data != nil { retData, err := copystructure.Copy(&input.Data) if err != nil { - return nil, fmt.Errorf("error copying Secret: %v", err) + return nil, fmt.Errorf("error copying Data: %v", err) } ret.Data = retData.(map[string]interface{}) } @@ -106,6 +106,14 @@ func init() { } } + if input.WrapInfo != nil { + retWrapInfo, err := copystructure.Copy(input.WrapInfo) + if err != nil { + return nil, fmt.Errorf("error copying WrapInfo: %v", err) + } + ret.WrapInfo = retWrapInfo.(*WrapInfo) + } + return &ret, nil } }