Skip to content

fix(storage): format sign-blob output fields - #16720

Open
nidhiii-27 wants to merge 2 commits into
mainfrom
fix/storage-sign-blob-stream-formatting
Open

nidhiii-27 wants to merge 2 commits into
mainfrom
fix/storage-sign-blob-stream-formatting

Conversation

@nidhiii-27

@nidhiii-27 nidhiii-27 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

SignBlobRequest and SignBlobResponse stream insertion operators, AsyncAccessTokenGeneratorLogging::SignBlob, and LoggingCredentials::SignBlob format blob payload and signed-blob fields as [censored], and RestStub builds iam_rest_client_ and the SignBlob request context through a logging-component filter that preserves other options and request headers. Other formatted fields (service_account, delegates, name, key_id, and signing_service_account), storage_rest_client_ configuration, HTTP response parsing, and signing behavior remain unchanged. Updated and added unit tests in google/cloud/storage/internal/sign_blob_requests_test.cc, google/cloud/internal/minimal_iam_credentials_stub_test.cc, google/cloud/internal/oauth2_logging_credentials_test.cc, google/cloud/storage/internal/logging_stub_test.cc, and google/cloud/storage/internal/rest/stub_test.cc.

SignBlobRequest and SignBlobResponse stream insertion operators now format base64_encoded_blob and signed_blob as [censored], and AsyncAccessTokenGeneratorLogging::SignBlob formats payload and signed_blob with [censored]. Other formatted fields (service_account, delegates, name, and key_id), HTTP response parsing, and signing behavior remain unchanged. Updated google/cloud/storage/internal/sign_blob_requests_test.cc and google/cloud/internal/minimal_iam_credentials_stub_test.cc to verify the formatted output.

[Generated-by: AI]
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces censoring for sensitive fields in SignBlob requests and responses to prevent leaking payloads and signed blobs in logs. Specifically, it replaces the generic LogWrapper with manual logging in MinimalIamCredentialsStub::SignBlob and updates the stream operators for SignBlobRequest and SignBlobResponse to output [censored] for sensitive fields. Corresponding unit tests have been updated and added to verify this behavior. I have no additional feedback to provide as the changes are correct and follow the repository's style guidelines.

@nidhiii-27 nidhiii-27 added the storage-bug-immunity Generated by storage-bug-immunity skill label Nov 29, 2026
@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.79%. Comparing base (4a2bfb0) to head (9adf3dc).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #16720    +/-   ##
========================================
  Coverage   92.78%   92.79%            
========================================
  Files        2277     2277            
  Lines      228147   228265   +118     
========================================
+ Hits       211696   211828   +132     
+ Misses      16451    16437    -14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 29, 2026 17:56
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 29, 2026 17:56

@kalragauri kalragauri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few additional findings:

  1. When "auth" logging is enabled, Client::SignBlobImpl also invokes LoggingCredentials::SignBlob, which currently formats string_to_sign with DebugString(...) rather than [censored]. That path runs both for local signing and before falling back to the IAM SignBlob RPC. Should we format string_to_sign as [censored] there as well (in this PR or a follow-up) so all sign-blob log entries are consistent?
  2. With "http" logging enabled, RestStub::SignBlob still logs the first 128 bytes of the JSON request and response bodies through DebugOutData and DebugInData. Both iam_rest_client_ and the RestContext merged in CurlRestClient::Post currently retain "http". Is disabling "http" logging for iam_rest_client_ planned for a follow-up PR, or should it be handled here?
  3. LoggingStub::SignBlob is the main caller of the updated SignBlobRequest and SignBlobResponse stream operators, but logging_stub_test.cc does not currently cover SignBlob. Consider adding a SignBlob test there verifying the logged [censored] fields and that the returned SignBlobResponse is unchanged.

LoggingCredentials::SignBlob formats string_to_sign as [censored], and RestStub builds iam_rest_client_ and the SignBlob request context through a logging-component filter that preserves other options and request headers. Signing behavior, storage_rest_client_ configuration, and all other storage operations remain unchanged. Added and updated unit tests in oauth2_logging_credentials_test.cc, minimal_iam_credentials_stub_test.cc, logging_stub_test.cc, and rest/stub_test.cc.

[Generated-by: AI]
@nidhiii-27

Copy link
Copy Markdown
Contributor Author

Re: feedback from @kalragauri

Done — addressed all three items in commit 9adf3dc:

  1. Updated LoggingCredentials::SignBlob to format string_to_sign=[censored] and updated oauth2_logging_credentials_test.cc to verify the formatted log line and returned signature bytes.
  2. Added RestStub::MakeIamRestClientOptions and a filtered RestContext in RestStub::SignBlob so iam_rest_client_ omits the HTTP-wire logging component while preserving other options and request headers, with unit tests in google/cloud/storage/internal/rest/stub_test.cc.
  3. Added LoggingStubTest.SignBlob in google/cloud/storage/internal/logging_stub_test.cc verifying the formatted request/response logs and unchanged SignBlobResponse.

Co-authored by AI Agent

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated api: storage Issues related to the Cloud Storage API. storage-bug-immunity Generated by storage-bug-immunity skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants