Skip to content

Commit

Permalink
#3679 hide certificate, key and chain ca in AS3 response (#3714)
Browse files Browse the repository at this point in the history
  • Loading branch information
vidyasagar-m authored Jan 15, 2025
1 parent 79353ee commit db749c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/RELEASE-NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Added Functionality

Bug Fixes
````````````
* `Issue 3679 <https://github.com/F5Networks/k8s-bigip-ctlr/issues/3679>`_: Certificate, CA chain, and private key shown in debug logs

2.19.0
-------------
Expand Down
11 changes: 8 additions & 3 deletions pkg/agent/as3/postManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,13 @@ func (postMgr *PostManager) getBigipRegKeyURL() string {
}

func (postMgr *PostManager) logAS3Response(responseMap map[string]interface{}) {
// Avoid modifying the original response
responseMapCopy := make(map[string]interface{})
for key, value := range responseMap {
responseMapCopy[key] = value
}
// removing the certificates/privateKey from response log
if declaration, ok := (responseMap["declaration"]).([]interface{}); ok {
if declaration, ok := (responseMapCopy["declaration"]).(map[string]interface{}); ok {
for _, value := range declaration {
if tenantMap, ok := value.(map[string]interface{}); ok {
for _, value2 := range tenantMap {
Expand All @@ -425,9 +430,9 @@ func (postMgr *PostManager) logAS3Response(responseMap map[string]interface{}) {
log.Errorf("[AS3] error while reading declaration from AS3 response: %v\n", err)
return
}
responseMap["declaration"] = as3Declaration(decl)
responseMapCopy["declaration"] = as3Declaration(decl)
}
log.Debugf("[AS3] Raw response from Big-IP: %v ", responseMap)
log.Debugf("[AS3] Raw response from Big-IP: %v ", responseMapCopy)
}

func (postMgr *PostManager) logAS3Request(cfg string) {
Expand Down
11 changes: 8 additions & 3 deletions pkg/controller/postManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,13 @@ func (postMgr *PostManager) getBigipRegKeyURL() string {
}

func (postMgr *PostManager) logAS3Response(responseMap map[string]interface{}) {
// Avoid modifying the original response
responseMapCopy := make(map[string]interface{})
for key, value := range responseMap {
responseMapCopy[key] = value
}
// removing the certificates/privateKey from response log
if declaration, ok := (responseMap["declaration"]).([]interface{}); ok {
if declaration, ok := (responseMapCopy["declaration"]).(map[string]interface{}); ok {
for _, value := range declaration {
if tenantMap, ok := value.(map[string]interface{}); ok {
for _, value2 := range tenantMap {
Expand All @@ -661,9 +666,9 @@ func (postMgr *PostManager) logAS3Response(responseMap map[string]interface{}) {
log.Errorf("[AS3]%v error while reading declaration from AS3 response: %v\n", postMgr.postManagerPrefix, err)
return
}
responseMap["declaration"] = as3Declaration(decl)
responseMapCopy["declaration"] = as3Declaration(decl)
}
log.Debugf("[AS3]%v Raw response from Big-IP: %v ", postMgr.postManagerPrefix, responseMap)
log.Debugf("[AS3]%v Raw response from Big-IP: %v ", postMgr.postManagerPrefix, responseMapCopy)
}

func (postMgr *PostManager) logAS3Request(cfg string) {
Expand Down

0 comments on commit db749c8

Please sign in to comment.