Skip to content

Commit c449e5b

Browse files
authored
Merge branch 'main' into limit-description-length
2 parents d776baa + 67c2f41 commit c449e5b

File tree

37 files changed

+558
-417
lines changed

37 files changed

+558
-417
lines changed

.buildkite/pipelines/intake.template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ steps:
9696
- trigger: elasticsearch-dra-workflow
9797
label: Trigger DRA snapshot workflow
9898
async: true
99-
branches: "main 8.* 7.17"
99+
branches: "main 9.* 8.* 7.17"
100100
build:
101101
branch: "$BUILDKITE_BRANCH"
102102
commit: "$BUILDKITE_COMMIT"

.buildkite/pipelines/intake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ steps:
9797
- trigger: elasticsearch-dra-workflow
9898
label: Trigger DRA snapshot workflow
9999
async: true
100-
branches: "main 8.* 7.17"
100+
branches: "main 9.* 8.* 7.17"
101101
build:
102102
branch: "$BUILDKITE_BRANCH"
103103
commit: "$BUILDKITE_COMMIT"

docs/changelog/121428.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 121428
2+
summary: Fix infer on and elasticsearch service endpoint created with a deployment
3+
id
4+
area: Machine Learning
5+
type: bug
6+
issues: []
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.qa.test;
11+
12+
import java.lang.annotation.ElementType;
13+
import java.lang.annotation.Retention;
14+
import java.lang.annotation.RetentionPolicy;
15+
import java.lang.annotation.Target;
16+
17+
@Target(ElementType.METHOD)
18+
@Retention(RetentionPolicy.RUNTIME)
19+
public @interface EntitlementTest {
20+
enum ExpectedAccess {
21+
PLUGINS,
22+
ES_MODULES_ONLY,
23+
ALWAYS_DENIED
24+
}
25+
26+
ExpectedAccess expectedAccess();
27+
28+
int fromJavaVersion() default -1;
29+
}

libs/entitlement/qa/entitlement-test-plugin/src/main/java/org/elasticsearch/entitlement/qa/test/FileCheckActions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.nio.file.attribute.UserPrincipal;
2323
import java.util.Scanner;
2424

