-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
rules/sdk: G705 should allow map copying #24
Comments
odeke-em
pushed a commit
that referenced
this issue
Jun 9, 2022
This lets us determine types much more reliably without having to worry about adding more cases to switch statements and pulling out the debugger when we panic on a new AST structure we haven't handled yet. It's always nice to half the number of lines in a file as well :) And of course this change causes the rule to notice more map statements that it previously mixed, so I've also fixed those. I also discovered a new case that this rule incorrectly flags -- map copying is safe to do directly. I've filed #24 and suppressed the rule for the map copy in analyzer.go. With this change, I'm able to run gosec on cosmos/cosmos-sdk without it crashing. Updates cosmos/cosmos-sdk#10572
odeke-em
pushed a commit
that referenced
this issue
Jun 23, 2022
This change permits map copies of the form: ```go for k, v := range from { to[k] = v } ``` It doesn't currently permit the alternative, which trickier to check for and doesn't really have any benefits: ```go for k := range from { to[k] = from[k] } ``` Updates #24
This is fixed as of #29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
Copying a map is a safe operation and shouldn't be flagged by the static analyzer. We should allow code like:
and probably:
Steps to reproduce the behavior
make test
gosec version
Go version (output of 'go version')
N/A
Operating system / Environment
N/A
Expected behavior
Don't raise a warning for copying a map.
Actual behavior
The text was updated successfully, but these errors were encountered: