mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] Upgrade golangci-lint, ignore existing int overflow warnings (#3420)
* [chore] Bump tooling versions, bump go -> v1.23.0 * undo silly change * sign * bump go version in go.mod * allow overflow in imaging * goreleaser deprecation notices * [chore] Upgrade golangci-lint, ignore existing int overflow warnings There is a new lint for unchecked int casts. Integer overflows are bad, but the old code that triggers this lint seems to be perfectly fine. Instead of disabling the lint entirely for new code as well, grandfather in existing code. * fix golangci-lint documentation link * revert unrelated changes * revert another unrelated change * get rid of remaining nolint:gosec * swagger updates * apply review feedback * fix wrong formatting specifier thing * fix the linter for real --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
committed by
GitHub
parent
3e8c4951e1
commit
a48cce82b9
@@ -25,7 +25,6 @@ import (
|
||||
"mime/multipart"
|
||||
"strings"
|
||||
|
||||
"codeberg.org/gruf/go-bytesize"
|
||||
"codeberg.org/gruf/go-iotools"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
@@ -46,9 +45,10 @@ func (p *Processor) EmojiCreate(
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxszInt64 := int64(maxsz) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if form.Image.Size > int64(maxsz) {
|
||||
if form.Image.Size > maxszInt64 {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", 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))
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxszInt64)
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
@@ -301,9 +301,10 @@ func (p *Processor) emojiUpdateCopy(
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxszInt := int(maxsz) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure target emoji image within size bounds.
|
||||
if bytesize.Size(target.ImageFileSize) > maxsz {
|
||||
if target.ImageFileSize > maxszInt {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
@@ -442,9 +443,10 @@ func (p *Processor) emojiUpdateModify(
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxszInt64 := int64(maxsz) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if image.Size > int64(maxsz) {
|
||||
if image.Size > maxszInt64 {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
@@ -457,7 +459,7 @@ func (p *Processor) emojiUpdateModify(
|
||||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz))
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz)) // #nosec G115 -- Already validated.
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user