get rid of remaining nolint:gosec

This commit is contained in:
Markus Unterwaditzer 2024-10-12 10:54:08 +02:00
parent 77736957ec
commit bd9ce6638e
6 changed files with 12 additions and 9 deletions

View file

@ -145,7 +145,7 @@ func drainToTmp(rc io.ReadCloser) (string, error) {
// Check to see if limit was reached,
// (produces more useful error messages).
if lr != nil && lr.N <= 0 {
err := fmt.Errorf("reached read limit %s", bytesize.Size(limit)) //nolint:gosec
err := fmt.Errorf("reached read limit %s", bytesize.Size(limit)) // #nosec G115 -- Just logging
return path, gtserror.SetLimitReached(err)
}

View file

@ -123,7 +123,7 @@ func Logger(logClientIP bool) gin.HandlerFunc {
}
// Generate a nicer looking bytecount
size := bytesize.Size(c.Writer.Size()) //nolint:gosec
size := bytesize.Size(c.Writer.Size()) // #nosec G115 -- Just logging
// Finally, write log entry with status text + body size.
l.Logf(lvl, "%s: wrote %s", statusText, size)

View file

@ -48,7 +48,7 @@ func NewRequestID() string {
b := make([]byte, 12)
// Get current time in milliseconds.
ms := uint64(time.Now().UnixMilli()) //nolint:gosec
ms := uint64(time.Now().UnixMilli()) // #nosec G115 -- Pre-1970 clock?
// Store binary time data in byte buffer.
binary.LittleEndian.PutUint64(b[0:8], ms)

View file

@ -82,12 +82,16 @@ func Throttle(cpuMultiplier int, retryAfter time.Duration) gin.HandlerFunc {
return func(c *gin.Context) {}
}
if retryAfter < 0 {
retryAfter = 0
}
var (
limit = runtime.GOMAXPROCS(0) * cpuMultiplier
queueLimit = limit * cpuMultiplier
tokens = make(chan token, limit)
requestCount = atomic.Int64{}
retryAfterStr = strconv.FormatUint(uint64(retryAfter/time.Second), 10) //nolint:gosec
retryAfterStr = strconv.FormatUint(uint64(retryAfter/time.Second), 10) // #nosec G115 -- Checked right above
)
// prefill token channel

View file

@ -25,7 +25,6 @@
"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"
@ -300,11 +299,11 @@ func (p *Processor) emojiUpdateCopy(
}
// Get maximum supported local emoji size.
maxsz := config.GetMediaEmojiLocalMaxSize()
maxsz := int(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated
// Ensure target emoji image within size bounds.
if bytesize.Size(target.ImageFileSize) > maxsz { //nolint:gosec
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
if target.ImageFileSize > maxsz {
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
}

View file

@ -1531,7 +1531,7 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins
Registrations: config.GetAccountsRegistrationOpen(),
ApprovalRequired: true, // approval always required
InvitesEnabled: false, // todo: not supported yet
MaxTootChars: uint(config.GetStatusesMaxChars()), //nolint:gosec
MaxTootChars: uint(config.GetStatusesMaxChars()), // #nosec G115 -- Already validated.
Rules: c.InstanceRulesToAPIRules(i.Rules),
Terms: i.Terms,
TermsRaw: i.TermsText,