Skip to content

Commit 4227ebd

Browse files
committed
impl: new UI setting for running unsigned binary execution
A new UI setting was introduced to allow users to run unsigned binaries without any input from the user. Defaults to false which means if a binary is unsigned we will ask the user what to do next.
1 parent 6ca08df commit 4227ebd

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

src/main/kotlin/com/coder/toolbox/settings/ReadOnlyCoderSettings.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ interface ReadOnlyCoderSettings {
2727
*/
2828
val binaryDirectory: String?
2929

30+
/**
31+
* Controls whether we run the unsigned binary or we prompt
32+
* the user for input.
33+
*/
34+
val allowUnsignedBinaryWithoutPrompt: Boolean
35+
3036
/**
3137
* Default CLI binary name based on OS and architecture
3238
*/

src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class CoderSettingsStore(
3737
override val defaultURL: String get() = store[DEFAULT_URL] ?: "https://dev.coder.com"
3838
override val binarySource: String? get() = store[BINARY_SOURCE]
3939
override val binaryDirectory: String? get() = store[BINARY_DIRECTORY]
40+
override val allowUnsignedBinaryWithoutPrompt: Boolean =
41+
store[ALLOW_UNSIGNED_BINARY_EXEC]?.toBooleanStrictOrNull() ?: false
4042
override val defaultCliBinaryNameByOsAndArch: String get() = getCoderCLIForOS(getOS(), getArch())
4143
override val binaryName: String get() = store[BINARY_NAME] ?: getCoderCLIForOS(getOS(), getArch())
4244
override val dataDirectory: String? get() = store[DATA_DIRECTORY]
@@ -158,6 +160,10 @@ class CoderSettingsStore(
158160
store[ENABLE_DOWNLOADS] = shouldEnableDownloads.toString()
159161
}
160162

163+
fun updateAllowUnsignedBinaryExec(allowUnsignedBinaryExec: Boolean) {
164+
store[ALLOW_UNSIGNED_BINARY_EXEC] = allowUnsignedBinaryExec.toString()
165+
}
166+
161167
fun updateBinaryDirectoryFallback(shouldEnableBinDirFallback: Boolean) {
162168
store[ENABLE_BINARY_DIR_FALLBACK] = shouldEnableBinDirFallback.toString()
163169
}

src/main/kotlin/com/coder/toolbox/store/StoreKeys.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ internal const val BINARY_SOURCE = "binarySource"
1010

1111
internal const val BINARY_DIRECTORY = "binaryDirectory"
1212

13+
internal const val ALLOW_UNSIGNED_BINARY_EXEC = "allowUnsignedBinaryExec"
14+
1315
internal const val BINARY_NAME = "binaryName"
1416

1517
internal const val DATA_DIRECTORY = "dataDirectory"

src/main/kotlin/com/coder/toolbox/views/CoderSettingsPage.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
3232
TextField(context.i18n.ptrl("Data directory"), settings.dataDirectory ?: "", TextType.General)
3333
private val enableDownloadsField =
3434
CheckboxField(settings.enableDownloads, context.i18n.ptrl("Enable downloads"))
35+
private val allowUnsignedBinaryExecField =
36+
CheckboxField(
37+
settings.allowUnsignedBinaryWithoutPrompt,
38+
context.i18n.ptrl("Allow unsigned binary execution without prompt")
39+
)
3540
private val enableBinaryDirectoryFallbackField =
3641
CheckboxField(
3742
settings.enableBinaryDirectoryFallback,
@@ -66,6 +71,7 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
6671
enableDownloadsField,
6772
binaryDirectoryField,
6873
enableBinaryDirectoryFallbackField,
74+
allowUnsignedBinaryExecField,
6975
dataDirectoryField,
7076
headerCommandField,
7177
tlsCertPathField,
@@ -87,6 +93,7 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
8793
context.settingsStore.updateBinaryDirectory(binaryDirectoryField.textState.value)
8894
context.settingsStore.updateDataDirectory(dataDirectoryField.textState.value)
8995
context.settingsStore.updateEnableDownloads(enableDownloadsField.checkedState.value)
96+
context.settingsStore.updateAllowUnsignedBinaryExec(allowUnsignedBinaryExecField.checkedState.value)
9097
context.settingsStore.updateBinaryDirectoryFallback(enableBinaryDirectoryFallbackField.checkedState.value)
9198
context.settingsStore.updateHeaderCommand(headerCommandField.textState.value)
9299
context.settingsStore.updateCertPath(tlsCertPathField.textState.value)

src/main/resources/localization/defaultMessages.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ msgstr ""
7979
msgid "Enable downloads"
8080
msgstr ""
8181

82+
msgid "Allow unsigned binary execution without prompt"
83+
msgstr ""
84+
8285
msgid "Enable binary directory fallback"
8386
msgstr ""
8487

0 commit comments

Comments
 (0)