crytic / crytic/slither

[Bug-Candidate]: Slither collects files and then sais that it does not exist

Open
#1,857 0 comments 0 reactions 0 assignees View on GitHub
bug-candidate
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

Hi!
I've tried to run slither with contracts from this [repo](https://github.com/foreseon/Vulnerable-Smart-Contracts) and find, that slither can collect contracts but can't analyze them. I don't understand why it can't work with already collected files. I'd be glad to know what's causing it)

I run slither from `Downloads` repo with this command:
```
slither ../Documents/Vulnerable-Smart-Contracts/
```

### Code example to reproduce the issue:

Repeate contracts repo:

### Version:

0.9.2

### Relevant log output:

```shell
Compilation warnings/errors on ../Documents/Vulnerable-Smart-Contracts/basic-bank-4.sol:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> ../Documents/Vulnerable-Smart-Contracts/basic-bank-4.sol

Warning: Return value of low-level calls not used.
--> ../Documents/Vulnerable-Smart-Contracts/basic-bank-4.sol:27:9:
|
27 | msg.sender.call{value: _amount}("");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Compilation warnings/errors on ../Documents/Vulnerable-Smart-Contracts/basic-bank-1.sol:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> ../Documents/Vulnerable-Smart-Contracts/basic-bank-1.sol

Traceback (most recent call last):
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 834, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 98, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 78, in process_single
return _process(slither, detector_classes, printer_classes)
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 128, in _process
detector_results = slither.run_detectors()
File "/home/gatart/.local/lib/python3.10/site-packages/slither/slither.py", line 204, in run_detectors
results = [d.detect() for d in self._detectors]
File "/home/gatart/.local/lib/python3.10/site-packages/slither/slither.py", line 204, in
results = [d.detect() for d in self._detectors]
File "/home/gatart/.local/lib/python3.10/site-packages/slither/detectors/abstract_detector.py", line 186, in detect
if self.compilation_unit.core.valid_result(r) and r not in results:
File "/home/gatart/.local/lib/python3.10/site-packages/slither/core/slither_core.py", line 433, in valid_result
if self.has_ignore_comment(r):
File "/home/gatart/.local/lib/python3.10/site-packages/slither/core/slither_core.py", line 371, in has_ignore_comment
ignore_line_text = self.crytic_compile.get_code_from_line(file, ignore_line_index)
File "/home/gatart/.local/lib/python3.10/site-packages/crytic_compile/crytic_compile.py", line 315, in get_code_from_line
file = self.filename_lookup(filename)
File "/home/gatart/.local/lib/python3.10/site-packages/crytic_compile/crytic_compile.py", line 182, in filename_lookup
raise ValueError(f"{filename} does not exist")
ValueError: /home/gatart/Documents/Vulnerable-Smart-Contracts/basic-bank-4.sol does not exist
Error in ../Documents/Vulnerable-Smart-Contracts/
Traceback (most recent call last):
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 834, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 98, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 78, in process_single
return _process(slither, detector_classes, printer_classes)
File "/home/gatart/.local/lib/python3.10/site-packages/slither/__main__.py", line 128, in _process
detector_results = slither.run_detectors()
File "/home/gatart/.local/lib/python3.10/site-packages/slither/slither.py", line 204, in run_detectors
results = [d.detect() for d in self._detectors]
File "/home/gatart/.local/lib/python3.10/site-packages/slither/slither.py", line 204, in
results = [d.detect() for d in self._detectors]
File "/home/gatart/.local/lib/python3.10/site-packages/slither/detectors/abstract_detector.py", line 186, in detect
if self.compilation_unit.core.valid_result(r) and r not in results:
File "/home/gatart/.local/lib/python3.10/site-packages/slither/core/slither_core.py", line 433, in valid_result
if self.has_ignore_comment(r):
File "/home/gatart/.local/lib/python3.10/site-packages/slither/core/slither_core.py", line 371, in has_ignore_comment
ignore_line_text = self.crytic_compile.get_code_from_line(file, ignore_line_index)
File "/home/gatart/.local/lib/python3.10/site-packages/crytic_compile/crytic_compile.py", line 315, in get_code_from_line
file = self.filename_lookup(filename)
File "/home/gatart/.local/lib/python3.10/site-packages/crytic_compile/crytic_compile.py", line 182, in filename_lookup
raise ValueError(f"{filename} does not exist")
ValueError: /home/gatart/Documents/Vulnerable-Smart-Contracts/basic-bank-4.sol does not exist
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.