diff --git a/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java b/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java index 7ae1bdfbcf..7142a05c2e 100644 --- a/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java +++ b/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java @@ -149,12 +149,12 @@ public void postIndex(ShardId shardId, Index index, IndexResult result) { if(previousContent == null) { //no previous content if(!result.isCreated()) { - log.warn("No previous content and not created (its an update but do not find orig source) for {}/{}/{}/{}", index.startTime(), shardId, index.type(), index.id()); + log.warn("No previous content and not created (its an update but do not find orig source) for {}/{}/{}", index.startTime(), shardId, index.id()); } assert result.isCreated():"No previous content and not created"; } else { if(result.isCreated()) { - log.warn("Previous content and created for {}/{}/{}/{}", index.startTime(), shardId, index.type(), index.id()); + log.warn("Previous content and created for {}/{}/{}", index.startTime(), shardId, index.id()); } assert !result.isCreated():"Previous content and created"; } diff --git a/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java b/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java index 585d5c750f..03858968f5 100644 --- a/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java +++ b/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java @@ -120,12 +120,12 @@ public void binaryFieldRead(final FieldInfo fieldInfo, byte[] fieldValue) { } } - public void stringFieldRead(final FieldInfo fieldInfo, final byte[] fieldValue) { + public void stringFieldRead(final FieldInfo fieldInfo, final String fieldValue) { try { if(!recordField(fieldInfo.name, true)) { return; } - fieldRead0(fieldInfo.name, new String(fieldValue, StandardCharsets.UTF_8)); + fieldRead0(fieldInfo.name, fieldValue); } catch (Exception e) { log.error("Unexpected error reading string field '{}' in index '{}'", fieldInfo.name, index.getName()); } diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java b/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java index 3d78dd9ac3..716b051fce 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java @@ -421,11 +421,6 @@ public void checkIntegrity() throws IOException { public void close() throws IOException { in.close(); } - - @Override - public long ramBytesUsed() { - return in.ramBytesUsed(); - } } @Override @@ -521,7 +516,7 @@ public int hashCode() { } @Override - public void stringField(final FieldInfo fieldInfo, final byte[] value) throws IOException { + public void stringField(final FieldInfo fieldInfo, final String value) throws IOException { fieldReadCallback.stringFieldRead(fieldInfo, value); delegate.stringField(fieldInfo, value); } @@ -610,7 +605,7 @@ public int hashCode() { } @Override - public void stringField(final FieldInfo fieldInfo, final byte[] value) throws IOException { + public void stringField(final FieldInfo fieldInfo, final String value) throws IOException { delegate.stringField(fieldInfo, value); } @@ -681,7 +676,7 @@ public int hashCode() { } @Override - public void stringField(final FieldInfo fieldInfo, final byte[] value) throws IOException { + public void stringField(final FieldInfo fieldInfo, final String value) throws IOException { final Optional mf = maskedFieldsMap.getMaskedField(fieldInfo.name); if(mf.isPresent()) { @@ -868,11 +863,6 @@ private SortedDocValues wrapSortedDocValues(final String field, final SortedDocV if (mf != null) { return new SortedDocValues() { - @Override - public BytesRef binaryValue() throws IOException { - return mf.mask(sortedDocValues.binaryValue()); - } - @Override public int lookupTerm(BytesRef key) throws IOException { return sortedDocValues.lookupTerm(key); diff --git a/src/test/java/org/opensearch/security/TracingTests.java b/src/test/java/org/opensearch/security/TracingTests.java index a5a626c671..fc193e2611 100644 --- a/src/test/java/org/opensearch/security/TracingTests.java +++ b/src/test/java/org/opensearch/security/TracingTests.java @@ -62,14 +62,10 @@ public void testAdvancedMapping() throws Exception { setup(Settings.EMPTY, new DynamicSecurityConfig(), Settings.EMPTY, true, ClusterConfiguration.DEFAULT); try (Client tc = getClient()) { - tc.admin().indices().create(new CreateIndexRequest("myindex1") - .mapping("mytype1", FileHelper.loadFile("mapping1.json"), XContentType.JSON)).actionGet(); - tc.admin().indices().create(new CreateIndexRequest("myindex2") - .mapping("mytype2", FileHelper.loadFile("mapping2.json"), XContentType.JSON)).actionGet(); - tc.admin().indices().create(new CreateIndexRequest("myindex3") - .mapping("mytype3", FileHelper.loadFile("mapping3.json"), XContentType.JSON)).actionGet(); - tc.admin().indices().create(new CreateIndexRequest("myindex4") - .mapping("mytype4", FileHelper.loadFile("mapping4.json"), XContentType.JSON)).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex1")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex2")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex3")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex4")).actionGet(); } RestHelper rh = nonSslRestHelper(); diff --git a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java index f4d79f571a..59951c2566 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java @@ -338,14 +338,10 @@ public void testAdvancedMapping() throws Exception { rh.executePutRequest("_opendistro/_security/api/audit/config", AuditTestUtils.createAuditPayload(settings), encodeBasicHeader("admin", "admin")); try (Client tc = getClient()) { - tc.admin().indices().create(new CreateIndexRequest("myindex1") - .mapping("mytype1", FileHelper.loadFile("mapping1.json"), XContentType.JSON)).actionGet(); - tc.admin().indices().create(new CreateIndexRequest("myindex2") - .mapping("mytype2", FileHelper.loadFile("mapping2.json"), XContentType.JSON)).actionGet(); - tc.admin().indices().create(new CreateIndexRequest("myindex3") - .mapping("mytype3", FileHelper.loadFile("mapping3.json"), XContentType.JSON)).actionGet(); - tc.admin().indices().create(new CreateIndexRequest("myindex4") - .mapping("mytype4", FileHelper.loadFile("mapping4.json"), XContentType.JSON)).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex1")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex2")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex3")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex4")).actionGet(); } System.out.println("############ write into mapping 1"); @@ -391,10 +387,8 @@ public void testImmutableIndex() throws Exception { rh.executePutRequest("_opendistro/_security/api/audit/config", AuditTestUtils.createAuditPayload(Settings.EMPTY), encodeBasicHeader("admin", "admin")); try (Client tc = getClient()) { - tc.admin().indices().create(new CreateIndexRequest("myindex1") - .mapping("mytype1", FileHelper.loadFile("mapping1.json"), XContentType.JSON)).actionGet(); - tc.admin().indices().create(new CreateIndexRequest("myindex2") - .mapping("mytype2", FileHelper.loadFile("mapping1.json"), XContentType.JSON)).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex1")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("myindex2")).actionGet(); } System.out.println("############ immutable 1"); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java index a6b968dbdd..2c2c74c7d6 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java @@ -36,7 +36,7 @@ public class CustomFieldMaskedComplexMappingTest extends AbstractDlsFlsTest{ protected void populateData(Client tc) { try { - tc.admin().indices().create(new CreateIndexRequest("logs").mapping("_doc", FileHelper.loadFile("dlsfls/masked_field_mapping.json"), XContentType.JSON)).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("logs")).actionGet(); byte[] data = FileHelper.loadFile("dlsfls/logs_bulk_data.json").getBytes(StandardCharsets.UTF_8); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java index 4369db6599..18ce04c9e5 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java @@ -44,8 +44,7 @@ protected void populateData(Client tc) { ""; tc.admin().indices().create(new CreateIndexRequest("deals") - .settings(Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build()) - .mapping("mytype", mapping, XContentType.JSON)).actionGet(); + .settings(Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build())).actionGet(); //tc.index(new IndexRequest("deals").id("3").setRefreshPolicy(RefreshPolicy.IMMEDIATE) // .source("{\"amount\": 7,\"owner\": \"a\", \"my_nested_object\" : {\"name\": \"spock\"}}", XContentType.JSON)).actionGet(); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java index 0de711caec..e0a24cb2ce 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java @@ -273,7 +273,7 @@ public void testDlsWithMinDocCountZeroAggregations() throws Exception { setup(); try (Client client = getClient()) { - client.admin().indices().create(new CreateIndexRequest("logs").mapping("_doc", ImmutableMap.of("properties", ImmutableMap.of("termX", ImmutableMap.of("type", "keyword"))))).actionGet(); + client.admin().indices().create(new CreateIndexRequest("logs")).actionGet(); for (int i = 0; i < 3; i++) { client.index(new IndexRequest("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("amount", i, "termX", "A", "timestamp", "2022-01-06T09:05:00Z")).actionGet(); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java index 103387d1f1..b0ce96c8a8 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java @@ -30,12 +30,7 @@ public class FlsExistsFieldsTest extends AbstractDlsFlsTest { protected void populateData(Client tc) { - tc.admin().indices().create(new CreateIndexRequest("data").mapping("doc", - "@timestamp", "type=date", - "host", "type=text,norms=false", - "response", "type=text,norms=false", - "non-existing", "type=text,norms=false" - )) + tc.admin().indices().create(new CreateIndexRequest("data")) .actionGet(); for (int i = 0; i < 1; i++) { diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java index b115f5d502..371f36efba 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java @@ -34,8 +34,7 @@ public class FlsFieldsTest extends AbstractDlsFlsTest{ protected void populateData(Client tc) { - tc.admin().indices().create(new CreateIndexRequest("deals") - .mapping("deals", "timestamp","type=date","@timestamp","type=date")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("deals")).actionGet(); try { String doc = FileHelper.loadFile("dlsfls/doc1.json"); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java index 5063eb3f25..19a0e9a791 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java @@ -34,8 +34,7 @@ public class FlsFieldsWcTest extends AbstractDlsFlsTest{ protected void populateData(Client tc) { - tc.admin().indices().create(new CreateIndexRequest("deals") - .mapping("deals", "timestamp","type=date","@timestamp","type=date")).actionGet(); + tc.admin().indices().create(new CreateIndexRequest("deals")).actionGet(); try { String doc = FileHelper.loadFile("dlsfls/doc1.json");