crytic / slither

Static Analyzer for Solidity and Vyper
https://blog.trailofbits.com/2018/10/19/slither-a-solidity-static-analysis-framework/
GNU Affero General Public License v3.0
5.28k stars 966 forks source link

[Bug-Candidate]: slither . doesn't work on Docker image with error message KeyError: 'ast' #1391

Open 0xdamon opened 2 years ago

0xdamon commented 2 years ago

Describe the issue:

I ran

docker run -it -v <PATH_TO_HARDHAT_PROJECT>:/share trailofbits/eth-security-toolbox

then within the container, in the /share folder I ran slither .

I got the following error message

Traceback (most recent call last):
  File "/home/ethsec/.local/lib/python3.6/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/ethsec/.local/lib/python3.6/site-packages/slither/__main__.py", line 76, in process_all
    compilations = compile_all(target, **vars(args))
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 637, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 117, in __init__
    self._compile(**kwargs)
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 548, in _compile
    self._platform.compile(self, **kwargs)
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/platform/hardhat.py", line 177, in compile
    compilation_unit.asts[path.absolute] = info["ast"]
KeyError: 'ast'
None
Error in .
Traceback (most recent call last):
  File "/home/ethsec/.local/lib/python3.6/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/ethsec/.local/lib/python3.6/site-packages/slither/__main__.py", line 76, in process_all
    compilations = compile_all(target, **vars(args))
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 637, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 117, in __init__
    self._compile(**kwargs)
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 548, in _compile
    self._platform.compile(self, **kwargs)
  File "/home/ethsec/.local/lib/python3.6/site-packages/crytic_compile/platform/hardhat.py", line 177, in compile
    compilation_unit.asts[path.absolute] = info["ast"]
KeyError: 'ast'

I was able to replicate this by pip3 install and run on my local machine instead.

Code example to reproduce the issue:

slither .

Version:

0.8.3

Relevant log output:

No response

elopez commented 2 years ago

Hi @0xdamon, thanks for the report. Could you share the hardhat config file your project uses here?