mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
cleanup ignored static analysis (#16767)
This commit is contained in:
@@ -82,8 +82,7 @@ func (f *Filter) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error
|
||||
return err
|
||||
}
|
||||
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
if se, ok := t.(xml.StartElement); ok {
|
||||
switch se.Name.Local {
|
||||
case "Prefix":
|
||||
var p Prefix
|
||||
|
||||
@@ -104,8 +104,7 @@ func (lc *Lifecycle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err e
|
||||
return err
|
||||
}
|
||||
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
if se, ok := t.(xml.StartElement); ok {
|
||||
switch se.Name.Local {
|
||||
case "Rule":
|
||||
var r Rule
|
||||
|
||||
@@ -51,8 +51,7 @@ func (tag *Tag) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
|
||||
return err
|
||||
}
|
||||
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
if se, ok := t.(xml.StartElement); ok {
|
||||
var s string
|
||||
if err = d.DecodeElement(&s, &se); err != nil {
|
||||
return err
|
||||
|
||||
@@ -514,8 +514,7 @@ func (l *ObjectLegalHold) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (
|
||||
return err
|
||||
}
|
||||
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
if se, ok := t.(xml.StartElement); ok {
|
||||
switch se.Name.Local {
|
||||
case "Status":
|
||||
var st LegalHoldStatus
|
||||
|
||||
@@ -38,8 +38,8 @@ import (
|
||||
//
|
||||
// The same context must be provided when decrypting the
|
||||
// ciphertext.
|
||||
func EncryptBytes(KMS kms.KMS, plaintext []byte, context kms.Context) ([]byte, error) {
|
||||
ciphertext, err := Encrypt(KMS, bytes.NewReader(plaintext), context)
|
||||
func EncryptBytes(k kms.KMS, plaintext []byte, context kms.Context) ([]byte, error) {
|
||||
ciphertext, err := Encrypt(k, bytes.NewReader(plaintext), context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -49,8 +49,8 @@ func EncryptBytes(KMS kms.KMS, plaintext []byte, context kms.Context) ([]byte, e
|
||||
// DecryptBytes decrypts the ciphertext using a key managed by the KMS.
|
||||
// The same context that have been used during encryption must be
|
||||
// provided.
|
||||
func DecryptBytes(KMS kms.KMS, ciphertext []byte, context kms.Context) ([]byte, error) {
|
||||
plaintext, err := Decrypt(KMS, bytes.NewReader(ciphertext), context)
|
||||
func DecryptBytes(k kms.KMS, ciphertext []byte, context kms.Context) ([]byte, error) {
|
||||
plaintext, err := Decrypt(k, bytes.NewReader(ciphertext), context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,13 +62,13 @@ func DecryptBytes(KMS kms.KMS, ciphertext []byte, context kms.Context) ([]byte,
|
||||
//
|
||||
// The same context must be provided when decrypting the
|
||||
// ciphertext.
|
||||
func Encrypt(KMS kms.KMS, plaintext io.Reader, ctx kms.Context) (io.Reader, error) {
|
||||
func Encrypt(k kms.KMS, plaintext io.Reader, ctx kms.Context) (io.Reader, error) {
|
||||
algorithm := sio.AES_256_GCM
|
||||
if !fips.Enabled && !sioutil.NativeAES() {
|
||||
algorithm = sio.ChaCha20Poly1305
|
||||
}
|
||||
|
||||
key, err := KMS.GenerateKey(context.Background(), "", ctx)
|
||||
key, err := k.GenerateKey(context.Background(), "", ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func Encrypt(KMS kms.KMS, plaintext io.Reader, ctx kms.Context) (io.Reader, erro
|
||||
// Decrypt decrypts the ciphertext using a key managed by the KMS.
|
||||
// The same context that have been used during encryption must be
|
||||
// provided.
|
||||
func Decrypt(KMS kms.KMS, ciphertext io.Reader, context kms.Context) (io.Reader, error) {
|
||||
func Decrypt(k kms.KMS, ciphertext io.Reader, context kms.Context) (io.Reader, error) {
|
||||
const (
|
||||
MaxMetadataSize = 1 << 20 // max. size of the metadata
|
||||
Version = 1
|
||||
@@ -149,7 +149,7 @@ func Decrypt(KMS kms.KMS, ciphertext io.Reader, context kms.Context) (io.Reader,
|
||||
return nil, fmt.Errorf("config: unsupported encryption algorithm: %q is not supported in FIPS mode", metadata.Algorithm)
|
||||
}
|
||||
|
||||
key, err := KMS.DecryptKey(metadata.KeyID, metadata.KMSKey, context)
|
||||
key, err := k.DecryptKey(metadata.KeyID, metadata.KMSKey, context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -104,8 +104,7 @@ func (c *OperatorDNS) Put(bucket string) error {
|
||||
var errorStringBuilder strings.Builder
|
||||
io.Copy(&errorStringBuilder, io.LimitReader(resp.Body, resp.ContentLength))
|
||||
errorString := errorStringBuilder.String()
|
||||
switch resp.StatusCode {
|
||||
case http.StatusConflict:
|
||||
if resp.StatusCode == http.StatusConflict {
|
||||
return ErrBucketConflict(Error{bucket, errors.New(errorString)})
|
||||
}
|
||||
return newError(bucket, fmt.Errorf("service create for bucket %s, failed with status %s, error %s", bucket, resp.Status, errorString))
|
||||
|
||||
@@ -107,9 +107,8 @@ func ErrorToErr(err error) Err {
|
||||
if errors.Is(err, syscall.EADDRINUSE) {
|
||||
return ErrPortAlreadyInUse(err).Msg("Specified port is already in use")
|
||||
} else if errors.Is(err, syscall.EACCES) || errors.Is(err, syscall.EPERM) {
|
||||
switch err.(type) {
|
||||
case *net.OpError:
|
||||
return ErrPortAccess(err).Msg("Insufficient permissions to use specified port")
|
||||
if netErr, ok := err.(*net.OpError); ok {
|
||||
return ErrPortAccess(netErr).Msg("Insufficient permissions to use specified port")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,9 +172,8 @@ func (l *Config) DoesGroupDNExist(groupDN string) (bool, error) {
|
||||
// some base DNs are subtrees of other base DNs - we should validate
|
||||
// and error out in such cases.
|
||||
return false, fmt.Errorf("found multiple DNs for the given group DN")
|
||||
} else {
|
||||
return false, nil
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Bind - binds to ldap, searches LDAP and returns the distinguished name of the
|
||||
|
||||
@@ -204,11 +204,12 @@ func (h *metrics) accumRequestRTT(reqStartTime time.Time, rttMs float64, isSucce
|
||||
h.updateLastFullMinute(reqTimeMinute)
|
||||
}
|
||||
var entry *serviceRTTMinuteStats
|
||||
if reqTimeMinute.Equal(h.currentMinute.statsTime) {
|
||||
switch {
|
||||
case reqTimeMinute.Equal(h.currentMinute.statsTime):
|
||||
entry = &h.currentMinute
|
||||
} else if reqTimeMinute.Equal(h.lastFullMinute.statsTime) {
|
||||
case reqTimeMinute.Equal(h.lastFullMinute.statsTime):
|
||||
entry = &h.lastFullMinute
|
||||
} else {
|
||||
default:
|
||||
// This request is too old, it should never happen, ignore it as we
|
||||
// cannot return an error.
|
||||
return
|
||||
|
||||
@@ -106,8 +106,8 @@ func (ssekms) IsEncrypted(metadata map[string]string) bool {
|
||||
// UnsealObjectKey extracts and decrypts the sealed object key
|
||||
// from the metadata using KMS and returns the decrypted object
|
||||
// key.
|
||||
func (s3 ssekms) UnsealObjectKey(KMS kms.KMS, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
|
||||
if KMS == nil {
|
||||
func (s3 ssekms) UnsealObjectKey(k kms.KMS, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
|
||||
if k == nil {
|
||||
return key, Errorf("KMS not configured")
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func (s3 ssekms) UnsealObjectKey(KMS kms.KMS, metadata map[string]string, bucket
|
||||
} else if _, ok := ctx[bucket]; !ok {
|
||||
ctx[bucket] = path.Join(bucket, object)
|
||||
}
|
||||
unsealKey, err := KMS.DecryptKey(keyID, kmsKey, ctx)
|
||||
unsealKey, err := k.DecryptKey(keyID, kmsKey, ctx)
|
||||
if err != nil {
|
||||
return key, err
|
||||
}
|
||||
|
||||
@@ -71,15 +71,15 @@ func (sses3) IsEncrypted(metadata map[string]string) bool {
|
||||
// UnsealObjectKey extracts and decrypts the sealed object key
|
||||
// from the metadata using KMS and returns the decrypted object
|
||||
// key.
|
||||
func (s3 sses3) UnsealObjectKey(KMS kms.KMS, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
|
||||
if KMS == nil {
|
||||
func (s3 sses3) UnsealObjectKey(k kms.KMS, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
|
||||
if k == nil {
|
||||
return key, Errorf("KMS not configured")
|
||||
}
|
||||
keyID, kmsKey, sealedKey, err := s3.ParseMetadata(metadata)
|
||||
if err != nil {
|
||||
return key, err
|
||||
}
|
||||
unsealKey, err := KMS.DecryptKey(keyID, kmsKey, kms.Context{bucket: path.Join(bucket, object)})
|
||||
unsealKey, err := k.DecryptKey(keyID, kmsKey, kms.Context{bucket: path.Join(bucket, object)})
|
||||
if err != nil {
|
||||
return key, err
|
||||
}
|
||||
@@ -92,8 +92,8 @@ func (s3 sses3) UnsealObjectKey(KMS kms.KMS, metadata map[string]string, bucket,
|
||||
// keys.
|
||||
//
|
||||
// The metadata, buckets and objects slices must have the same length.
|
||||
func (s3 sses3) UnsealObjectKeys(ctx context.Context, KMS kms.KMS, metadata []map[string]string, buckets, objects []string) ([]ObjectKey, error) {
|
||||
if KMS == nil {
|
||||
func (s3 sses3) UnsealObjectKeys(ctx context.Context, k kms.KMS, metadata []map[string]string, buckets, objects []string) ([]ObjectKey, error) {
|
||||
if k == nil {
|
||||
return nil, Errorf("KMS not configured")
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func (s3 sses3) UnsealObjectKeys(ctx context.Context, KMS kms.KMS, metadata []ma
|
||||
for i := range buckets {
|
||||
contexts = append(contexts, kms.Context{buckets[i]: path.Join(buckets[i], objects[i])})
|
||||
}
|
||||
unsealKeys, err := KMS.DecryptAll(ctx, keyIDs[0], kmsKeys, contexts)
|
||||
unsealKeys, err := k.DecryptAll(ctx, keyIDs[0], kmsKeys, contexts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func (s3 sses3) UnsealObjectKeys(ctx context.Context, KMS kms.KMS, metadata []ma
|
||||
|
||||
keys := make([]ObjectKey, 0, len(keyIDs))
|
||||
for i := range keyIDs {
|
||||
key, err := s3.UnsealObjectKey(KMS, metadata[i], buckets[i], objects[i])
|
||||
key, err := s3.UnsealObjectKey(k, metadata[i], buckets[i], objects[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -149,8 +149,7 @@ func (h *Target) Init() error {
|
||||
xhttp.DrainBody(resp.Body)
|
||||
|
||||
if !acceptedResponseStatusCode(resp.StatusCode) {
|
||||
switch resp.StatusCode {
|
||||
case http.StatusForbidden:
|
||||
if resp.StatusCode == http.StatusForbidden {
|
||||
return fmt.Errorf("%s returned '%s', please check if your auth token is correctly set",
|
||||
h.config.Endpoint, resp.Status)
|
||||
}
|
||||
|
||||
@@ -76,8 +76,7 @@ func (args *ReaderArgs) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (er
|
||||
return err
|
||||
}
|
||||
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
if se, ok := t.(xml.StartElement); ok {
|
||||
tagName := se.Name.Local
|
||||
switch tagName {
|
||||
case "AllowQuotedRecordDelimiter":
|
||||
@@ -158,8 +157,7 @@ func (args *WriterArgs) UnmarshalXML(d *xml.Decoder, start xml.StartElement) err
|
||||
return err
|
||||
}
|
||||
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
if se, ok := t.(xml.StartElement); ok {
|
||||
var s string
|
||||
if err = d.DecodeElement(&s, &se); err != nil {
|
||||
return err
|
||||
|
||||
@@ -28,9 +28,7 @@ import (
|
||||
// valueBuilders contains one constructor for each value type.
|
||||
// Values should match if type is the same.
|
||||
var valueBuilders = []func() *Value{
|
||||
func() *Value {
|
||||
return FromNull()
|
||||
},
|
||||
FromNull,
|
||||
func() *Value {
|
||||
return FromBool(true)
|
||||
},
|
||||
@@ -58,9 +56,7 @@ var valueBuilders = []func() *Value{
|
||||
// altValueBuilders contains one constructor for each value type.
|
||||
// Values are zero values and should NOT match the values in valueBuilders, except Null type.
|
||||
var altValueBuilders = []func() *Value{
|
||||
func() *Value {
|
||||
return FromNull()
|
||||
},
|
||||
FromNull,
|
||||
func() *Value {
|
||||
return FromBool(false)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user