Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: address G115: integer overflow conversion int issues and re-enable linter (gosec) #5584

Open
thaJeztah opened this issue Oct 30, 2024 · 0 comments · May be fixed by #5871
Open

testing: address G115: integer overflow conversion int issues and re-enable linter (gosec) #5584

thaJeztah opened this issue Oct 30, 2024 · 0 comments · May be fixed by #5871

Comments

@thaJeztah
Copy link
Member

thaJeztah commented Oct 30, 2024

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),
		                 ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant