slither fails to resolve imports in dependency due to issue in foundry
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the issue:
`forge` is able to compile the contracts and run the test successfully, but `slither` fails to resolve the imports in the dependency even when the `--ignore-compile` flag is passed.
### Code example to reproduce the issue:
Repo: https://github.com/alphastorm/slither-import-breaking
Steps:
- `forge init` a new repo
- `forge install euler-xyz/euler-price-oracle`
- add `euler-price-oracle/=lib/euler-price-oracle/` to `remappings.txt`
- add this import to `Counter.sol`: `import { BaseAdapter, Errors, IPriceOracle } from "euler-price-oracle/src/adapter/BaseAdapter.sol";`
### Version:
0.10.3
### Relevant log output:
```shell
~/Dev/slither-import-breaking master forge test ✔ cove-contracts-boosties 3.9.17 01:59:22 PM
[⠊] Compiling...
[⠃] Compiling 28 files with Solc 0.8.23
[⠊] Solc 0.8.23 finished in 869.49ms
Compiler run successful!
Ran 2 tests for test/Counter.t.sol:CounterTest
[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 31154, ~: 31310)
[PASS] test_Increment() (gas: 31325)
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 11.80ms (6.66ms CPU time)
Ran 1 test suite in 119.02ms (11.80ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)
~/Dev/slither-import-breaking master forge clean ✔ cove-contracts-boosties 3.9.17 01:59:26 PM
~/Dev/slither-import-breaking master forge build --build-info --skip '*/test/**' '*/script/**' ✔ cove-contracts-boosties 3.9.17 01:59:29 PM
[⠊] Compiling...
[⠒] Compiling 5 files with Solc 0.8.23
[⠢] Solc 0.8.23 finished in 20.93ms
Compiler run successful!
~/Dev/slither-import-breaking master slither --version ✔ cove-contracts-boosties 3.9.17 01:59:33 PM
0.10.3
~/Dev/slither-import-breaking master slither . --ignore-compile ✔ cove-contracts-boosties 3.9.17 01:59:38 PM
--ignore-compile used, if something goes wrong, consider removing the ignore compile flag
Traceback (most recent call last):
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/bin/slither", line 8, in
sys.exit(main())
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 782, in main
main_impl(all_detector_classes=detectors, all_printer_classes=printers)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 888, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 113, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 80, in process_single
slither = Slither(target, ast_format=ast, **vars(args))
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/slither.py", line 156, in __init__
sol_parser.parse_top_level_items(ast, path)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 326, in parse_top_level_items
get_imported_scope = self.compilation_unit.get_scope(import_directive.filename)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/core/compilation_unit.py", line 282, in get_scope
filename = self._crytic_compile_compilation_unit.crytic_compile.filename_lookup(
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 283, in filename_lookup
raise ValueError(f"{filename} does not exist")
ValueError: src/interfaces/IPriceOracle.sol does not exist
~/Dev/slither-import-breaking master slither . 1 ✘ cove-contracts-boosties 3.9.17 01:59:43 PM
'forge clean' running (wd: /Users/srs/Development/slither-import-breaking)
'forge config --json' running
'forge build --build-info --skip */test/** */script/** --force' running (wd: /Users/srs/Development/slither-import-breaking)
Traceback (most recent call last):
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/bin/slither", line 8, in
sys.exit(main())
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 782, in main
main_impl(all_detector_classes=detectors, all_printer_classes=printers)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 888, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 113, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/__main__.py", line 80, in process_single
slither = Slither(target, ast_format=ast, **vars(args))
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/slither.py", line 156, in __init__
sol_parser.parse_top_level_items(ast, path)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 326, in parse_top_level_items
get_imported_scope = self.compilation_unit.get_scope(import_directive.filename)
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/slither/core/compilation_unit.py", line 282, in get_scope
filename = self._crytic_compile_compilation_unit.crytic_compile.filename_lookup(
File "/Users/srs/.pyenv/versions/cove-contracts-boosties/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 283, in filename_lookup
raise ValueError(f"{filename} does not exist")
ValueError: src/interfaces/IPriceOracle.sol does not exist
```
Contributor guide
Assessment
This issue has not been assessed yet.