Browse Source

[Entitlements] Add missing file entitlements for server (#122728)

Add missing file entitlements for server.

closes https://github.com/elastic/elasticsearch/issues/122569, closes
https://github.com/elastic/elasticsearch/issues/122568, closes
https://github.com/elastic/elasticsearch/issues/122567, closes
https://github.com/elastic/elasticsearch/issues/122566 

(Note, some failures are due to a `NoSuchAlgorithmException` when fips
is enabled. This issue is unrelated to entitlements)
Moritz Mack 8 months ago
parent
commit
cc9679162f

+ 20 - 2
libs/entitlement/src/main/java/org/elasticsearch/entitlement/initialization/EntitlementInitialization.java

@@ -59,6 +59,7 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 import java.util.stream.StreamSupport;
 
 
+import static org.elasticsearch.entitlement.runtime.policy.entitlements.FilesEntitlement.Mode.READ;
 import static org.elasticsearch.entitlement.runtime.policy.entitlements.FilesEntitlement.Mode.READ_WRITE;
 import static org.elasticsearch.entitlement.runtime.policy.entitlements.FilesEntitlement.Mode.READ_WRITE;
 
 
 /**
 /**
@@ -149,8 +150,25 @@ public class EntitlementInitialization {
                         new ManageThreadsEntitlement(),
                         new ManageThreadsEntitlement(),
                         new FilesEntitlement(
                         new FilesEntitlement(
                             List.of(
                             List.of(
-                                FilesEntitlement.FileData.ofPath(EntitlementBootstrap.bootstrapArgs().tempDir(), READ_WRITE),
-                                FilesEntitlement.FileData.ofPath(EntitlementBootstrap.bootstrapArgs().logsDir(), READ_WRITE)
+                                FileData.ofPath(bootstrapArgs.tempDir(), READ_WRITE),
+                                FileData.ofPath(bootstrapArgs.logsDir(), READ_WRITE),
+                                // OS release on Linux
+                                FileData.ofPath(Path.of("/etc/os-release"), READ),
+                                FileData.ofPath(Path.of("/etc/system-release"), READ),
+                                FileData.ofPath(Path.of("/usr/lib/os-release"), READ),
+                                // read max virtual memory areas
+                                FileData.ofPath(Path.of("/proc/sys/vm/max_map_count"), READ),
+                                FileData.ofPath(Path.of("/proc/meminfo"), READ),
+                                // load averages on Linux
+                                FileData.ofPath(Path.of("/proc/loadavg"), READ),
+                                // control group stats on Linux. cgroup v2 stats are in an unpredicable
+                                // location under `/sys/fs/cgroup`, so unfortunately we have to allow
+                                // read access to the entire directory hierarchy.
+                                FileData.ofPath(Path.of("/proc/self/cgroup"), READ),
+                                FileData.ofPath(Path.of("/sys/fs/cgroup/"), READ),
+                                // // io stats on Linux
+                                FileData.ofPath(Path.of("/proc/self/mountinfo"), READ),
+                                FileData.ofPath(Path.of("/proc/diskstats"), READ)
                             )
                             )
                         )
                         )
                     )
                     )

+ 0 - 8
muted-tests.yml

@@ -338,14 +338,6 @@ tests:
 - class: org.elasticsearch.entitlement.runtime.policy.PolicyParserFailureTests
 - class: org.elasticsearch.entitlement.runtime.policy.PolicyParserFailureTests
   method: testEntitlementAbsolutePathWhenRelative
   method: testEntitlementAbsolutePathWhenRelative
   issue: https://github.com/elastic/elasticsearch/issues/122666
   issue: https://github.com/elastic/elasticsearch/issues/122666
-- class: org.elasticsearch.entitlement.qa.EntitlementsAllowedNonModularIT
-  issue: https://github.com/elastic/elasticsearch/issues/122568
-- class: org.elasticsearch.entitlement.qa.EntitlementsDeniedIT
-  issue: https://github.com/elastic/elasticsearch/issues/122566
-- class: org.elasticsearch.entitlement.qa.EntitlementsDeniedNonModularIT
-  issue: https://github.com/elastic/elasticsearch/issues/122569
-- class: org.elasticsearch.entitlement.qa.EntitlementsAllowedIT
-  issue: https://github.com/elastic/elasticsearch/issues/122680
 - class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
 - class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
   method: test {yaml=reference/snapshot-restore/apis/get-snapshot-api/line_408}
   method: test {yaml=reference/snapshot-restore/apis/get-snapshot-api/line_408}
   issue: https://github.com/elastic/elasticsearch/issues/122681
   issue: https://github.com/elastic/elasticsearch/issues/122681