Skip to content

Commit a522c74

Browse files
committed
Redact token from logger output
1 parent 9686fee commit a522c74

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/kotlin/com/coder/gateway/sdk/CoderCLIManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,16 @@ class CoderCLIManager(deployment: URL, buildVersion: String) {
150150
.readOutput(true)
151151
.execute()
152152
.outputUTF8()
153-
logger.info("`${localBinaryPath} ${listOf(*args).joinToString(" ")}`: $stdout")
153+
val redactedArgs = listOf(*args).joinToString(" ").replace(tokenRegex, "--token <redacted>")
154+
logger.info("`$localBinaryPath $redactedArgs`: $stdout")
154155
return stdout
155156
}
156157

157158
companion object {
158159
val logger = Logger.getInstance(CoderCLIManager::class.java.simpleName)
159160

161+
private val tokenRegex = "--token [^ ]+".toRegex()
162+
160163
/**
161164
* Return the URL and token from the CLI config.
162165
*/

0 commit comments

Comments
 (0)