I am trying to analyze a Solidity smart contract using Mythril via Docker on a Windows machine. The contract has dependencies on OpenZeppelin libraries installed via npm in the node_modules folder. When running Mythril to analyze the smart contract, I get the following error: ParserError: Source “@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol” not found: File not found.
Docker Version: Docker version 20.10.8, build 3967b7d
Mythril Version: Latest Docker image mythril/myth:latest
Solidity Compiler Version: 0.8.19+commit.7dd6d404.Windows.msvc
Node.js and npm Version: Node v16.13.1, npm 8.1.2 (if relevant)
I verified that the ReentrancyGuardUpgradeable.sol file exists in node_modules/@openzeppelin/contracts-upgradeable/security/, tried using the -v flag to mount the node_modules directory in Docker and also checked the version compatibility. Still the same error.
Here is a simplified piece:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {ReentrancyGuardUpgradeable} from '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
contract MiniCore is ReentrancyGuardUpgradeable {
// Minimal implementation that triggers the error
function exampleFunction() external nonReentrant {
// Function logic here
}
}
Here is the dir :
mini_core/
├── contracts/
│ └── core/
│ └── MiniCore.sol
├── node_modules/
│ └── @openzeppelin/
│ └── contracts-upgradeable/
│ └── security/
│ └── ReentrancyGuardUpgradeable.sol
As for the code I am running :
docker run -v “C:/Users/user/Desktop/x_man_hack/x_hack/mini_core:/share” -v “C:/Users/user/Desktop/x_man_hack/x_hack/mini_core/node_modules:/share/node_modules” mythril/myth analyze /share/contracts/core/MiniCore.sol
And getting the following error :
mythril.interfaces.cli [ERROR]: Solc experienced a fatal error.
ParserError: Source "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol" not found: File not found. Searched the following locations: "".
--> /share/contracts/core/MiniCore.sol:20:1:
romania is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.