This repository has been archived by the owner on Jul 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Warn if contract has a selfdestruct call #347
Merged
+112
−2
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c72a5d9
Warn if contract has a selfdestruct call
5faf4e6
Fixed test fails.
5dcedf9
Minor style change
15be6a0
@spalladino Correct, the original approach did not work. I had misun…
3b98da0
Addressing feedback
ea47e8e
Merge branch 'master' of https://github.com/zeppelinos/zos-cli
1338c53
Added a delegatecall warning.
7474a1d
Addressing feedback.
6354853
Fixed test fails.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,10 +92,32 @@ contract('add script', function() { | |
this.logs.errors[0].should.match(/constructor/i); | ||
}); | ||
|
||
it('should not warn when adding a contract without a constructor', async function() { | ||
it('should not warn when adding a contract without a constructor or a selfdestruct call', async function() { | ||
add({ contractsData, packageFile: this.packageFile }); | ||
|
||
this.logs.errors.should.have.lengthOf(0); | ||
this.logs.warns.should.have.lengthOf(0); | ||
}); | ||
|
||
it('should warn when adding a contract with a selfdestruct call', async function() { | ||
add({ contractsData: [{ name: 'WithSelfDestruct', alias: 'WithSelfDestruct' }], packageFile: this.packageFile }); | ||
|
||
this.logs.warns.should.have.lengthOf(1); | ||
this.logs.warns[0].should.match(/selfdestruct/i); | ||
}); | ||
|
||
it('should warn when adding a contract who\'s parent has a selfdestruct call', async function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. who' s => whose (sorry, grammar nazi here) |
||
add({ contractsData: [{ name: 'WithParentWithSelfDestruct', alias: 'WithParentWithSelfDestruct' }], packageFile: this.packageFile }); | ||
|
||
this.logs.warns.should.have.lengthOf(1); | ||
this.logs.warns[0].should.match(/selfdestruct/i); | ||
}); | ||
|
||
it('should warn when adding a contract with a delegatecall call', async function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test for |
||
add({ contractsData: [{ name: 'WithDelegateCall', alias: 'WithDelegateCall' }], packageFile: this.packageFile }); | ||
|
||
this.logs.warns.should.have.lengthOf(1); | ||
this.logs.warns[0].should.match(/delegatecall/i); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's change:
Avoid using low-level function 'delegatecall'. This is potentially a security risk.
To the following:
This is potentially a security risk, as the logic contract could be destructed by issuing a delegatecall to another contract with a selfdestruct instruction.
WDYT?