Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: enforce Content-Type to accept only binary responses#174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fioan89 merged 3 commits intomainfromfix-enforce-content-type-when-downloading-cli
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,10 @@

## Unreleased

### Changed

- content-type is now enforced when downloading the CLI to accept only binary responses

## 0.6.1 - 2025-08-11

### Added
Expand Down
2 changes: 1 addition & 1 deletiongradle.properties
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
version=0.6.1
version=0.6.2
group=com.coder.toolbox
name=coder-toolbox
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,6 +51,13 @@ class CoderDownloadService(

return when (response.code()) {
HTTP_OK -> {
val contentType = response.headers()["Content-Type"]?.lowercase()
if (contentType?.startsWith("application/octet-stream") != true) {
throw ResponseException(
"Invalid content type '$contentType' when downloading CLI from $remoteBinaryURL. Expected application/octet-stream.",
response.code()
)
}
context.logger.info("Downloading binary to temporary $cliTempDst")
response.saveToDisk(cliTempDst, showTextProgress, buildVersion)?.makeExecutable()
DownloadResult.Downloaded(remoteBinaryURL, cliTempDst)
Expand Down
33 changes: 17 additions & 16 deletionssrc/test/kotlin/com/coder/toolbox/cli/CoderCLIManagerTest.kt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -137,6 +137,7 @@ internal class CoderCLIManagerTest {
}

val body = response.toByteArray()
exchange.responseHeaders["Content-Type"] = "application/octet-stream"
exchange.sendResponseHeaders(code, if (code == HttpURLConnection.HTTP_OK) body.size.toLong() else -1)
exchange.responseBody.write(body)
exchange.close()
Expand DownExpand Up@@ -197,11 +198,11 @@ internal class CoderCLIManagerTest {
val ccm = CoderCLIManager(
context.copy(
settingsStore = CoderSettingsStore(
pluginTestSettingsStore(
DATA_DIRECTORY to tmpdir.resolve("cli-dir-fail-to-write").toString(),
),
Environment(),
context.logger
pluginTestSettingsStore(
DATA_DIRECTORY to tmpdir.resolve("cli-dir-fail-to-write").toString(),
),
Environment(),
context.logger
)
),
url
Expand DownExpand Up@@ -307,11 +308,11 @@ internal class CoderCLIManagerTest {
val ccm = CoderCLIManager(
context.copy(
settingsStore = CoderSettingsStore(
pluginTestSettingsStore(
DATA_DIRECTORY to tmpdir.resolve("does-not-exist").toString(),
),
Environment(),
context.logger
pluginTestSettingsStore(
DATA_DIRECTORY to tmpdir.resolve("does-not-exist").toString(),
),
Environment(),
context.logger
)
),
URL("https://foo")
Expand All@@ -329,12 +330,12 @@ internal class CoderCLIManagerTest {
val ccm = CoderCLIManager(
context.copy(
settingsStore = CoderSettingsStore(
pluginTestSettingsStore(
FALLBACK_ON_CODER_FOR_SIGNATURES to "allow",
DATA_DIRECTORY to tmpdir.resolve("overwrite-cli").toString(),
),
Environment(),
context.logger
pluginTestSettingsStore(
FALLBACK_ON_CODER_FOR_SIGNATURES to "allow",
DATA_DIRECTORY to tmpdir.resolve("overwrite-cli").toString(),
),
Environment(),
context.logger
)
),
url
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp