[#498] Remove log string sanitizer
`zap` lib does all the job anyway. Suppress CWE-117 from CodeQL. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
ec6039c53b
commit
5219965105
3 changed files with 5 additions and 16 deletions
|
@ -10,16 +10,15 @@ import (
|
|||
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/internal/misc"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (h *handler) logAndSendError(w http.ResponseWriter, logText string, reqInfo *api.ReqInfo, err error, additional ...zap.Field) {
|
||||
fields := []zap.Field{zap.String("request_id", misc.SanitizeString(reqInfo.RequestID)),
|
||||
zap.String("method", misc.SanitizeString(reqInfo.API)),
|
||||
zap.String("bucket_name", misc.SanitizeString(reqInfo.BucketName)),
|
||||
zap.String("object_name", misc.SanitizeString(reqInfo.ObjectName)),
|
||||
fields := []zap.Field{zap.String("request_id", reqInfo.RequestID),
|
||||
zap.String("method", reqInfo.API),
|
||||
zap.String("bucket_name", reqInfo.BucketName),
|
||||
zap.String("object_name", reqInfo.ObjectName),
|
||||
zap.Error(err)}
|
||||
fields = append(fields, additional...)
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/internal/misc"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"go.uber.org/zap"
|
||||
|
@ -391,7 +390,7 @@ func (n *layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipar
|
|||
})
|
||||
if err != nil {
|
||||
n.log.Error("could not put a completed object (multipart upload)",
|
||||
zap.String("uploadID", misc.SanitizeString(p.Info.UploadID)),
|
||||
zap.String("uploadID", p.Info.UploadID),
|
||||
zap.String("uploadKey", p.Info.Key),
|
||||
zap.Error(err))
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package misc
|
||||
|
||||
import "strings"
|
||||
|
||||
// SanitizeString sanitizes string before using it in logs. Required
|
||||
// for data from the user input: request body, headers, etc.
|
||||
func SanitizeString(s string) string {
|
||||
return strings.Replace(s, "\n", "", -1)
|
||||
}
|
Loading…
Reference in a new issue