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

chore: added integer overflow linter error to exclude list #1223

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

keruch
Copy link
Contributor

@keruch keruch commented Nov 12, 2024

PR Standards

Linter CI is failing with multiple "G115: integer overflow conversion" errors. All these errors are false positives; conversions were done intentionally, and there is no way to fix them (or there are, but hardly feasible). Adding //nolint:gosec everywhere is annoying, so I decided to exclude the G115 error from linter. 

For example:

2024-11-11T19:31:33.8301723Z ##[error]block/executor.go:317:19: G115: integer overflow conversion int -> uint32 (gosec)
2024-11-11T19:31:33.8311382Z 				Index:  uint32(i),
2024-11-11T19:31:33.8312034Z 				              ^
2024-11-11T19:31:33.8313738Z ##[error]block/fork.go:164:19: G115: integer overflow conversion uint64 -> uint32 (gosec)
2024-11-11T19:31:33.8315742Z 		if drs == uint32(actualDRS) {
2024-11-11T19:31:33.8316405Z 		                ^
2024-11-11T19:31:33.8319188Z ##[error]block/fork.go:172:22: unnecessary conversion (unconvert)
2024-11-11T19:31:33.8320829Z 			DrsVersion: uint64(actualDRS),
2024-11-11T19:31:33.8321488Z 			                  ^
2024-11-11T19:31:33.8322719Z ##[error]block/manager.go:204:43: G115: integer overflow conversion uint64 -> uint32 (gosec)
2024-11-11T19:31:33.8324735Z 			state.RollappParams.DrsVersion = uint32(drsVersion)
2024-11-11T19:31:33.8325861Z 			                                       ^
2024-11-11T19:31:33.8327669Z ##[error]block/manager.go:368:11: G115: integer overflow conversion uint64 -> uint32 (gosec)
2024-11-11T19:31:33.8330098Z 	if uint32(drsVersion) != m.State.RollappParams.DrsVersion {
2024-11-11T19:31:33.8330975Z 	         ^
2024-11-11T19:31:33.8332500Z ##[error]block/submit.go:221:9: G115: integer overflow conversion uint64 -> int (gosec)
2024-11-11T19:31:33.8334403Z 		if int(maxBatchSize) < totalSize {
2024-11-11T19:31:33.8334990Z 		      ^
2024-11-11T19:31:33.8336198Z ##[error]da/celestia/celestia.go:501:24: G115: integer overflow conversion int -> uint32 (gosec)
2024-11-11T19:31:33.8337337Z 		blobSizes[i] = uint32(len(blob.Data))
2024-11-11T19:31:33.8337730Z 		                     ^
2024-11-11T19:31:33.8338708Z ##[error]da/celestia/types/types.go:92:12: G115: integer overflow conversion int -> uint32 (gosec)
2024-11-11T19:31:33.8339866Z 	for uint32(bytesAvailable) < sequenceLen {
2024-11-11T19:31:33.8340239Z 	          ^
2024-11-11T19:31:33.8341207Z ##[error]da/grpc/mockserv/mockserv.go:53:36: G115: integer overflow conversion uint64 -> int32 (gosec)
2024-11-11T19:31:33.8342335Z 			Code:            dalc.StatusCode(resp.Code),
2024-11-11T19:31:33.8342818Z 			                                ^
2024-11-11T19:31:33.8343766Z ##[error]da/grpc/mockserv/mockserv.go:67:28: G115: integer overflow conversion uint64 -> int32 (gosec)
2024-11-11T19:31:33.8344902Z 			Code:    dalc.StatusCode(resp.Code),
2024-11-11T19:31:33.8345725Z 			                        ^
2024-11-11T19:31:33.8346679Z ##[error]da/grpc/mockserv/mockserv.go:84:28: G115: integer overflow conversion uint64 -> int32 (gosec)
2024-11-11T19:31:33.8348001Z 			Code:    dalc.StatusCode(resp.Code),
2024-11-11T19:31:33.8348408Z 			                        ^
2024-11-11T19:31:33.8349390Z ##[error]rpc/client/client.go:314:8: G115: integer overflow conversion uint -> int (gosec)
2024-11-11T19:31:33.8350450Z 	if int(id) > chunkLen-1 {
2024-11-11T19:31:33.8350944Z 	      ^
2024-11-11T19:31:33.8352019Z ##[error]rpc/client/client.go:320:19: G115: integer overflow conversion uint -> int (gosec)
2024-11-11T19:31:33.8353069Z 		ChunkNumber: int(id),
2024-11-11T19:31:33.8353376Z 		                ^
2024-11-11T19:31:33.8354250Z ##[error]types/block.go:49:27: G115: integer overflow conversion uint64 -> int64 (gosec)
2024-11-11T19:31:33.8355260Z 	return time.Unix(0, int64(h.Time))
2024-11-11T19:31:33.8355650Z 	                         ^
2024-11-11T19:31:33.8356487Z ##[error]types/conv.go:26:16: G115: integer overflow conversion uint64 -> int64 (gosec)
2024-11-11T19:31:33.8357517Z 		Height: int64(header.Height),
2024-11-11T19:31:33.8357841Z 		             ^
2024-11-11T19:31:33.8358578Z ##[error]types/conv.go:27:29: G115: integer overflow conversion uint64 -> int64 (gosec)
2024-11-11T19:31:33.8359583Z 		Time:   time.Unix(0, int64(header.Time)),
2024-11-11T19:31:33.8360172Z 		                          ^
2024-11-11T19:31:33.8361691Z ##[error]types/pb/dymensionxyz/dymension/rollapp/message_update_state.go:38:27: G115: integer overflow conversion uint64 -> int (gosec)
2024-11-11T19:31:33.8363296Z 	if len(msg.BDs.BD) != int(msg.NumBlocks) {
2024-11-11T19:31:33.8363726Z 	                         ^
2024-11-11T19:31:33.8363905Z 
2024-11-11T19:31:33.8379505Z ##[error]issues found
2024-11-11T19:31:33.8380459Z Ran golangci-lint in 114348ms

logs_30757136338.zip


Close #XXX

<-- Briefly describe the content of this pull request -->

For Author:

  • Targeted PR against correct branch
  • included the correct type prefix in the PR title
  • Linked to Github issue with discussion and accepted design
  • Targets only one github issue
  • Wrote unit and integration tests
  • All CI checks have passed
  • Added relevant godoc comments

For Reviewer:

  • confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • confirmed all author checklist items have been addressed

After reviewer approval:

  • In case targets main branch, PR should be squashed and merged.
  • In case PR targets a release branch, PR should be rebased.

@keruch keruch self-assigned this Nov 12, 2024
@keruch keruch requested a review from a team as a code owner November 12, 2024 09:17
@mtsitrin mtsitrin merged commit dd734b0 into main Nov 12, 2024
4 checks passed
@mtsitrin mtsitrin deleted the kirill/fix-linter branch November 12, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants