Skip to content
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

Mythril cannot identify imported openzeppelin contracts in foundry project. #1816

Open
itsabinashb opened this issue Nov 4, 2023 · 5 comments

Comments

@itsabinashb
Copy link

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'
@norhh
Copy link
Collaborator

norhh commented Nov 6, 2023

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

@itsabinashb
Copy link
Author

Yes, it is still persist.

@norhh
Copy link
Collaborator

norhh commented Nov 8, 2023

Did you try v0.22.2?

@derawl
Copy link

derawl commented Jan 23, 2024

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";

@norhh
Copy link
Collaborator

norhh commented Jan 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants