-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Support file entitlements relative to the user's home directory #122724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
cc3b81b
6a5fcac
4a7ab65
8e3e8e0
1f485b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,8 @@ public enum Mode { | |
|
|
||
| public enum BaseDir { | ||
| CONFIG, | ||
| DATA | ||
| DATA, | ||
| HOME | ||
| } | ||
|
|
||
| public sealed interface FileData { | ||
|
|
@@ -93,6 +94,8 @@ public Stream<Path> resolvePaths(PathLookup pathLookup) { | |
| return Stream.of(pathLookup.configDir().resolve(relativePath)); | ||
| case DATA: | ||
| return Arrays.stream(pathLookup.dataDirs()).map(d -> d.resolve(relativePath)); | ||
| case HOME: | ||
| return pathLookup.homeDir() != null ? Stream.of(pathLookup.homeDir().resolve(relativePath)) : Stream.empty(); | ||
| default: | ||
| throw new IllegalArgumentException(); | ||
| } | ||
|
|
@@ -145,12 +148,14 @@ private static Mode parseMode(String mode) { | |
| } | ||
|
|
||
| private static BaseDir parseBaseDir(String baseDir) { | ||
| if (baseDir.equals("config")) { | ||
| return BaseDir.CONFIG; | ||
| } else if (baseDir.equals("data")) { | ||
| return BaseDir.DATA; | ||
| } | ||
| throw new PolicyValidationException("invalid relative directory: " + baseDir + ", valid values: [config, data]"); | ||
| return switch (baseDir) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice IMO, but I think it'll fail backport (8.x is not at this Java lang level IIRC). Just a warning.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 8.17 is at a minimum of Java 17 (based on https://www.elastic.co/support/matrix), so would expect this to be safe for backports as well |
||
| case "config" -> BaseDir.CONFIG; | ||
| case "data" -> BaseDir.DATA; | ||
| case "home" -> BaseDir.HOME; | ||
| default -> throw new PolicyValidationException( | ||
| "invalid relative directory: " + baseDir + ", valid values: [config, data, home]" | ||
| ); | ||
| }; | ||
| } | ||
|
|
||
| @ExternalEntitlement(parameterNames = { "paths" }, esModulesOnly = false) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.