-
Notifications
You must be signed in to change notification settings - Fork 442
fix(gnovm): fix private package re-upload issue (#4871) #4877
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
base: master
Are you sure you want to change the base?
Conversation
Fixed incorrect operation order preventing re-upload of edited private packages. Also added a test case for this scenario.
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
gno.land/pkg/sdk/vm/keeper.go
Outdated
| // Private packages can be re-uploaded (overwritten). | ||
| if !gm.Private { | ||
| return ErrPkgAlreadyExists("package already exists: " + pkgPath) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove object of the previous realm from the store ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a .txtar integration test to ensure this behaviour works on-chain?
Try making sure also that we can modify function and method signatures, and that if a method/function is removed it doesn't exist anymore.
mvertes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general idea is ok, but extra care must be taken to not introduce a vulnerability.
gno.land/pkg/sdk/vm/keeper.go
Outdated
| if pv := gnostore.GetPackage(pkgPath, false); pv != nil { | ||
| return ErrPkgAlreadyExists("package already exists: " + pkgPath) | ||
| // Private packages can be re-uploaded (overwritten). | ||
| if !gm.Private { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful: the Private property must be asserted on the package already present in the store, not the new one, otherwise it's a security breach, where any loaded package could be overwritten (by a private instance)!
Can you try again, this time testing pv.Private?
In this case, no need to compute gm before, as you did. The original order should still be correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with @mvertes . aside, should a private package can only be overridden/upgraded by another private package? maybe not. but if so, we need to check both. cc:/ @moul @thehowl @MikaelVallenet for more insights.
also, it seems more reasonable and economical to check pkg existence before TypeCheckMemPackage and ParseMemPackage, so maybe the original order is more reasonable, what do you think?
…eset the original check order, use pv instead of gm for first check
|
@thehowl does the test you mention for function and method signatures are already here ? I added the basic tests for private packages by creating I reverted the operations order, and used pv.Private instead of gm.Private. I also added checks that prevents overwriting a public package with a private one and vice-versa, but let me know if you want me to remove that one as private > public may be a wanted feature to have. Also, thanks everyone for the reviews :) |
Fixed incorrect operation order preventing re-upload of edited private packages.
Also added a test case for this scenario.