25+
import static org.elasticsearch.entitlement.qa.test.EntitlementTest.ExpectedAccess.PLUGINS;
26+
2527
@SuppressForbidden(reason = "Explicitly checking APIs that are forbidden")
2628
class FileCheckActions {
2729

@@ -43,38 +45,47 @@ private static Path readWriteFile() {
4345
return testRootDir.resolve("read_write_file");
4446
}
4547

48+
@EntitlementTest(expectedAccess = PLUGINS)
4649
static void createScannerFile() throws FileNotFoundException {
4750
new Scanner(readFile().toFile());
4851
}
4952

53+
@EntitlementTest(expectedAccess = PLUGINS)
5054
static void createScannerFileWithCharset() throws IOException {
5155
new Scanner(readFile().toFile(), StandardCharsets.UTF_8);
5256
}
5357

58+
@EntitlementTest(expectedAccess = PLUGINS)
5459
static void createScannerFileWithCharsetName() throws FileNotFoundException {
5560
new Scanner(readFile().toFile(), "UTF-8");
5661
}
5762

63+
@EntitlementTest(expectedAccess = PLUGINS)
5864
static void createFileOutputStreamString() throws IOException {
5965
new FileOutputStream(readWriteFile().toString()).close();
6066
}
6167

68+
@EntitlementTest(expectedAccess = PLUGINS)
6269
static void createFileOutputStreamStringWithAppend() throws IOException {
6370
new FileOutputStream(readWriteFile().toString(), false).close();
6471
}
6572

73+
@EntitlementTest(expectedAccess = PLUGINS)
6674
static void createFileOutputStreamFile() throws IOException {
6775
new FileOutputStream(readWriteFile().toFile()).close();
6876
}
6977

78+
@EntitlementTest(expectedAccess = PLUGINS)
7079
static void createFileOutputStreamFileWithAppend() throws IOException {
7180
new FileOutputStream(readWriteFile().toFile(), false).close();
7281
}
7382

83+
@EntitlementTest(expectedAccess = PLUGINS)
7484
static void filesProbeContentType() throws IOException {
7585
Files.probeContentType(readFile());
7686
}
7787

88+
@EntitlementTest(expectedAccess = PLUGINS)
7889
static void filesSetOwner() throws IOException {
7990
UserPrincipal owner = EntitledActions.getFileOwner(readWriteFile());
8091
Files.setOwner(readWriteFile(), owner); // set to existing owner, just trying to execute the method

libs/entitlement/qa/entitlement-test-plugin/src/main/java/org/elasticsearch/entitlement/qa/test/RestEntitlementsCheckAction.java

Lines changed: 183 additions & 135 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
package org.elasticsearch.entitlement.runtime.policy;
1111

12-
import org.elasticsearch.core.SuppressForbidden;
1312
import org.elasticsearch.entitlement.runtime.policy.entitlements.FileEntitlement;
1413

15-
import java.io.File;
1614
import java.nio.file.Path;
1715
import java.util.ArrayList;
1816
import java.util.Arrays;
@@ -51,20 +49,10 @@ boolean canRead(Path path) {
5149
return checkPath(normalize(path), readPaths);
5250
}
5351

54-
@SuppressForbidden(reason = "Explicitly checking File apis")
55-
boolean canRead(File file) {
56-
return checkPath(normalize(file.toPath()), readPaths);
57-
}
58-
5952
boolean canWrite(Path path) {
6053
return checkPath(normalize(path), writePaths);
6154
}
6255

63-
@SuppressForbidden(reason = "Explicitly checking File apis")
64-
boolean canWrite(File file) {
65-
return checkPath(normalize(file.toPath()), writePaths);
66-
}
67-
6856
private static String normalize(Path path) {
6957
return path.toAbsolutePath().normalize().toString();
7058
}

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

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,7 @@ private static void validateEntitlementsPerModule(String sourceName, String modu
169169
}
170170

171171
public void checkStartProcess(Class<?> callerClass) {
172-
neverEntitled(callerClass, "start process");
173-
}
174-
175-
private void neverEntitled(Class<?> callerClass, String operationDescription) {
176-
var requestingClass = requestingClass(callerClass);
177-
if (isTriviallyAllowed(requestingClass)) {
178-
return;
179-
}
180-
181-
throw new NotEntitledException(
182-
Strings.format(
183-
"Not entitled: caller [%s], module [%s], operation [%s]",
184-
callerClass,
185-
requestingClass.getModule() == null ? "<none>" : requestingClass.getModule().getName(),
186-
operationDescription
187-
)
188-
);
172+
neverEntitled(callerClass, () -> "start process");
189173
}
190174

191175
/**
@@ -241,31 +225,9 @@ public void checkChangeNetworkHandling(Class<?> callerClass) {
241225
checkChangeJVMGlobalState(callerClass);
242226
}
243227

244-
/**
245-
* Check for operations that can access sensitive network information, e.g. secrets, tokens or SSL sessions
246-
*/
247-
public void checkReadSensitiveNetworkInformation(Class<?> callerClass) {
248-
neverEntitled(callerClass, "access sensitive network information");
249-
}
250-
251228
@SuppressForbidden(reason = "Explicitly checking File apis")
252229
public void checkFileRead(Class<?> callerClass, File file) {
253-
var requestingClass = requestingClass(callerClass);
254-
if (isTriviallyAllowed(requestingClass)) {
255-
return;
256-
}
257-
258-
ModuleEntitlements entitlements = getEntitlements(requestingClass);
259-
if (entitlements.fileAccess().canRead(file) == false) {
260-
throw new NotEntitledException(
261-
Strings.format(
262-
"Not entitled: caller [%s], module [%s], entitlement [file], operation [read], path [%s]",
263-
callerClass,
264-
requestingClass.getModule(),
265-
file
266-
)
267-
);
268-
}
230+
checkFileRead(callerClass, file.toPath());
269231
}
270232

271233
public void checkFileRead(Class<?> callerClass, Path path) {
@@ -289,22 +251,7 @@ public void checkFileRead(Class<?> callerClass, Path path) {
289251

290252
@SuppressForbidden(reason = "Explicitly checking File apis")
291253
public void checkFileWrite(Class<?> callerClass, File file) {
292-
var requestingClass = requestingClass(callerClass);
293-
if (isTriviallyAllowed(requestingClass)) {
294-
return;
295-
}
296-
297-
ModuleEntitlements entitlements = getEntitlements(requestingClass);
298-
if (entitlements.fileAccess().canWrite(file) == false) {
299-
throw new NotEntitledException(
300-
Strings.format(
301-
"Not entitled: caller [%s], module [%s], entitlement [file], operation [write], path [%s]",
302-
callerClass,
303-
requestingClass.getModule(),
304-
file
305-
)
306-
);
307-
}
254+
checkFileWrite(callerClass, file.toPath());
308255
}
309256

310257
public void checkFileWrite(Class<?> callerClass, Path path) {

libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyManagerTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ public void testRequestingClassFastPath() throws IOException, ClassNotFoundExcep
238238
}
239239

240240
public void testRequestingModuleWithStackWalk() throws IOException, ClassNotFoundException {
241-
var agentsClass = new TestAgent();
242241
var entitlementsClass = makeClassInItsOwnModule(); // A class in the entitlements library itself
243242
var requestingClass = makeClassInItsOwnModule(); // This guy is always the right answer
244243
var instrumentedClass = makeClassInItsOwnModule(); // The class that called the check method
@@ -365,13 +364,6 @@ private static Class<?> makeClassInItsOwnModule() throws IOException, ClassNotFo
365364
return layer.findLoader("org.example.plugin").loadClass("q.B");
366365
}
367366

368-
private static Class<?> makeClassInItsOwnUnnamedModule() throws IOException, ClassNotFoundException {
369-
final Path home = createTempDir();
370-
Path jar = createMockPluginJar(home);
371-
var layer = createLayerForJar(jar, "org.example.plugin");
372-
return layer.findLoader("org.example.plugin").loadClass("q.B");
373-
}
374-
375367
private static PolicyManager policyManager(String agentsPackageName, Module entitlementsModule) {
376368
return new PolicyManager(createEmptyTestServerPolicy(), List.of(), Map.of(), c -> "test", agentsPackageName, entitlementsModule);
377369
}

muted-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ tests:
360360
- class: org.elasticsearch.xpack.security.CoreWithSecurityClientYamlTestSuiteIT
361361
method: test {yaml=indices.get_alias/10_basic/Get aliases via /*/_alias/}
362362
issue: https://github.com/elastic/elasticsearch/issues/121290
363-
- class: org.elasticsearch.xpack.inference.common.InferenceServiceNodeLocalRateLimitCalculatorTests
364-
issue: https://github.com/elastic/elasticsearch/issues/121294
365363
- class: org.elasticsearch.env.NodeEnvironmentTests
366364
method: testGetBestDowngradeVersion
367365
issue: https://github.com/elastic/elasticsearch/issues/121316
@@ -391,6 +389,9 @@ tests:
391389
issue: https://github.com/elastic/elasticsearch/issues/121395
392390
- class: org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT
393391
issue: https://github.com/elastic/elasticsearch/issues/121407
392+
- class: org.elasticsearch.xpack.ml.integration.ClassificationIT
393+
method: testDependentVariableIsAliasToNested
394+
issue: https://github.com/elastic/elasticsearch/issues/121415
394395

395396
# Examples:
396397
#

0 commit comments

Comments
 (0)