82 строки
2.8 KiB
Diff
82 строки
2.8 KiB
Diff
From 900f7e0532332e4efbce65a3b35ce28c1fd89369 Mon Sep 17 00:00:00 2001
|
|
From: Balakumaran Kannan <kumaran.4353@gmail.com>
|
|
Date: Thu, 1 Aug 2024 12:27:25 +0000
|
|
Subject: [PATCH] Patch CVE-2024-6104
|
|
|
|
---
|
|
.../hashicorp/go-retryablehttp/client.go | 28 ++++++++++++++-----
|
|
1 file changed, 21 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/vendor/github.com/hashicorp/go-retryablehttp/client.go b/vendor/github.com/hashicorp/go-retryablehttp/client.go
|
|
index adbdd92..11d146a 100644
|
|
--- a/vendor/github.com/hashicorp/go-retryablehttp/client.go
|
|
+++ b/vendor/github.com/hashicorp/go-retryablehttp/client.go
|
|
@@ -546,9 +546,9 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
|
|
if logger != nil {
|
|
switch v := logger.(type) {
|
|
case LeveledLogger:
|
|
- v.Debug("performing request", "method", req.Method, "url", req.URL)
|
|
+ v.Debug("performing request", "method", req.Method, "url", redactURL(req.URL))
|
|
case Logger:
|
|
- v.Printf("[DEBUG] %s %s", req.Method, req.URL)
|
|
+ v.Printf("[DEBUG] %s %s", req.Method, redactURL(req.URL))
|
|
}
|
|
}
|
|
|
|
@@ -599,9 +599,9 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
|
|
if doErr != nil {
|
|
switch v := logger.(type) {
|
|
case LeveledLogger:
|
|
- v.Error("request failed", "error", doErr, "method", req.Method, "url", req.URL)
|
|
+ v.Error("request failed", "error", doErr, "method", req.Method, "url", redactURL(req.URL))
|
|
case Logger:
|
|
- v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, doErr)
|
|
+ v.Printf("[ERR] %s %s request failed: %v", req.Method, redactURL(req.URL), doErr)
|
|
}
|
|
} else {
|
|
// Call this here to maintain the behavior of logging all requests,
|
|
@@ -636,7 +636,7 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
|
|
}
|
|
|
|
wait := c.Backoff(c.RetryWaitMin, c.RetryWaitMax, i, resp)
|
|
- desc := fmt.Sprintf("%s %s", req.Method, req.URL)
|
|
+ desc := fmt.Sprintf("%s %s", req.Method, redactURL(req.URL))
|
|
if code > 0 {
|
|
desc = fmt.Sprintf("%s (status: %d)", desc, code)
|
|
}
|
|
@@ -687,11 +687,11 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
|
|
// communicate why
|
|
if err == nil {
|
|
return nil, fmt.Errorf("%s %s giving up after %d attempt(s)",
|
|
- req.Method, req.URL, attempt)
|
|
+ req.Method, redactURL(req.URL), attempt)
|
|
}
|
|
|
|
return nil, fmt.Errorf("%s %s giving up after %d attempt(s): %w",
|
|
- req.Method, req.URL, attempt, err)
|
|
+ req.Method, redactURL(req.URL), attempt, err)
|
|
}
|
|
|
|
// Try to read the response body so we can reuse this connection.
|
|
@@ -772,3 +772,17 @@ func (c *Client) StandardClient() *http.Client {
|
|
Transport: &RoundTripper{Client: c},
|
|
}
|
|
}
|
|
+
|
|
+
|
|
+// Taken from url.URL#Redacted() which was introduced in go 1.15.
|
|
+func redactURL(u *url.URL) string {
|
|
+ if u == nil {
|
|
+ return ""
|
|
+ }
|
|
+
|
|
+ ru := *u
|
|
+ if _, has := ru.User.Password(); has {
|
|
+ ru.User = url.UserPassword(ru.User.Username(), "xxxxx")
|
|
+ }
|
|
+ return ru.String()
|
|
+}
|
|
--
|
|
2.33.8
|
|
|