From a9a37c5d1a3362f254cf0e07860ea557a6faacbe Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Tue, 22 Jul 2025 23:15:20 +0300 Subject: [PATCH 1/4] fix: class cast exception when handling Failed verification result verification result was improperly cast to download result when signature verification failed to run. --- CHANGELOG.md | 4 ++++ src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d769d0..6945c1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixed + +- fix class cast exception during signature verification + ## 0.5.1 - 2025-07-21 ### Added diff --git a/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt b/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt index 177ba81..61c114e 100644 --- a/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt +++ b/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt @@ -277,8 +277,8 @@ class CoderCLIManager( } else -> { - UnsignedBinaryExecutionDeniedException((result as Failed).error.message) - val failure = result as DownloadResult.Failed + val failure = result as Failed + UnsignedBinaryExecutionDeniedException(result.error.message) context.logger.error(failure.error, "Failed to verify signature for ${cliResult.dst}") } } From 75385a11e632c304c5c011a43d4a48e366afc51b Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Tue, 22 Jul 2025 23:15:41 +0300 Subject: [PATCH 2/4] chore: next version is 0.5.2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 79386fe..e6dc4d8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -version=0.5.1 +version=0.5.2 group=com.coder.toolbox name=coder-toolbox From f01d9f63e2c401cb4974b3b34d942d45cdb15932 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Tue, 22 Jul 2025 23:25:56 +0300 Subject: [PATCH 3/4] chore: fix more linting issues --- src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt b/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt index 61c114e..8afd954 100644 --- a/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt +++ b/src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt @@ -467,7 +467,7 @@ class CoderCLIManager( */ private fun writeSSHConfig(contents: String?) { if (contents != null) { - if (!context.settingsStore.sshConfigPath.isNullOrBlank()) { + if (context.settingsStore.sshConfigPath.isNotBlank()) { val sshConfPath = Path.of(context.settingsStore.sshConfigPath) sshConfPath.parent.toFile().mkdirs() sshConfPath.toFile().writeText(contents) @@ -492,9 +492,9 @@ class CoderCLIManager( throw MissingVersionException("No version found in output") } return SemVer.parse(json.version) - } catch (exception: JsonDataException) { + } catch (_: JsonDataException) { throw MissingVersionException("No version found in output") - } catch (exception: EOFException) { + } catch (_: EOFException) { throw MissingVersionException("No version found in output") } } @@ -532,7 +532,7 @@ class CoderCLIManager( val buildVersion = try { SemVer.parse(rawBuildVersion) - } catch (e: InvalidVersionException) { + } catch (_: InvalidVersionException) { context.logger.info("Got invalid build version: $rawBuildVersion") return null } From a25338808da6886534041d28d0916d0206c45fda Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Wed, 23 Jul 2025 00:17:13 +0300 Subject: [PATCH 4/4] fix: download the correct CLI signature for Windows The signature for windows CLI follows the format: coder-windows-amd64.exe.asc Currently it is coded to coder-windows-amd64.asc which means the plugin always fail to find any signature for windows cli --- CHANGELOG.md | 1 + .../coder/toolbox/store/CoderSettingsStore.kt | 56 ++++++------------- .../toolbox/store/CoderSettingsStoreTest.kt | 14 +---- 3 files changed, 21 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6945c1f..68290b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - fix class cast exception during signature verification +- the correct CLI signature for Windows is now downloaded ## 0.5.1 - 2025-07-21 diff --git a/src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt b/src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt index a57ff45..ff56380 100644 --- a/src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt +++ b/src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt @@ -250,42 +250,17 @@ class CoderSettingsStore( /** * Return the name of the binary (with extension) for the provided OS and architecture. */ - private fun getCoderCLIForOS( - os: OS?, - arch: Arch?, - ): String { + private fun getCoderCLIForOS(os: OS?, arch: Arch?): String { logger.debug("Resolving binary for $os $arch") - return buildCoderFileName(os, arch) - } - - /** - * Return the name of the signature file (.asc) for the provided OS and architecture. - */ - private fun getCoderSignatureForOS( - os: OS?, - arch: Arch?, - ): String { - logger.debug("Resolving signature for $os $arch") - return buildCoderFileName(os, arch, true) - } - - /** - * Build the coder file name based on OS, architecture, and whether it's a signature file. - */ - private fun buildCoderFileName( - os: OS?, - arch: Arch?, - isSignature: Boolean = false - ): String { - if (os == null) { - logger.error("Could not resolve client OS and architecture, defaulting to WINDOWS AMD64") - return if (isSignature) "coder-windows-amd64.asc" else "coder-windows-amd64.exe" - } - val osName = when (os) { - OS.WINDOWS -> "windows" - OS.LINUX -> "linux" - OS.MAC -> "darwin" + val (osName, extension) = when (os) { + OS.WINDOWS -> "windows" to ".exe" + OS.LINUX -> "linux" to "" + OS.MAC -> "darwin" to "" + null -> { + logger.error("Could not resolve client OS and architecture, defaulting to WINDOWS AMD64") + return "coder-windows-amd64.exe" + } } val archName = when (arch) { @@ -295,14 +270,17 @@ class CoderSettingsStore( else -> "amd64" // default fallback } - val extension = if (isSignature) ".asc" else when (os) { - OS.WINDOWS -> ".exe" - OS.LINUX, OS.MAC -> "" - } - return "coder-$osName-$archName$extension" } + /** + * Return the name of the signature file (.asc) for the provided OS and architecture. + */ + private fun getCoderSignatureForOS(os: OS?, arch: Arch?): String { + logger.debug("Resolving signature for $os $arch") + return "${getCoderCLIForOS(os, arch)}.asc" + } + /** * Append the host to the path. For example, foo/bar could become * foo/bar/dev.coder.com-8080. diff --git a/src/test/kotlin/com/coder/toolbox/store/CoderSettingsStoreTest.kt b/src/test/kotlin/com/coder/toolbox/store/CoderSettingsStoreTest.kt index 5798524..636ef61 100644 --- a/src/test/kotlin/com/coder/toolbox/store/CoderSettingsStoreTest.kt +++ b/src/test/kotlin/com/coder/toolbox/store/CoderSettingsStoreTest.kt @@ -35,15 +35,11 @@ class CoderSettingsStoreTest { @Test fun `Default CLI and signature for Windows AMD64`() = - assertBinaryAndSignature("Windows 10", "amd64", "coder-windows-amd64.exe", "coder-windows-amd64.asc") + assertBinaryAndSignature("Windows 10", "amd64", "coder-windows-amd64.exe", "coder-windows-amd64.exe.asc") @Test fun `Default CLI and signature for Windows ARM64`() = - assertBinaryAndSignature("Windows 10", "aarch64", "coder-windows-arm64.exe", "coder-windows-arm64.asc") - - @Test - fun `Default CLI and signature for Windows ARMV7`() = - assertBinaryAndSignature("Windows 10", "armv7l", "coder-windows-armv7.exe", "coder-windows-armv7.asc") + assertBinaryAndSignature("Windows 10", "aarch64", "coder-windows-arm64.exe", "coder-windows-arm64.exe.asc") @Test fun `Default CLI and signature for Linux AMD64`() = @@ -65,13 +61,9 @@ class CoderSettingsStoreTest { fun `Default CLI and signature for Mac ARM64`() = assertBinaryAndSignature("Mac OS X", "aarch64", "coder-darwin-arm64", "coder-darwin-arm64.asc") - @Test - fun `Default CLI and signature for Mac ARMV7`() = - assertBinaryAndSignature("Mac OS X", "armv7l", "coder-darwin-armv7", "coder-darwin-armv7.asc") - @Test fun `Default CLI and signature for unknown OS and Arch`() = - assertBinaryAndSignature(null, null, "coder-windows-amd64.exe", "coder-windows-amd64.asc") + assertBinaryAndSignature(null, null, "coder-windows-amd64.exe", "coder-windows-amd64.exe.asc") @Test fun `Default CLI and signature for unknown Arch fallback on Linux`() = pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy