mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
chore: fix deprecated ioutil nopcloser (#27650)
Signed-off-by: idnandre <andre@idntimes.com>
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
@@ -77,13 +76,13 @@ func (r *Request) ToHTTP() (*http.Request, error) {
|
||||
// No body
|
||||
|
||||
case r.BodyBytes != nil:
|
||||
req.Request.Body = ioutil.NopCloser(bytes.NewReader(r.BodyBytes))
|
||||
req.Request.Body = io.NopCloser(bytes.NewReader(r.BodyBytes))
|
||||
|
||||
default:
|
||||
if c, ok := r.Body.(io.ReadCloser); ok {
|
||||
req.Request.Body = c
|
||||
} else {
|
||||
req.Request.Body = ioutil.NopCloser(r.Body)
|
||||
req.Request.Body = io.NopCloser(r.Body)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -44,7 +43,7 @@ func (r *Response) Error() error {
|
||||
}
|
||||
|
||||
r.Body.Close()
|
||||
r.Body = ioutil.NopCloser(bodyBuf)
|
||||
r.Body = io.NopCloser(bodyBuf)
|
||||
ns := r.Header.Get(NamespaceHeaderName)
|
||||
|
||||
// Build up the error object
|
||||
|
||||
3
command/agentproxyshared/cache/handler.go
vendored
3
command/agentproxyshared/cache/handler.go
vendored
@@ -11,7 +11,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
@@ -218,7 +217,7 @@ func sanitizeAutoAuthTokenResponse(ctx context.Context, logger hclog.Logger, inm
|
||||
if resp.Response.Body != nil {
|
||||
resp.Response.Body.Close()
|
||||
}
|
||||
resp.Response.Body = ioutil.NopCloser(bytes.NewReader(bodyBytes))
|
||||
resp.Response.Body = io.NopCloser(bytes.NewReader(bodyBytes))
|
||||
resp.Response.ContentLength = int64(len(bodyBytes))
|
||||
|
||||
// Serialize and re-read the response
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"mime"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -313,7 +312,7 @@ func (w *copyResponseWriter) WriteHeader(code int) {
|
||||
func handleAuditNonLogical(core *vault.Core, h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
origBody := new(bytes.Buffer)
|
||||
reader := ioutil.NopCloser(io.TeeReader(r.Body, origBody))
|
||||
reader := io.NopCloser(io.TeeReader(r.Body, origBody))
|
||||
r.Body = reader
|
||||
req, _, status, err := buildLogicalRequestNoAuth(core.PerfStandby(), core.RouterAccess(), w, r)
|
||||
if err != nil || status != 0 {
|
||||
@@ -815,14 +814,14 @@ func parseJSONRequest(perfStandby bool, r *http.Request, w http.ResponseWriter,
|
||||
// Since we're checking PerfStandby here we key on origBody being nil
|
||||
// or not later, so we need to always allocate so it's non-nil
|
||||
origBody = new(bytes.Buffer)
|
||||
reader = ioutil.NopCloser(io.TeeReader(reader, origBody))
|
||||
reader = io.NopCloser(io.TeeReader(reader, origBody))
|
||||
}
|
||||
err := jsonutil.DecodeJSONFromReader(reader, out)
|
||||
if err != nil && err != io.EOF {
|
||||
return nil, fmt.Errorf("failed to parse JSON input: %w", err)
|
||||
}
|
||||
if origBody != nil {
|
||||
return ioutil.NopCloser(origBody), err
|
||||
return io.NopCloser(origBody), err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/textproto"
|
||||
@@ -885,7 +885,7 @@ func TestHandler_Parse_Form(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Body = ioutil.NopCloser(strings.NewReader(values.Encode()))
|
||||
req.Body = io.NopCloser(strings.NewReader(values.Encode()))
|
||||
req.Header.Set("x-vault-token", cluster.RootToken)
|
||||
req.Header.Set("content-type", "application/x-www-form-urlencoded")
|
||||
resp, err := c.Do(req)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sort"
|
||||
@@ -172,7 +173,7 @@ func (o *Backend) Put(ctx context.Context, entry *physical.Entry) error {
|
||||
BucketName: &o.bucketName,
|
||||
ObjectName: &entry.Key,
|
||||
ContentLength: &size,
|
||||
PutObjectBody: ioutil.NopCloser(bytes.NewReader(entry.Value)),
|
||||
PutObjectBody: io.NopCloser(bytes.NewReader(entry.Value)),
|
||||
OpcMeta: nil,
|
||||
OpcClientRequestId: &opcClientRequestId,
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sync"
|
||||
@@ -487,7 +488,7 @@ func (l *Lock) writeLock() (bool, error) {
|
||||
BucketName: &l.backend.lockBucketName,
|
||||
ObjectName: &l.key,
|
||||
ContentLength: &size,
|
||||
PutObjectBody: ioutil.NopCloser(bytes.NewReader(newLockRecordJson)),
|
||||
PutObjectBody: io.NopCloser(bytes.NewReader(newLockRecordJson)),
|
||||
OpcMeta: nil,
|
||||
OpcClientRequestId: &opcClientRequestId,
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ func (f *BoltSnapshotStore) openFromFile(id string) (*raft.SnapshotMeta, io.Read
|
||||
filename := filepath.Join(f.path, id, databaseFilename)
|
||||
installer := &boltSnapshotInstaller{
|
||||
meta: meta,
|
||||
ReadCloser: ioutil.NopCloser(strings.NewReader(filename)),
|
||||
ReadCloser: io.NopCloser(strings.NewReader(filename)),
|
||||
filename: filename,
|
||||
}
|
||||
|
||||
|
||||
@@ -495,7 +495,7 @@ func TestRaft_Snapshot_Take_Restore(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
snapFile, cleanup, metadata, err := raft1.WriteSnapshotToTemp(ioutil.NopCloser(recorder.Body), nil)
|
||||
snapFile, cleanup, metadata, err := raft1.WriteSnapshotToTemp(io.NopCloser(recorder.Body), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -2159,7 +2159,7 @@ func (c *Core) validatePingID(ctx context.Context, mConfig *mfa.Config, username
|
||||
req = req.WithContext(ctx)
|
||||
req.Method = "POST"
|
||||
req.URL = reqURL
|
||||
req.Body = ioutil.NopCloser(bytes.NewBufferString(signedToken))
|
||||
req.Body = io.NopCloser(bytes.NewBufferString(signedToken))
|
||||
if req.Header == nil {
|
||||
req.Header = make(http.Header)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user