Skip to content

Commit 10514b7

Browse files
committed
[Entitlements] Print a warning during plugin installation if a legacy policy file is found (elastic#125294)
This PR adds a check and a warning message if the user is trying to install a plugin containing the legacy plugin-security.policy used by SecurityManager. Relates to ES-10846
1 parent b5d84a4 commit 10514b7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,17 @@ void jarHellCheck(PluginDescriptor candidateInfo, Path candidateDir, Path plugin
923923
*/
924924
private PluginDescriptor installPlugin(InstallablePlugin descriptor, Path tmpRoot, List<Path> deleteOnFailure) throws Exception {
925925
final PluginDescriptor info = loadPluginInfo(tmpRoot);
926+
927+
Path legacyPolicyFile = tmpRoot.resolve(PluginDescriptor.ES_PLUGIN_POLICY);
928+
if (Files.exists(legacyPolicyFile)) {
929+
terminal.errorPrintln(
930+
"WARNING: this plugin contains a legacy Security Policy file. Starting with version 8.18, "
931+
+ "Entitlements replace SecurityManager as the security mechanism. Plugins must migrate their policy files to the new "
932+
+ "format. For more information, please refer to "
933+
+ PluginSecurity.ENTITLEMENTS_DESCRIPTION_URL
934+
);
935+
}
936+
926937
if (RuntimeVersionFeature.isSecurityManagerAvailable()) {
927938
PluginPolicyInfo pluginPolicy = PolicyUtil.getPluginPolicyInfo(tmpRoot, env.tmpDir());
928939
if (pluginPolicy != null) {

distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/PluginSecurity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
*/
3535
public class PluginSecurity {
3636

37+
public static final String ENTITLEMENTS_DESCRIPTION_URL =
38+
"https://www.elastic.co/guide/en/elasticsearch/plugins/current/creating-classic-plugins.html";
39+
3740
/**
3841
* prints/confirms policy exceptions with the user
3942
*/

0 commit comments

Comments
 (0)