Repository navigation
[Cosmos Encryption] Encrypt each array element independently for mixed-type arrays #51247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Abhijeet Mohanty (jeet1995)
merged 25 commits into
Azure:main
from
jeet1995:fix/encryption-patch-mixed-arrays
Nov 24, 2026
+1,115
−221
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5fe1bc5
Fix mixed-array client-side encryption
jeet1995 e3f6230
Report legacy mixed-array decryption failures
jeet1995 a561f5c
Fix encryption changelog migration link
jeet1995 4b8cf09
Align encryption changelog PR references
jeet1995 eb0f6b2
Add mixed-array encryption compatibility opt-out
jeet1995 f45ac08
Fix Cosmos gateway user agent propagation
jeet1995 4f22182
Simplify Cosmos gateway default headers
jeet1995 3481211
Refresh Cosmos user agent at serialization boundary
jeet1995 258767b
Update Cosmos changelog for user agent propagation
jeet1995 e7cac69
Refine Cosmos user agent changelog entry
jeet1995 2f1446c
Harden Cosmos user agent propagation
jeet1995 a68e427
Remove user agent hot-path locking
jeet1995 29456f6
Simplify Gateway user agent refresh
jeet1995 602b152
Test combined Cosmos user agent suffixes
jeet1995 fd02f5e
Limit Cosmos user agent refresh scope
jeet1995 f3564d7
Minimize Cosmos feature suffix publication
jeet1995 826b85e
Merge Azure main into encryption mixed-array fix
jeet1995 a3a6d01
Test encryption opt-out marker in Gateway user agents
jeet1995 9379934
Encode encryption opt-out as a user-agent feature bit
jeet1995 6e2e75a
Route encryption user-agent updates through wrapped client
jeet1995 f35f2a5
Separate legacy and corrected encryption array traversal
jeet1995 6664f5f
Shorten mixed-array decryption error guidance
jeet1995 3341498
Keep encryption array traversal close to main
jeet1995 62d18d8
Remove encryption user-agent unit tests and module opening
jeet1995 6be7d27
Keep standalone scalar PATCH behavior unchanged
jeet1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ncryption/src/main/java/com/azure/cosmos/encryption/implementation/EncryptionConfigs.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.cosmos.encryption.implementation; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
|
|
||
| /** | ||
| * Internal configuration for the encryption SDK. | ||
| */ | ||
| public final class EncryptionConfigs { | ||
| static final String MIXED_ARRAYS_ENABLED = "COSMOS.ENCRYPTION_MIXED_ARRAYS_ENABLED"; | ||
| static final String MIXED_ARRAYS_ENABLED_VARIABLE = "COSMOS_ENCRYPTION_MIXED_ARRAYS_ENABLED"; | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(EncryptionConfigs.class); | ||
| private static final AtomicBoolean LEGACY_MODE_WARNING_LOGGED = new AtomicBoolean(false); | ||
|
|
||
| private EncryptionConfigs() { | ||
| } | ||
|
|
||
| /** | ||
| * Resolves the mixed-array encryption setting, giving the JVM property precedence over the environment variable. | ||
| * | ||
| * @return whether corrected mixed-array traversal is enabled | ||
| */ | ||
| public static boolean isMixedArrayEncryptionEnabled() { | ||
| return isMixedArrayEncryptionEnabled(System.getProperty(MIXED_ARRAYS_ENABLED), | ||
| System.getenv(MIXED_ARRAYS_ENABLED_VARIABLE)); | ||
| } | ||
|
|
||
| static boolean isMixedArrayEncryptionEnabled(String systemPropertyValue, String environmentVariableValue) { | ||
| String value = systemPropertyValue == null || systemPropertyValue.isEmpty() | ||
| ? environmentVariableValue : systemPropertyValue; | ||
| if (value == null || value.isEmpty() || "true".equalsIgnoreCase(value)) { | ||
| return true; | ||
| } | ||
| if ("false".equalsIgnoreCase(value)) { | ||
| if (LEGACY_MODE_WARNING_LOGGED.compareAndSet(false, true)) { | ||
| LOGGER.warn("Mixed-array encryption is disabled through {} or {}. Legacy traversal can leave " | ||
| + "scalar array elements unencrypted and cannot correctly read mixed arrays written with " | ||
| + "the fix enabled. Use this temporary compatibility mode only until legacy data is migrated.", | ||
| MIXED_ARRAYS_ENABLED, MIXED_ARRAYS_ENABLED_VARIABLE); | ||
| } | ||
| return false; | ||
| } | ||
| throw new IllegalArgumentException("Invalid " + MIXED_ARRAYS_ENABLED + " or " | ||
| + MIXED_ARRAYS_ENABLED_VARIABLE + " setting. Only 'true' or 'false' are supported."); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.