Skip to content

Mask credentials in debug output and config commands - #368

Open
baiyuqing wants to merge 3 commits into
mainfrom
fix/redact-debug-logging
Open

baiyuqing wants to merge 3 commits into
mainfrom
fix/redact-debug-logging

Conversation

@baiyuqing

Copy link
Copy Markdown

Problem

Debug mode (--debug / TICLOUD_DEBUG) dumped full HTTP requests and responses. The dump contained:

  • the Authorization header (Bearer token, Digest metadata)
  • OAuth access/refresh tokens and the OAuth client secret in auth login / auth logout bodies
  • cloud storage access keys, service account keys and SAS tokens in import / export / audit-log request bodies
  • pre-signed URL signatures and file content in the S3 uploader and export download paths

config describe printed private-key, oauth-client-secret and access-token (with --insecure-storage). config set echoed the value of private-key and oauth-client-secret.

Change

  • New package internal/redact: one masking implementation for headers, JSON body fields, pre-signed URL query parameters and profile properties, plus a DebugTransport that prints masked dumps. Non-JSON bodies (uploads, downloads) are not read; only their size is printed.
  • cloud.NewDebugTransport delegates to it (covers Bearer and Digest API clients).
  • auth login/logout/whoami, the S3 uploader and the export download helper wrap their existing transport with it instead of calling resty SetDebug.
  • config describe masks private-key, oauth-client-secret, access-token. public-key stays visible.
  • config set prints *** for private-key and oauth-client-secret.
  • Generated v1beta1 clients: the latent cfg.Debug dump passes body=false. Auth headers are added below that layer, so the remaining dump carries no credentials. This is a mechanical patch of generated files; a regeneration would revert it, but transport-level masking still applies.

Behavior notes

  • Debug output for the three auth commands, uploader and download now goes to stdout through the shared transport instead of resty's stderr logger. Non-debug behavior is unchanged.
  • --debug still prints method, URL, headers, status and JSON bodies, with only credential fields replaced by ***.

Tests

  • Existing config describe/set and root_test.go expectations updated for the mask.
  • New internal/redact/redact_test.go sends a request with a bearer token, cloud AKSK body, pre-signed URL parameters and a Set-Cookie response through the dumper and asserts none of them appear in the output while request and response bodies remain readable.
  • go build ./..., go vet ./..., go test ./... pass.

Debug mode (--debug / TICLOUD_DEBUG) dumped full HTTP requests and
responses, including the Authorization header, OAuth access/refresh
tokens, the OAuth client secret, cloud storage access keys and SAS
tokens in import/export/audit-log request bodies, and pre-signed URL
signatures. config describe printed private-key, oauth-client-secret
and access-token, and config set echoed the value of private-key and
oauth-client-secret.

Add internal/redact with one masking implementation for headers, JSON
body fields, pre-signed URL query parameters and profile properties,
plus a DebugTransport that prints masked dumps. Non-JSON bodies (file
uploads, export downloads) are not read; only their size is printed.

Route every debug path through it:
- cloud.NewDebugTransport (Bearer and Digest API clients)
- resty clients in auth login/logout/whoami, the S3 uploader and the
  export download helper (replaces resty SetDebug)
- config describe masks private-key, oauth-client-secret, access-token
- config set prints *** for private-key and oauth-client-secret
- generated v1beta1 clients no longer include bodies in the cfg.Debug
  dump

Add internal/redact tests that assert a bearer token, cloud AKSK, SAS
token, pre-signed URL signature and Set-Cookie value do not appear in
the dump while request and response bodies remain readable.
@ti-chi-bot ti-chi-bot Bot added the size/XL label Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant