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

rules/sdk: use ctx.Info.TypeOf() to get types #25

Merged
merged 1 commit into from
Jun 9, 2022
Merged

rules/sdk: use ctx.Info.TypeOf() to get types #25

merged 1 commit into from
Jun 9, 2022

Conversation

kirbyquerby
Copy link
Collaborator

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

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
@codecov-commenter
Copy link

Codecov Report

Merging #25 (051caa9) into master (74c0f4d) will increase coverage by 0.12%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
+ Coverage   70.74%   70.86%   +0.12%     
==========================================
  Files           9        9              
  Lines         581      587       +6     
==========================================
+ Hits          411      416       +5     
  Misses        146      146              
- Partials       24       25       +1     
Impacted Files Coverage Δ
analyzer.go 89.02% <ø> (ø)
config.go 82.92% <75.00%> (-1.29%) ⬇️
helpers.go 45.83% <100.00%> (+0.76%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74c0f4d...051caa9. Read the comment docs.

Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @kirbyquerby!

@odeke-em odeke-em merged commit f6f1167 into cosmos:master Jun 9, 2022
@odeke-em odeke-em deleted the map-no-crash-pls branch June 9, 2022 23:31
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.

3 participants