crytic / slither

Static Analyzer for Solidity and Vyper
https://blog.trailofbits.com/2018/10/19/slither-a-solidity-static-analysis-framework/
GNU Affero General Public License v3.0
5.33k stars 967 forks source link

[Bug]: Slither cannot process file aliases #2309

Closed Tiko7454 closed 7 months ago

Tiko7454 commented 8 months ago

Describe the issue:

When I aliased a file, I cannot access its contracts using alias.contract notation

Code example to reproduce the issue:

# a.sol
pragma solidity 0.7.6;
import "b.sol" as B;
contract A is B.C{}
# b.sol
pragma solidity 0.7.6;
contract C{}

Version:

0.10.0

Relevant log output:

'solc --version' running
'solc a.sol --combined-json abi,ast,bin,bin-runtime,srcmap,srcmap-runtime,userdoc,devdoc,hashes,compact-format --allow-paths .,/home/tigran/temp/reduced' running
Compilation warnings/errors on a.sol:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> a.sol

Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> b.sol

Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.7.6;"
--> b.sol

Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.7.6;"
--> a.sol

Traceback (most recent call last):
  File "/home/tigran/Projects/integrator/query-engine/venv/bin/slither", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/__main__.py", line 727, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/__main__.py", line 833, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/slither.py", line 144, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/slither.py", line 154, in _init_parsing_and_analyses
    raise e
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/slither.py", line 150, in _init_parsing_and_analyses
    parser.parse_contracts()
  File "/home/tigran/Projects/integrator/query-engine/venv/lib/python3.11/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 449, in parse_contracts
    assert target, f"Contract {contract_name} not found"
AssertionError: Contract B.C not found
0xalpharush commented 8 months ago

This is not currently supported and being tracked in https://github.com/crytic/slither/issues/1452