Skip to content

Fix decryption of indexed (list) properties.#1634

Merged
ryanjbaxter merged 1 commit intospring-cloud:4.3.xfrom
kvmw:topic/kvmw/4.3.x/decrypt
Jan 15, 2026
Merged

Fix decryption of indexed (list) properties.#1634
ryanjbaxter merged 1 commit intospring-cloud:4.3.xfrom
kvmw:topic/kvmw/4.3.x/decrypt

Conversation

@kvmw
Copy link
Copy Markdown
Contributor

@kvmw kvmw commented Jan 14, 2026

This pull request fixes #1253.

It also fixes the following cases:

  • In current (before this fix) implementation, when there is a list (indexed) property with encrypted items in a property source, All lists are copied to the new decrypted property-source, not only the one that has encrypted items.

For example, in the following case only my-list should be copied to the decrypted property source but current implementation copies another-list as well.

  my-list:
    - foo: '{cipher}4ffef9'
    - foo: 'plain'
    - foo: 'another plain value'
 
  another-list:
    - bar: plain
    - bar: another plain   
  • When searching for properties, during decryption, relaxed-binding should be considered. Otherwise It is not possible to override the value of foo.text : '{cipher}4ffef9' by adding FOO_TEXT : 'updated value' in another property source with higher priority.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the decryption logic for encrypted properties in Spring Cloud Context to fix issues with indexed (list) properties and relaxed binding. The changes streamline the decryption algorithm to only copy indexed properties that contain encrypted values and to properly handle relaxed binding scenarios where property names can have different formats (e.g., foo.text, FOO_TEXT, foo_text).

Changes:

  • Rewrote AbstractEnvironmentDecrypt.decrypt() to use a visitor pattern that tracks processed properties with relaxed binding support
  • Simplified API by removing unnecessary parameters and helper methods in multiple classes
  • Added comprehensive tests in new AbstractEnvironmentDecryptTests class to verify the fix
  • Updated existing tests to use modern Java syntax (Map.of(), var keyword)

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AbstractEnvironmentDecrypt.java Complete rewrite of decryption logic with visitor pattern, relaxed binding support, and selective indexed property copying
TextEncryptorUtils.java Simplified decrypt method signature to remove redundant parameter
EnvironmentDecryptApplicationInitializer.java Updated to use simplified decrypt API and removed obsolete helper methods
DecryptEnvironmentPostProcessor.java Updated to use simplified decrypt API
AbstractEnvironmentDecryptTests.java New comprehensive test suite covering all decryption scenarios including relaxed binding and indexed properties
EnvironmentDecryptApplicationInitializerTests.java Modernized test code with Java improvements and refactored composite property source test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kvmw kvmw force-pushed the topic/kvmw/4.3.x/decrypt branch 2 times, most recently from b80cfc0 to 9556774 Compare January 15, 2026 08:10
When decrypting indexed properties all items of the list with at
least one encrypted item should be copied to the new property-source but not the other lists.

When searching for properties relaxed-binding should be considered.

Signed-off-by: kvmw <[email protected]>
@kvmw kvmw force-pushed the topic/kvmw/4.3.x/decrypt branch from 9556774 to 8747fad Compare January 15, 2026 08:19
@ryanjbaxter ryanjbaxter merged commit 9314320 into spring-cloud:4.3.x Jan 15, 2026
1 check passed
@shitikanth
Copy link
Copy Markdown

@ryanjbaxter Looks like this fix is still not merged to the mainline.

@ryanjbaxter
Copy link
Copy Markdown
Contributor

@shitikanth yes it was merged in main
9314320

That commit has a tag of 5.0.1.

@kvmw kvmw deleted the topic/kvmw/4.3.x/decrypt branch April 9, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

5 participants