-
Notifications
You must be signed in to change notification settings - Fork 989
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
Remapping Troubleshooting FAQ to README #2236
Conversation
@@ -274,6 +274,22 @@ If you have a `node_modules/` folder, it must be in the same directory as `contr | |||
run the compilation command for the framework you are using e.g `npx hardhat compile`. That must work successfully; | |||
otherwise, slither's compilation engine, crytic-compile, cannot generate the AST. | |||
|
|||
* If `node_modules/` is not in your `contracts/` directory of your project, you will need to involve **remappings**. If a project has dependencies like OpenZeppelin or Chainlink, but you want to run Slither on a single `.sol` file or use [slither's tools](https://github.com/crytic/slither#tools) like `slither-check-erc`, you can add the `--solc-remaps @=node_modules/@` flag and/or configure `slither.config.json` in your project's root with the remapping. If `slither.config.json` remappings are setup the flag is no longer needed unless using [slither's tools](https://github.com/crytic/slither#tools). Foundry projects also require remappings if you want to analyze a specific `.sol` file that requires imports. Read more here: [Foundry Static Analysis Docs](https://book.getfoundry.sh/config/static-analyzers). | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foundry projects also require remappings if you want to analyze a specific
.sol
file that requires imports. Read more here: Foundry Static Analysis Docs.
I'm not sure this is accurate as of the 0.10.0 release. We use Foundry (which automatically configures the remappings) to compile single files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the last bit ("... or use a slither tool like slither-check-erc
...") is accurate either. You can run both slither
and tools like slither-check-erc
with a project directory (like .
) as target and not worry about remappings; in the case of standalone tools, they take the contract name you want to analyze:
% slither-check-erc . Counter
# Check Counter
## Check functions
[ ] totalSupply() is missing
[ ] balanceOf(address) is missing
[ ] transfer(address,uint256) is missing
[ ] transferFrom(address,address,uint256) is missing
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elopez is correct my mistake, slither-check-erc . Counter
does work without any remappings.
README.md
Outdated
@@ -274,6 +274,22 @@ If you have a `node_modules/` folder, it must be in the same directory as `contr | |||
run the compilation command for the framework you are using e.g `npx hardhat compile`. That must work successfully; | |||
otherwise, slither's compilation engine, crytic-compile, cannot generate the AST. | |||
|
|||
* If `node_modules/` is not in your `contracts/` directory of your project, you will need to involve **remappings**. If a project has dependencies like OpenZeppelin or Chainlink, but you want to run Slither on a single `.sol` file or use [slither's tools](https://github.com/crytic/slither#tools) like `slither-check-erc`, you can add the `--solc-remaps @=node_modules/@` flag and/or configure `slither.config.json` in your project's root with the remapping. If `slither.config.json` remappings are setup the flag is no longer needed unless using [slither's tools](https://github.com/crytic/slither#tools). Foundry projects also require remappings if you want to analyze a specific `.sol` file that requires imports. Read more here: [Foundry Static Analysis Docs](https://book.getfoundry.sh/config/static-analyzers). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* If `node_modules/` is not in your `contracts/` directory of your project, you will need to involve **remappings**. If a project has dependencies like OpenZeppelin or Chainlink, but you want to run Slither on a single `.sol` file or use [slither's tools](https://github.com/crytic/slither#tools) like `slither-check-erc`, you can add the `--solc-remaps @=node_modules/@` flag and/or configure `slither.config.json` in your project's root with the remapping. If `slither.config.json` remappings are setup the flag is no longer needed unless using [slither's tools](https://github.com/crytic/slither#tools). Foundry projects also require remappings if you want to analyze a specific `.sol` file that requires imports. Read more here: [Foundry Static Analysis Docs](https://book.getfoundry.sh/config/static-analyzers). | |
* If `node_modules/` is not in the `contracts/` directory of your project, you may need to use **remappings**. If a project has dependencies such as OpenZeppelin and you want to run Slither on a single `.sol` file or use a [slither tool](https://github.com/crytic/slither#tools) like `slither-check-erc`, add the remapping on the command line e.g. `--solc-remaps @=node_modules/@` or to the `slither.config.json` in your project's root. Note, this should not be required for Foundry projects as it is handled automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! We need to publish the FAQs somewhere besides the README but this is fine in the meantime
Please run https://github.com/DavidAnson/markdownlint |
Let me know if you'd like anything else, latest attempt is |
(I ran the markdownlint in both cases and passed, but the Lint Code Base Superlinter failed). |
FAQ for others figuring out the remappings in order to run slither on a single contract that had imports from OpenZeppelin. I also found that remapping was needed for the special slither tools like
slither-check-erc
.This adds another bullet point to the FAQ about remaps and setting up slither.config.json if node_modules is not in the same housing as contracts/, using hardhat as an example.