优化
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions

This commit is contained in:
Horis
2025-04-02 22:09:57 +08:00
parent 0e6a00fbaf
commit 3995d1e9ad
2 changed files with 9 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ import org.mozilla.javascript.Scriptable
class ProtectedNativeJavaClass( class ProtectedNativeJavaClass(
scope: Scriptable, scope: Scriptable,
javaClass: Class<*>, javaClass: Class<*>,
private val protectedName: HashSet<String> private val protectedName: Set<String>
) : NativeJavaClass(scope, javaClass) { ) : NativeJavaClass(scope, javaClass) {
override fun has( override fun has(

View File

@@ -34,6 +34,7 @@ import java.io.ObjectOutputStream
import java.lang.reflect.Member import java.lang.reflect.Member
import java.nio.file.FileSystem import java.nio.file.FileSystem
import java.nio.file.Path import java.nio.file.Path
import java.util.Collections
/** /**
* This class prevents script access to certain sensitive classes. * This class prevents script access to certain sensitive classes.
@@ -94,14 +95,19 @@ object RhinoClassShutter : ClassShutter {
"androidx.sqlite.db", "androidx.sqlite.db",
"androidx.room", "androidx.room",
"cn.hutool.core.io", "cn.hutool.core.io",
"cn.hutool.core.lang.reflect",
"dalvik.system", "dalvik.system",
"java.nio.file", "java.nio.file",
"java.lang.reflect",
"java.lang.invoke",
"io.legado.app.data.dao", "io.legado.app.data.dao",
) "com.script",
"org.mozilla",
).let { Collections.unmodifiableSet(it) }
} }
private val systemClassProtectedName by lazy { private val systemClassProtectedName by lazy {
hashSetOf("load", "loadLibrary", "exit") Collections.unmodifiableSet(hashSetOf("load", "loadLibrary", "exit"))
} }
fun visibleToScripts(obj: Any): Boolean { fun visibleToScripts(obj: Any): Boolean {