Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c3ba071
Fix entitlements in internalClusterTest
mosche Jul 18, 2025
3bf8256
continue logging stacktrace in isTriviallyAllowed
mosche Jul 21, 2025
707e792
Run Azure tests without entitlements until ES-12435
mosche Jul 22, 2025
491f8b6
Run inference tests without entitlements until ES-12435
mosche Jul 22, 2025
a43e9b1
Merge branch 'main' into entitlements/fixInternalClusterTest
mosche Jul 22, 2025
02757bf
Don't log exception in isTriviallyAllowed
mosche Jul 22, 2025
1373ee1
Merge branch 'main' into entitlements/fixInternalClusterTest
mosche Jul 23, 2025
ca4fd4b
Grant file entitlements for shared data dir to ES base due to lack of…
mosche Jul 23, 2025
cadd799
Merge branch 'entitlements/shared_data_path_fix' into entitlements/fi…
mosche Jul 23, 2025
eac1835
grant shared_data dir to lucene
mosche Jul 23, 2025
ea06394
Merge branch 'entitlements/shared_data_path_fix' into entitlements/fi…
mosche Jul 23, 2025
b85aff5
fix
mosche Jul 23, 2025
36fa717
Merge branch 'entitlements/shared_data_path_fix' into entitlements/fi…
mosche Jul 23, 2025
7b7a7f3
fix
mosche Jul 23, 2025
cc5fdeb
Merge branch 'entitlements/shared_data_path_fix' into entitlements/fi…
mosche Jul 23, 2025
6351dde
logging
mosche Jul 24, 2025
43f856e
grant shared_data dir to plugins that have a grant on data dir indices/
mosche Jul 24, 2025
8af6bfa
Merge branch 'entitlements/shared_data_path_fix' into entitlements/fi…
mosche Jul 24, 2025
d112237
Merge branch 'main' into entitlements/shared_data_path_fix
mosche Jul 24, 2025
e86c705
Merge branch 'main' into entitlements/fixInternalClusterTest
mosche Jul 24, 2025
35dfa0d
fix parser
mosche Jul 24, 2025
87cc124
Merge branch 'main' into entitlements/shared_data_path_fix
mosche Jul 24, 2025
ffd993f
Merge branch 'entitlements/shared_data_path_fix' into entitlements/fi…
mosche Jul 24, 2025
475ecd9
Merge branch 'main' into entitlements/fixInternalClusterTest
mosche Jul 24, 2025
d657f0e
Better isolation using closable node grant
mosche Jul 28, 2025
41fe7a5
[CI] Auto commit changes from spotless
Jul 28, 2025
01df9c6
support duplicate paths
mosche Jul 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
new CreateClassLoaderEntitlement(),
new FilesEntitlement(
List.of(
// TODO: what in es.base is accessing shared repo?
// necessary due to lack of delegation ES-12382
FilesEntitlement.FileData.ofBaseDirPath(SHARED_REPO, READ_WRITE),
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
)
)
Expand Down Expand Up @@ -122,6 +123,7 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
new FilesEntitlement(
List.of(
FilesEntitlement.FileData.ofBaseDirPath(CONFIG, READ),
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
)
)
Expand All @@ -130,7 +132,12 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
new Scope(
"org.apache.lucene.misc",
List.of(
new FilesEntitlement(List.of(FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE))),
new FilesEntitlement(
List.of(
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
)
),
new ReadStoreAttributesEntitlement()
)
),
Expand All @@ -145,7 +152,12 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
"org.elasticsearch.nativeaccess",
List.of(
new LoadNativeLibrariesEntitlement(),
new FilesEntitlement(List.of(FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)))
new FilesEntitlement(
List.of(
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
)
)
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,7 @@ private ModuleEntitlements getModuleScopeEntitlements(
* @return true if permission is granted regardless of the entitlement
*/
boolean isTriviallyAllowed(Class<?> requestingClass) {
if (generalLogger.isTraceEnabled()) {
generalLogger.trace("Stack trace for upcoming trivially-allowed check", new Exception());
}
// note: do not log exceptions in here, this could interfere with loading of additionally necessary classes such as ThrowableProxy
if (requestingClass == null) {
generalLogger.debug("Entitlement trivially allowed: no caller frames outside the entitlement library");
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ private static BaseDir parseBaseDir(String baseDir) {
case "config" -> BaseDir.CONFIG;
case "data" -> BaseDir.DATA;
case "home" -> BaseDir.USER_HOME;
case "shared_data" -> BaseDir.SHARED_DATA;
// it would be nice to limit this to just ES modules, but we don't have a way to plumb that through to here
// however, we still don't document in the error case below that shared_repo is valid
// however, we still don't document in the error case below that shared_repo and shared_data is valid
case "shared_repo" -> BaseDir.SHARED_REPO;
default -> throw new PolicyValidationException(
"invalid relative directory: " + baseDir + ", valid values: [config, data, home]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.elasticsearch.telemetry.Measurement;
import org.elasticsearch.telemetry.TestTelemetryPlugin;
import org.elasticsearch.test.BackgroundIndexer;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -73,6 +74,7 @@
import static org.hamcrest.Matchers.is;

@SuppressForbidden(reason = "this test uses a HttpServer to emulate an Azure endpoint")
@ESTestCase.WithoutEntitlements // due to dependency issue ES-12435
public class AzureBlobStoreRepositoryTests extends ESMockAPIBasedRepositoryIntegTestCase {

protected static final String DEFAULT_ACCOUNT_NAME = "account";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.repositories.RepositoryVerificationException;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;

import java.util.Collection;

import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;

@ESTestCase.WithoutEntitlements // due to dependency issue ES-12435
public class AzureRepositoryMissingCredentialsIT extends ESIntegTestCase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ ALL-UNNAMED:
- relative_path: "indices/"
relative_to: data
mode: read_write
- relative_path: ""
relative_to: shared_data
mode: read_write
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ReloadablePlugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.junit.BeforeClass;

import java.io.InputStream;
Expand All @@ -47,6 +48,7 @@
import static org.hamcrest.Matchers.nullValue;

@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
@ESTestCase.WithoutEntitlements // requires entitlement delegation ES-10920
public class ReloadSecureSettingsIT extends ESIntegTestCase {

private static final String VALID_SECURE_SETTING_NAME = "some.setting.that.exists";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.InternalTestCluster;

import java.util.Arrays;
Expand All @@ -22,6 +23,7 @@
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_READ_ONLY;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE;

@ESTestCase.WithoutEntitlements // requires entitlement delegation ES-10920
public class PendingTasksBlocksIT extends ESIntegTestCase {

public void testPendingTasksWithIndexBlocks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;

import java.util.Map;

import static org.hamcrest.Matchers.containsString;

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, autoManageMasterNodes = false)
@ESTestCase.WithoutEntitlements // commands don't run with entitlements enforced
public class RemoveCustomsCommandIT extends ESIntegTestCase {

public void testRemoveCustomsAbortedByUser() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;

import java.util.Collection;
import java.util.List;
Expand All @@ -31,6 +32,7 @@
import static org.hamcrest.Matchers.not;

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, autoManageMasterNodes = false)
@ESTestCase.WithoutEntitlements // commands don't run with entitlements enforced
public class RemoveIndexSettingsCommandIT extends ESIntegTestCase {

static final Setting<Integer> FOO = Setting.intSetting("index.foo", 1, Setting.Property.IndexScope, Setting.Property.Dynamic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;

import java.util.Map;

Expand All @@ -27,6 +28,7 @@
import static org.hamcrest.Matchers.not;

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, autoManageMasterNodes = false)
@ESTestCase.WithoutEntitlements // commands don't run with entitlements enforced
public class RemoveSettingsCommandIT extends ESIntegTestCase {

public void testRemoveSettingsAbortedByUser() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public Path nodeConfigPath(int nodeOrdinal) {
0,
"other",
Arrays.asList(getTestTransportPlugin(), MockHttpTransport.TestPlugin.class),
Function.identity()
Function.identity(),
TEST_ENTITLEMENTS::newNodeGrant
);
try {
other.beforeTest(random());
Expand Down Expand Up @@ -137,7 +138,8 @@ public Path nodeConfigPath(int nodeOrdinal) {
0,
"other",
Arrays.asList(getTestTransportPlugin(), MockHttpTransport.TestPlugin.class),
Function.identity()
Function.identity(),
TEST_ENTITLEMENTS::newNodeGrant
);
try (var mockLog = MockLog.capture(JoinHelper.class)) {
mockLog.addExpectation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.CorruptionUtils;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.engine.MockEngineSupport;
Expand Down Expand Up @@ -93,6 +94,7 @@
import static org.hamcrest.Matchers.startsWith;

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
@ESTestCase.WithoutEntitlements // commands don't run with entitlements enforced
public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public Path nodeConfigPath(int nodeOrdinal) {
InternalSettingsPlugin.class,
getTestTransportPlugin()
),
Function.identity()
Function.identity(),
TEST_ENTITLEMENTS::newNodeGrant
);
secondCluster.beforeTest(random());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
package org.elasticsearch.bootstrap;

import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.entitlement.bootstrap.TestEntitlementBootstrap;
import org.elasticsearch.entitlement.bootstrap.TestEntitlementsRule;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.ESTestCase.WithEntitlementsOnTestCode;

import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -42,7 +41,7 @@
*/
public class EntitlementMetaTests extends ESTestCase {
public void testSelfTestPasses() {
assumeTrue("Not yet working in serverless", TestEntitlementBootstrap.isEnabledForTest());
assumeTrue("Not yet working in serverless", TestEntitlementsRule.isEnabledForTest());
Elasticsearch.entitlementSelfTest();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.elasticsearch.bootstrap;

import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.entitlement.bootstrap.TestEntitlementBootstrap;
import org.elasticsearch.entitlement.bootstrap.TestEntitlementsRule;
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.ESTestCase.WithEntitlementsOnTestCode;
Expand All @@ -30,13 +30,13 @@ public class WithEntitlementsOnTestCodeMetaTests extends ESTestCase {
* is called from server code. The self-test should pass as usual.
*/
public void testSelfTestPasses() {
assumeTrue("Not yet working in serverless", TestEntitlementBootstrap.isEnabledForTest());
assumeTrue("Not yet working in serverless", TestEntitlementsRule.isEnabledForTest());
Elasticsearch.entitlementSelfTest();
}

@SuppressForbidden(reason = "Testing that a forbidden API is disallowed")
public void testForbiddenActionDenied() {
assumeTrue("Not yet working in serverless", TestEntitlementBootstrap.isEnabledForTest());
assumeTrue("Not yet working in serverless", TestEntitlementsRule.isEnabledForTest());
assertThrows(NotEntitledException.class, () -> Path.of(".").toRealPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private Node startNode() throws NodeValidationException {
Node node = new MockNode(
settings,
Arrays.asList(getTestTransportPlugin(), MockHttpTransport.TestPlugin.class, InternalSettingsPlugin.class),
true
true,
() -> {}
);
node.start();
return node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.entitlement.bootstrap.TestEntitlementBootstrap;
import org.elasticsearch.entitlement.bootstrap.TestEntitlementsRule;
import org.elasticsearch.jdk.JarHell;

import java.io.IOException;
Expand Down Expand Up @@ -75,7 +75,7 @@ public class BootstrapForTesting {

// Fire up entitlements
try {
TestEntitlementBootstrap.bootstrap(javaTmpDir);
TestEntitlementsRule.initialize(javaTmpDir);
} catch (IOException e) {
throw new IllegalStateException(e.getClass().getSimpleName() + " while initializing entitlements for tests", e);
}
Expand Down
Loading