Skip to content

Commit 74672ab

Browse files
Merge 417f308 into openjdk23-bundle
2 parents 2eec62e + 417f308 commit 74672ab

File tree

140 files changed

+2323
-1977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2323
-1977
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionModuleCheckTaskProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public class InternalDistributionModuleCheckTaskProvider {
5959
"org.elasticsearch.nativeaccess",
6060
"org.elasticsearch.plugin",
6161
"org.elasticsearch.plugin.analysis",
62-
"org.elasticsearch.pluginclassloader",
6362
"org.elasticsearch.securesm",
6463
"org.elasticsearch.server",
6564
"org.elasticsearch.simdvec",

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/MrjarPlugin.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import org.gradle.api.tasks.SourceSetContainer;
2323
import org.gradle.api.tasks.compile.CompileOptions;
2424
import org.gradle.api.tasks.compile.JavaCompile;
25+
import org.gradle.api.tasks.javadoc.Javadoc;
2526
import org.gradle.api.tasks.testing.Test;
27+
import org.gradle.external.javadoc.CoreJavadocOptions;
2628
import org.gradle.jvm.tasks.Jar;
2729
import org.gradle.jvm.toolchain.JavaLanguageVersion;
2830
import org.gradle.jvm.toolchain.JavaToolchainService;
@@ -73,8 +75,10 @@ public void apply(Project project) {
7375
List<Integer> mainVersions = findSourceVersions(project);
7476
List<String> mainSourceSets = new ArrayList<>();
7577
mainSourceSets.add(SourceSet.MAIN_SOURCE_SET_NAME);
78+
configurePreviewFeatures(project, javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME), 21);
7679
List<String> testSourceSets = new ArrayList<>(mainSourceSets);
7780
testSourceSets.add(SourceSet.TEST_SOURCE_SET_NAME);
81+
configurePreviewFeatures(project, javaExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME), 21);
7882
for (int javaVersion : mainVersions) {
7983
String mainSourceSetName = SourceSet.MAIN_SOURCE_SET_NAME + javaVersion;
8084
SourceSet mainSourceSet = addSourceSet(project, javaExtension, mainSourceSetName, mainSourceSets, javaVersion);
@@ -124,11 +128,8 @@ private SourceSet addSourceSet(
124128
compileTask.setSourceCompatibility(Integer.toString(javaVersion));
125129
CompileOptions compileOptions = compileTask.getOptions();
126130
compileOptions.getRelease().set(javaVersion);
127-
compileOptions.getCompilerArgs().add("--enable-preview");
128-
compileOptions.getCompilerArgs().add("-Xlint:-preview");
129-
130-
compileTask.doLast(t -> { stripPreviewFromFiles(compileTask.getDestinationDirectory().getAsFile().get().toPath()); });
131131
});
132+
configurePreviewFeatures(project, sourceSet, javaVersion);
132133

133134
// Since we configure MRJAR sourcesets to allow preview apis, class signatures for those
134135
// apis are not known by forbidden apis, so we must ignore all missing classes. We could, in theory,
@@ -142,6 +143,21 @@ private SourceSet addSourceSet(
142143
return sourceSet;
143144
}
144145

