File tree Expand file tree Collapse file tree 4 files changed +38
-6
lines changed
utbot-framework/src/test/kotlin/org/utbot/examples
utbot-framework-api/src/main/kotlin/org/utbot/framework
utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process Expand file tree Collapse file tree 4 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -406,6 +406,11 @@ object UtSettings {
406
406
*/
407
407
var ignoreStaticsFromTrustedLibraries by getBooleanProperty(true )
408
408
409
+ /* *
410
+ * Disable sandbox in the concrete executor. All unsafe/dangerous calls will be permitted.
411
+ */
412
+ var disableSandbox by getBooleanProperty(false )
413
+
409
414
override fun toString (): String =
410
415
settingsValues
411
416
.mapKeys { it.key.name }
Original file line number Diff line number Diff line change @@ -2890,3 +2890,16 @@ inline fun <reified T> withUsingReflectionForMaximizingCoverage(maximizeCoverage
2890
2890
UtSettings .maximizeCoverageUsingReflection = prev
2891
2891
}
2892
2892
}
2893
+
2894
+ /* *
2895
+ * Run [block] with disabled sandbox in the concrete executor
2896
+ */
2897
+ inline fun <reified T > withoutSandbox (block : () -> T ): T {
2898
+ val prev = UtSettings .disableSandbox
2899
+ UtSettings .disableSandbox = true
2900
+ try {
2901
+ return block()
2902
+ } finally {
2903
+ UtSettings .disableSandbox = prev
2904
+ }
2905
+ }
Original file line number Diff line number Diff line change @@ -48,14 +48,21 @@ private fun log(any: Any?) {
48
48
49
49
private val kryoHelper: KryoHelper = KryoHelper (System .`in `, System .`out `)
50
50
51
+ /* *
52
+ * Command-line option do disable the sandbox
53
+ */
54
+ const val DISABLE_SANDBOX_OPTION = " --disable-sandbox"
55
+
51
56
/* *
52
57
* It should be compiled into separate jar file (child_process.jar) and be run with an agent (agent.jar) option.
53
58
*/
54
- fun main () {
55
- permissions {
56
- // Enable all permissions for instrumentation.
57
- // SecurityKt.sandbox() is used to restrict these permissions.
58
- + AllPermission ()
59
+ fun main (args : Array <String >) {
60
+ if (! args.contains(DISABLE_SANDBOX_OPTION )) {
61
+ permissions {
62
+ // Enable all permissions for instrumentation.
63
+ // SecurityKt.sandbox() is used to restrict these permissions.
64
+ + AllPermission ()
65
+ }
59
66
}
60
67
61
68
// We don't want user code to litter the standard output, so we redirect it.
Original file line number Diff line number Diff line change @@ -49,7 +49,14 @@ class ChildProcessRunner {
49
49
50
50
val directory = WorkingDirService .provide().toFile()
51
51
52
- val processBuilder = ProcessBuilder (cmds)
52
+ val commandsWithOptions = buildList {
53
+ addAll(cmds)
54
+ if (UtSettings .disableSandbox) {
55
+ add(DISABLE_SANDBOX_OPTION )
56
+ }
57
+ }
58
+
59
+ val processBuilder = ProcessBuilder (commandsWithOptions)
53
60
.redirectError(errorLogFile)
54
61
.directory(directory)
55
62
You can’t perform that action at this time.
0 commit comments