-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cloudflare: move HTTP request debugging to httputil
#1164
cloudflare: move HTTP request debugging to httputil
#1164
Conversation
Within the library, we provide a way to output the HTTP interactions that the library makes. We previously used a custom approach and format the output. Even though it works, there are better approaches using `httputil.DumpRequestOut` and `httputil.DumpResponseOut` for dumping the HTTP interactions. Alongside this work, we're adding support for redacting sensitive values in the HTTP interactions. This is useful for both this library and the consumers of this library (like the Terraform Provider) to prevent leaking sensitive information in logs. Closes cloudflare#1143
09e67f6
to
fdc3a7d
Compare
changelog detected ✅ |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1164 +/- ##
==========================================
- Coverage 49.40% 49.28% -0.13%
==========================================
Files 127 128 +1
Lines 12290 12416 +126
==========================================
+ Hits 6072 6119 +47
- Misses 4840 4896 +56
- Partials 1378 1401 +23 ☔ View full report in Codecov by Sentry. |
This functionality has been released in v0.58.1. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
As of cloudflare/cloudflare-go#1164 we have the ability to use the inbuilt logger for redacting sensitive HTTP headers. Previously, we were discarding the provided logger due to instantiating a new `cleanhttp` client to use however, with this change we are now using the cloudflare-go logger for HTTP interactions inside the Terraform Core sink. By default we redact the values found in the following HTTP headers (not the headers themselves) in the entire HTTP interaction: - `X-Auth-Email` - `X-Auth-Key` - `X-Auth-User-Service-Key` - `Authorization` And here is an example of the logger in action for `TF_LOG=DEBUG`. ``` 2023-01-05T06:49:41.208221+11:00 [DEBUG] cloudflare GET /client/v4/zones/0da42c8d2132a9ddaf714f9e7c920711/access/apps/dec500cc-4eb3-4c64-b10d-1fce8f686339 HTTP/1.1 Host: api.cloudflare.com User-Agent: terraform/1.3.6 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/dev Content-Type: application/json X-Auth-Email: [redacted] X-Auth-Key: [redacted] Accept-Encoding: gzip 2023-01-05T06:49:41.208221+11:00 [DEBUG] cloudflare HTTP/1.1 200 OK Transfer-Encoding: chunked Cf-Cache-Status: DYNAMIC Cf-Ray: 78467fb52e4baaf9-SYD Connection: keep-alive ... { "result": { "id": "dec500cc-4eb3-4c64-b10d-1fce8f686339", "uid": "dec500cc-4eb3-4c64-b10d-1fce8f686339", // .. "http_only_cookie_attribute": false }, "success": true, "errors": [], "messages": [] } ```
Within the library, we provide a way to output the HTTP interactions that the library makes. We previously used a custom approach and format the output. Even though it works, there are better approaches using
httputil.DumpRequestOut
andhttputil.DumpResponseOut
for dumping the HTTP interactions.Alongside this work, we're adding support for redacting sensitive values in the HTTP interactions. This is useful for both this library and the consumers of this library (like the Terraform Provider) to prevent leaking sensitive information in logs.
Closes #1143