Skip to content

Settings: Fix secure settings by prefix #25064

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
merged 1 commit into from
Jun 6, 2017
Merged

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Jun 5, 2017

This commit fixes a bug in retrieving a sub Settings object for a given
prefix with secure settings. Before this commit the returned Settings
would be filtered by the prefix, but the found setting names would not
have the prefix removed.

Note that nothing was yet using the prefix behavior for secure settings, so I marked this as a non-issue.

This commit fixes a bug in retrieving a sub Settings object for a given
prefix with secure settings. Before this commit the returned Settings
would be filtered by the prefix, but the found setting names would not
have the prefix removed.
Copy link
Member

@dadoonet dadoonet left a comment

Choose a reason for hiding this comment

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

Ha thanks! I was planning to ping about this as I found the same issue while working on azure repo plugin and found that we have the issue with s3.
That's going to fix the problem I saw. (I've been hitting my head to the wall yesterday :))

@dadoonet
Copy link
Member

dadoonet commented Jun 6, 2017

I actually read your PR description and I think that we had this issue in s3 with multiple clients. I'll paste in few hours a test case for this. Can you hold merging until then?

@dadoonet
Copy link
Member

dadoonet commented Jun 6, 2017

@rjernst So I tried to see if your branch actually fixes the issue I have seen and apparently it does not.
So may be I'm doing something bad. Here is the test I wrote:

Index: plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AwsS3ServiceImplTests.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AwsS3ServiceImplTests.java	(date 1496730707000)
+++ plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/AwsS3ServiceImplTests.java	(revision )
@@ -29,6 +29,9 @@
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.test.ESTestCase;
 
+import java.util.Map;
+
+import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.is;
@@ -114,6 +117,18 @@
             "aws_proxy_password", 3, false, 10000);
     }
 
