spring-cloud / spring-cloud-commons

Common classes used in different Spring Cloud implementations
Apache License 2.0
707 stars 704 forks source link

Properties decryption not working correctly when they are on a list (yaml) #1253

Open FuRi0n opened 1 year ago

FuRi0n commented 1 year ago

When we have properties on a list that are encrypted and we overwrite them on another profile they will keep their initial value and ignore other profiles. This happens even to other properties but if we add them also ciphered on the other profiles then it will work correctly. I have a sample application to reproduce the issue: https://github.com/FuRi0n/decrypt

In the sample, with this yml file:

application:
  list:
    - plain: good
      cipher: '{cipher}4ffef96df11b9e9ca7b33aa5ccd60b6ed8406ec5edb68618b2469208fceb2626'

---

application:
  list:
    - plain: updated
      cipher: 'updated'
spring:
  config:
    activate:
      on-profile: decrypt

When running 'decrypt' profile it will print on console plain='good' and cipher='bad' but, if we update the 'cipher' value on 'decrypt' profile to be also encrypted then we will get plain='updated' and cipher='updated'

The expected behaviour is that properties in the profile with higher priority must overwrite other profiles even if those properties values are not encrypted.