Skip to content

Commit 6f49e98

Browse files
authored
Merge branch 'main' into feature/multi-project/health-dlm
2 parents 578d78c + 0d64aab commit 6f49e98

File tree

18 files changed

+440
-285
lines changed

18 files changed

+440
-285
lines changed

build-tools-internal/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ protobuf = 3.25.5
3838
# test dependencies
3939
randomizedrunner = 2.8.2
4040
junit = 4.13.2
41-
junit5 = 5.7.1
42-
hamcrest = 2.1
41+
junit5 = 5.12.1
42+
hamcrest = 3.0
4343
mocksocket = 1.2
4444

4545
# test container dependencies

docs/reference/search-connectors/es-postgresql-connector-client-tutorial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
navigation_title: "Tutorial"
33
mapped_pages:
44
- https://www.elastic.co/guide/en/elasticsearch/reference/current/es-postgresql-connector-client-tutorial.html
5+
- https://www.elastic.co/guide/en/starting-with-the-elasticsearch-platform-and-its-solutions/current/getting-started-appsearch.html
56
---
67

78
# PostgreSQL self-managed connector tutorial [es-postgresql-connector-client-tutorial]

gradle/build.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
asm = "9.7.1"
33
jackson = "2.15.0"
4-
junit5 = "5.8.1"
4+
junit5 = "5.12.1"
55
spock = "2.1-groovy-3.0"
66

77
[libraries]
@@ -17,7 +17,7 @@ commmons-io = "commons-io:commons-io:2.2"
1717
docker-compose = "com.avast.gradle:gradle-docker-compose-plugin:0.17.5"
1818
forbiddenApis = "de.thetaphi:forbiddenapis:3.8"
1919
gradle-enterprise = "com.gradle:develocity-gradle-plugin:3.19.2"
20-
hamcrest = "org.hamcrest:hamcrest:2.1"
20+
hamcrest = "org.hamcrest:hamcrest:3.0"
2121
httpcore5 = "org.apache.httpcomponents.core5:httpcore5:5.3.3"
2222
httpclient5 = "org.apache.httpcomponents.client5:httpclient5:5.4.2"
2323
idea-ext = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.4"

