Skip to content

Commit 3283ff2

Browse files
committed
more debugging
1 parent dc6d3ed commit 3283ff2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/FileAccessTree.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ private FileAccessTree(
154154
this.writePaths = pruneSortedPaths(writePaths).toArray(new String[0]);
155155
}
156156

157+
public String toDebugString() {
158+
return Strings.format("FileAccessTree[readPaths: [%s], writePaths: [%s], exclusivePaths: [%s]]",
159+
String.join(",", readPaths), String.join(",", writePaths), String.join(",", exclusivePaths));
160+
}
161+
157162
private static List<String> pruneSortedPaths(List<String> paths) {
158163
List<String> prunedReadPaths = new ArrayList<>();
159164
if (paths.isEmpty() == false) {

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,14 @@ public void checkFileRead(Class<?> callerClass, Path path) {
335335

336336
ModuleEntitlements entitlements = getEntitlements(requestingClass);
337337
if (entitlements.fileAccess().canRead(path) == false) {
338+
logger.info(entitlements.fileAccess().toDebugString());
338339
notEntitled(
339340
Strings.format(
340341
"Not entitled: component [%s], module [%s], class [%s], entitlement [file], operation [read], path [%s]",
341342
entitlements.componentName(),
342343
requestingClass.getModule().getName(),
343344
requestingClass,
344-
path
345+
FileAccessTree.normalizePath(path)
345346
),
346347
callerClass
347348
);
@@ -364,13 +365,14 @@ public void checkFileWrite(Class<?> callerClass, Path path) {
364365

365366
ModuleEntitlements entitlements = getEntitlements(requestingClass);
366367
if (entitlements.fileAccess().canWrite(path) == false) {
368+
logger.info(entitlements.fileAccess().toDebugString());
367369
notEntitled(
368370
Strings.format(
369371
"Not entitled: component [%s], module [%s], class [%s], entitlement [file], operation [write], path [%s]",
370372
entitlements.componentName(),
371373
requestingClass.getModule().getName(),
372374
requestingClass,
373-
path
375+
FileAccessTree.normalizePath(path)
374376
),
375377
callerClass
376378
);

0 commit comments

Comments
 (0)