-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Make crypto store settings immutable #20123
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,6 +142,7 @@ public void updateSettings( | |
| validateRefreshIntervalSettings(normalizedSettings, clusterService.getClusterSettings()); | ||
| validateTranslogDurabilitySettings(normalizedSettings, clusterService.getClusterSettings(), clusterService.getSettings()); | ||
| validateIndexTotalPrimaryShardsPerNodeSetting(normalizedSettings, clusterService); | ||
| validateCryptoStoreSettings(normalizedSettings, request.indices(), clusterService.state()); | ||
| final int defaultReplicaCount = clusterService.getClusterSettings().get(Metadata.DEFAULT_REPLICA_COUNT_SETTING); | ||
|
|
||
| Settings.Builder settingsForClosedIndices = Settings.builder(); | ||
|
|
@@ -589,4 +590,32 @@ public static void validateIndexTotalPrimaryShardsPerNodeSetting(Settings indexS | |
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Validates crypto store settings are immutable after index creation. | ||
| */ | ||
| public static void validateCryptoStoreSettings(Settings indexSettings, Index[] indices, ClusterState clusterState) { | ||
| final String[] restrictedCryptoSettings = { | ||
| "index.store.crypto.key_provider", | ||
| "index.store.crypto.kms.key_arn", | ||
| "index.store.crypto.kms.encryption_context" }; | ||
|
|
||
| // Crypto settings are completely immutable - reject any attempt to modify them | ||
| for (String settingKey : restrictedCryptoSettings) { | ||
| if (indexSettings.keySet().contains(settingKey)) { | ||
| throw new IllegalArgumentException("Cannot update [" + settingKey + "] - crypto settings are immutable"); | ||
| } | ||
| } | ||
|
|
||
| // Validate store type changes | ||
| String newStoreType = indexSettings.get("index.store.type"); | ||
| if ("cryptofs".equals(newStoreType)) { | ||
|
||
| for (Index index : indices) { | ||
| String currentStoreType = clusterState.metadata().getIndexSafe(index).getSettings().get("index.store.type", ""); | ||
| if (!"cryptofs".equals(currentStoreType)) { | ||
| throw new IllegalArgumentException("Cannot change store type to 'cryptofs' for index [" + index.getName() + "]"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be done through properties like
Property.FilteredorProperty.InternalIndexSee https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/common/settings/Setting.java#L160-L164
The last param in https://github.com/opensearch-project/OpenSearch/blob/main/plugins/crypto-kms/src/main/java/org/opensearch/crypto/kms/KmsService.java#L53 is a vararg list of properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes, this is neat, didn't know about this, thanks!