Skip to content

Commit

Permalink
Merge branch 'prestodb:master' into okie-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariamalmesfer authored and Mariam Almesfer committed Nov 4, 2024
2 parents e3b47f0 + e4c7e05 commit 4c3284e
Show file tree
Hide file tree
Showing 216 changed files with 5,615 additions and 3,163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ jobs:
- name: Maven Checks
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
./mvnw install -B -V -T 1C -DskipTests -Dmaven.javadoc.skip=true --no-transfer-progress -P ci -pl '!presto-test-coverage,!:presto-server,!:presto-docs'
./mvnw install -B -V -T 1C -DskipTests -Dmaven.javadoc.skip=true --no-transfer-progress -P ci -pl '!presto-test-coverage,!:presto-docs'
- name: Clean Maven Output
run: ./mvnw clean -pl '!:presto-server,!:presto-cli,!presto-test-coverage'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ cmake-build-*/
*.swp
*~
a.out
presto-native-execution/deps-download
presto-native-execution/deps-install

# Compiled Object files
*.slo
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ To commit code, you should:
1. User friendliness
1. Config options have names and descriptions that can be understood by someone configuring Presto
1. All new language features, new functions, and major features have documentation added
1. When adding a new method to [Plugin.java](https://github.com/prestodb/presto/blob/master/presto-spi/src/main/java/com/facebook/presto/spi/Plugin.java), include documentation for the new method in the [Presto Developer Guide](https://prestodb.io/docs/current/develop.html).
1. Release notes following the [Release Note Guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines) are added for user visible changes
* For large features, discuss your design with relevant code owners before you start implementing it.

Expand Down
54 changes: 52 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<dep.tempto.version>1.53</dep.tempto.version>
<dep.testng.version>7.5</dep.testng.version>
<dep.assertj-core.version>3.8.0</dep.assertj-core.version>
<dep.logback.version>1.2.13</dep.logback.version>
<dep.parquet.version>1.13.1</dep.parquet.version>
<dep.nexus-staging-plugin.version>1.6.8</dep.nexus-staging-plugin.version>
<dep.asm.version>9.2</dep.asm.version>
Expand Down Expand Up @@ -203,6 +204,12 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.107.Final</version>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-testing-docker</artifactId>
Expand Down Expand Up @@ -1226,7 +1233,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
<version>42.6.1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -2369,7 +2376,8 @@
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${dep.nexus-staging-plugin.version}</version>
<extensions>true</extensions>
<!-- This plugin is not registered as an extension because it will fail to activate
concurrently with the Maven Provisio plugin, as that has its own deployment lifecycle -->
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
Expand All @@ -2388,15 +2396,28 @@
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
</plugin>

<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
<configuration>
<ignoredClassPatterns combine.children="append">
<ignoredClassPattern>module-info</ignoredClassPattern>
<ignoredClassPattern>META-INF.versions.9.module-info</ignoredClassPattern>
<ignoredClassPattern>okhttp3.internal.tls.DistinguishedNameParser</ignoredClassPattern>
</ignoredClassPatterns>
</configuration>
</plugin>

</plugins>
</pluginManagement>

Expand All @@ -2406,6 +2427,13 @@
<artifactId>presto-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>ca.vanzyl.provisio.maven.plugins</groupId>
<artifactId>provisio-maven-plugin</artifactId>
<version>1.0.18</version>
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -2585,9 +2613,31 @@
<id>deploy-to-ossrh</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<!-- This plugin must be configured manually ("Maven 2" style in the docs) due to the usage of the
Maven Provisio plugin, which includes its own deployment lifecycle -->
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import static com.facebook.presto.plugin.bigquery.BigQueryErrorCode.BIGQUERY_FAILED_TO_EXECUTE_QUERY;
import static com.google.cloud.bigquery.storage.v1beta1.Storage.ReadSession;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;
import static java.util.stream.IntStream.range;
Expand Down Expand Up @@ -131,7 +130,7 @@ private List<BigQuerySplit> createEmptyProjection(TableId tableId, int actualPar
return splits;
}
catch (BigQueryException e) {
throw new PrestoException(BIGQUERY_FAILED_TO_EXECUTE_QUERY, format("Failed to compute empty projection"), e);
throw new PrestoException(BIGQUERY_FAILED_TO_EXECUTE_QUERY, "Failed to compute empty projection", e);
}
}
}
11 changes: 0 additions & 11 deletions presto-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,6 @@
</dependency>
</dependencies>

<dependencyManagement>
<!-- This is to fix the upper bound issues arising out of different components-->
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.107.Final</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ public class ClientOptions

@Option(name = "--truststore-type", title = "truststore type", description = "Truststore type")
public String trustStoreType = KeyStore.getDefaultType();

@Option(name = "--access-token", title = "access token", description = "Access token")
public String accessToken;

@Option(name = "--insecure", title = "trust all certificates", description = "Skip validation of HTTP server certificates (should only be used for debugging)")
public boolean insecure;

@Option(name = "--user", title = "user", description = "Username")
public String user = System.getProperty("user.name");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public boolean run()
Optional.ofNullable(clientOptions.truststorePassword),
Optional.ofNullable(clientOptions.trustStoreType),
Optional.ofNullable(clientOptions.accessToken),
clientOptions.insecure,
Optional.ofNullable(clientOptions.user),
clientOptions.password ? Optional.of(getPassword()) : Optional.empty(),
Optional.ofNullable(clientOptions.krb5Principal),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package com.facebook.presto.cli;

import com.facebook.presto.client.ClientSession;
import com.facebook.presto.client.OkHttpUtil;
import com.facebook.presto.client.StatementClient;
import com.google.common.net.HostAndPort;
import okhttp3.OkHttpClient;
Expand Down Expand Up @@ -63,6 +64,7 @@ public QueryRunner(
Optional<String> truststorePassword,
Optional<String> trustStoreType,
Optional<String> accessToken,
boolean insecureSsl,
Optional<String> user,
Optional<String> password,
Optional<String> kerberosPrincipal,
Expand All @@ -77,7 +79,12 @@ public QueryRunner(
this.debug = debug;
this.runtime = runtime;

this.sslSetup = builder -> setupSsl(builder, keystorePath, keystorePassword, keyStoreType, truststorePath, truststorePassword, trustStoreType);
if (insecureSsl) {
this.sslSetup = OkHttpUtil::setupInsecureSsl;
}
else {
this.sslSetup = builder -> setupSsl(builder, keystorePath, keystorePassword, keyStoreType, truststorePath, truststorePassword, trustStoreType);
}

OkHttpClient.Builder builder = new OkHttpClient.Builder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,19 @@ protected MockResponse createMockResponse()

protected void executeQueries(List<String> queries)
{
Console console = new Console();
QueryRunner queryRunner = createQueryRunner(createMockClientSession());
executeQueries(queryRunner, queries);
}

protected void executeQueries(QueryRunner queryRunner, List<String> queries)
{
Console console = new Console();
for (String query : queries) {
console.executeCommand(queryRunner, query, CSV, false);
}
}

protected static QueryRunner createQueryRunner(ClientSession clientSession)
protected static QueryRunner createQueryRunner(ClientSession clientSession, boolean insecureSsl)
{
return new QueryRunner(
clientSession,
Expand All @@ -136,6 +141,7 @@ protected static QueryRunner createQueryRunner(ClientSession clientSession)
Optional.empty(),
Optional.empty(),
Optional.empty(),
insecureSsl,
Optional.empty(),
Optional.empty(),
Optional.empty(),
Expand All @@ -147,6 +153,11 @@ protected static QueryRunner createQueryRunner(ClientSession clientSession)
true);
}

protected static QueryRunner createQueryRunner(ClientSession clientSession)
{
return createQueryRunner(clientSession, false);
}

protected static void assertHeaders(String headerName, Headers headers, Set<String> expectedSessionHeaderValues)
{
assertEquals(ImmutableSet.copyOf(headers.values(headerName)), expectedSessionHeaderValues);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.cli;

import com.google.common.collect.ImmutableList;
import okhttp3.mockwebserver.MockWebServer;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;

import static com.google.common.io.Resources.getResource;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.testng.Assert.assertEquals;

@Test(singleThreaded = true)
public class TestInsecureQueryRunner
extends AbstractCliTest
{
@Override
@BeforeMethod
public void setup()
throws IOException
{
server = new MockWebServer();
SSLContext sslContext = buildTestSslContext();
server.useHttps(sslContext.getSocketFactory(), false);
server.start();
}

@Override
@AfterMethod(alwaysRun = true)
public void teardown()
throws IOException
{
server.close();
}

@Test
public void testInsecureConnection()
{
server.enqueue(createMockResponse());
server.enqueue(createMockResponse());
executeQueries(createQueryRunner(createMockClientSession(), true),
ImmutableList.of("query with insecure mode;"));
try {
assertEquals(server.takeRequest(1, SECONDS).getPath(), "/v1/statement");
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}

private SSLContext buildTestSslContext()
throws IOException
{
try {
// Load self-signed certificate
char[] serverKeyStorePassword = "insecure-ssl-test".toCharArray();
KeyStore serverKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
try (InputStream in = getResource(getClass(), "/insecure-ssl-test.jks").openStream()) {
serverKeyStore.load(in, serverKeyStorePassword);
}
String kmfAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
KeyManagerFactory kmf = KeyManagerFactory.getInstance(kmfAlgorithm);
kmf.init(serverKeyStore, serverKeyStorePassword);
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(kmfAlgorithm);
trustManagerFactory.init(serverKeyStore);
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(kmf.getKeyManagers(), trustManagerFactory.getTrustManagers(), new SecureRandom());
return sslContext;
}
catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | UnrecoverableKeyException | KeyManagementException e) {
throw new IOException("failed to initialize SSL context", e);
}
}
}
Binary file not shown.
Loading

0 comments on commit 4c3284e

Please sign in to comment.