Skip to content

Commit 65126b1

Browse files
author
Rajat Gupta
committed
Make crypto store settings immutable
Signed-off-by: Rajat Gupta <[email protected]>
1 parent 1ee30dc commit 65126b1

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3333
- Allow the truncate filter in normalizers ([#19778](https://github.com/opensearch-project/OpenSearch/issues/19778))
3434
- Support pull-based ingestion message mappers and raw payload support ([#19765](https://github.com/opensearch-project/OpenSearch/pull/19765))
3535
- Support dynamic consumer configuration update in pull-based ingestion ([#19963](https://github.com/opensearch-project/OpenSearch/pull/19963))
36-
36+
- Add validation to make crypto store settings immutable ([#20123](https://github.com/opensearch-project/OpenSearch/pull/20123))
3737
### Changed
3838
- Faster `terms` query creation for `keyword` field with index and docValues enabled ([#19350](https://github.com/opensearch-project/OpenSearch/pull/19350))
3939
- Refactor to move prepareIndex and prepareDelete methods to Engine class ([#19551](https://github.com/opensearch-project/OpenSearch/pull/19551))

server/src/main/java/org/opensearch/cluster/metadata/MetadataUpdateSettingsService.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public void updateSettings(
142142
validateRefreshIntervalSettings(normalizedSettings, clusterService.getClusterSettings());
143143
validateTranslogDurabilitySettings(normalizedSettings, clusterService.getClusterSettings(), clusterService.getSettings());
144144
validateIndexTotalPrimaryShardsPerNodeSetting(normalizedSettings, clusterService);
145+
validateCryptoStoreSettings(normalizedSettings, request.indices(), clusterService.state());
145146
final int defaultReplicaCount = clusterService.getClusterSettings().get(Metadata.DEFAULT_REPLICA_COUNT_SETTING);
146147

147148
Settings.Builder settingsForClosedIndices = Settings.builder();
@@ -589,4 +590,32 @@ public static void validateIndexTotalPrimaryShardsPerNodeSetting(Settings indexS
589590
);
590591
}
591592
}
593+
594+
/**
595+
* Validates crypto store settings are immutable after index creation.
596+
*/
597+
public static void validateCryptoStoreSettings(Settings indexSettings, Index[] indices, ClusterState clusterState) {
598+
final String[] restrictedCryptoSettings = {
599+
"index.store.crypto.key_provider",
600+
"index.store.crypto.kms.key_arn",
601+
"index.store.crypto.kms.encryption_context" };
602+
603+
// Crypto settings are completely immutable - reject any attempt to modify them
604+
for (String settingKey : restrictedCryptoSettings) {
605+
if (indexSettings.keySet().contains(settingKey)) {
606+
throw new IllegalArgumentException("Cannot update [" + settingKey + "] - crypto settings are immutable");
607+
}
608+
}
609+
610+
// Validate store type changes
611+
String newStoreType = indexSettings.get("index.store.type");
612+
if ("cryptofs".equals(newStoreType)) {
613+
for (Index index : indices) {
614+
String currentStoreType = clusterState.metadata().getIndexSafe(index).getSettings().get("index.store.type", "");
615+
if (!"cryptofs".equals(currentStoreType)) {
616+
throw new IllegalArgumentException("Cannot change store type to 'cryptofs' for index [" + index.getName() + "]");
617+
}
618+
}
619+
}
620+
}
592621
}

0 commit comments

Comments
 (0)