mythril icon indicating copy to clipboard operation
mythril copied to clipboard

Mythril cannot identify imported openzeppelin contracts in foundry project.

Open itsabinashb opened this issue 1 year ago • 5 comments

My mythril.solc.json file looks like this:

{
  "remappings": [
    "@openzeppelin/contracts/access/=lib/openzeppelin-contracts/contracts/access/",
    "@openzeppelin/contracts/utils/=lib/openzeppelin-contracts/contracts/utils/"
  ],
  "optimizer":{
    "enabled": true,
    "runs": 500
  }
}

The error i get:

abinash@hacek:~/Desktop/Lottery$ myth analyze ./src/Lottery.sol --solc-json mythril.solc.json
mythril.interfaces.cli [ERROR]: Traceback (most recent call last):
  File "/home/abinash/.local/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 966, in parse_args_and_execute
    address = load_code(disassembler, args)
  File "/home/abinash/.local/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 717, in load_code
    address, _ = disassembler.load_from_solidity(
  File "/home/abinash/.local/lib/python3.10/site-packages/mythril/mythril/mythril_disassembler.py", line 297, in load_from_solidity
    for contract in get_contracts_from_file(
  File "/home/abinash/.local/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 132, in get_contracts_from_file
    yield SolidityContract(
  File "/home/abinash/.local/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 197, in __init__
    ).extract_features()
  File "/home/abinash/.local/lib/python3.10/site-packages/mythril/solidity/features.py", line 31, in extract_features
    all_require_vars.update(modifier_vars[modifier["modifierName"]["name"]])
KeyError: 'Ownable'

itsabinashb avatar Nov 04 '23 12:11 itsabinashb

Can you try it with the develop version of the code and see if the issue still persists?

norhh avatar Nov 06 '23 07:11 norhh

Yes, it is still persist.

itsabinashb avatar Nov 07 '23 18:11 itsabinashb

Did you try v0.22.2?

norhh avatar Nov 08 '23 02:11 norhh

I have the same issue

ParserError: Source "@openzeppelin/contracts/access/AccessControl.sol" not found: File not found. Searched the following locations: "".
 --> /nftTradingCards/src/Factory1155.sol:6:1:
  |
6 | import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

derawl avatar Jan 23 '24 07:01 derawl

Hi @derawl , this is a different issue, can you log a bug report for this?

norhh avatar Jan 24 '24 14:01 norhh