146+
private void configurePreviewFeatures(Project project, SourceSet sourceSet, int javaVersion) {
147+
project.getTasks().withType(JavaCompile.class).named(sourceSet.getCompileJavaTaskName()).configure(compileTask -> {
148+
CompileOptions compileOptions = compileTask.getOptions();
149+
compileOptions.getCompilerArgs().add("--enable-preview");
150+
compileOptions.getCompilerArgs().add("-Xlint:-preview");
151+
152+
compileTask.doLast(t -> { stripPreviewFromFiles(compileTask.getDestinationDirectory().getAsFile().get().toPath()); });
153+
});
154+
project.getTasks().withType(Javadoc.class).named(name -> name.equals(sourceSet.getJavadocTaskName())).configureEach(javadocTask -> {
155+
CoreJavadocOptions options = (CoreJavadocOptions) javadocTask.getOptions();
156+
options.addBooleanOption("-enable-preview", true);
157+
options.addStringOption("-release", String.valueOf(javaVersion));
158+
});
159+
}
160+
145161
private void configureSourceSetInJar(Project project, SourceSet sourceSet, int javaVersion) {
146162
var jarTask = project.getTasks().withType(Jar.class).named(JavaPlugin.JAR_TASK_NAME);
147163
jarTask.configure(task -> task.into("META-INF/versions/" + javaVersion, copySpec -> copySpec.from(sourceSet.getOutput())));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Entitlement Agent
2+
3+
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.
4+
5+
The entitlements system provides an alternative to the legacy `SecurityManager` system, which is deprecated for removal.
6+
With this agent, the Elasticsearch server can retain some control over which class library methods can be invoked by which callers.
7+
8+
This module is responsible for inserting the appropriate bytecode to achieve enforcement of the rules governed by the `entitlement-runtime` module.
9+
10+
It is not responsible for permission granting or checking logic. That responsibility lies with `entitlement-runtime`.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
apply plugin: 'elasticsearch.build'
11+
12+
configurations {
13+
entitlementRuntime
14+
}
15+
16+
dependencies {
17+
entitlementRuntime project(":libs:elasticsearch-entitlement-runtime")
18+
implementation project(":libs:elasticsearch-entitlement-runtime")
19+
testImplementation project(":test:framework")
20+
}
21+
22+
tasks.named('test').configure {
23+
dependsOn('jar')
24+
jvmArgs "-javaagent:${ tasks.named('jar').flatMap{ it.archiveFile }.get()}"
25+
}
26+
27+
tasks.named('jar').configure {
28+
manifest {
29+
attributes(
30+
'Premain-Class': 'org.elasticsearch.entitlement.agent.EntitlementAgent'
31+
, 'Can-Retransform-Classes': 'true'
32+
)
33+
}
34+
}
35+
36+
tasks.named('forbiddenApisMain').configure {
37+
replaceSignatureFiles 'jdk-signatures'
38+
}
39+

libs/plugin-classloader/src/main/java/module-info.java renamed to distribution/tools/entitlement-agent/src/main/java/module-info.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
module org.elasticsearch.pluginclassloader {
11-
exports org.elasticsearch.plugins.loader;
10+
module org.elasticsearch.entitlement.agent {
11+
requires java.instrument;
12+
requires org.elasticsearch.entitlement.runtime;
1213
}

libs/plugin-classloader/build.gradle renamed to distribution/tools/entitlement-agent/src/main/java/org/elasticsearch/entitlement/agent/EntitlementAgent.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
// This is only required because :server needs this at runtime.
11-
// We'll be removing this in 8.0 so for now just publish the JAR to make dependency resolution work.
12-
apply plugin: 'elasticsearch.publish'
10+
package org.elasticsearch.entitlement.agent;
1311

14-
tasks.named("test").configure { enabled = false }
12+
import org.elasticsearch.entitlement.runtime.api.EntitlementChecks;
1513

16-
// test depend on ES core...
17-
tasks.named('forbiddenApisMain').configure { enabled = false}
18-
tasks.named("jarHell").configure { enabled = false }
14+
import java.lang.instrument.Instrumentation;
15+
16+
public class EntitlementAgent {
17+
18+
public static void premain(String agentArgs, Instrumentation inst) throws Exception {
19+
EntitlementChecks.setAgentBooted();
20+
}
21+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.entitlement.agent;
11+
12+
import org.elasticsearch.entitlement.runtime.api.EntitlementChecks;
13+
import org.elasticsearch.test.ESTestCase;
14+
import org.elasticsearch.test.ESTestCase.WithoutSecurityManager;
15+
16+
/**
17+
* This is an end-to-end test that runs with the javaagent installed.
18+
* It should exhaustively test every instrumented method to make sure it passes with the entitlement
19+
* and fails without it.
20+
* See {@code build.gradle} for how we set the command line arguments for this test.
21+
*/
22+
@WithoutSecurityManager
23+
public class EntitlementAgentTests extends ESTestCase {
24+
25+
public void testAgentBooted() {
26+
assertTrue(EntitlementChecks.isAgentBooted());
27+
}
28+
29+
}

docs/changelog/113102.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 113102
2+
summary: Trigger merges after recovery
3+
area: Recovery
4+
type: enhancement
5+
issues: []

docs/changelog/113103.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 113103
2+
summary: "ESQL: Align year diffing to the rest of the units in DATE_DIFF: chronological"
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 112482

docs/changelog/113123.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 113123
2+
summary: "ES|QL: Skip CASE function from `InferIsNotNull` rule checks"
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 112704

0 commit comments

Comments
 (0)