Skip to content

Commit b5ef3df

Browse files
committed
Redact token from logger output
1 parent 10fe47b commit b5ef3df

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
@@ -149,13 +149,16 @@ class CoderCLIManager(deployment: URL, buildVersion: String) {
149149
.readOutput(true)
150150
.execute()
151151
.outputUTF8()
152-
logger.info("`${localBinaryPath} ${listOf(*args).joinToString(" ")}`: $stdout")
152+
val redactedArgs = listOf(*args).joinToString(" ").replace(tokenRegex, "--token <redacted>")
153+
logger.info("`$localBinaryPath $redactedArgs`: $stdout")
153154
return stdout
154155
}
155156

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

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

0 commit comments

Comments
 (0)