Class LocalFileAccess
java.lang.Object
org.elasticsearch.xpack.esql.datasources.LocalFileAccess
Enforces the
esql.datasource.local_allowed_paths allowlist gate for file:// external sources.
An empty allowlist (the default) disables local-disk access entirely — the list is the enable,
mirroring path.repo / FsRepository. When non-empty, a file:// path is accepted only if
it normalizes to a location under one of the configured roots; ..-escape traversals and paths outside
every root are rejected.
Use create(Settings) at node startup. The special singleton UNRESTRICTED bypasses all
checks and is intended solely for test-only constructors.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError shown when afile://read is attempted but local-disk access is disabled (empty allowlist).static final LocalFileAccessAllow-all sentinel for test-only constructors inStorageProviderRegistry,FileSourceFactory, andDataSourceModule. -
Method Summary
Modifier and TypeMethodDescriptionvoidConvenience overload that parses a raw location string and delegates tocheck(StoragePath).voidcheck(StoragePath path) Validates that the givenStoragePathis permitted.static LocalFileAccessBuilds aLocalFileAccessfrom the node's startup settings.booleanenabled()Returnstruewhen local-disk reads are permitted (non-empty allowlist).
-
Field Details
-
LOCAL_DISK_DISABLED_MESSAGE
Error shown when afile://read is attempted but local-disk access is disabled (empty allowlist). Shared between the coordinator-side check (FileSourceFactory) and the data-node-side check (StorageProviderRegistry) so both paths report the same message.- See Also:
-
UNRESTRICTED
Allow-all sentinel for test-only constructors inStorageProviderRegistry,FileSourceFactory, andDataSourceModule. Does not apply path confinement. Never use in production.
-
-
Method Details
-
create
Builds aLocalFileAccessfrom the node's startup settings. An emptyExternalSourceSettings.LOCAL_ALLOWED_PATHSlist (the default) disables local-disk reads. -
enabled
public boolean enabled()Returnstruewhen local-disk reads are permitted (non-empty allowlist). -
check
Validates that the givenStoragePathis permitted.No-op for non-
fileschemes. Forfile://:- If disabled (empty allowlist): throws
IllegalArgumentExceptionwithLOCAL_DISK_DISABLED_MESSAGE. - If enabled: resolves the path against the allowed roots via
PathUtils.get(Path[], String)(lexical normalize +startsWith— same asFsRepository/Environment.resolveRepoDir). Anullresult means the path falls outside every allowed root (including..-escapes); throws with the location appended toPATH_OUTSIDE_ALLOWLIST_PREFIX.
- Throws:
IllegalArgumentException- if the path is rejected
- If disabled (empty allowlist): throws
-
check
Convenience overload that parses a raw location string and delegates tocheck(StoragePath).StoragePathextracts the scheme, so any non-filescheme (and anyfileURI form, including authority-lessfile:/path) is handled uniformly without relying on a literal prefix match.- Throws:
IllegalArgumentException- if the location is afile://path that is rejected
-