Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
acab982
Add check functions for NIO Files
ldematte Feb 14, 2025
91fc04a
Adding IT tests
ldematte Feb 14, 2025
17383a3
Add logsDir to bootstrap params
ldematte Feb 14, 2025
e10f9bf
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 14, 2025
a404b17
Add implicit temp dir/file checks + add entitlement for OsProbe
ldematte Feb 14, 2025
edb8047
Add entitlement for reading system files
ldematte Feb 14, 2025
3a9c288
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 17, 2025
013e649
More OsProbe
ldematte Feb 17, 2025
35bdc0c
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 17, 2025
92d56e9
spotless
ldematte Feb 17, 2025
370d7e0
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 17, 2025
883bbe3
Entitlement trivially allowed for EntitlementChecker class
ldematte Feb 17, 2025
c2a626c
Plugins policies
ldematte Feb 17, 2025
c5d6966
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 17, 2025
0e5b011
[CI] Auto commit changes from spotless
Feb 17, 2025
c32a08a
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 19, 2025
10ad9bc
Pass down repoDirResolver to Entitlements
ldematte Feb 19, 2025
3774f2c
Add repository file entitlement data
ldematte Feb 19, 2025
a63cc7a
More missing policies
ldematte Feb 19, 2025
89ed0e5
Azure and Ml file policies
ldematte Feb 19, 2025
e3bcad4
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 19, 2025
9d295ef
Try again Azure policy
ldematte Feb 19, 2025
4df15bb
Azure policies again, plus netty4
ldematte Feb 19, 2025
83f5814
Ml policy: write data
ldematte Feb 19, 2025
7ee21e8
Merge branch 'main' into entitlements/nio-files-1
ldematte Feb 19, 2025
0159767
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 19, 2025
690fd09
Merge branch 'entitlements/nio-files-1' of github.com:ldematte/elasti…
ldematte Feb 19, 2025
4bb7df3
store-sm, repository-hdfs and identity-provider policies
ldematte Feb 19, 2025
60a2f1b
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 19, 2025
56462ba
Silly APM Agent fake file permissions
ldematte Feb 19, 2025
62897b5
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 19, 2025
2592d97
[CI] Auto commit changes from spotless
Feb 19, 2025
db3e499
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 19, 2025
2174f27
Merge remote-tracking branch 'upstream/main' into entitlements/nio-fi…
ldematte Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.foreign.AddressLayout;
Expand Down Expand Up @@ -57,12 +58,18 @@
import java.nio.file.CopyOption;
import java.nio.file.DirectoryStream;
import java.nio.file.FileStore;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitor;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.WatchEvent;
import java.nio.file.WatchService;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.FileTime;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.UserPrincipal;
import java.nio.file.spi.FileSystemProvider;
import java.security.cert.CertStoreParameters;
Expand All @@ -74,6 +81,7 @@
import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.function.BiPredicate;
import java.util.function.Consumer;

