Skip to content

SYN-6783: redact sensitive fields in response and error debug details - #51

Draft
jcsco wants to merge 1 commit into
v2from
SYN-6783-redact-response-error-debug
Draft

SYN-6783: redact sensitive fields in response and error debug details#51
jcsco wants to merge 1 commit into
v2from
SYN-6783-redact-response-error-debug

Conversation

@jcsco

@jcsco jcsco commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up from SYN-6770 / SYN-5524: RequestDetails.ResponseBody and API error responses from makePublicAPICall previously carried sensitive fields (secrets, certificate content, passwords) with no redaction, unlike RequestBody which is already sanitized.
  • Adds RequestDetails.SanitizedResponseBody, a redacted copy of the response body for debug/logging use, reusing the existing redactSensitiveJSONFields/sensitiveJSONFieldNames machinery.
  • Redacts the error path's marshaled errorResponse.Details map before it's embedded in the returned error string.
  • Note on scope: the raw ResponseBody field is intentionally left unredacted, because every parse*Response(details.ResponseBody) call site unmarshals that exact string into typed structs that back Terraform state (e.g. Variable.Value, TotpVariable.Secret, ClientCertificatePrivateKey.Content/Password). Redacting it in place would silently corrupt real values returned to callers — non-secret Variable.Value has no fallback at all, and TOTP/certificate secrets already rely on the API's own "<REDACTED>" sentinel plus provider-side fallback logic (totpVariableSecretForState, stateOrAPISecret, caCertificateContentForState) that expects that exact marker. A new [REDACTED] marker written into the parsed value would defeat that fallback and persist the literal string into state. Redacting only the new debug-only copy avoids that regression while still hardening what gets logged/surfaced in errors.

Test plan

  • go build -tags=unit_tests ./...
  • go test ./syntheticsclientv2/... -tags=unit_tests -timeout=30s -parallel=8 -cover — all existing + new tests pass, coverage 73.6% → 73.8%
  • Added TestMakePublicAPICallRedactsSensitiveFieldsInSanitizedResponseBody, TestMakePublicAPICallSanitizedResponseBodyHandlesEmptyAndMalformedBodies, TestMakePublicAPICallRedactsErrorResponseDetails
  • golangci-lint not available in this environment; go vet ./... and gofmt -l . are clean

🤖 Generated with Claude Code

RequestDetails.ResponseBody and error responses from makePublicAPICall
previously passed sensitive API response fields (secrets, certificate
content, passwords) through with no redaction. Add a sanitized copy of
the response body for debug purposes and redact the error path's
Details map, while leaving the raw ResponseBody untouched so existing
parse*Response call sites keep unmarshaling real values into typed
structs and Terraform state.

Co-Authored-By: Claude <noreply@anthropic.com>
@jcsco jcsco self-assigned this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant