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: Setup Slither #7

Merged
merged 24 commits into from
Feb 21, 2024
Merged

Conversation

gpylypchuk
Copy link
Contributor

@gpylypchuk gpylypchuk commented Feb 15, 2024

Resolves #3 issue.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

src/NftReward.sol Fixed Show resolved Hide resolved
@gpylypchuk gpylypchuk marked this pull request as ready for review February 15, 2024 18:09
@gpylypchuk
Copy link
Contributor Author

I'm ignoring the Slither warning because the actual contracts of OpenZeppelin are with pragma solidity ^0.8.20

@0x4007 0x4007 requested a review from rndquu February 15, 2024 19:13
@@ -197,6 +199,7 @@ contract NftReward is Initializable, ERC721Upgradeable, OwnableUpgradeable, Paus
* @param _newMinter New minter address
*/
function setMinter(address _newMinter) external onlyOwner {
require(_newMinter != address(0), "Minter cannot be zero address");
Copy link
Member

Choose a reason for hiding this comment

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

Pls add tests for all newly added require() statements

@gpylypchuk gpylypchuk requested a review from rndquu February 16, 2024 19:40
@gpylypchuk gpylypchuk changed the title Setup Slither feat: Setup Slither Feb 16, 2024
@gpylypchuk
Copy link
Contributor Author

gpylypchuk commented Feb 16, 2024

should I add the merged changes to this PR? (about #4)

@rndquu
Copy link
Member

rndquu commented Feb 16, 2024

should I add the merged changes to this PR? (about #4)

Yes, you should merge the development branch because there are code conflicts which should be resolved

@gpylypchuk
Copy link
Contributor Author

Done @rndquu !

Copy link
Member

@rndquu rndquu left a comment

Choose a reason for hiding this comment

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

  1. There is still this warning:
NftReward.safeMint(NftReward.MintRequest,bytes) (src/NftReward.sol#145-176) uses timestamp for comparisons
	Dangerous comparisons:
	- require(bool,string)(block.timestamp < _mintRequest.deadline,Signature expired) (src/NftReward.sol#155)
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#block-timestamp

I think we can simply exclude the block-timestamp detector.

  1. There is still this warning:
Pragma version^0.8.20 (src/NftReward.sol#2) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.
solc-0.8.24 is not recommended for deployment
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity

What if we use solidity v0.8.18?

  1. There is still this info warning:
Parameter NftReward.invalidateNonce(uint256)._nonceValue (src/NftReward.sol#223) is not in mixedCase
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions

Either exclude this detector either refactor the code.

  1. Pls make sure the slither check workflow fails on any warning in the NftReward.sol contract

  2. Pls update the slither worflow to run only when *.sol files are changed

@gpylypchuk
Copy link
Contributor Author

  1. There is still this warning:
NftReward.safeMint(NftReward.MintRequest,bytes) (src/NftReward.sol#145-176) uses timestamp for comparisons
	Dangerous comparisons:
	- require(bool,string)(block.timestamp < _mintRequest.deadline,Signature expired) (src/NftReward.sol#155)
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#block-timestamp

I think we can simply exclude the block-timestamp detector.

  1. There is still this warning:
Pragma version^0.8.20 (src/NftReward.sol#2) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.
solc-0.8.24 is not recommended for deployment
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity

What if we use solidity v0.8.18?

  1. There is still this info warning:
Parameter NftReward.invalidateNonce(uint256)._nonceValue (src/NftReward.sol#223) is not in mixedCase
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions

Either exclude this detector either refactor the code.

  1. Pls make sure the slither check workflow fails on any warning in the NftReward.sol contract
  2. Pls update the slither worflow to run only when *.sol files are changed

In 2, I tested before and there is still the warning because of the OZ libraries

@rndquu
Copy link
Member

rndquu commented Feb 19, 2024

In 2, I tested before and there is still the warning because of the OZ libraries

But there is no warning for NftReward.sol in this case, right?

@gpylypchuk
Copy link
Contributor Author

In 2, I tested before and there is still the warning because of the OZ libraries

But there is no warning for NftReward.sol in this case, right?

correct!

@rndquu
Copy link
Member

rndquu commented Feb 19, 2024

In 2, I tested before and there is still the warning because of the OZ libraries

But there is no warning for NftReward.sol in this case, right?

correct!

Then it makes sense to update NftReward.sol to use solidity v0.8.18 since OZ contracts are not part of this project

src/NftReward.sol Fixed Show resolved Hide resolved
@gpylypchuk
Copy link
Contributor Author

Should we fail on medium or low? Also I think we should Ignore the OZ libraries 🤔

@rndquu
Copy link
Member

rndquu commented Feb 19, 2024

Should we fail on medium or low? Also I think we should Ignore the OZ libraries 🤔

Yes, we use this strategy (fall on any slither warning or compiler warning) in our main repo https://github.com/ubiquity/ubiquity-dollar/

Not all of the slither detectors are included in our main repo because it makes sense to be reasonable (for example, block.timestamp related warnings can be excluded)

@gpylypchuk
Copy link
Contributor Author

Should we fail on medium or low? Also I think we should Ignore the OZ libraries 🤔

Yes, we use this strategy (fall on any slither warning or compiler warning) in our main repo https://github.com/ubiquity/ubiquity-dollar/

Not all of the slither detectors are included in our main repo because it makes sense to be reasonable (for example, block.timestamp related warnings can be excluded)

yep, I added a detector ignore about OZ libraries & timestamp

@gpylypchuk
Copy link
Contributor Author

@rndquu should I add this: "exclude_informational": true to ignore this solc-0.8.24 is not recommended for deployment Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity ?

@gpylypchuk gpylypchuk requested a review from rndquu February 19, 2024 20:06
@rndquu
Copy link
Member

rndquu commented Feb 20, 2024

@rndquu should I add this: "exclude_informational": true to ignore this solc-0.8.24 is not recommended for deployment Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity ?

If we remove the exclude_informational config the slither workflow still passes, right?

@gpylypchuk
Copy link
Contributor Author

gpylypchuk commented Feb 20, 2024

@rndquu should I add this: "exclude_informational": true to ignore this solc-0.8.24 is not recommended for deployment Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity ?

If we remove the exclude_informational config the slither workflow still passes, right?

No, I think that is because is like a low vuln.
In this commit I removed the exclude_informational and the log show that failed because of that.

@rndquu
Copy link
Member

rndquu commented Feb 20, 2024

@rndquu should I add this: "exclude_informational": true to ignore this solc-0.8.24 is not recommended for deployment Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity ?

If we remove the exclude_informational config the slither workflow still passes, right?

No, I think that is because is like a low vuln. In this commit I removed the exclude_informational and the log show that failed because of that.

I don't understand from the log output, what file causes the solc-0.8.24 is not recommended for deployment error?

@gpylypchuk
Copy link
Contributor Author

gpylypchuk commented Feb 20, 2024

exclude_informational

That is because slither only recommends deployment with the version 0.8.18 and the OZ contracts are in ^0.8.20 so there is no way to not recognize that error.

@gpylypchuk
Copy link
Contributor Author

I just added a line in foundry.toml about solc_version = "0.8.20" so you can select the version you want to compile.

@rndquu
Copy link
Member

rndquu commented Feb 20, 2024

I just added a line in foundry.toml about solc_version = "0.8.20" so you can select the version you want to compile.

But that doesn't solve the warning as far as I understand

Overall we shouldn't exclude all low level issues. This is getting out of hand so lets:

  1. Remove exclude_informational: true
  2. Add the solc-version detector to exceptions. The only valid case I can think of is the usage of the PUSH0 instruction which is mainly supported.

@gpylypchuk
Copy link
Contributor Author

I just added a line in foundry.toml about solc_version = "0.8.20" so you can select the version you want to compile.

But that doesn't solve the warning as far as I understand

Overall we shouldn't exclude all low level issues. This is getting out of hand so lets:

  1. Remove exclude_informational: true
  2. Add the solc-version detector to exceptions. The only valid case I can think of is the usage of the PUSH0 instruction which is mainly supported.

done!

@rndquu rndquu requested a review from gitcoindev February 21, 2024 14:36
Copy link
Contributor

@gitcoindev gitcoindev left a comment

Choose a reason for hiding this comment

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

Reviewed, read all comments and approving from my side, too!

@gitcoindev gitcoindev merged commit ede7d05 into ubiquity:development Feb 21, 2024
3 checks passed
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.

Setup slither
4 participants