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

feat: add ReadFileWithSizeLimit and use it on x/wasm #696

Merged
merged 8 commits into from
Oct 11, 2022

Conversation

tnasu
Copy link
Member

@tnasu tnasu commented Oct 5, 2022

Description

Reading a huge file has the risk of the crash application by using ioutil.ReadFile/os.ReadFile.
Here is the updates:

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Merging #696 (19d28f9) into main (1a3eabd) will increase coverage by 0.05%.
The diff coverage is 77.08%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #696      +/-   ##
==========================================
+ Coverage   61.18%   61.23%   +0.05%     
==========================================
  Files         873      874       +1     
  Lines       98501    98546      +45     
==========================================
+ Hits        60265    60349      +84     
+ Misses      34667    34619      -48     
- Partials     3569     3578       +9     
Impacted Files Coverage Δ
x/wasm/client/cli/tx.go 16.10% <50.00%> (ø)
internal/os/file.go 76.19% <76.19%> (ø)
x/distribution/client/cli/utils.go 57.14% <100.00%> (+11.68%) ⬆️
crypto/keys/internal/ecdsa/privkey.go 82.45% <0.00%> (-1.76%) ⬇️
x/wasm/keeper/keeper.go 85.80% <0.00%> (-0.37%) ⬇️
x/collection/msgs.go 41.29% <0.00%> (+4.62%) ⬆️
x/token/msgs.go 38.57% <0.00%> (+8.12%) ⬆️
x/token/validation.go 90.90% <0.00%> (+21.81%) ⬆️

@tnasu tnasu changed the title Add ReadFileWithSizeLimit and use it on x/wasm feat add ReadFileWithSizeLimit and use it on x/wasm Oct 5, 2022
@tnasu tnasu changed the title feat add ReadFileWithSizeLimit and use it on x/wasm feat: add ReadFileWithSizeLimit and use it on x/wasm Oct 5, 2022
@tnasu tnasu self-assigned this Oct 5, 2022
@tnasu tnasu marked this pull request as ready for review October 5, 2022 10:28
Copy link
Contributor

@dudong2 dudong2 left a comment

Choose a reason for hiding this comment

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

LGTM

@tnasu
Copy link
Member Author

tnasu commented Oct 11, 2022

Add to address it on x/distribution

CHANGELOG.md Outdated
Comment on lines 76 to 77
* (x/wasm) [\#696](https://github.com/line/lbm-sdk/pull/696) x/wasm - add checking a wasm file size before reading it
* (x/distribution) [\#696](https://github.com/line/lbm-sdk/pull/696) x/distribution - add checking a proposal file size before reading it
Copy link
Member

Choose a reason for hiding this comment

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

How about changing one line?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated it. Thanks

@zemyblue zemyblue requested review from zemyblue and dudong2 October 11, 2022 04:49
@tnasu tnasu merged commit df29ba8 into Finschia:main Oct 11, 2022
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