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

Linter: gosec, Rule: G601 - Implicit memory aliasing of items from a range statement. Should we enable it? #12955

Closed
zak-pawel opened this issue Mar 26, 2023 · 2 comments · Fixed by #13042
Labels

Comments

@zak-pawel
Copy link
Collaborator

Use Case

This issue starts discussion about enabling:

Rule is mapped to CWE-118: Incorrect Access of Indexable Resource ('Range Error').

Expected behavior

Decision if rule should be enabled or not.

Actual behavior

For this rule following findings were found in current code:

plugins/inputs/clickhouse/clickhouse.go:144:30         gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/clickhouse/clickhouse.go:150:36         gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/mongodb/mongodb_data.go:303:33          gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/mongodb/mongodb_data.go:319:34          gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/mongodb/mongodb_data.go:336:35          gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/mongodb/mongodb_data.go:352:34          gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/ras/ras_test.go:17:22                   gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/ras/ras_test.go:98:22                   gosec  G601: Implicit memory aliasing in for loop.
plugins/inputs/vsphere/endpoint.go:1221:52             gosec  G601: Implicit memory aliasing in for loop.
plugins/outputs/azure_monitor/azure_monitor.go:284:34  gosec  G601: Implicit memory aliasing in for loop.
plugins/parsers/collectd/parser_test.go:304:28         gosec  G601: Implicit memory aliasing in for loop.

Additional info

For this rule no additional configuration can be provided.

@powersj
Copy link
Contributor

powersj commented Mar 27, 2023

+1

@srebhan
Copy link
Member

srebhan commented Apr 3, 2023

Definitively +1! I've hit this so many times...

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

Successfully merging a pull request may close this issue.

3 participants