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

Add bounds checks to type conversions to resolve gosec G115 errors #572

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bstoll
Copy link
Contributor

@bstoll bstoll commented Nov 6, 2024

Add bounds checking to appease golangci-lint's gosec G115 checks.

Errors before changes:

docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint run -v --config=.github/linters/.golangci.yml --max-issues-per-linter 0 --max-same-issues 0 --timeout 10m ./...
...
topo/node/drivenets/drivenets.go:105:20: G115: integer overflow conversion uint32 -> int32 (gosec)
                        InnerPort: int32(v.Inside),
                                        ^
topo/node/drivenets/drivenets.go:106:20: G115: integer overflow conversion uint32 -> int32 (gosec)
                        OuterPort: int32(k),
                                        ^
topo/node/openconfig/openconfig.go:108:20: G115: integer overflow conversion uint32 -> int32 (gosec)
                        InnerPort: int32(v.Inside),
                                        ^
topo/node/openconfig/openconfig.go:109:20: G115: integer overflow conversion uint32 -> int32 (gosec)
                        OuterPort: int32(k),
                                        ^
topo/node/keysight/keysight.go:66:14: G115: integer overflow conversion uint32 -> int32 (gosec)
                        In:  int32(svc.Inside),
                                  ^
topo/node/keysight/keysight.go:67:14: G115: integer overflow conversion uint32 -> int32 (gosec)
                        Out: int32(svc.Outside),
                                  ^
topo/node/arista/arista.go:186:29: G115: integer overflow conversion int -> int32 (gosec)
                        NumInterfaces:      int32(len(links)),
                                                 ^
topo/node/arista/arista.go:187:29: G115: integer overflow conversion uint32 -> int32 (gosec)
                        Sleep:              int32(config.GetSleep()),
                                                 ^
topo/node/arista/arista.go:199:15: G115: integer overflow conversion uint32 -> int32 (gosec)
                                In:  int32(service.Inside),
                                          ^
topo/node/arista/arista.go:200:15: G115: integer overflow conversion uint32 -> int32 (gosec)
                                Out: int32(service.Outside),
                                          ^
topo/node/arista/arista.go:210:23: G115: integer overflow conversion uint32 -> int32 (gosec)
                                        KeySize:    int32(ssCert.KeySize),
                                                         ^
topo/node/node.go:483:21: G115: integer overflow conversion uint32 -> int32 (gosec)
                        Port:       int32(k),
                                         ^
topo/node/node.go:484:21: G115: integer overflow conversion uint32 -> int32 (gosec)
                        NodePort:   int32(v.NodePort),
                                         ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant