Skip to content

Commit 37edf70

Browse files
prdoylejdconradldematterjernst
authored
Backport entitlement work up to #116473 to 8.x (#116613)
* Add initial entitlement policy parsing (#114448) This change adds entitlement policy parsing with the following design: * YAML file for readability and re-use of our x-content parsers * hierarchical structure to group entitlements under a single scope * no general entitlements without a scope or for the entire project * Avoid double instrumentation via class annotation (#115398) * Move entitlement jars to libs (#115883) The distribution tools are meant to be CLIs. This commit moves the entitlements jar projects to the libs dir, under a single libs/entitlement root directory to keep the related jars together. * Entitlement tools: SecurityManager scanner (#116020) * Dynamic entitlement agent (#116125) * Refactor: treat "maybe" JVM options uniformly * WIP * Get entitlement running with bridge all the way through, with qualified exports * Cosmetic changes to SystemJvmOptions * Disable entitlements by default * Bridge module comments * Fixup forbidden APIs * spotless * Rename EntitlementChecker * Fixup InstrumenterTests * exclude recursive dep * Fix some compliance stuff * Rename asm-provider * Stop using bridge in InstrumenterTests * Generalize readme for asm-provider * InstrumenterTests doesn't need EntitlementCheckerHandle * Better javadoc * Call parseBoolean * Add entitlement to internal module list * Docs as requested by Lorenzo * Changes from Jack * Rename ElasticsearchEntitlementChecker * Remove logging javadoc * exportInitializationToAgent should reference EntitlementInitialization, not EntitlementBootstrap. They're currently in the same module, but if that ever changes, this code would have become wrong. * Some suggestions from Mark --------- Co-authored-by: Ryan Ernst <[email protected]> * Remove unused EntitlementInternals (#116473) * Revert "Entitlement tools: SecurityManager scanner (#116020)" This reverts commit 023fb66. --------- Co-authored-by: Jack Conradson <[email protected]> Co-authored-by: Lorenzo Dematté <[email protected]> Co-authored-by: Ryan Ernst <[email protected]>
1 parent b9c2b52 commit 37edf70

File tree

58 files changed

+1375
-505
lines changed

Some content is hidden

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

58 files changed

+1375
-505
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ public class InternalDistributionModuleCheckTaskProvider {
4848
/** ES jars in the lib directory that are not modularized. For now, es-log4j is the only one. */
4949
private static final List<String> ES_JAR_EXCLUDES = List.of("elasticsearch-log4j");
5050

51-
/** List of the current Elasticsearch Java Modules, by name. */
51+
/** List of the current Elasticsearch Java Modules, alphabetically by name. */
5252
private static final List<String> EXPECTED_ES_SERVER_MODULES = List.of(
5353
"org.elasticsearch.base",
5454
"org.elasticsearch.cli",
55+
"org.elasticsearch.entitlement",
5556
"org.elasticsearch.geo",
5657
"org.elasticsearch.grok",
5758
"org.elasticsearch.logging",

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/RunTask.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public abstract class RunTask extends DefaultTestClustersTask {
4242

4343
private Boolean debug = false;
4444
private Boolean cliDebug = false;
45+
private Boolean entitlementsEnabled = false;
4546
private Boolean apmServerEnabled = false;
4647

4748
private Boolean preserveData = false;
@@ -69,6 +70,14 @@ public void setCliDebug(boolean enabled) {
6970
this.cliDebug = enabled;
7071
}
7172

73+
@Option(
74+
option = "entitlements",
75+
description = "Use the Entitlements agent system in place of SecurityManager to enforce sandbox policies."
76+
)
77+
public void setEntitlementsEnabled(boolean enabled) {
78+
this.entitlementsEnabled = enabled;
79+
}
80+
7281
@Input
7382
public Boolean getDebug() {
7483
return debug;
@@ -79,6 +88,11 @@ public Boolean getCliDebug() {
7988
return cliDebug;
8089
}
8190

91+
@Input
92+
public Boolean getEntitlementsEnabled() {
93+
return entitlementsEnabled;
94+
}
95+
8296
@Input
8397
public Boolean getApmServerEnabled() {
8498
return apmServerEnabled;
@@ -226,6 +240,9 @@ else if (node.getSettingKeys().contains("telemetry.metrics.enabled") == false) {
226240
if (cliDebug) {
227241
enableCliDebug();
228242
}
243+
if (entitlementsEnabled) {
244+
enableEntitlements();
245+
}
229246
}
230247

231248
@TaskAction

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ default void enableCliDebug() {
7474
}
7575
}
7676
}
77+
78+
default void enableEntitlements() {
79+
for (ElasticsearchCluster cluster : getClusters()) {
80+
for (ElasticsearchNode node : cluster.getNodes()) {
81+
node.cliJvmArgs("-Des.entitlements.enabled=true");
82+
}
83+
}
84+
}
7785
}

distribution/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
262262
* Properties to expand when copying packaging files *
263263
*****************************************************************************/
264264
configurations {
265-
['libs', 'libsVersionChecker', 'libsCliLauncher', 'libsServerCli', 'libsWindowsServiceCli', 'libsPluginCli', 'libsKeystoreCli', 'libsSecurityCli', 'libsGeoIpCli', 'libsAnsiConsole', 'libsNative'].each {
265+
['libs', 'libsVersionChecker', 'libsCliLauncher', 'libsServerCli', 'libsWindowsServiceCli', 'libsPluginCli', 'libsKeystoreCli', 'libsSecurityCli', 'libsGeoIpCli', 'libsAnsiConsole', 'libsNative', 'libsEntitlementAgent', 'libsEntitlementBridge'].each {
266266
create(it) {
267267
canBeConsumed = false
268268
canBeResolved = true
@@ -292,6 +292,8 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
292292
libsSecurityCli project(':x-pack:plugin:security:cli')
293293
libsGeoIpCli project(':distribution:tools:geoip-cli')
294294
libsNative project(':libs:native:native-libraries')
295+
libsEntitlementAgent project(':libs:entitlement:agent')
296+
libsEntitlementBridge project(':libs:entitlement:bridge')
295297
}
296298

297299
project.ext {
@@ -336,6 +338,12 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
336338
include (os + '-' + architecture + '/*')
337339
}
338340
}
341+
into('entitlement-agent') {
342+
from(configurations.libsEntitlementAgent)
343+
}
344+
into('entitlement-bridge') {
345+
from(configurations.libsEntitlementBridge)
346+
}
339347
}
340348
}
341349

distribution/tools/entitlement-agent/build.gradle

Lines changed: 0 additions & 62 deletions
This file was deleted.

distribution/tools/entitlement-agent/impl/src/test/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterTests.java

Lines changed: 0 additions & 153 deletions
This file was deleted.

distribution/tools/entitlement-agent/src/test/java/org/elasticsearch/entitlement/agent/EntitlementAgentTests.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)