Repository: crytic/slither

Issue:
Traceback Error after running "slither . "
Installed slither with pip3, using hardhat 2.0.11, @openzeppelin/contracts 4.0.0, fresh npm install, fresh hardhat compile, my unit tests pass, but slither throws errors. It looks like it's having problems finding the imports.
```
$ slither --version
0.7.0

$ python --version
Python 3.7.7

$ solc --version
solc, the solidity compiler commandline interface
Version: 0.8.0+commit.c7dfd78e.Linux.g++
```
```
$ slither .
'npx hardhat compile' running
Nothing to compile
Creating Typechain artifacts in directory typechain for target ethers-v5
Successfully generated Typechain artifacts!

Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/__main__.py", line 712, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/__main__.py", line 82, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/__main__.py", line 65, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/slither.py", line 102, in __init__
    self._parser.parse_contracts()
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 380, in parse_contracts
    self._analyze_second_part(contracts_to_be_analyzed, libraries)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 459, in _analyze_second_part
    self._analyze_struct_events(contract)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 510, in _analyze_struct_events
    contract.analyze_using_for()
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 530, in analyze_using_for
    lib_name = parse_type(using_for["libraryName"], self)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 356, in parse_type
    raise ParsingError("Type name not found " + str(t))
slither.solc_parsing.exceptions.ParsingError: Type name not found {'id': 584, 'name': 'Address', 'nodeType': 'IdentifierPath', 'referencedDeclaration': 1098, 'src': '608:7:2'}
ERROR:root:Error:
ERROR:root:Type name not found {'id': 584, 'name': 'Address', 'nodeType': 'IdentifierPath', 'referencedDeclaration': 1098, 'src': '608:7:2'}
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues
```
```
$ slither contracts/File.sol
Compilation warnings/errors on contracts/File.sol:
Error: Source "@openzeppelin/contracts/utils/math/Math.sol" not found: File not found.
 --> contracts/File.sol:4:1:
  |
4 | import "@openzeppelin/contracts/utils/math/Math.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol" not found: File not found.
 --> contracts/File.sol:5:1:
  |
5 | import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/utils/Address.sol" not found: File not found.
 --> contracts/File2.sol:4:1:
  |
4 | import "@openzeppelin/contracts/utils/Address.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found.
 --> contracts/File2.sol:5:1:
  |
5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol" not found: File not found.
 --> contracts/File2.sol:6:1:
  |
6 | import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Traceback Error after running "slither . "
Installed slither with pip3, using hardhat 2.0.11, @openzeppelin/contracts 4.0.0, fresh npm install, fresh hardhat compile, my unit tests pass, but slither throws errors. It looks like it's having problems finding the imports.
```
$ slither --version
0.7.0

$ python --version
Python 3.7.7

$ solc --version
solc, the solidity compiler commandline interface
Version: 0.8.0+commit.c7dfd78e.Linux.g++
```
```
$ slither .
'npx hardhat compile' running
Nothing to compile
Creating Typechain artifacts in directory typechain for target ethers-v5
Successfully generated Typechain artifacts!

Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/__main__.py", line 712, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/__main__.py", line 82, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/__main__.py", line 65, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/slither.py", line 102, in __init__
    self._parser.parse_contracts()
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 380, in parse_contracts
    self._analyze_second_part(contracts_to_be_analyzed, libraries)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 459, in _analyze_second_part
    self._analyze_struct_events(contract)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/slitherSolc.py", line 510, in _analyze_struct_events
    contract.analyze_using_for()
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/declarations/contract.py", line 530, in analyze_using_for
    lib_name = parse_type(using_for["libraryName"], self)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 356, in parse_type
    raise ParsingError("Type name not found " + str(t))
slither.solc_parsing.exceptions.ParsingError: Type name not found {'id': 584, 'name': 'Address', 'nodeType': 'IdentifierPath', 'referencedDeclaration': 1098, 'src': '608:7:2'}
ERROR:root:Error:
ERROR:root:Type name not found {'id': 584, 'name': 'Address', 'nodeType': 'IdentifierPath', 'referencedDeclaration': 1098, 'src': '608:7:2'}
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues
```
```
$ slither contracts/File.sol
Compilation warnings/errors on contracts/File.sol:
Error: Source "@openzeppelin/contracts/utils/math/Math.sol" not found: File not found.
 --> contracts/File.sol:4:1:
  |
4 | import "@openzeppelin/contracts/utils/math/Math.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol" not found: File not found.
 --> contracts/File.sol:5:1:
  |
5 | import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/utils/Address.sol" not found: File not found.
 --> contracts/File2.sol:4:1:
  |
4 | import "@openzeppelin/contracts/utils/Address.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found.
 --> contracts/File2.sol:5:1:
  |
5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol" not found: File not found.
 --> contracts/File2.sol:6:1:
  |
6 | import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```


Discussion:
Hi @leonardishere, thank you for reporting this.

Can you share the codebase where this happens?
Hi @leonardishere, thank you for reporting this.

Can you share the codebase where this happens?

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -5,13 +5,13 @@
     description="Slither is a Solidity static analysis framework written in Python 3.",
     url="https://github.com/crytic/slither",
     author="Trail of Bits",
-    version="0.7.0",
+    version="0.7.1",
     packages=find_packages(),
     python_requires=">=3.6",
     install_requires=[
         "prettytable>=0.7.2",
         "pysha3>=1.0.2",
-        "crytic-compile>=0.1.12",
+        "crytic-compile>=0.1.13",
         # "crytic-compile",
     ],
     # dependency_links=["git+https://github.com/crytic/crytic-compile.git@master#egg=crytic-compile"],
diff --git a/slither/solc_parsing/solidity_types/type_parsing.py b/slither/solc_parsing/solidity_types/type_parsing.py
--- a/slither/solc_parsing/solidity_types/type_parsing.py
+++ b/slither/solc_parsing/solidity_types/type_parsing.py
@@ -14,6 +14,7 @@
 from slither.core.solidity_types.type import Type
 from slither.core.solidity_types.user_defined_type import UserDefinedType
 from slither.core.variables.function_type_variable import FunctionTypeVariable
+from slither.exceptions import SlitherError
 from slither.solc_parsing.exceptions import ParsingError
 
 if TYPE_CHECKING:
@@ -291,6 +292,21 @@ def parse_type(t: Union[Dict, UnknownType], caller_context):
             all_enums,
         )
 
+    # Introduced with Solidity 0.8
+    if t[key] == "IdentifierPath":
+        if is_compact_ast:
+            return _find_from_type_name(
+                t["name"],
+                functions,
+                contracts,
+                structures_direct_access,
+                all_structures,
+                enums_direct_access,
+                all_enums,
+            )
+
+        raise SlitherError("Solidity 0.8 not supported with the legacy AST")
+
     if t[key] == "ArrayTypeName":
         length = None
         if is_compact_ast:


Test patch: