mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-03 08:23:16 -06:00
Merge branch 'go_123' into golangci-lint-upgrade
This commit is contained in:
commit
2693b8827d
19 changed files with 98 additions and 86 deletions
|
|
@ -462,11 +462,11 @@ func (p *Processor) UpdateAvatar(
|
|||
gtserror.WithCode,
|
||||
) {
|
||||
// Get maximum supported local media size.
|
||||
maxsz := config.GetMediaLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if avatar.Size > int64(maxsz) { //nolint:gosec
|
||||
text := fmt.Sprintf("media exceeds configured max size: %s", maxsz)
|
||||
if avatar.Size > maxsz {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -478,7 +478,7 @@ func (p *Processor) UpdateAvatar(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz)) //nolint:gosec
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
|
||||
// Write to instance storage.
|
||||
return p.c.StoreLocalMedia(ctx,
|
||||
|
|
@ -507,11 +507,11 @@ func (p *Processor) UpdateHeader(
|
|||
gtserror.WithCode,
|
||||
) {
|
||||
// Get maximum supported local media size.
|
||||
maxsz := config.GetMediaLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if header.Size > int64(maxsz) { //nolint:gosec
|
||||
text := fmt.Sprintf("media exceeds configured max size: %s", maxsz)
|
||||
if header.Size > maxsz {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ func (p *Processor) UpdateHeader(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz)) //nolint:gosec
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
|
||||
// Write to instance storage.
|
||||
return p.c.StoreLocalMedia(ctx,
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ func (p *Processor) EmojiCreate(
|
|||
) (*apimodel.Emoji, gtserror.WithCode) {
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if form.Image.Size > int64(maxsz) { //nolint:gosec
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
if form.Image.Size > maxsz {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ func (p *Processor) EmojiCreate(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz)) //nolint:gosec
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
|
@ -441,11 +441,11 @@ func (p *Processor) emojiUpdateModify(
|
|||
// We can do both at the same time :)
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if image.Size > int64(maxsz) { //nolint:gosec
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
if image.Size > maxsz {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ func (p *Processor) emojiUpdateModify(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz)) //nolint:gosec
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ import (
|
|||
func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form *apimodel.AttachmentRequest) (*apimodel.Attachment, gtserror.WithCode) {
|
||||
|
||||
// Get maximum supported local media size.
|
||||
maxsz := config.GetMediaLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if form.File.Size > int64(maxsz) { //nolint:gosec
|
||||
text := fmt.Sprintf("media exceeds configured max size: %s", maxsz)
|
||||
if form.File.Size > maxsz {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz)) //nolint:gosec
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
|
||||
// Create local media and write to instance storage.
|
||||
attachment, errWithCode := p.c.StoreLocalMedia(ctx,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue