slither icon indicating copy to clipboard operation
slither copied to clipboard

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

Open 0xdamon opened this issue 3 years ago • 1 comments

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

0xdamon avatar Oct 01 '22 03:10 0xdamon

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

elopez avatar Oct 03 '22 20:10 elopez