import javax.net.ssl.HostnameVerifier;
Expand Down Expand Up @@ -593,6 +601,173 @@ public interface EntitlementChecker {

void check$java_nio_file_Files$$setOwner(Class<?> callerClass, Path path, UserPrincipal principal);

void check$java_nio_file_Files$$newInputStream(Class<?> callerClass, Path path, OpenOption... options);

void check$java_nio_file_Files$$newOutputStream(Class<?> callerClass, Path path, OpenOption... options);

void check$java_nio_file_Files$$newByteChannel(
Class<?> callerClass,
Path path,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs
);

void check$java_nio_file_Files$$newByteChannel(Class<?> callerClass, Path path, OpenOption... options);

void check$java_nio_file_Files$$newDirectoryStream(Class<?> callerClass, Path dir);

void check$java_nio_file_Files$$newDirectoryStream(Class<?> callerClass, Path dir, String glob);

void check$java_nio_file_Files$$newDirectoryStream(Class<?> callerClass, Path dir, DirectoryStream.Filter<? super Path> filter);

void check$java_nio_file_Files$$createFile(Class<?> callerClass, Path path, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createDirectory(Class<?> callerClass, Path dir, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createDirectories(Class<?> callerClass, Path dir, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createTempFile(Class<?> callerClass, Path dir, String prefix, String suffix, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createTempFile(Class<?> callerClass, String prefix, String suffix, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createTempDirectory(Class<?> callerClass, Path dir, String prefix, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createTempDirectory(Class<?> callerClass, String prefix, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createSymbolicLink(Class<?> callerClass, Path link, Path target, FileAttribute<?>... attrs);

void check$java_nio_file_Files$$createLink(Class<?> callerClass, Path link, Path existing);

void check$java_nio_file_Files$$delete(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$deleteIfExists(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$copy(Class<?> callerClass, Path source, Path target, CopyOption... options);

void check$java_nio_file_Files$$move(Class<?> callerClass, Path source, Path target, CopyOption... options);

void check$java_nio_file_Files$$readSymbolicLink(Class<?> callerClass, Path link);

void check$java_nio_file_Files$$getFileStore(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$isSameFile(Class<?> callerClass, Path path, Path path2);

void check$java_nio_file_Files$$mismatch(Class<?> callerClass, Path path, Path path2);

void check$java_nio_file_Files$$isHidden(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$getFileAttributeView(
Class<?> callerClass,
Path path,
Class<? extends FileAttributeView> type,
LinkOption... options
);

void check$java_nio_file_Files$$readAttributes(
Class<?> callerClass,
Path path,
Class<? extends BasicFileAttributes> type,
LinkOption... options
);

void check$java_nio_file_Files$$setAttribute(Class<?> callerClass, Path path, String attribute, Object value, LinkOption... options);

void check$java_nio_file_Files$$getAttribute(Class<?> callerClass, Path path, String attribute, LinkOption... options);

void check$java_nio_file_Files$$readAttributes(Class<?> callerClass, Path path, String attributes, LinkOption... options);

void check$java_nio_file_Files$$getPosixFilePermissions(Class<?> callerClass, Path path, LinkOption... options);

void check$java_nio_file_Files$$setPosixFilePermissions(Class<?> callerClass, Path path, Set<PosixFilePermission> perms);

void check$java_nio_file_Files$$isSymbolicLink(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$isDirectory(Class<?> callerClass, Path path, LinkOption... options);

void check$java_nio_file_Files$$isRegularFile(Class<?> callerClass, Path path, LinkOption... options);

void check$java_nio_file_Files$$getLastModifiedTime(Class<?> callerClass, Path path, LinkOption... options);

void check$java_nio_file_Files$$setLastModifiedTime(Class<?> callerClass, Path path, FileTime time);

void check$java_nio_file_Files$$size(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$exists(Class<?> callerClass, Path path, LinkOption... options);

void check$java_nio_file_Files$$notExists(Class<?> callerClass, Path path, LinkOption... options);

void check$java_nio_file_Files$$isReadable(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$isWritable(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$isExecutable(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$walkFileTree(
Class<?> callerClass,
Path start,
Set<FileVisitOption> options,
int maxDepth,
FileVisitor<? super Path> visitor
);

void check$java_nio_file_Files$$walkFileTree(Class<?> callerClass, Path start, FileVisitor<? super Path> visitor);

void check$java_nio_file_Files$$newBufferedReader(Class<?> callerClass, Path path, Charset cs);

void check$java_nio_file_Files$$newBufferedReader(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$newBufferedWriter(Class<?> callerClass, Path path, Charset cs, OpenOption... options);

void check$java_nio_file_Files$$newBufferedWriter(Class<?> callerClass, Path path, OpenOption... options);

void check$java_nio_file_Files$$copy(Class<?> callerClass, InputStream in, Path target, CopyOption... options);

void check$java_nio_file_Files$$copy(Class<?> callerClass, Path source, OutputStream out);

void check$java_nio_file_Files$$readAllBytes(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$readString(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$readString(Class<?> callerClass, Path path, Charset cs);

void check$java_nio_file_Files$$readAllLines(Class<?> callerClass, Path path, Charset cs);

void check$java_nio_file_Files$$readAllLines(Class<?> callerClass, Path path);

void check$java_nio_file_Files$$write(Class<?> callerClass, Path path, byte[] bytes, OpenOption... options);

void check$java_nio_file_Files$$write(
Class<?> callerClass,
Path path,
Iterable<? extends CharSequence> lines,
Charset cs,
OpenOption... options
);

void check$java_nio_file_Files$$write(Class<?> callerClass, Path path, Iterable<? extends CharSequence> lines, OpenOption... options);

void check$java_nio_file_Files$$writeString(Class<?> callerClass, Path path, CharSequence csq, OpenOption... options);

void check$java_nio_file_Files$$writeString(Class<?> callerClass, Path path, CharSequence csq, Charset cs, OpenOption... options);

void check$java_nio_file_Files$$list(Class<?> callerClass, Path dir);

void check$java_nio_file_Files$$walk(Class<?> callerClass, Path start, int maxDepth, FileVisitOption... options);

void check$java_nio_file_Files$$walk(Class<?> callerClass, Path start, FileVisitOption... options);

void check$java_nio_file_Files$$find(
Class<?> callerClass,
Path start,
int maxDepth,
BiPredicate<Path, BasicFileAttributes> matcher,
FileVisitOption... options
);

void check$java_nio_file_Files$$lines(Class<?> callerClass, Path path, Charset cs);

void check$java_nio_file_Files$$lines(Class<?> callerClass, Path path);

// file system providers
void check$java_nio_file_spi_FileSystemProvider$(Class<?> callerClass);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.UserPrincipal;
import java.util.Scanner;

import static org.elasticsearch.entitlement.qa.test.EntitlementTest.ExpectedAccess.PLUGINS;
Expand Down Expand Up @@ -236,21 +234,5 @@ static void createFileOutputStreamFileWithAppend() throws IOException {
new FileOutputStream(readWriteFile().toFile(), false).close();
}

@EntitlementTest(expectedAccess = PLUGINS)
static void filesGetOwner() throws IOException {
Files.getOwner(readFile());
}

@EntitlementTest(expectedAccess = PLUGINS)
static void filesProbeContentType() throws IOException {
Files.probeContentType(readFile());
}

@EntitlementTest(expectedAccess = PLUGINS)
static void filesSetOwner() throws IOException {
UserPrincipal owner = EntitledActions.getFileOwner(readWriteFile());
Files.setOwner(readWriteFile(), owner); // set to existing owner, just trying to execute the method
}

private FileCheckActions() {}
}
Loading