janhoy commented on code in PR #4471:
URL: https://github.com/apache/solr/pull/4471#discussion_r3317378410


##########
solr/server/etc/agent-security.policy:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Solr Security Agent — default production policy
+//
+// This file is the bundled default policy for the Solr security agent. It 
should not be edited
+// by operators. To grant additional permissions for your deployment, use the 
operator extension
+// file at: ${server.dir}/etc/agent-security-extra.policy (or the path set by
+// SOLR_SECURITY_AGENT_EXTRA_POLICY / -Dsolr.security.agent.extra.policy).
+//
+// Syntax: JDK-style .policy files with Solr variable substitution.
+// Supported variables: ${solr.solr.home}, ${solr.data.home}, 
${solr.logs.dir}, ${solr.install.dir},
+//                      ${solr.install.symDir}, ${java.io.tmpdir}, 
${java.home},
+//                      ${solr.port.listen}, ${solr.zk.port}
+//
+// For documentation see the Solr Reference Guide: Security Agent.
+
+// ---------------------------------------------------------------------------
+// Global grant — applies to all code running in the Solr JVM
+// ---------------------------------------------------------------------------
+grant {
+
+  // --- File system access ---
+
+  // Solr installation directory: read-only (JARs, modules, Jetty config, etc.)
+  // Both the real path and the symlinked path are permitted so that 
installations where
+  // /opt/solr -> /opt/solr-X.Y.Z/ work correctly (FileInterceptor uses 
toAbsolutePath(),
+  // not toRealPath(), so accesses via the symlink path must be explicitly 
allowed).
+  permission java.io.FilePermission "${solr.install.dir}/-",    "read";
+  permission java.io.FilePermission "${solr.install.symDir}/-", "read";
+
+  // Solr home: read-only (config files, schema, solrconfig.xml, etc.)
+  permission java.io.FilePermission "${solr.solr.home}/-", "read";
+
+  // Solr data and index directories: full read/write/delete
+  permission java.io.FilePermission "${solr.data.home}/-", "read,write,delete";
+
+  // Log directory: write access for log files
+  permission java.io.FilePermission "${solr.logs.dir}/-", "read,write,delete";
+
+  // Temporary files: full access (sort buffers, merged segments, etc.)
+  permission java.io.FilePermission "${java.io.tmpdir}/-", "read,write,delete";
+
+  // JDK runtime libraries: read-only (class loading, native libs, etc.)
+  permission java.io.FilePermission "${java.home}/-", "read";
+
+  // Linux pseudo-filesystems: read-only access for JVM internals (e.g. 
memory-mapping checks,
+  // network configuration, kernel parameters). These paths do not exist on 
macOS/Windows and
+  // their presence in a cross-platform policy is harmless.
+  permission java.io.FilePermission "/proc/-", "read";
+  permission java.io.FilePermission "/sys/-",  "read";
+
+  // --- Outbound network access ---
+
+  // Loopback addresses: unconditionally permitted (inter-thread, localhost 
HTTP, embedded ZK)
+  permission java.net.SocketPermission "localhost:1-65535",  "connect,resolve";
+  permission java.net.SocketPermission "127.0.0.1:1-65535", "connect,resolve";
+  permission java.net.SocketPermission "[::1]:1-65535",     "connect,resolve";
+
+  // Intra-cluster connectivity
+  // Any host on the Solr HTTP port is permitted, covering all current and 
future cluster nodes
+  // without requiring a static node list at startup. Similarly for the 
ZooKeeper port.
+  permission java.net.SocketPermission "*:${solr.port.listen}", 
"connect,resolve";
+  permission java.net.SocketPermission "*:${solr.zk.port}",    
"connect,resolve";
+
+};

Review Comment:
   I believe SolrCLI (executed through bin/solr foo bar) is executed by 
bin/solr without -javaagent, because they are just CLI tools, not starting solr 
backend; so SolrCLI won't need this. 
   
   Question is whether the running solr backend ever has any legitimate need to 
call exit. Perhaps when calling the STOP_PORT in Jetty, that Jetty code has a 
need to call exit?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to