-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Remove ignoreUrl file setting property #123718
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
Merged
rjernst
merged 4 commits into
elastic:main
from
rjernst:entitlements/always_ignore_setting_urls
Mar 2, 2025
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,8 +91,8 @@ static FileData ofRelativePath(Path relativePath, BaseDir baseDir, Mode mode) { | |
| return new RelativePathFileData(relativePath, baseDir, mode, null, false); | ||
| } | ||
|
|
||
| static FileData ofPathSetting(String setting, BaseDir baseDir, Mode mode, boolean ignoreUrl) { | ||
| return new PathSettingFileData(setting, baseDir, mode, ignoreUrl, null, false); | ||
| static FileData ofPathSetting(String setting, BaseDir baseDir, Mode mode) { | ||
| return new PathSettingFileData(setting, baseDir, mode, null, false); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -221,13 +221,13 @@ public FileData withPlatform(Platform platform) { | |
| } | ||
| } | ||
|
|
||
| private record PathSettingFileData(String setting, BaseDir baseDir, Mode mode, boolean ignoreUrl, Platform platform, boolean exclusive) | ||
| private record PathSettingFileData(String setting, BaseDir baseDir, Mode mode, Platform platform, boolean exclusive) | ||
| implements | ||
| RelativeFileData { | ||
|
|
||
| @Override | ||
| public PathSettingFileData withExclusive(boolean exclusive) { | ||
| return new PathSettingFileData(setting, baseDir, mode, ignoreUrl, platform, exclusive); | ||
| return new PathSettingFileData(setting, baseDir, mode, platform, exclusive); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -239,9 +239,7 @@ public Stream<Path> resolveRelativePaths(PathLookup pathLookup) { | |
| String path = pathLookup.settingResolver().apply(setting); | ||
| result = path == null ? Stream.of() : Stream.of(path); | ||
| } | ||
| if (ignoreUrl) { | ||
| result = result.filter(s -> s.toLowerCase(Locale.ROOT).startsWith("https://") == false); | ||
| } | ||
| result = result.filter(s -> s.toLowerCase(Locale.ROOT).startsWith("https://") == false); | ||
|
||
| return result.map(pathLookup.configDir()::resolve); | ||
| } | ||
|
|
||
|
|
@@ -250,7 +248,7 @@ public FileData withPlatform(Platform platform) { | |
| if (platform == platform()) { | ||
| return this; | ||
| } | ||
| return new PathSettingFileData(setting, baseDir, mode, ignoreUrl, platform, exclusive); | ||
| return new PathSettingFileData(setting, baseDir, mode, platform, exclusive); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -338,8 +336,6 @@ public static FilesEntitlement build(List<Object> paths) { | |
| String settingBaseDirAsString = checkString.apply(file, "basedir_if_relative"); | ||
| String modeAsString = checkString.apply(file, "mode"); | ||
| String platformAsString = checkString.apply(file, "platform"); | ||
| Boolean ignoreUrlAsStringBoolean = checkBoolean.apply(file, "ignore_url"); | ||
| boolean ignoreUrlAsString = ignoreUrlAsStringBoolean != null && ignoreUrlAsStringBoolean; | ||
| Boolean exclusiveBoolean = checkBoolean.apply(file, "exclusive"); | ||
| boolean exclusive = exclusiveBoolean != null && exclusiveBoolean; | ||
|
|
||
|
|
@@ -366,9 +362,6 @@ public static FilesEntitlement build(List<Object> paths) { | |
| throw new PolicyValidationException("'relative_to' may only be used with 'relative_path'"); | ||
| } | ||
|
|
||
| if (ignoreUrlAsStringBoolean != null && pathSetting == null) { | ||
| throw new PolicyValidationException("'ignore_url' may only be used with 'path_setting'"); | ||
| } | ||
| if (settingBaseDirAsString != null && pathSetting == null) { | ||
| throw new PolicyValidationException("'basedir_if_relative' may only be used with 'path_setting'"); | ||
| } | ||
|
|
@@ -395,7 +388,7 @@ public static FilesEntitlement build(List<Object> paths) { | |
| throw new PolicyValidationException("files entitlement with a 'path_setting' must specify 'basedir_if_relative'"); | ||
| } | ||
| BaseDir baseDir = parseBaseDir(settingBaseDirAsString); | ||
| fileData = FileData.ofPathSetting(pathSetting, baseDir, mode, ignoreUrlAsString); | ||
| fileData = FileData.ofPathSetting(pathSetting, baseDir, mode); | ||
| } else { | ||
| throw new AssertionError("File entry validation error"); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we ignore all URLs? http://, ftp:// (if we even allow that thing).
Even file:// if passed down to FileAccessTree as is would make a mess of the path sting.