WIP checkpoint: Research and design GDScript sandboxing approach
This commit is contained in:
@@ -0,0 +1,78 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("=== SANDBOX PROBE 2: ScriptServer & Restrictions ===")
|
||||||
|
probe_scriptserver()
|
||||||
|
probe_script_restrictions()
|
||||||
|
probe_engine_restrictions()
|
||||||
|
probe_global_scope()
|
||||||
|
probe_classdb()
|
||||||
|
probe_script_extension()
|
||||||
|
print("=== SANDBOX PROBE 2 END ===")
|
||||||
|
get_tree().quit()
|
||||||
|
|
||||||
|
func probe_scriptserver():
|
||||||
|
print("--- ScriptServer ---")
|
||||||
|
# Is ScriptServer available? It's a static class in Godot 4.
|
||||||
|
print("ScriptServer exists: ", ClassDB.class_exists("ScriptServer"))
|
||||||
|
if ClassDB.class_exists("ScriptServer"):
|
||||||
|
# What methods does it expose?
|
||||||
|
var methods = ClassDB.class_get_method_list("ScriptServer")
|
||||||
|
for m in methods:
|
||||||
|
print(" ScriptServer method: ", m.name, " args=", m.args.size())
|
||||||
|
|
||||||
|
func probe_script_restrictions():
|
||||||
|
print("--- Script restrictions ---")
|
||||||
|
# Can we restrict script loading via ProjectSettings?
|
||||||
|
var keys = [
|
||||||
|
"debug/gdscript/warnings/",
|
||||||
|
"debug/gdscript/",
|
||||||
|
"application/run/",
|
||||||
|
]
|
||||||
|
for k in keys:
|
||||||
|
var settings = ProjectSettings.get_setting(k)
|
||||||
|
print(" ProjectSettings['", k, "'] = ", settings)
|
||||||
|
|
||||||
|
func probe_engine_restrictions():
|
||||||
|
print("--- Engine restrictions ---")
|
||||||
|
# Check if there's any sandbox/restriction setting
|
||||||
|
var all_settings = ProjectSettings.get_property_list()
|
||||||
|
var sandbox_like = []
|
||||||
|
for s in all_settings:
|
||||||
|
var name = String(s.name)
|
||||||
|
if "sandbox" in name.to_lower() or "restrict" in name.to_lower() or "security" in name.to_lower():
|
||||||
|
sandbox_like.append(name)
|
||||||
|
print(" Sandbox/restrict/security settings found: ", sandbox_like)
|
||||||
|
|
||||||
|
func probe_global_scope():
|
||||||
|
print("--- Global scope ---")
|
||||||
|
# What global classes/functions are available to scripts?
|
||||||
|
# Check if we can enumerate global scope
|
||||||
|
var global_classes = []
|
||||||
|
if ClassDB.class_exists("GlobalScope"):
|
||||||
|
var methods = ClassDB.class_get_method_list("GlobalScope")
|
||||||
|
for m in methods:
|
||||||
|
global_classes.append(m.name)
|
||||||
|
print(" GlobalScope methods count: ", global_classes.size())
|
||||||
|
# Key dangerous globals
|
||||||
|
var dangerous = ["OS", "FileAccess", "DirAccess", "TCPServer", "HTTPClient", "ProjectSettings", "Engine", "ResourceLoader", "ClassDB", "Expression", "JavaScriptBridge"]
|
||||||
|
for d in dangerous:
|
||||||
|
print(" Class '", d, "' exists: ", ClassDB.class_exists(d))
|
||||||
|
|
||||||
|
func probe_classdb():
|
||||||
|
print("--- ClassDB ---")
|
||||||
|
# Can scripts access ClassDB to instantiate arbitrary classes?
|
||||||
|
print(" ClassDB.class_exists('Node') = ", ClassDB.class_exists("Node"))
|
||||||
|
# Can we get all classes?
|
||||||
|
var all_classes = ClassDB.get_class_list()
|
||||||
|
print(" ClassDB.get_class_list().size() = ", all_classes.size())
|
||||||
|
|
||||||
|
func probe_script_extension():
|
||||||
|
print("--- Script extension / custom interpreter ---")
|
||||||
|
# Check if ScriptExtension exists (for custom script languages)
|
||||||
|
print(" ScriptExtension exists: ", ClassDB.class_exists("ScriptExtension"))
|
||||||
|
# Check GDScript internals
|
||||||
|
print(" GDScript class exists: ", ClassDB.class_exists("GDScript"))
|
||||||
|
var gd_methods = ClassDB.class_get_method_list("GDScript")
|
||||||
|
for m in gd_methods:
|
||||||
|
print(" GDScript method: ", m.name)
|
||||||
Reference in New Issue
Block a user