Repository navigation
fix: mask write-only credentials in debug logs [ENG-9372] - #259
Merged
Merged
Conversation
[ENG-9372](https://stacklet.atlassian.net/browse/ENG-9372) ### what at `TF_LOG=DEBUG` or `TRACE` the API client logs whole GraphQL request bodies, including write-only credentials; mask them - mutations that send a credential register it with `tflog.MaskLogStrings` on the request context, through a `maskSecrets` helper that also masks its JSON-encoded form - the logging transport logs through the request's context rather than the one it was built with, so the masking applies (the client no longer takes a context) - covers every write-only credential: account and binding security contexts, Azure and GCP discovery credentials, the Datadog keys, repository auth, and the Email, Jira, ServiceNow, Slack and Symphony profiles #257 adds the Anthropic integration's admin key; whichever of the two lands second adds `ctx = maskSecrets(ctx, input.AdminKey)` to its upsert ### why debug logs are often shared when reporting problems, and shouldn't carry credentials ### testing unit test capturing the provider's debug logs for a Datadog update, asserting both keys appear only masked, including one JSON-encoding escapes; existing tests pass ### docs none needed
There was a problem hiding this comment.
No issues found across 11 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Provider as Terraform Provider
participant API as API Client (api package)
participant Mask as maskSecrets Helper
participant LogCtx as Request Context with Log Masking
participant Transport as logTransport
participant HTTP as HTTP Transport
participant Server as GraphQL API Server
participant Logs as Debug Logs
Note over Provider,Server: Credential Masking in Debug Logs Flow
Provider->>API: Call mutation (e.g., Datadog Update)
API->>API: Build GraphQL mutation with input
Note over API,Mask: NEW: Register secrets for masking
API->>Mask: maskSecrets(ctx, secrets...)
Mask->>Mask: Check nil/empty secrets
alt Has secrets to mask
Mask->>Mask: JSON-encode each secret
Mask->>Mask: Collect raw + encoded values
Mask->>LogCtx: Create tflog.MaskLogStrings context
LogCtx-->>API: Return masked context
else No secrets to mask
Mask-->>API: Return original context
end
API->>API: Assign masked context to request
API->>Transport: Mutate(maskedCtx, mutation, variables)
Transport->>Transport: Log request with masked context
LogCtx->>Transport: Apply masking rules
Transport->>HTTP: Send HTTP request
HTTP->>Server: GraphQL request with credentials
Server-->>HTTP: GraphQL response
HTTP-->>Transport: Return response
Transport->>Transport: Log response with masked context
LogCtx->>Transport: Apply masking rules
Note over Transport,Logs: NEW: Credentials appear as "***"
Transport->>Logs: Write debug log entries
Logs-->>Logs: Masked request/response bodies
Transport-->>API: Return response
API-->>Provider: Return result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ENG-9372
what
at
TF_LOG=DEBUGorTRACEthe API client logs whole GraphQL request bodies, including write-only credentials; mask themtflog.MaskLogStringson the request context, through amaskSecretshelper that also masks its JSON-encoded form#257 adds the Anthropic integration's admin key; whichever of the two lands second adds
ctx = maskSecrets(ctx, input.AdminKey)to its upsertwhy
debug logs are often shared when reporting problems, and shouldn't carry credentials
testing
unit test capturing the provider's debug logs for a Datadog update, asserting both keys appear only masked, including one JSON-encoding escapes; existing tests pass
docs
none needed