Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into esql_functions_never_…
Browse files Browse the repository at this point in the history
…return_text
  • Loading branch information
craigtaverner committed Oct 11, 2024
2 parents 589f5e2 + 64f6617 commit 568c069
Show file tree
Hide file tree
Showing 859 changed files with 30,024 additions and 6,975 deletions.
2 changes: 2 additions & 0 deletions .buildkite/pipelines/dra-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ steps:
- command: .buildkite/scripts/dra-workflow.sh
env:
USE_DRA_CREDENTIALS: "true"
USE_PROD_DOCKER_CREDENTIALS: "true"
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2204
Expand All @@ -18,4 +19,5 @@ steps:
branch: "${BUILDKITE_BRANCH}"
env:
DRA_WORKFLOW: staging
USE_PROD_DOCKER_CREDENTIALS: "true"
if: build.env('DRA_WORKFLOW') == 'staging'
3 changes: 2 additions & 1 deletion .buildkite/pipelines/periodic-packaging.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ steps:
image: family/elasticsearch-{{matrix.image}}
diskSizeGb: 350
machineType: n1-standard-8
env: {}
env:
USE_PROD_DOCKER_CREDENTIALS: "true"
- group: packaging-tests-upgrade
steps: $BWC_STEPS
- group: packaging-tests-windows
Expand Down
3 changes: 2 additions & 1 deletion .buildkite/pipelines/periodic-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ steps:
image: family/elasticsearch-{{matrix.image}}
diskSizeGb: 350
machineType: n1-standard-8
env: {}
env:
USE_PROD_DOCKER_CREDENTIALS: "true"
- group: packaging-tests-upgrade
steps:
- label: "{{matrix.image}} / 8.0.1 / packaging-tests-upgrade"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ steps:
diskSizeGb: 350
machineType: custom-16-32768
env:
USE_PROD_DOCKER_CREDENTIALS: "true"
PACKAGING_TASK: "{{matrix.PACKAGING_TASK}}"
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void apply(Project project) {
gitInfo.disallowChanges();
gitInfo.finalizeValueOnRead();

revision = gitInfo.map(info -> info.getRevision() == null ? info.getRevision() : "master");
revision = gitInfo.map(info -> info.getRevision() == null ? info.getRevision() : "main");
}

public Property<GitInfo> getGitInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public class LicensingPlugin implements Plugin<Project> {
static final String ELASTIC_LICENSE_URL_PREFIX = "https://raw.githubusercontent.com/elastic/elasticsearch/";
static final String ELASTIC_LICENSE_URL_POSTFIX = "/licenses/ELASTIC-LICENSE-2.0.txt";
static final String AGPL_ELASTIC_LICENSE_URL_POSTFIX = "/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt";

private ProviderFactory providerFactory;

Expand All @@ -36,15 +37,18 @@ public void apply(Project project) {
isSnapshotVersion(project) ? revision.get() : "v" + project.getVersion()
);

Provider<String> projectLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX +
Provider<String> elasticLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX +
licenseCommit + ELASTIC_LICENSE_URL_POSTFIX);
Provider<String> agplLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX +
licenseCommit + AGPL_ELASTIC_LICENSE_URL_POSTFIX);
// But stick the Elastic license url in project.ext so we can get it if we need to switch to it
project.getExtensions().getExtraProperties().set("elasticLicenseUrl", projectLicenseURL);
project.getExtensions().getExtraProperties().set("elasticLicenseUrl", elasticLicenseURL);

MapProperty<String, String> licensesProperty = project.getObjects().mapProperty(String.class, String.class).convention(
providerFactory.provider(() -> Map.of(
"Server Side Public License, v 1", "https://www.mongodb.com/licensing/server-side-public-license",
"Elastic License 2.0", projectLicenseURL.get())
"Elastic License 2.0", elasticLicenseURL.get(),
"GNU Affero General Public License Version 3", agplLicenseURL.get())
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>GNU Affero General Public License Version 3</name>
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>Server Side Public License, v 1</name>
<url>https://www.mongodb.com/licensing/server-side-public-license</url>
Expand Down Expand Up @@ -144,6 +149,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>GNU Affero General Public License Version 3</name>
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>Server Side Public License, v 1</name>
<url>https://www.mongodb.com/licensing/server-side-public-license</url>
Expand Down Expand Up @@ -228,6 +238,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>GNU Affero General Public License Version 3</name>
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>Server Side Public License, v 1</name>
<url>https://www.mongodb.com/licensing/server-side-public-license</url>
Expand Down Expand Up @@ -321,6 +336,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>GNU Affero General Public License Version 3</name>
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>Server Side Public License, v 1</name>
<url>https://www.mongodb.com/licensing/server-side-public-license</url>
Expand Down Expand Up @@ -394,6 +414,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v2.0/licenses/ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>GNU Affero General Public License Version 3</name>
<url>https://raw.githubusercontent.com/elastic/elasticsearch/v2.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>Server Side Public License, v 1</name>
<url>https://www.mongodb.com/licensing/server-side-public-license</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ public void execute(BuildFinishedFlowAction.Parameters parameters) throws FileNo
// So, if you change this such that the artifact will have a slash/directory in it, you'll need to update the logic
// below as well
pb.directory(uploadFileDir);
pb.start().waitFor();
try {
// we are very generious here, as the upload can take
// a long time depending on its size
pb.start().waitFor(30, java.util.concurrent.TimeUnit.MINUTES);
} catch (InterruptedException e) {
System.out.println("Failed to upload buildkite artifact " + e.getMessage());
}

System.out.println("Generating buildscan link for artifact...");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ public void execute(Task t) {
});

if (OS.current().equals(OS.WINDOWS) && System.getProperty("tests.timeoutSuite") == null) {
// override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man
test.systemProperty("tests.timeoutSuite", "2400000!");
// override the suite timeout to 60 mins for windows, because it has the most inefficient filesystem known to man
test.systemProperty("tests.timeoutSuite", "3600000!");
}

/*
Expand Down
2 changes: 1 addition & 1 deletion distribution/docker/src/docker/Dockerfile.ess
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ USER root

COPY plugins/*.zip /opt/plugins/archive/

RUN chown root.root /opt/plugins/archive/*
RUN chown 1000:1000 /opt/plugins/archive/*
RUN chmod 0444 /opt/plugins/archive/*

FROM ${base_image}
Expand Down
2 changes: 1 addition & 1 deletion distribution/tools/entitlement-agent/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Entitlement Agent

This is a java agent that instruments sensitive class library methods with calls into the `entitlement-runtime` module to check for permissions granted under the _entitlements_ system.
This is a java agent that instruments sensitive class library methods with calls into the `entitlement-bridge` module to check for permissions granted under the _entitlements_ system.

The entitlements system provides an alternative to the legacy `SecurityManager` system, which is deprecated for removal.
With this agent, the Elasticsearch server can retain some control over which class library methods can be invoked by which callers.
Expand Down
31 changes: 27 additions & 4 deletions distribution/tools/entitlement-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,44 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import static java.util.stream.Collectors.joining

apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.embedded-providers'

embeddedProviders {
impl 'entitlement-agent', project(':distribution:tools:entitlement-agent:impl')
}

configurations {
entitlementRuntime
entitlementBridge
}

dependencies {
entitlementRuntime project(":libs:elasticsearch-entitlement-runtime")
implementation project(":libs:elasticsearch-entitlement-runtime")
entitlementBridge project(":distribution:tools:entitlement-bridge")
compileOnly project(":libs:elasticsearch-core")
compileOnly project(":distribution:tools:entitlement-runtime")
testImplementation project(":test:framework")
testImplementation project(":distribution:tools:entitlement-bridge")
testImplementation project(":distribution:tools:entitlement-agent:impl")
}

tasks.named('test').configure {
systemProperty "tests.security.manager", "false"
dependsOn('jar')
jvmArgs "-javaagent:${ tasks.named('jar').flatMap{ it.archiveFile }.get()}"

// Register an argument provider to avoid eager resolution of configurations
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
@Override
Iterable<String> asArguments() {
return ["-javaagent:${tasks.jar.archiveFile.get()}", "-Des.entitlements.bridgeJar=${configurations.entitlementBridge.singleFile}"]
}
})


// The Elasticsearch build plugin automatically adds all compileOnly deps as testImplementation.
// We must not add the bridge this way because it is also on the boot classpath, and that would lead to jar hell.
classpath -= files(configurations.entitlementBridge)
}

tasks.named('jar').configure {
Expand Down
20 changes: 20 additions & 0 deletions distribution/tools/entitlement-agent/impl/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

apply plugin: 'elasticsearch.build'

dependencies {
compileOnly project(':distribution:tools:entitlement-agent')
implementation 'org.ow2.asm:asm:9.7'
}

tasks.named('forbiddenApisMain').configure {
replaceSignatureFiles 'jdk-signatures'
}

26 changes: 26 additions & 0 deletions distribution/tools/entitlement-agent/impl/licenses/asm-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2012 France Télécom
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import org.elasticsearch.entitlement.instrumentation.InstrumentationService;
import org.elasticsearch.entitlement.instrumentation.impl.InstrumentationServiceImpl;

module org.elasticsearch.entitlement.agent.impl {
requires org.objectweb.asm;
requires org.elasticsearch.entitlement.agent;

provides InstrumentationService with InstrumentationServiceImpl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.entitlement.instrumentation.impl;

import org.elasticsearch.entitlement.instrumentation.InstrumentationService;
import org.elasticsearch.entitlement.instrumentation.Instrumenter;
import org.elasticsearch.entitlement.instrumentation.MethodKey;
import org.objectweb.asm.Type;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Map;
import java.util.stream.Stream;

public class InstrumentationServiceImpl implements InstrumentationService {
@Override
public Instrumenter newInstrumenter(String classNameSuffix, Map<MethodKey, Method> instrumentationMethods) {
return new InstrumenterImpl(classNameSuffix, instrumentationMethods);
}

/**
* @return a {@link MethodKey} suitable for looking up the given {@code targetMethod} in the entitlements trampoline
*/
public MethodKey methodKeyForTarget(Method targetMethod) {
Type actualType = Type.getMethodType(Type.getMethodDescriptor(targetMethod));
return new MethodKey(
Type.getInternalName(targetMethod.getDeclaringClass()),
targetMethod.getName(),
Stream.of(actualType.getArgumentTypes()).map(Type::getInternalName).toList(),
Modifier.isStatic(targetMethod.getModifiers())
);
}

}
Loading

0 comments on commit 568c069

Please sign in to comment.