Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions sdk/clientcore/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features Added

- Added `azure-deprecating` to the default allowed (unsanitized) HTTP response header list so it is logged without redaction.

### Breaking Changes
- Changed `HttpRetryOptions.delayFromHeaders` to `HttpRetryOptions.delayFromRetryCondition`. The `Function` is now a
`Function<HttpRetryCondition, Duration>` instead of `Function<HttpHeaders, Duration>`. This allows richer inspection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public boolean equals(Object obj) {
*/
public static final HttpHeaderName AUTHORIZATION = fromString("Authorization");

/**
* {@code azure-deprecating}
*/
public static final HttpHeaderName AZURE_DEPRECATING = fromString("azure-deprecating");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clientcore is meant to be agnostic of underlying services it's calling, shouldn't have an Azure-based header here.


/**
* {@code Cache-Control}/{@code cache-control}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public final class HttpInstrumentationOptions extends InstrumentationOptions {
HttpHeaderName.ETAG, HttpHeaderName.EXPIRES, HttpHeaderName.IF_MATCH, HttpHeaderName.IF_MODIFIED_SINCE,
HttpHeaderName.IF_NONE_MATCH, HttpHeaderName.IF_UNMODIFIED_SINCE, HttpHeaderName.LAST_MODIFIED,
HttpHeaderName.PRAGMA, HttpHeaderName.RETRY_AFTER, HttpHeaderName.SERVER, HttpHeaderName.TRANSFER_ENCODING,
HttpHeaderName.USER_AGENT, HttpHeaderName.WWW_AUTHENTICATE);
HttpHeaderName.USER_AGENT, HttpHeaderName.WWW_AUTHENTICATE, HttpHeaderName.AZURE_DEPRECATING);

static final HttpLogLevel ENVIRONMENT_HTTP_LOG_LEVEL
= HttpLogLevel.fromConfiguration(Configuration.getGlobalConfiguration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public HttpInstrumentationLoggingTests() {
this.logCaptureStream = new AccessibleByteArrayOutputStream();
}

@Test
public void defaultAllowlistContainsAzureDeprecating() {
assertTrue(new HttpInstrumentationOptions().getAllowedHeaderNames().contains(HttpHeaderName.AZURE_DEPRECATING),
"azure-deprecating should be in the default headers allowlist");
}

@ParameterizedTest
@MethodSource("disabledHttpLoggingSource")
public void testDisabledHttpLogging(LogLevel logLevel, HttpInstrumentationOptions.HttpLogLevel detailLevel)
Expand Down
1 change: 1 addition & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features Added

- Added `azure-deprecating` to the default allowed (unsanitized) HTTP response header list so it is logged without redaction. ([#XXXXX](https://github.com/Azure/azure-sdk-for-java/pull/XXXXX))
- Promoted `AccessTokenCache` to a public API in the `com.azure.core.credential` package. This class provides a thread-safe, proactively refreshing token cache that wraps a `TokenCredential`, supporting both synchronous and asynchronous token retrieval.

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ public boolean equals(Object obj) {
*/
public static final HttpHeaderName AZURE_ASYNCOPERATION = fromString("Azure-AsyncOperation");

/**
* {@code azure-deprecating}
*/
public static final HttpHeaderName AZURE_DEPRECATING = fromString("azure-deprecating");

/**
* {@code Cache-Control}/{@code cache-control}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public class HttpLogOptions {
private static final String INVALID_APPLICATION_ID_LENGTH
= "'applicationId' length cannot be greater than " + MAX_APPLICATION_ID_LENGTH;
private static final String INVALID_APPLICATION_ID_SPACE = "'applicationId' cannot contain spaces.";
static final Set<HttpHeaderName> DEFAULT_HEADERS_ALLOWLIST
= Collections.unmodifiableSet(new HashSet<>(Arrays.asList(HttpHeaderName.X_MS_REQUEST_ID,
HttpHeaderName.X_MS_CLIENT_REQUEST_ID, X_MS_RETURN_CLIENT_REQUEST_ID, HttpHeaderName.TRACEPARENT, MS_CV,
HttpHeaderName.ACCEPT, HttpHeaderName.CACHE_CONTROL, HttpHeaderName.CONNECTION,
HttpHeaderName.CONTENT_LENGTH, HttpHeaderName.DATE, HttpHeaderName.ETAG, HttpHeaderName.EXPIRES,
HttpHeaderName.IF_MATCH, HttpHeaderName.IF_MODIFIED_SINCE, HttpHeaderName.IF_NONE_MATCH,
HttpHeaderName.IF_UNMODIFIED_SINCE, HttpHeaderName.LAST_MODIFIED, HttpHeaderName.PRAGMA, REQUEST_ID,
HttpHeaderName.RETRY_AFTER, HttpHeaderName.RETRY_AFTER_MS, HttpHeaderName.SERVER,
HttpHeaderName.TRANSFER_ENCODING, HttpHeaderName.USER_AGENT, HttpHeaderName.WWW_AUTHENTICATE)));
static final Set<HttpHeaderName> DEFAULT_HEADERS_ALLOWLIST = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(HttpHeaderName.X_MS_REQUEST_ID, HttpHeaderName.X_MS_CLIENT_REQUEST_ID,
X_MS_RETURN_CLIENT_REQUEST_ID, HttpHeaderName.TRACEPARENT, MS_CV, HttpHeaderName.ACCEPT,
HttpHeaderName.CACHE_CONTROL, HttpHeaderName.CONNECTION, HttpHeaderName.CONTENT_LENGTH, HttpHeaderName.DATE,
HttpHeaderName.ETAG, HttpHeaderName.EXPIRES, HttpHeaderName.IF_MATCH, HttpHeaderName.IF_MODIFIED_SINCE,
HttpHeaderName.IF_NONE_MATCH, HttpHeaderName.IF_UNMODIFIED_SINCE, HttpHeaderName.LAST_MODIFIED,
HttpHeaderName.PRAGMA, REQUEST_ID, HttpHeaderName.RETRY_AFTER, HttpHeaderName.RETRY_AFTER_MS,
HttpHeaderName.SERVER, HttpHeaderName.TRANSFER_ENCODING, HttpHeaderName.USER_AGENT,
HttpHeaderName.WWW_AUTHENTICATE, HttpHeaderName.AZURE_DEPRECATING)));

static final List<String> DEFAULT_QUERY_PARAMS_ALLOWLIST = Collections.singletonList("api-version");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.azure.core.http.policy;

import com.azure.core.http.HttpHeaderName;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -35,4 +36,10 @@ public void testSetApplicationId() {
public void testSetPrettyPrintBody() {
assertTrue(new HttpLogOptions().setPrettyPrintBody(true).isPrettyPrintBody());
}

@Test
public void defaultAllowlistContainsAzureDeprecating() {
assertTrue(HttpLogOptions.DEFAULT_HEADERS_ALLOWLIST.contains(HttpHeaderName.AZURE_DEPRECATING),
"azure-deprecating should be in the default headers allowlist");
}
Comment on lines +40 to +44
}
Loading