Skip to content

Commit ce7e1d2

Browse files
chore: redact api-key headers in debug logs
1 parent aa7ad0c commit ce7e1d2

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

stagehand-java-core/src/main/kotlin/com/browserbase/api/core/http/LoggingHttpClient.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ private constructor(
3131
/**
3232
* Sensitive headers to redact from logs.
3333
*
34-
* Defaults to `Set.of("x-bb-api-key", "x-bb-project-id", "x-model-api-key")`.
34+
* Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie",
35+
* "x-bb-api-key", "x-bb-project-id", "x-model-api-key")`.
3536
*/
3637
@get:JvmName("redactedHeaders") val redactedHeaders: SortedSet<String>,
3738
/**
@@ -193,7 +194,16 @@ private constructor(
193194

194195
private var httpClient: HttpClient? = null
195196
private var redactedHeaders: Set<String> =
196-
setOf("x-bb-api-key", "x-bb-project-id", "x-model-api-key")
197+
setOf(
198+
"authorization",
199+
"api-key",
200+
"x-api-key",
201+
"cookie",
202+
"set-cookie",
203+
"x-bb-api-key",
204+
"x-bb-project-id",
205+
"x-model-api-key",
206+
)
197207
private var clock: Clock = Clock.systemUTC()
198208
private var level: LogLevel? = null
199209

@@ -211,7 +221,8 @@ private constructor(
211221
/**
212222
* Sensitive headers to redact from logs.
213223
*
214-
* Defaults to `Set.of("x-bb-api-key", "x-bb-project-id", "x-model-api-key")`.
224+
* Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie",
225+
* "x-bb-api-key", "x-bb-project-id", "x-model-api-key")`.
215226
*/
216227
fun redactedHeaders(redactedHeaders: Set<String>) = apply {
217228
this.redactedHeaders = redactedHeaders

stagehand-java-core/src/test/kotlin/com/browserbase/api/core/http/LoggingHttpClientTest.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,17 @@ internal class LoggingHttpClientTest {
870870
httpClient: HttpClient,
871871
level: LogLevel,
872872
clock: Clock = clockFrom(Instant.parse("1998-04-21T00:00:00Z")),
873-
redactedHeaders: Set<String> = setOf("x-bb-api-key", "x-bb-project-id", "x-model-api-key"),
873+
redactedHeaders: Set<String> =
874+
setOf(
875+
"authorization",
876+
"api-key",
877+
"x-api-key",
878+
"cookie",
879+
"set-cookie",
880+
"x-bb-api-key",
881+
"x-bb-project-id",
882+
"x-model-api-key",
883+
),
874884
): LoggingHttpClient =
875885
LoggingHttpClient.builder()
876886
.httpClient(httpClient)

0 commit comments

Comments
 (0)