2

I have a hardhat project on my local system. For running Mythril security analysis I am using the following command:

myth analyze contracts/MyFile.sol --execution-timeout 900 Receiving the following error:

ParserError: Source "@openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File not found. Searched the following locations: "".

How do I include openzeppelin and other file import locations in the command?

Mythril version v0.22.43

2 Answers 2

4

As mentioned here, myth doesn't know what @openzeppelin is and you have to map this to explicit path to the imported contract. You need to specify path to node_modules where @openzeppelin contracts is presented to help myth replace @openzeppelin string with original path and find them.

To do that you can create .json file with remappings (e.g. in project root) with such content:

{   
"remappings": [ "@openzeppelin/=/share/node_modules/@openzeppelin/" ]
}

*In my case absolut path starts with /share/... as I use docker volume.

Add this file path as option --solc-json /path/to/remappings/file.json to analyze command.

Final command using docker looks like:

docker run -it -v $(pwd):/share  mythril/myth analyze  /share/Contract.sol --solc-json /share/remappings.json

(I runned docker container from project directory, but should works in your case too)

Final command without docker is almost the same:

myth analyze  /path/to/Contract.sol --solc-json /path/to/remappings.json
0

How would you create the path for if you were using remappings for: "@rari-capital/solmate/src/utils/SafeCastLib.sol"

I can't seem to get my head around the framework you're using to create the remapping?

@bestpilot

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.