gradle/verification-metadata.xml

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,16 +1634,6 @@
16341634
<sha256 value="d65b4f127d36cf52b9b7b439552db22f3de92b892014512870cb3c98a3cf505e" origin="Generated by Gradle"/>
16351635
</artifact>
16361636
</component>
1637-
<component group="junit" name="junit" version="3.8.1">
1638-
<artifact name="junit-3.8.1.jar">
1639-
<sha256 value="b58e459509e190bed737f3592bc1950485322846cf10e78ded1d065153012d70" origin="Generated by Gradle"/>
1640-
</artifact>
1641-
</component>
1642-
<component group="junit" name="junit" version="4.12">
1643-
<artifact name="junit-4.12.jar">
1644-
<sha256 value="59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a" origin="Generated by Gradle"/>
1645-
</artifact>
1646-
</component>
16471637
<component group="junit" name="junit" version="4.13.2">
16481638
<artifact name="junit-4.13.2.jar">
16491639
<sha256 value="8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3" origin="Generated by Gradle"/>
@@ -3317,6 +3307,11 @@
33173307
<sha256 value="d749db58c2bd353f1c03541d747b753931d4b84da8e48993ef51efe8694b4ed7" origin="Generated by Gradle"/>
33183308
</artifact>
33193309
</component>
3310+
<component group="org.assertj" name="assertj-core" version="3.27.3">
3311+
<artifact name="assertj-core-3.27.3.jar">
3312+
<sha256 value="5b8a26205f6d5ea60ad9ce65ce4a40a2afe4c48abeec61bd0740a088c24e89f5" origin="Generated by Gradle"/>
3313+
</artifact>
3314+
</component>
33203315
<component group="org.bouncycastle" name="bc-fips" version="1.0.2.5">
33213316
<artifact name="bc-fips-1.0.2.5.jar">
33223317
<sha256 value="50e4c7a0d0c68413d3d8587560d56945ac09e7c89c41bd971cd22d76be6f1085" origin="Generated by Gradle"/>
@@ -3887,16 +3882,16 @@
38873882
<sha256 value="54045988848801e84cffd604cfd94f6e2a613248d81ca315c20e74d0ac3b602c" origin="Generated by Gradle"/>
38883883
</artifact>
38893884
</component>
3890-
<component group="org.hamcrest" name="hamcrest" version="2.1">
3891-
<artifact name="hamcrest-2.1.jar">
3892-
<sha256 value="ba93b2e3a562322ba432f0a1b53addcc55cb188253319a020ed77f824e692050" origin="Generated by Gradle"/>
3893-
</artifact>
3894-
</component>
38953885
<component group="org.hamcrest" name="hamcrest" version="2.2">
38963886
<artifact name="hamcrest-2.2.jar">
38973887
<sha256 value="5e62846a89f05cd78cd9c1a553f340d002458380c320455dd1f8fc5497a8a1c1" origin="Generated by Gradle"/>
38983888
</artifact>
38993889
</component>
3890+
<component group="org.hamcrest" name="hamcrest" version="3.0">
3891+
<artifact name="hamcrest-3.0.jar">
3892+
<sha256 value="5d66b6a4a680755cb6ed7cb104fa7835ef644667586ff0737adeb977c39ecdbc" origin="Generated by Gradle"/>
3893+
</artifact>
3894+
</component>
39003895
<component group="org.hamcrest" name="hamcrest-core" version="1.3">
39013896
<artifact name="hamcrest-core-1.3.jar">
39023897
<sha256 value="66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9" origin="Generated by Gradle"/>
@@ -4007,49 +4002,74 @@
40074002
<sha256 value="e2b99c0d2fa39f69f27efb1c0016390713feb2f2e02d8ea7f1c36b780271598a" origin="Generated by Gradle"/>
40084003
</artifact>
40094004
</component>
4005+
<component group="org.junit.jupiter" name="junit-jupiter" version="5.12.1">
4006+
<artifact name="junit-jupiter-5.12.1.jar">
4007+
<sha256 value="228a94c9ee743d55bfea09b57630681ea7b20a661a477447f5c1f60dc12d9e3a" origin="Generated by Gradle"/>
4008+
</artifact>
4009+
</component>
40104010
<component group="org.junit.jupiter" name="junit-jupiter" version="5.8.1">
40114011
<artifact name="junit-jupiter-5.8.1.jar">
40124012
<sha256 value="8f1049ee24b34a10b60cd810048099f781c2658cde2181e831496ab30a982985" origin="Generated by Gradle"/>
40134013
</artifact>
40144014
</component>
4015-
<component group="org.junit.jupiter" name="junit-jupiter-api" version="5.8.1">
4016-
<artifact name="junit-jupiter-api-5.8.1.jar">
4017-
<sha256 value="ce3374a7efba605e2d2b69a3fef90134032bab3ecc3ed8579a4871b1c2c4729c" origin="Generated by Gradle"/>
4015+
<component group="org.junit.jupiter" name="junit-jupiter-api" version="5.12.1">
4016+
<artifact name="junit-jupiter-api-5.12.1.jar">
4017+
<sha256 value="a401e0b60373edf7df0962c25eb3213e451a4778792d33a76876c3b8a5bb209b" origin="Generated by Gradle"/>
4018+
</artifact>
4019+
</component>
4020+
<component group="org.junit.jupiter" name="junit-jupiter-engine" version="5.12.1">
4021+
<artifact name="junit-jupiter-engine-5.12.1.jar">
4022+
<sha256 value="0e7f2dbeb91bfaeb0d4cb33a487351baf0e5a6ed72906154d8fd9975d329c592" origin="Generated by Gradle"/>
40184023
</artifact>
40194024
</component>
4020-
<component group="org.junit.jupiter" name="junit-jupiter-engine" version="5.8.1">
4021-
<artifact name="junit-jupiter-engine-5.8.1.jar">
4022-
<sha256 value="4689bc902255a19fe98277683ba3231c094d107c54c8d35f2b6f9c97d226418e" origin="Generated by Gradle"/>
4025+
<component group="org.junit.jupiter" name="junit-jupiter-params" version="5.12.1">
4026+
<artifact name="junit-jupiter-params-5.12.1.jar">
4027+
<sha256 value="5951706999e35951d4df0eca6e091d3619f659a9c10858f2f5a3ce191cb57673" origin="Generated by Gradle"/>
40234028
</artifact>
40244029
</component>
4025-
<component group="org.junit.jupiter" name="junit-jupiter-params" version="5.8.1">
4026-
<artifact name="junit-jupiter-params-5.8.1.jar">
4027-
<sha256 value="389b8d13a8d8872fcbd4f0eba7b2c46afc628419f9a1b2a3a9f93241a06a7218" origin="Generated by Gradle"/>
4030+
<component group="org.junit.platform" name="junit-platform-commons" version="1.12.1">
4031+
<artifact name="junit-platform-commons-1.12.1.jar">
4032+
<sha256 value="c316163581aaa5649280122b12ea36fe4e9c202a1a2267753fea7c9e1df055eb" origin="Generated by Gradle"/>
40284033
</artifact>
40294034
</component>
40304035
<component group="org.junit.platform" name="junit-platform-commons" version="1.8.1">
40314036
<artifact name="junit-platform-commons-1.8.1.jar">
40324037
<sha256 value="fa4fa68c8bd54dd0cb49c3fcbe9b2e42f4da6bedbe7e7ccf2a05f1a1e609b593" origin="Generated by Gradle"/>
40334038
</artifact>
40344039
</component>
4040+
<component group="org.junit.platform" name="junit-platform-engine" version="1.12.1">
4041+
<artifact name="junit-platform-engine-1.12.1.jar">
4042+
<sha256 value="7fedff93fd92aec7d29fc60dc01fa027246b36b8088423a5efc4949e5f6affa4" origin="Generated by Gradle"/>
4043+
</artifact>
4044+
</component>
40354045
<component group="org.junit.platform" name="junit-platform-engine" version="1.8.1">
40364046
<artifact name="junit-platform-engine-1.8.1.jar">
40374047
<sha256 value="702868ed7e86b9b4672ede0f1e185e905baca9afab57746a7c650be3c7bca047" origin="Generated by Gradle"/>
40384048
</artifact>
40394049
</component>
4050+
<component group="org.junit.platform" name="junit-platform-launcher" version="1.12.1">
4051+
<artifact name="junit-platform-launcher-1.12.1.jar">
4052+
<sha256 value="ebbb14e7b29f60730eaede862ed69d7de0d581ea0c038fa6a202955c7541f525" origin="Generated by Gradle"/>
4053+
</artifact>
4054+
</component>
40404055
<component group="org.junit.platform" name="junit-platform-launcher" version="1.8.1">
40414056
<artifact name="junit-platform-launcher-1.8.1.jar">
40424057
<sha256 value="83a9ed68adcb76e60316a4d682fc48507865df2f0ab35f82695cc9995410e05e" origin="Generated by Gradle"/>
40434058
</artifact>
40444059
</component>
4060+
<component group="org.junit.platform" name="junit-platform-testkit" version="1.12.1">
4061+
<artifact name="junit-platform-testkit-1.12.1.jar">
4062+
<sha256 value="40623b54782410e0855c543e0ff150d221ed3f77ed75693d66710640ec2271be" origin="Generated by Gradle"/>
4063+
</artifact>
4064+
</component>
40454065
<component group="org.junit.platform" name="junit-platform-testkit" version="1.8.1">
40464066
<artifact name="junit-platform-testkit-1.8.1.jar">
40474067
<sha256 value="38d6b8bdd3e5de159564bf33bd8918ce24baca57a84f1ea743f0074e4819e697" origin="Generated by Gradle"/>
40484068
</artifact>
40494069
</component>
4050-
<component group="org.junit.vintage" name="junit-vintage-engine" version="5.8.1">
4051-
<artifact name="junit-vintage-engine-5.8.1.jar">
4052-
<sha256 value="176b53cd1bdbf9233e96c8b0c7a9e5b864282fbbdeba43b5ceafdedb29a49156" origin="Generated by Gradle"/>
4070+
<component group="org.junit.vintage" name="junit-vintage-engine" version="5.12.1">
4071+
<artifact name="junit-vintage-engine-5.12.1.jar">
4072+
<sha256 value="9b93fb605b9fa0b750a69212a0141eb648c6c90f3b7f2c48dd8cdd2b72513109" origin="Generated by Gradle"/>
40534073
</artifact>
40544074
</component>
40554075
<component group="org.locationtech.jts" name="jts-core" version="1.15.0">
@@ -4292,6 +4312,11 @@
42924312
<sha256 value="58812de60898d976fb81ef3b62da05c6604c18fd4a249f5044282479fc286af2" origin="Generated by Gradle"/>
42934313
</artifact>
42944314
</component>
4315+
<component group="org.opentest4j" name="opentest4j" version="1.3.0">
4316+
<artifact name="opentest4j-1.3.0.jar">
4317+
<sha256 value="48e2df636cab6563ced64dcdff8abb2355627cb236ef0bf37598682ddf742f1b" origin="Generated by Gradle"/>
4318+
</artifact>
4319+
</component>
42954320
<component group="org.orbisgis" name="cts" version="1.5.2">
42964321
<artifact name="cts-1.5.2.jar">
42974322
<sha256 value="72f8b1fbb59fe777dd1cbd618d39e22ab28436fa0843979c6120bd6cd5833e0e" origin="Generated by Gradle"/>

libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES;
3838
import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS;
3939
import static org.objectweb.asm.Opcodes.ACC_STATIC;
40-
import static org.objectweb.asm.Opcodes.GETSTATIC;
4140
import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
4241
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
43-
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
4442

4543
public class InstrumenterImpl implements Instrumenter {
4644
private static final Logger logger = LogManager.getLogger(InstrumenterImpl.class);
@@ -286,22 +284,9 @@ private void pushCallerClass() {
286284
false
287285
);
288286
} else {
289-
mv.visitFieldInsn(
290-
GETSTATIC,
291-
Type.getInternalName(StackWalker.Option.class),
292-
"RETAIN_CLASS_REFERENCE",
293-
Type.getDescriptor(StackWalker.Option.class)
294-
);
295287
mv.visitMethodInsn(
296288
INVOKESTATIC,
297-
Type.getInternalName(StackWalker.class),
298-
"getInstance",
299-
Type.getMethodDescriptor(Type.getType(StackWalker.class), Type.getType(StackWalker.Option.class)),
300-
false
301-
);
302-
mv.visitMethodInsn(
303-
INVOKEVIRTUAL,
304-
Type.getInternalName(StackWalker.class),
289+
"org/elasticsearch/entitlement/bridge/Util",
305290
"getCallerClass",
306291
Type.getMethodDescriptor(Type.getType(Class.class)),
307292
false

libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementCheckerHandle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class EntitlementCheckerHandle {
1818
* This is how the bytecodes injected by our instrumentation access the {@link EntitlementChecker}
1919
* so they can call the appropriate check method.
2020
*/
21+
@SuppressWarnings("unused")
2122
public static EntitlementChecker instance() {
2223
return Holder.instance;
2324
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.bridge;
11+
12+
import java.util.Optional;
13+
14+
import static java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE;
15+
16+
public class Util {
17+
/**
18+
* A special value representing the case where a method <em>has no caller</em>.
19+
* This can occur if it's called directly from the JVM.
20+
*
21+
* @see StackWalker#getCallerClass()
22+
*/
23+
public static final Class<?> NO_CLASS = new Object() {
24+
}.getClass();
25+
26+
/**
27+
* Why would we write this instead of using {@link StackWalker#getCallerClass()}?
28+
* Because that method throws {@link IllegalCallerException} if called from the "outermost frame",
29+
* which includes at least some cases of a method called from a native frame.
30+
*
31+
* @return the class that called the method which called this; or {@link #NO_CLASS} from the outermost frame.
32+
*/
33+
@SuppressWarnings("unused") // Called reflectively from InstrumenterImpl
34+
public static Class<?> getCallerClass() {
35+
Optional<Class<?>> callerClassIfAny = StackWalker.getInstance(RETAIN_CLASS_REFERENCE)
36+
.walk(
37+
frames -> frames.skip(2) // Skip this method and its caller
38+
.findFirst()
39+
.map(StackWalker.StackFrame::getDeclaringClass)
40+
);
41+
return callerClassIfAny.orElse(NO_CLASS);
42+
}
43+
44+
}

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static java.util.stream.Collectors.toUnmodifiableMap;
5858
import static java.util.zip.ZipFile.OPEN_DELETE;
5959
import static java.util.zip.ZipFile.OPEN_READ;
60+
import static org.elasticsearch.entitlement.bridge.Util.NO_CLASS;
6061

6162
public class PolicyManager {
6263
/**
@@ -712,8 +713,6 @@ Class<?> requestingClass(Class<?> callerClass) {
712713

713714
/**
714715
* Given a stream of {@link StackFrame}s, identify the one whose entitlements should be checked.
715-
*
716-
* @throws NullPointerException if the requesting module is {@code null}
717716
*/
718717
Optional<StackFrame> findRequestingFrame(Stream<StackFrame> frames) {
719718
return frames.filter(f -> f.getDeclaringClass().getModule() != entitlementsModule) // ignore entitlements library
@@ -732,6 +731,10 @@ private static boolean isTriviallyAllowed(Class<?> requestingClass) {
732731
generalLogger.debug("Entitlement trivially allowed: no caller frames outside the entitlement library");
733732
return true;
734733
}
734+
if (requestingClass == NO_CLASS) {
735+
generalLogger.debug("Entitlement trivially allowed from outermost frame");
736+
return true;
737+
}
735738
if (SYSTEM_LAYER_MODULES.contains(requestingClass.getModule())) {
736739
generalLogger.debug("Entitlement trivially allowed from system module [{}]", requestingClass.getModule().getName());
737740
return true;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.bridge;
11+
12+
import org.elasticsearch.test.ESTestCase;
13+
14+
import static org.elasticsearch.entitlement.bridge.UtilTests.MockSensitiveClass.mockSensitiveMethod;
15+
16+
@ESTestCase.WithoutSecurityManager
17+
public class UtilTests extends ESTestCase {
18+
19+
public void testCallerClass() {
20+
assertEquals(UtilTests.class, mockSensitiveMethod());
21+
}
22+
23+
/**
24+
* A separate class so the stack walk can discern the sensitive method's own class
25+
* from that of its caller.
26+
*/
27+
static class MockSensitiveClass {
28+
public static Class<?> mockSensitiveMethod() {
29+
return Util.getCallerClass();
30+
}
31+
}
32+
33+
}

modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultUserTreeToIRTreePhase.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.elasticsearch.painless.Location;
1616
import org.elasticsearch.painless.MethodWriter;
1717
import org.elasticsearch.painless.Operation;
18-
import org.elasticsearch.painless.WriterConstants;
1918
import org.elasticsearch.painless.api.ValueIterator;
2019
import org.elasticsearch.painless.ir.BinaryImplNode;
2120
import org.elasticsearch.painless.ir.BinaryMathNode;
@@ -913,10 +912,6 @@ public void visitAssignment(EAssignment userAssignmentNode, ScriptScope scriptSc
913912
stringConcatenationNode.attachDecoration(new IRDExpressionType(String.class));
914913
irCompoundNode = stringConcatenationNode;
915914

916-
// must handle the StringBuilder case for java version <= 8
917-
if (irLoadNode instanceof BinaryImplNode bin && WriterConstants.STRING_CONCAT_BOOTSTRAP_HANDLE == null) {
918-
bin.getLeftNode().attachDecoration(new IRDDepth(1));
919-
}
920915
// handles when the operation is mathematical
921916
} else {
922917
BinaryMathNode irBinaryMathNode = new BinaryMathNode(irStoreNode.getLocation());

0 commit comments

Comments
 (0)