Skip to content

Commit cac4a47

Browse files
committed
Merge branch 'master' into feature/watcher-java-time-migration
2 parents 9258b30 + 0154052 commit cac4a47

File tree

19 files changed

+412
-38
lines changed

19 files changed

+412
-38
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ task verifyVersions {
159159
* the enabled state of every bwc task. It should be set back to true
160160
* after the backport of the backcompat code is complete.
161161
*/
162-
final boolean bwc_tests_enabled = true
163-
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
162+
final boolean bwc_tests_enabled = false
163+
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/37899" /* place a PR link here when committing bwc changes */
164164
if (bwc_tests_enabled == false) {
165165
if (bwc_tests_disabled_issue.isEmpty()) {
166166
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class BuildPlugin implements Plugin<Project> {
150150
}
151151

152152
String inFipsJvmScript = 'print(java.security.Security.getProviders()[0].name.toLowerCase().contains("fips"));'
153-
boolean inFipsJvm = Boolean.parseBoolean(runJavascript(project, runtimeJavaHome, inFipsJvmScript))
153+
boolean inFipsJvm = Boolean.parseBoolean(runJavaAsScript(project, runtimeJavaHome, inFipsJvmScript))
154154

155155
// Build debugging info
156156
println '======================================='
@@ -438,28 +438,28 @@ class BuildPlugin implements Plugin<Project> {
438438
String versionInfoScript = 'print(' +
439439
'java.lang.System.getProperty("java.vendor") + " " + java.lang.System.getProperty("java.version") + ' +
440440
'" [" + java.lang.System.getProperty("java.vm.name") + " " + java.lang.System.getProperty("java.vm.version") + "]");'
441-
return runJavascript(project, javaHome, versionInfoScript).trim()
441+
return runJavaAsScript(project, javaHome, versionInfoScript).trim()
442442
}
443443

444444
/** Finds the parsable java specification version */
445445
private static String findJavaSpecificationVersion(Project project, String javaHome) {
446446
String versionScript = 'print(java.lang.System.getProperty("java.specification.version"));'
447-
return runJavascript(project, javaHome, versionScript)
447+
return runJavaAsScript(project, javaHome, versionScript)
448448
}
449449

450450
private static String findJavaVendor(Project project, String javaHome) {
451451
String vendorScript = 'print(java.lang.System.getProperty("java.vendor"));'
452-
return runJavascript(project, javaHome, vendorScript)
452+
return runJavaAsScript(project, javaHome, vendorScript)
453453
}
454454

455455
/** Finds the parsable java specification version */
456456
private static String findJavaVersion(Project project, String javaHome) {
457457
String versionScript = 'print(java.lang.System.getProperty("java.version"));'
458-
return runJavascript(project, javaHome, versionScript)
458+
return runJavaAsScript(project, javaHome, versionScript)
459459
}
460460

461461
/** Runs the given javascript using jjs from the jdk, and returns the output */
462-
private static String runJavascript(Project project, String javaHome, String script) {
462+
private static String runJavaAsScript(Project project, String javaHome, String script) {
463463
ByteArrayOutputStream stdout = new ByteArrayOutputStream()
464464
ByteArrayOutputStream stderr = new ByteArrayOutputStream()
465465
if (Os.isFamily(Os.FAMILY_WINDOWS)) {

dev-tools/es_release_notes.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
">enhancement", ">bug", ">regression", ">upgrade"
3333
);
3434
my %Ignore = map { $_ => 1 }
35-
( ">non-issue", ">refactoring", ">docs", ">test", ">test-failure", ":Core/Build", "backport" );
35+
( ">non-issue", ">refactoring", ">docs", ">test", ">test-failure", ":Core/Infra/Build", "backport" );
3636

3737
my %Group_Labels = (
3838
'>breaking' => 'Breaking changes',
@@ -48,7 +48,7 @@
4848

4949
my %Area_Overrides = (
5050
':ml' => 'Machine Learning',
51-
':beats' => 'Beats Plugin',
51+
':Beats' => 'Beats Plugin',
5252
':Docs' => 'Docs Infrastructure'
5353
);
5454

docs/java-rest/high-level/getting-started.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ dependencies {
8383
The very first releases of any major version (like a beta), might have been built on top of a Lucene Snapshot version.
8484
In such a case you will be unable to resolve the Lucene dependencies of the client.
8585

86-
For example, if you want to use the `7.0.0-alpha1` version which depends on Lucene `8.0.0-snapshot-6d9c714052`, you must
86+
For example, if you want to use the `7.0.0-alpha2` version which depends on Lucene `8.0.0-snapshot-774e9aefbc`, you must
8787
define the following repository.
8888

8989
For Maven:
@@ -93,7 +93,7 @@ For Maven:
9393
<repository>
9494
<id>elastic-lucene-snapshots</id>
9595
<name>Elastic Lucene Snapshots</name>
96-
<url>http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/6d9c714052</url>
96+
<url>http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/774e9aefbc</url>
9797
<releases><enabled>true</enabled></releases>
9898
<snapshots><enabled>false</enabled></snapshots>
9999
</repository>
@@ -104,7 +104,7 @@ For Gradle:
104104
["source","groovy",subs="attributes"]
105105
--------------------------------------------------
106106
maven {
107-
url 'http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/6d9c714052'
107+
url 'http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/774e9aefbc'
108108
}
109109
--------------------------------------------------
110110

docs/reference/mapping/removal_of_types.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,5 +606,5 @@ PUT index-2-01
606606

607607
In case of implicit index creation, because of documents that get indexed in
608608
an index that doesn't exist yet, the template is always honored. This is
609-
usually not a problem due to the fact that typless index calls work on typed
609+
usually not a problem due to the fact that typeless index calls work on typed
610610
indices.

docs/reference/sql/endpoints/jdbc.asciidoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ Query timeout (in seconds). That is the maximum amount of time waiting for a que
115115

116116
`ssl.truststore.pass`:: trust store password
117117

118-
`ssl.cert.allow.self.signed` (default `false`):: Whether or not to allow self signed certificates
119-
120118
`ssl.protocol`(default `TLS`):: SSL protocol to be used
121119

122120
[float]

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,8 @@ protected static void configureClient(RestClientBuilder builder, Settings settin
708708
throw new IllegalStateException(TRUSTSTORE_PATH + " is set but points to a non-existing file");
709709
}
710710
try {
711-
KeyStore keyStore = KeyStore.getInstance("jks");
711+
final String keyStoreType = keystorePath.endsWith(".p12") ? "PKCS12" : "jks";
712+
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
712713
try (InputStream is = Files.newInputStream(path)) {
713714
keyStore.load(is, keystorePass.toCharArray());
714715
}

x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/JdbcConfigurationTests.java

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
package org.elasticsearch.xpack.sql.jdbc;
77

88
import org.elasticsearch.test.ESTestCase;
9+
import org.elasticsearch.xpack.sql.client.SslConfig;
910

11+
import java.net.URI;
12+
import java.net.URISyntaxException;
13+
import java.sql.DriverManager;
1014
import java.sql.SQLException;
15+
import java.util.HashMap;
16+
import java.util.Map;
1117
import java.util.Properties;
18+
import java.util.stream.Collectors;
1219

1320
import static org.elasticsearch.xpack.sql.client.ConnectionConfiguration.CONNECT_TIMEOUT;
1421
import static org.elasticsearch.xpack.sql.client.ConnectionConfiguration.PAGE_TIMEOUT;
@@ -130,5 +137,153 @@ public void testTimoutOverride() throws Exception {
130137
assertThat(ci.pageTimeout(), equalTo(4L));
131138
}
132139

133-
140+
public void testSSLPropertiesInUrl() throws Exception {
141+
Map<String, String> urlPropMap = sslProperties();
142+
143+
Properties allProps = new Properties();
144+
allProps.putAll(urlPropMap);
145+
String sslUrlProps = urlPropMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
146+
147+
assertSslConfig(allProps, ci("jdbc:es://test?" + sslUrlProps.toString()).sslConfig());
148+
}
149+
150+
public void testSSLPropertiesInUrlAndProperties() throws Exception {
151+
Map<String, String> urlPropMap = new HashMap<>(4);
152+
urlPropMap.put("ssl", "false");
153+
urlPropMap.put("ssl.protocol", "SSLv3");
154+
urlPropMap.put("ssl.keystore.location", "/abc/xyz");
155+
urlPropMap.put("ssl.keystore.pass", "mypass");
156+
157+
Map<String, String> propMap = new HashMap<>(4);
158+
propMap.put("ssl.keystore.type", "PKCS12");
159+
propMap.put("ssl.truststore.location", "/foo/bar");
160+
propMap.put("ssl.truststore.pass", "anotherpass");
161+
propMap.put("ssl.truststore.type", "jks");
162+
163+
Properties props = new Properties();
164+
props.putAll(propMap);
165+
String sslUrlProps = urlPropMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
166+
167+
Properties allProps = new Properties();
168+
allProps.putAll(urlPropMap);
169+
allProps.putAll(propMap);
170+
assertSslConfig(allProps, JdbcConfiguration.create("jdbc:es://test?" + sslUrlProps.toString(), props, 0).sslConfig());
171+
}
172+
173+
public void testSSLPropertiesOverride() throws Exception {
174+
Map<String, String> urlPropMap = sslProperties();
175+
Map<String, String> propMap = new HashMap<>(8);
176+
propMap.put("ssl", "false");
177+
propMap.put("ssl.protocol", "TLS");
178+
propMap.put("ssl.keystore.location", "/xyz");
179+
propMap.put("ssl.keystore.pass", "different_mypass");
180+
propMap.put("ssl.keystore.type", "JKS");
181+
propMap.put("ssl.truststore.location", "/baz");
182+
propMap.put("ssl.truststore.pass", "different_anotherpass");
183+
propMap.put("ssl.truststore.type", "PKCS11");
184+
185+
Properties props = new Properties();
186+
props.putAll(propMap);
187+
String sslUrlProps = urlPropMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
188+
assertSslConfig(props, JdbcConfiguration.create("jdbc:es://test?" + sslUrlProps.toString(), props, 0).sslConfig());
189+
}
190+
191+
public void testDriverConfigurationWithSSLInURL() {
192+
Map<String, String> urlPropMap = sslProperties();
193+
194+
Properties allProps = new Properties();
195+
allProps.putAll(urlPropMap);
196+
String sslUrlProps = urlPropMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
197+
198+
try {
199+
DriverManager.getDriver("jdbc:es://test?" + sslUrlProps);
200+
} catch (SQLException sqle) {
201+
fail("Driver registration should have been successful. Error: " + sqle);
202+
}
203+
}
204+
205+
public void testDataSourceConfigurationWithSSLInURL() throws SQLException, URISyntaxException {
206+
Map<String, String> urlPropMap = sslProperties();
207+
208+
Properties allProps = new Properties();
209+
allProps.putAll(urlPropMap);
210+
String sslUrlProps = urlPropMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
211+
212+
EsDataSource dataSource = new EsDataSource();
213+
String address = "jdbc:es://test?" + sslUrlProps;
214+
dataSource.setUrl(address);
215+
JdbcConnection connection = null;
216+
217+
try {
218+
connection = (JdbcConnection) dataSource.getConnection();
219+
} catch (SQLException sqle) {
220+
fail("Connection creation should have been successful. Error: " + sqle);
221+
}
222+
223+
assertEquals(address, connection.getURL());
224+
assertSslConfig(allProps, connection.cfg.sslConfig());
225+
}
226+
227+
public void testTyposInSslConfigInUrl(){
228+
assertJdbcSqlExceptionFromUrl("ssl.protocl", "ssl.protocol");
229+
assertJdbcSqlExceptionFromUrl("sssl", "ssl");
230+
assertJdbcSqlExceptionFromUrl("ssl.keystore.lction", "ssl.keystore.location");
231+
assertJdbcSqlExceptionFromUrl("ssl.keystore.pss", "ssl.keystore.pass");
232+
assertJdbcSqlExceptionFromUrl("ssl.keystore.typ", "ssl.keystore.type");
233+
assertJdbcSqlExceptionFromUrl("ssl.trustsore.location", "ssl.truststore.location");
234+
assertJdbcSqlExceptionFromUrl("ssl.tuststore.pass", "ssl.truststore.pass");
235+
assertJdbcSqlExceptionFromUrl("ssl.ruststore.type", "ssl.truststore.type");
236+
}
237+
238+
public void testTyposInSslConfigInProperties() {
239+
assertJdbcSqlExceptionFromProperties("ssl.protocl", "ssl.protocol");
240+
assertJdbcSqlExceptionFromProperties("sssl", "ssl");
241+
assertJdbcSqlExceptionFromProperties("ssl.keystore.lction", "ssl.keystore.location");
242+
assertJdbcSqlExceptionFromProperties("ssl.keystore.pss", "ssl.keystore.pass");
243+
assertJdbcSqlExceptionFromProperties("ssl.keystore.typ", "ssl.keystore.type");
244+
assertJdbcSqlExceptionFromProperties("ssl.trustsore.location", "ssl.truststore.location");
245+
assertJdbcSqlExceptionFromProperties("ssl.tuststore.pass", "ssl.truststore.pass");
246+
assertJdbcSqlExceptionFromProperties("ssl.ruststore.type", "ssl.truststore.type");
247+
}
248+
249+
private Map<String, String> sslProperties() {
250+
Map<String, String> sslPropertiesMap = new HashMap<>(8);
251+
// always using "false" so that the SSLContext doesn't actually start verifying the keystore and trustore
252+
// locations, as we don't have file permissions to access them.
253+
sslPropertiesMap.put("ssl", "false");
254+
sslPropertiesMap.put("ssl.protocol", "SSLv3");
255+
sslPropertiesMap.put("ssl.keystore.location", "/abc/xyz");
256+
sslPropertiesMap.put("ssl.keystore.pass", "mypass");
257+
sslPropertiesMap.put("ssl.keystore.type", "PKCS12");
258+
sslPropertiesMap.put("ssl.truststore.location", "/foo/bar");
259+
sslPropertiesMap.put("ssl.truststore.pass", "anotherpass");
260+
sslPropertiesMap.put("ssl.truststore.type", "jks");
261+
262+
return sslPropertiesMap;
263+
}
264+
265+
private void assertSslConfig(Properties allProperties, SslConfig sslConfig) throws URISyntaxException {
266+
// because SslConfig doesn't expose its internal properties (and it shouldn't),
267+
// we compare a newly created SslConfig with the one from the JdbcConfiguration with the equals() method
268+
SslConfig mockSslConfig = new SslConfig(allProperties, new URI("http://test:9200/"));
269+
assertEquals(mockSslConfig, sslConfig);
270+
}
271+
272+
private void assertJdbcSqlExceptionFromUrl(String wrongSetting, String correctSetting) {
273+
String url = "jdbc:es://test?" + wrongSetting + "=foo";
274+
assertJdbcSqlException(wrongSetting, correctSetting, url, null);
275+
}
276+
277+
private void assertJdbcSqlExceptionFromProperties(String wrongSetting, String correctSetting) {
278+
String url = "jdbc:es://test";
279+
Properties props = new Properties();
280+
props.put(wrongSetting, correctSetting);
281+
assertJdbcSqlException(wrongSetting, correctSetting, url, props);
282+
}
283+
284+
private void assertJdbcSqlException(String wrongSetting, String correctSetting, String url, Properties props) {
285+
JdbcSQLException ex = expectThrows(JdbcSQLException.class,
286+
() -> JdbcConfiguration.create(url, props, 0));
287+
assertEquals("Unknown parameter [" + wrongSetting + "] ; did you mean [" + correctSetting + "]", ex.getMessage());
288+
}
134289
}

x-pack/plugin/sql/qa/security/with-ssl/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ integTestCluster {
208208
}
209209
}
210210
Closure notRunningFips = {
211-
Boolean.parseBoolean(BuildPlugin.runJavascript(project, project.runtimeJavaHome,
211+
Boolean.parseBoolean(BuildPlugin.runJavaAsScript(project, project.runtimeJavaHome,
212212
'print(java.security.Security.getProviders()[0].name.toLowerCase().contains("fips"));')) == false
213213
}
214214

x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/SslConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class SslConfig {
6363

6464
private final SSLContext sslContext;
6565

66-
SslConfig(Properties settings, URI baseURI) {
66+
public SslConfig(Properties settings, URI baseURI) {
6767
boolean isSchemaPresent = baseURI.getScheme() != null;
6868
boolean isSSLPropertyPresent = settings.getProperty(SSL) != null;
6969
boolean isHttpsScheme = "https".equals(baseURI.getScheme());

0 commit comments

Comments
 (0)