-
Notifications
You must be signed in to change notification settings - Fork 996
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
solc 0.5.12 causes TypeError: argument of type 'int' is not iterable due to bug in AST output #1319
Comments
Can you put this on github? |
I am having same issue. Seems like the problem is here: slither/slither/solc_parsing/slither_compilation_unit_solc.py Lines 47 to 53 in ce9dbf6
And
Would it be possible to define types for some of these AST nodes, so they're not just Does anyone have a link to the json AST schema? I can't seem to find it anywhere, just typescript libs like this: https://github.com/OpenZeppelin/solidity-ast . |
Any progress? I have tried narrowing it down as much as possible. It looks it has something to do with the compiler version. With You can test this easily in the repo below by editing |
By any chance, you tested using slither and crytic-compile from their respective master branches? |
Some problem. What I did:
I did this for both
Here's the error again, with the new line numbers:
|
The code I highlighted earlier is from the master branch. Most likely different compiler versions output a different json AST, and slither doesn't support them. |
@KholdStare Do you have any suggestions for a workaround or quickfix I can apply locally? |
Can you use solc |
I'm not sure, it is not my own codebase. I'm trying to reproduce a known vulnerabilty and "re-find" it with echidna. I'm not sure if updating to I might give it a try next week, but something like a small patch to |
@rappie as a temporary fix can you change in slitherbug |
Awesome! This indeed works. Thanks 😄 |
@smonicas @0xalpharush Hi, any acknowledgement about what I pointed out above as the bug? I think a lot of issues would be fixed if there were proper types for the AST. We currently cannot use Slither because of these kinds of issues - we don't want to be bending over backwards changing our code, just so that slither doesn't crash on it. I and my team can help out making fixes, but not if our comments are basically ignored. |
I have labeled this issue as a bug. Yes, having a typed AST would be nice; however, it is not our highest priority. We do our best to keep up with breaking changes in Solidity while maintaining backwards compatibility. There was an effort to separate the legacy and compact parsers, but it was not completed (#627). I will try to fix this specific issue soon. |
@0xalpharush Thanks for the reply. I think Slither's core strength is in the detectors etc. Right now it is hindered by the parsing stage which is just a necessary step to get to the detectors. Without the parsing stage, it renders the rest of it useless, so paradoxically IMHO it should be of high priority to do parsing properly. Taking a step back, I think there should be standalone library specifically handling AST parsing and having a single representation for all versions (not necessarily maintained by you, just in general). Slither could then use it and not have to worry about parsing. Does such a project exist in python land? It exists in typescript land: https://github.com/OpenZeppelin/solidity-ast . Any insights into who can start such a project? |
Hello, are there any updates on this issue, this bug also blocks us, we can't run CI solidity slighter audit jobs anymore.
|
Based off of this issue, the AST for solc 0.5.12 is completely missing the |
Thanks for pinpointing it to the solc bug. Looks like the earliest solc version in which it was fixed is 0.6.0, so unfortunately upgrading solc might require some changes in the solidity code base. The following patch applied to slither seems to work around the solc bug: diff --git a/slither/solc_parsing/slither_compilation_unit_solc.py b/slither/solc_parsing/slither_compilation_unit_solc.py
index d12bda1b..67614e84 100644
--- a/slither/solc_parsing/slither_compilation_unit_solc.py
+++ b/slither/solc_parsing/slither_compilation_unit_solc.py
@@ -47,6 +47,7 @@ def _handle_import_aliases(
for symbol_alias in symbol_aliases:
if (
"foreign" in symbol_alias
+ and not isinstance(symbol_alias["foreign"], int)
and "name" in symbol_alias["foreign"]
and "local" in symbol_alias
): If my reading is correct, this should do the right thing as long as the problematic imports are of the format import {Foo} from "bar.sol"; and not import {Foo as AnotherName} from "bar.sol"; (Of course, I'm not suggesting this should be applied to slither globally, since that would probably break the latter kind of imports.) |
We add a better error message and support |
Describe the issue:
Slither crashes.
Commands used:
Software used:
Yarn Berry (PnP), with old versions of hardhat, openzeppelin, etc.
Slither version 0.8.3
Python version 3.10.5
OS: Manjaro Linux (arch)
Error:
Code example to reproduce the issue:
https://github.com/rappie/slither-issue1319-environment
https://github.com/rappie/slither-issue1319-narrowed-down
Version:
0.8.3
Relevant log output:
No response
The text was updated successfully, but these errors were encountered: