trailofbits / manticore

Symbolic execution tool
https://blog.trailofbits.com/2017/04/27/manticore-symbolic-execution-for-humans/
GNU Affero General Public License v3.0
3.67k stars 472 forks source link

Failed to build contract None Errors : Invalid solc compilation Error: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found. #2497

Open patelvishal1401 opened 2 years ago

patelvishal1401 commented 2 years ago

Summary of the problem

Imported contract not found Manticore

Command : manticore path to /A.sol

Manticore version

Summary: Manticore is a symbolic execution tool for analysis of binaries and smart contracts. Home-page: https://github.com/trailofbits/manticore Author: Trail of Bits Author-email: License: UNKNOWN Location: /usr/local/lib/python3.9/site-packages Requires: intervaltree, ply, wasm, pysha3, pyyaml, crytic-compile, pyevmasm, protobuf, z3-solver, prettytable, rlp Required-by:

Python version

Python 2.7.16

OS / Environment

MacOs Big Sur : Ver 11.6 (20G165)

Dependencies

asn1crypto==1.4.0 attrdict==2.0.1 attrs==21.2.0 blake2b-py==0.1.4 cached-property==1.5.2 certifi==2021.10.8 cffi==1.15.0 charset-normalizer==2.0.7 click==7.1.2 coincurve==15.0.1 coloredlogs==15.0.1 configparser==5.0.2 coverage==6.0.2 crytic-compile==0.2.1 cycler==0.10.0 cytoolz==0.11.0 dictionaries==0.0.2 eth-abi==1.3.0 eth-account==0.3.0 eth-bloom==1.0.4 eth-hash==0.3.2 eth-keyfile==0.5.1 eth-keys==0.2.4 eth-rlp==0.2.1 eth-tester==0.1.0b32 eth-typing==2.2.2 eth-utils==1.9.0 ethereum==2.3.2 ethereum-input-decoder==0.2.2 future==0.18.2 hexbytes==0.2.2 htmlmin==0.1.12 humanfriendly==10.0 idna==3.3 inflection==0.5.0 intervaltree==3.1.0 Jinja2==2.11.2 jsonschema==3.2.0 kiwisolver==1.3.2 lru-dict==1.1.7 manticore==0.3.6 MarkupSafe==2.0.1 matplotlib==3.4.3 mock==4.0.3 mypy-extensions==0.4.3 mythril==0.22.27 mythx-cli==0.6.22 mythx-models==1.9.1 numpy==1.19.0 parsimonious==0.8.1 pbkdf2==1.3 persistent==4.7.0 Pillow==8.4.0 ply==3.11 plyvel==1.3.0 prettytable==2.2.1 protobuf==3.14.0 py-ecc==1.6.0 py-evm==0.3.0a13 py-flags==1.1.4 py-solc==3.2.0 py-solc-x==1.0.0 pycparser==2.20 pycryptodome==3.11.0 pyethash==0.1.27 pyevmasm==0.2.3 PyJWT==1.7.1 pyparsing==2.4.7 pyrsistent==0.18.0 pysha3==1.0.2 python-dateutil==2.8.1 pythx==1.6.1 PyYAML==5.3.1 repoze.lru==0.7 requests==2.26.0 rlp==1.2.0 scrypt==0.8.18 semantic-version==2.8.5 six==1.15.0 sortedcontainers==2.4.0 tabulate==0.8.7 toolz==0.11.1 transaction==3.0.1 trie==1.4.0 typing-extensions==3.10.0.2 urllib3==1.26.7 wasm==1.2 wcwidth==0.2.5 z3-solver==4.8.12.0 zope.interface==5.4.0

0xalpharush commented 2 years ago

Are you using a framework like hardhat? Can you run crytic-compile <your-file> and let us know if that works?

superical commented 2 years ago

Are you using a framework like hardhat? Can you run crytic-compile <your-file> and let us know if that works?

@0xalpharush I'm having similar issue as @patelvishal1401 with manticore not resolving Open Zeppelin libraries imported from node modules folder. I'm using Hardhat. I get a bunch of errors like these when I run manticore against one of my contracts:

[83553] m.e.manticore:INFO: Failed to build contract None Errors : Invalid solc compilation Error: Source "@openzeppelin/contracts/proxy/utils/Initializable.sol" not found: File not found. Searched the following locations: "".
 --> contracts/MyTestContract.sol:4:1:
  |
4 | import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...

When I run crytic-compile contracts/MyTestContract.sol, I get the following:

INFO:CryticCompile:Compilation warnings/errors on contracts/MyTestContract.sol:
Invalid option to --combined-json: compact-format

ERROR:CryticCompile:Invalid solc compilation Invalid option to --combined-json: compact-format

Is there something else I should also do to get manticore to resolve the imported contracts from node modules?

0xmichalis commented 1 year ago

May be worth to document this somewhere but this is fixed by remapping:

manticore [path/to/contract] --solc-remaps "@openzeppelin/=node_modules/@openzeppelin/"