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

only warn once per compilation unit for solc-version detector #1593

Closed
0xalpharush opened this issue Jan 11, 2023 · 5 comments
Closed

only warn once per compilation unit for solc-version detector #1593

0xalpharush opened this issue Jan 11, 2023 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@0xalpharush
Copy link
Contributor

Describe the desired feature

Currently a result is created for every file but we could only warn once for each version that is considered too recent

@0xalpharush 0xalpharush added the enhancement New feature or request label Jan 11, 2023
@0xalpharush 0xalpharush changed the title only warn once per compilation unit for solc-version only warn once per compilation unit for solc-version detector Jan 11, 2023
@0xalpharush 0xalpharush added the good first issue Good for newcomers label Jan 11, 2023
@EnbangWu
Copy link

Can I take on this issue? I think it's incorrect_solc.py detector right?

@0xalpharush
Copy link
Contributor Author

@EnbangWu That would be great! Yes, it's incorrect_solc.py. I think a good way to fix this would be to make disallowed_pragmas a set instead of list so that only unique results are kept.

disallowed_pragmas = []
for p in pragma:
# Skip any pragma directives which do not refer to version
if len(p.directive) < 1 or p.directive[0] != "solidity":
continue
# This is version, so we test if this is disallowed.
reason = self._check_pragma(p.version)
if reason:
disallowed_pragmas.append((reason, p))
# If we found any disallowed pragmas, we output our findings.
if disallowed_pragmas:

Then, you'll may need to update the detector's tests using python ./tests/test_detectors.py --overwrite as explained here. Lmk if you need help or have questions!

@EnbangWu
Copy link

That's a great help! Thanks a lot, @0xalpharush !

@EnbangWu
Copy link

EnbangWu commented Jan 15, 2023

OK just wrote two test solidity files using version 0.8.17 ( as how the too_recent_versions are defined in incorrect.sol) Running slither . would give us
Pragma version^0.8.17 (test1.sol#2) necessitates a version too recent to be trusted. Consider deploying with 0.6.12/0.7.6/0.8.16 solc-0.8.17 is not recommended for deployment Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity
Pragma version^0.8.17 (test2.sol#2) necessitates a version too recent to be trusted. Consider deploying with 0.6.12/0.7.6/0.8.16 solc-0.8.17 is not recommended for deployment Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity

would like to see something like this:
Pragma version^0.8.17 (test1.sol#2), (test2.sol#2) necessitates a version too recent to be trusted. Consider deploying with 0.6.12/0.7.6/0.8.16 solc-0.8.17 is not recommended for deployment Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity

@EnbangWu
Copy link

Just made the pull request. Is there a way I can run the slither and see the changed output locally? Or should I duplicate the detector file and customize it and then run python3 incorrect_solc.py by taking some test sol files as inputs?
Sorry, it's a lot, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants