ScriptGuards

Best-effort guards that reject the most common, literal JVM-termination calls in evaluated JVM (Kotlin/Java) scripts: System.exit(...), kotlin.system.exitProcess(...), and Runtime.getRuntime().exit(...) / .halt(...).

These guards are NOT a security sandbox. They match only obvious, literal call forms by simple pattern matching and are trivially bypassed — for example by building the call from string fragments ("ex" + "it"), reflection, aliasing the runtime (val r = Runtime.getRuntime(); r.halt(0)), or any other indirection. They also match calls that appear inside string literals or comments. Their purpose is to catch accidental JVM termination during development, not to safely run untrusted code. To run untrusted scripts, isolate them in a separate process or JVM with a restrictive security policy.

Functions

Link copied to clipboard
fun checkNoJvmExit(vararg fragments: String)

Throws a ScriptException if any of fragments contains a recognized literal JVM-termination call.