Do not allow to access compiler internals in .kts scripts

Set parent class loader to null explicitly instead of the system class
loader
This commit is contained in:
Alexander Udalov
2017-07-10 20:39:35 +03:00
parent d1603c4329
commit 36001ff931
6 changed files with 55 additions and 62 deletions
+14
View File
@@ -0,0 +1,14 @@
fun checkInaccessible(name: String) {
try {
Class.forName(name)
throw AssertionError("Class should not be accessible from script via the class loader: $name")
}
catch (e: ClassNotFoundException) {
// OK
}
}
checkInaccessible("org.jetbrains.kotlin.config.KotlinCompilerVersion")
checkInaccessible("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
checkInaccessible("org.jetbrains.kotlin.preloading.Preloader")
print("OK")