Skip to content

Commit

Permalink
Fix bug where decoding stringdata modified the existing object directly
Browse files Browse the repository at this point in the history
Solution: when decoding, operate on a copy of the existing object's data

Ref: https://issues.redhat.com/browse/ACM-8739
Signed-off-by: Jeffrey Luo <jeluo@redhat.com>
  • Loading branch information
JeffeyL committed Nov 22, 2023
1 parent a901475 commit 34c5a93
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/configurationpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2410,16 +2410,16 @@ func handleSingleKey(
}

if key == "stringData" && existingObj.GetKind() == "Secret" {
// override automatic conversion from stringData to data prior to evaluation
existingValue = existingObj.UnstructuredContent()["data"]

// override automatic conversion from stringData to data before evaluation
encodedValue, _, err := unstructured.NestedStringMap(existingObj.Object, "data")
if err != nil {
message := "Error accessing encoded data"

return message, false, mergedValue, false
}

existingValue = make(map[string]interface{}, len(encodedValue))

for k, value := range encodedValue {
decodedVal, err := base64.StdEncoding.DecodeString(value)
if err != nil {
Expand Down

0 comments on commit 34c5a93

Please sign in to comment.