Skip to content

Commit 4ec4832

Browse files
committed
Trim dead sensitive-logging wrappers and document scope
1 parent fcd54ce commit 4ec4832

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

‎client/src/main/java/org/asynchttpclient/netty/handler/HttpMessageFormatter.java‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
*/
3131
public final class HttpMessageFormatter {
3232

33-
/** The value used in place of sensitive header values. */
34-
public static final String REDACTED = SensitiveLoggingUtils.REDACTED;
35-
3633
private HttpMessageFormatter() {
3734
}
3835

@@ -54,18 +51,8 @@ static String format(HttpResponse response) {
5451
private static StringBuilder appendHeaders(StringBuilder value, HttpHeaders headers) {
5552
for (Map.Entry<String, String> header : headers) {
5653
value.append('\n').append(header.getKey()).append(": ")
57-
.append(isSensitiveHeader(header.getKey()) ? REDACTED : header.getValue());
54+
.append(SensitiveLoggingUtils.isSensitiveHeader(header.getKey()) ? SensitiveLoggingUtils.REDACTED : header.getValue());
5855
}
5956
return value;
6057
}
61-
62-
/**
63-
* Returns whether a header value must be redacted from logs.
64-
*
65-
* @param name the header name
66-
* @return {@code true} for authentication and cookie headers when sensitive logging is disabled
67-
*/
68-
public static boolean isSensitiveHeader(CharSequence name) {
69-
return SensitiveLoggingUtils.isSensitiveHeader(name);
70-
}
7158
}

‎client/src/main/java/org/asynchttpclient/netty/request/NettyRequest.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
2323

24+
// Deliberately no toString() override: NettyResponseFuture#toString renders this object via
25+
// Object.toString() so debug logs never include the wrapped httpRequest's headers. Adding a
26+
// toString() here that exposes httpRequest would leak Authorization/Cookie values into logs.
2427
public final class NettyRequest {
2528

2629
@SuppressWarnings("rawtypes")

‎client/src/main/java/org/asynchttpclient/util/SensitiveLoggingUtils.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
* Shared policy for rendering sensitive HTTP headers in logs. The policy is read once from the
2424
* {@code org.asynchttpclient.enableSensitiveLogging} system property or {@code AHC_ENABLE_SENSITIVE_LOGGING} environment
2525
* variable when this class is initialized.
26+
* <p>
27+
* Covers request credential headers only. {@code WWW-Authenticate} and {@code Proxy-Authenticate} response
28+
* challenge headers are logged unredacted, and request form/query/multipart/body values are out of scope since
29+
* they have no reliable generic sensitivity classification.
2630
*/
2731
public final class SensitiveLoggingUtils {
2832

0 commit comments

Comments
 (0)