Add staticcheck to console API (#2883)
This commit is contained in:
@@ -69,23 +69,23 @@ type DiscoveryDoc struct {
|
||||
}
|
||||
|
||||
func (ac Config) Exchange(ctx context.Context, code string, opts ...xoauth2.AuthCodeOption) (*xoauth2.Token, error) {
|
||||
return ac.Exchange(ctx, code, opts...)
|
||||
return ac.Config.Exchange(ctx, code, opts...)
|
||||
}
|
||||
|
||||
func (ac Config) AuthCodeURL(state string, opts ...xoauth2.AuthCodeOption) string {
|
||||
return ac.AuthCodeURL(state, opts...)
|
||||
return ac.Config.AuthCodeURL(state, opts...)
|
||||
}
|
||||
|
||||
func (ac Config) PasswordCredentialsToken(ctx context.Context, username, password string) (*xoauth2.Token, error) {
|
||||
return ac.PasswordCredentialsToken(ctx, username, password)
|
||||
return ac.Config.PasswordCredentialsToken(ctx, username, password)
|
||||
}
|
||||
|
||||
func (ac Config) Client(ctx context.Context, t *xoauth2.Token) *http.Client {
|
||||
return ac.Client(ctx, t)
|
||||
return ac.Config.Client(ctx, t)
|
||||
}
|
||||
|
||||
func (ac Config) TokenSource(ctx context.Context, t *xoauth2.Token) xoauth2.TokenSource {
|
||||
return ac.TokenSource(ctx, t)
|
||||
return ac.Config.TokenSource(ctx, t)
|
||||
}
|
||||
|
||||
// Provider is a wrapper of the oauth2 configuration and the oidc provider
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -295,7 +294,7 @@ func decrypt(ciphertext, associatedData []byte) ([]byte, error) {
|
||||
return nil, fmt.Errorf("invalid nonce size %d, expected %d", len(nonce), aead.NonceSize())
|
||||
}
|
||||
|
||||
sealedBytes, err := ioutil.ReadAll(r)
|
||||
sealedBytes, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -85,7 +84,7 @@ var (
|
||||
func ParsePublicCertFile(certFile string) (x509Certs []*x509.Certificate, err error) {
|
||||
// Read certificate file.
|
||||
var data []byte
|
||||
if data, err = ioutil.ReadFile(certFile); err != nil {
|
||||
if data, err = os.ReadFile(certFile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -188,11 +187,11 @@ const EnvCertPassword = "CONSOLE_CERT_PASSWD"
|
||||
// from the provided paths. The private key may be encrypted and is
|
||||
// decrypted using the ENV_VAR: MINIO_CERT_PASSWD.
|
||||
func LoadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) {
|
||||
certPEMBlock, err := ioutil.ReadFile(certFile)
|
||||
certPEMBlock, err := os.ReadFile(certFile)
|
||||
if err != nil {
|
||||
return tls.Certificate{}, err
|
||||
}
|
||||
keyPEMBlock, err := ioutil.ReadFile(keyFile)
|
||||
keyPEMBlock, err := os.ReadFile(keyFile)
|
||||
if err != nil {
|
||||
return tls.Certificate{}, err
|
||||
}
|
||||
@@ -200,11 +199,13 @@ func LoadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) {
|
||||
if len(rest) > 0 {
|
||||
return tls.Certificate{}, errors.New("the private key contains additional data")
|
||||
}
|
||||
// nolint:staticcheck // ignore SA1019
|
||||
if x509.IsEncryptedPEMBlock(key) {
|
||||
password := env.Get(EnvCertPassword, "")
|
||||
if len(password) == 0 {
|
||||
return tls.Certificate{}, errors.New("no password")
|
||||
}
|
||||
// nolint:staticcheck // ignore SA1019
|
||||
decryptedKey, decErr := x509.DecryptPEMBlock(key, []byte(password))
|
||||
if decErr != nil {
|
||||
return tls.Certificate{}, decErr
|
||||
|
||||
@@ -18,7 +18,6 @@ package http
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -69,6 +68,6 @@ func DrainBody(respBody io.ReadCloser) {
|
||||
// the same connection for future uses.
|
||||
// - http://stackoverflow.com/a/17961593/4465767
|
||||
defer respBody.Close()
|
||||
io.Copy(ioutil.Discard, respBody)
|
||||
io.Copy(io.Discard, respBody)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ func (h *Target) logEntry(entry interface{}) {
|
||||
func (h *Target) startHTTPLogger() {
|
||||
// Create a routine which sends json logs received
|
||||
// from an internal channel.
|
||||
h.wg.Add(1)
|
||||
go func() {
|
||||
h.wg.Add(1)
|
||||
defer h.wg.Done()
|
||||
for entry := range h.logCh {
|
||||
h.logEntry(entry)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
|
||||
@@ -155,7 +154,7 @@ func subnetReqDo(client xhttp.ClientI, r *http.Request, headers map[string]strin
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
respBytes, e := ioutil.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit))
|
||||
respBytes, e := io.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit))
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package utils
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"regexp"
|
||||
|
||||
"github.com/minio/console/pkg/http"
|
||||
@@ -35,7 +35,7 @@ func GetLatestMinIOImage(client http.ClientI) (*string, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user