Repository navigation
fix(common): make encryption key header output consistent with CreateHmacKeyResponse - #16725
kalragauri wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces changes to censor sensitive customer-supplied encryption keys (x-goog-encryption-key and x-goog-copy-source-encryption-key) in both curl debug logs and OpenTelemetry span attributes. Specifically, it adds helper functions in curl_wrappers.cc and rest_opentelemetry.cc to identify and replace these header values with [censored], and includes comprehensive unit tests in curl_wrappers_test.cc and rest_opentelemetry_test.cc to verify correct behavior across various formats (such as HTTP/2 and HTTP/3 bracketed traces). The implementation is clean, conforms to the repository's C++17 style guidelines, and I have no further feedback or changes to suggest.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16725 +/- ##
==========================================
+ Coverage 92.78% 92.80% +0.01%
==========================================
Files 2279 2279
Lines 228396 228572 +176
==========================================
+ Hits 211921 212117 +196
+ Misses 16475 16455 -20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f922d71 to
fa847b4
Compare
scotthart
left a comment
There was a problem hiding this comment.
The changes in curl_wrappers.cc and rest_opentelemetry.cc look very clean, and the unit test coverage for line endings, bracketed HTTP/2 & HTTP/3 traces, sibling headers, and Bearer ordering is thorough.
One gap to address before merging:
-
Missing redaction in
EndResponseSpan(google/cloud/internal/tracing_rest_client.cc:72-89):
WrappedRequestcallsMakeSpanHttp(request, method)and thenEndResponseSpan(std::move(span), context, ...), which also setshttp.request.header.<name>attributes on the same span fromcontext.headers().EndResponseSpanalready censorsauthorizationandx-goog-api-key(tested inTracingRestClient.CensorsAuthFields), but does not redactx-goog-encryption-keyorx-goog-copy-source-encryption-key. Any caller supplying these headers viaRestContext::AddHeaderorCustomHeadersOption(viarest_internal::SetMetadata) will still record the plaintext key on the span (and overwriteMakeSpanHttp's[censored]value if set in both). Could we shareIsCensoredHeader(or a small helper inrest_opentelemetry.{h,cc}) betweenMakeSpanHttpandEndResponseSpan, and add a test case ingoogle/cloud/internal/tracing_rest_client_test.cc? -
Optional nit (
google/cloud/internal/http_header.cc:64-72):
HttpHeader::DebugString()currently truncates all values to 10 characters. It's only called for duplicateauthorization/content-lengthheaders inCurlImpl::MergeAndWriteHeaderstoday so there's no active leak, but returning[censored]for encryption key headers there too could be nice defense-in-depth.
Thanks - done. Shared |
MakeSpanHttp,TracingRestClient,HttpHeader::DebugString, and the curl debug formattersDebugSendHeaderandDebugInfonow use[censored]for the values of thex-goog-encryption-keyandx-goog-copy-source-encryption-keyheaders, the same placeholderCreateHmacKeyResponseuses. Sibling headers such asx-goog-encryption-key-sha256andx-goog-encryption-algorithm, the existingauthorizationtruncation, and the headers sent on the wire are unchanged.