+    public void testAWSConfigurationWith2ClientSettings() {
+        MockSecureSettings secureSettings = new MockSecureSettings();
+        secureSettings.setString("s3.client.myconfig.access_key", "myconfig_key");
+        secureSettings.setString("s3.client.myconfig.secret_key", "myconfig_secret");
+        secureSettings.setString("s3.client.default.access_key", "default_key");
+        secureSettings.setString("s3.client.default.secret_key", "default_secret");
+        Settings settings = Settings.builder().setSecureSettings(secureSettings).build();
+        Map<String, S3ClientSettings> loadedSettings = S3ClientSettings.load(settings);
+
+        assertThat(loadedSettings.keySet(), containsInAnyOrder("myconfig", "default"));
+    }
+
     public void testRepositoryMaxRetries() {
         Settings settings = Settings.builder()
             .put("s3.client.default.max_retries", 5)

Indeed. You did not fix the getGroups method. Basically this is not passing:

    public void testGroupsWithSecuredSettings() {
        MockSecureSettings secureSettings = new MockSecureSettings();
        secureSettings.setString("s3.client.myconfig.access_key", "myconfig_key");
        secureSettings.setString("s3.client.myconfig.secret_key", "myconfig_secret");
        secureSettings.setString("s3.client.default.access_key", "default_key");
        secureSettings.setString("s3.client.default.secret_key", "default_secret");
        Settings settings = Settings.builder().setSecureSettings(secureSettings).build();

        assertThat(settings.getGroups("s3.client.").keySet(), containsInAnyOrder("myconfig", "default"));
    }

Do you want me to open a new issue about this or should be use another method than getGroups?
I think that this is happening only when we have secure settings only.

LMK where I can help.

@rjernst
Copy link
Member Author

rjernst commented Jun 6, 2017

Hrm, it looks like groups are very messed up. Let's address that in a separate issue.

@rjernst rjernst merged commit ac82824 into elastic:master Jun 6, 2017
@rjernst rjernst deleted the keystore14 branch June 6, 2017 07:11
rjernst added a commit that referenced this pull request Jun 6, 2017
This commit fixes a bug in retrieving a sub Settings object for a given
prefix with secure settings. Before this commit the returned Settings
would be filtered by the prefix, but the found setting names would not
have the prefix removed.
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 6, 2017
* master:
  Add support for clear scroll to high level REST client (elastic#25038)
  Tiny correction in inner-hits.asciidoc (elastic#25066)
  Added release notes for 6.0.0-alpha2
  Expand index expressions against indices only when managing aliases (elastic#23997)
  Collapse inner hits rest test should not skip 5.x
  Settings: Fix secure settings by prefix (elastic#25064)
  add `exclude_keys` option to KeyValueProcessor (elastic#24876)
  Test: update missing body tests to run against versions >= 5.5.0
  Track EWMA[1] of task execution time in search threadpool executor
  Removes an invalid assert in resizing big arrays which does not always hold (resizing can result in a smaller size than the current size, while the assert attempted to verify the new size is always greater than the current).
  Fixed NPEs caused by requests without content. (elastic#23497)
  Plugins can register pre-configured char filters (elastic#25000)
  Build: Allow preserving shared dir (elastic#24962)
  Tests: Make secure settings available from settings builder for tests (elastic#25037)
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 6, 2017
* master: (1210 commits)
  Add support for clear scroll to high level REST client (elastic#25038)
  Tiny correction in inner-hits.asciidoc (elastic#25066)
  Added release notes for 6.0.0-alpha2
  Expand index expressions against indices only when managing aliases (elastic#23997)
  Collapse inner hits rest test should not skip 5.x
  Settings: Fix secure settings by prefix (elastic#25064)
  add `exclude_keys` option to KeyValueProcessor (elastic#24876)
  Test: update missing body tests to run against versions >= 5.5.0
  Track EWMA[1] of task execution time in search threadpool executor
  Removes an invalid assert in resizing big arrays which does not always hold (resizing can result in a smaller size than the current size, while the assert attempted to verify the new size is always greater than the current).
  Fixed NPEs caused by requests without content. (elastic#23497)
  Plugins can register pre-configured char filters (elastic#25000)
  Build: Allow preserving shared dir (elastic#24962)
  Tests: Make secure settings available from settings builder for tests (elastic#25037)
  [TEST] Skip wildcard expansion test due to breaking change
  Test that gradle and Java version types match (elastic#24943)
  Include duplicate jar when jarhell check fails
  Change ScriptContexts to use needs instead of uses$. (elastic#25036)
  Change `has_child`, `has_parent` queries and `childen` aggregation to work with the new join field type and at the same time maintaining support for the `_parent` meta field type.
  Remove comma-separated feature parsing for GetIndicesAction
  ...
jasontedor added a commit to zeha/elasticsearch that referenced this pull request Jun 6, 2017
* master: (619 commits)
  Add support for clear scroll to high level REST client (elastic#25038)
  Tiny correction in inner-hits.asciidoc (elastic#25066)
  Added release notes for 6.0.0-alpha2
  Expand index expressions against indices only when managing aliases (elastic#23997)
  Collapse inner hits rest test should not skip 5.x
  Settings: Fix secure settings by prefix (elastic#25064)
  add `exclude_keys` option to KeyValueProcessor (elastic#24876)
  Test: update missing body tests to run against versions >= 5.5.0
  Track EWMA[1] of task execution time in search threadpool executor
  Removes an invalid assert in resizing big arrays which does not always hold (resizing can result in a smaller size than the current size, while the assert attempted to verify the new size is always greater than the current).
  Fixed NPEs caused by requests without content. (elastic#23497)
  Plugins can register pre-configured char filters (elastic#25000)
  Build: Allow preserving shared dir (elastic#24962)
  Tests: Make secure settings available from settings builder for tests (elastic#25037)
  [TEST] Skip wildcard expansion test due to breaking change
  Test that gradle and Java version types match (elastic#24943)
  Include duplicate jar when jarhell check fails
  Change ScriptContexts to use needs instead of uses$. (elastic#25036)
  Change `has_child`, `has_parent` queries and `childen` aggregation to work with the new join field type and at the same time maintaining support for the `_parent` meta field type.
  Remove comma-separated feature parsing for GetIndicesAction
  ...
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.

4 participants