testing: address G115: integer overflow conversion int issues and re-enable linter (gosec) #5584
Open
Description
opened on Oct 30, 2024
- related / same issue in moby: testing: address G115: integer overflow conversion int issues and re-enable linter (gosec) moby/moby#48358
Description
Updating golangci-lint to the current version also includes some new linting rules around integer overflows. Most, if not all, of these are likely harmless, but we should evaluate each of them, and where possible either //nolint
ignore them, or update the code.
opts/port.go:166:26: G115: integer overflow conversion int -> uint32 (gosec)
TargetPort: uint32(port.Int()),
^
opts/port.go:167:26: G115: integer overflow conversion uint64 -> uint32 (gosec)
PublishedPort: uint32(i),
^
cli/command/service/logs.go:115:32: G115: integer overflow conversion uint64 -> int (gosec)
maxLength = getMaxLength(int(replicas))
^
cli/compose/convert/service.go:464:16: G115: integer overflow conversion uint64 -> int (gosec)
retries = int(*healthcheck.Retries)
^
cli/compose/convert/service.go:491:22: G115: integer overflow conversion int -> uint64 (gosec)
attempts := uint64(policy.MaximumRetryCount)
^
cli/command/container/cp.go:112:36: G115: integer overflow conversion int -> uint (gosec)
fmt.Fprint(buf, aec.Column(uint(len(header)+1)))
^
cli/command/container/opts.go:623:31: G115: integer overflow conversion int64 -> uint64 (gosec)
IOMaximumBandwidth: uint64(copts.ioMaxBandwidth),
^
cli/command/container/stats_helpers.go:187:25: G115: integer overflow conversion int64 -> uint64 (gosec)
possIntervals := uint64(v.Read.Sub(v.PreRead).Nanoseconds()) // Start with number of ns intervals
^
cli/command/image/tree.go:195:18: G115: integer overflow conversion uint -> int (gosec)
nameWidth := int(width)
^
cli/command/service/progress/progress.go:344:42: G115: integer overflow conversion uint64 -> int (gosec)
writeOverallProgress(u.progressOut, int(running), int(replicas), rollback)
^
cli/command/service/progress/progress.go:305:45: G115: integer overflow conversion uint64 -> int (gosec)
writeOverallProgress(u.progressOut, 0, int(replicas), rollback)
^
cli/command/service/progress/progress.go:387:51: G115: integer overflow conversion int -> uint64 (gosec)
if u.done || replicas > maxProgressBars || uint64(mappedSlot) > replicas {
^
cli/command/service/progress/progress.go:578:20: G115: integer overflow conversion uint64 -> int (gosec)
concurrent: int(*service.Spec.Mode.ReplicatedJob.MaxConcurrent),
^
cli/command/service/progress/progress.go:579:20: G115: integer overflow conversion uint64 -> int (gosec)
total: int(*service.Spec.Mode.ReplicatedJob.TotalCompletions),
^
Activity