From 44596712979791cf4e655fc45f30d601a53d015a Mon Sep 17 00:00:00 2001 From: Dmitrii Timofeev Date: Mon, 5 Sep 2022 14:48:50 +0300 Subject: [PATCH] Replace `disableSandbox` with `useSandbox` in `UtSettings` Although `disableSandbox` is a descriptive name, the inverted logic makes it harder to use and does not match the naming of other settings. This commit replaces `disableSandbox` with `useSandbox` and correspondingly modifies necessary checks. --- .../src/main/kotlin/org/utbot/framework/UtSettings.kt | 11 ++++++++--- .../org/utbot/testcheckers/SettingsModificators.kt | 6 +++--- .../instrumentation/process/ChildProcessRunner.kt | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt index 93797852e5..af653ab4bb 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt @@ -374,10 +374,15 @@ object UtSettings : AbstractSettings( var ignoreStaticsFromTrustedLibraries by getBooleanProperty(true) /** - * Disable sandbox in the concrete executor. All unsafe/dangerous calls will be permitted. + * Use the sandbox in the concrete executor. + * + * If true (default), the sandbox will prevent potentially dangerous calls, e.g., file access, reading + * or modifying the environment, calls to `Unsafe` methods etc. + * + * If false, all these operations will be enabled and may lead to data loss during code analysis + * and test generation. */ - var disableSandbox by getBooleanProperty(false) - + var useSandbox by getBooleanProperty(true) } /** diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/testcheckers/SettingsModificators.kt b/utbot-framework-api/src/main/kotlin/org/utbot/testcheckers/SettingsModificators.kt index 7bcd3bfce9..c330c5d1a4 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/testcheckers/SettingsModificators.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/testcheckers/SettingsModificators.kt @@ -113,11 +113,11 @@ inline fun withoutConcrete(block: () -> T): T { * Run [block] with disabled sandbox in the concrete executor */ inline fun withoutSandbox(block: () -> T): T { - val prev = UtSettings.disableSandbox - UtSettings.disableSandbox = true + val prev = UtSettings.useSandbox + UtSettings.useSandbox = false try { return block() } finally { - UtSettings.disableSandbox = prev + UtSettings.useSandbox = prev } } diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcessRunner.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcessRunner.kt index 10dc7b5cc3..df00534cd9 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcessRunner.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcessRunner.kt @@ -51,7 +51,7 @@ class ChildProcessRunner { val directory = WorkingDirService.provide().toFile() val commandsWithOptions = buildList { addAll(cmds) - if (UtSettings.disableSandbox) { + if (!UtSettings.useSandbox) { add(DISABLE_SANDBOX_OPTION) } add(portArgument)