Skip to content
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

fix: object of type NoneType has no len() - detector fail #148

Closed
wants to merge 0 commits into from

Conversation

shortdoom
Copy link
Contributor

Small fix to get rid of detector failing completely for some contracts. This is annoying because single detector fail stops the execution of other detectors.

Example error:

ERROR:root:Slither detection failed: object of type 'NoneType' has no len()
Traceback (most recent call last):
  File "/home/user/Github/Local/forgAi/core/analyze.py", line 670, in run_analysis
    self.run_slither_scan()
  File "/home/user/Github/Local/forgAi/core/analyze.py", line 556, in run_slither_scan
    slither, results_detectors, counter = run_all_detectors(
  File "/home/user/Github/Local/forgAi/core/utils.py", line 58, in run_all_detectors
    detector_resultss = slither.run_detectors()
  File "/home/user/Github/Local/forgAi/venv/lib/python3.10/site-packages/slither/slither.py", line 241, in run_detectors
    results = [d.detect() for d in self._detectors]
  File "/home/user/Github/Local/forgAi/venv/lib/python3.10/site-packages/slither/slither.py", line 241, in <listcomp>
    results = [d.detect() for d in self._detectors]
  File "/home/user/Github/Local/forgAi/venv/lib/python3.10/site-packages/slither/detectors/abstract_detector.py", line 203, in detect
    for r in [output.data for output in self._detect()]:
  File "/home/user/Github/Local/forgAi/venv/lib/python3.10/site-packages/slitherin/detectors/potential_arith_overflow.py", line 110, in _detect
    vulnerable_expressions = self._find_vulnerable_expressions(f)
  File "/home/user/Github/Local/forgAi/venv/lib/python3.10/site-packages/slitherin/detectors/potential_arith_overflow.py", line 89, in _find_vulnerable_expressions
    if len(irs) > 0 and isinstance(irs[-1], ops.Return) and len(fun.return_type) == 1 and str(fun.return_type[0]) in INT_TYPES: # @todo currently works only with single returns
TypeError: object of type 'NoneType' has no len()

Example contract to test with (without the patch): 0x61d25e9c65fb3bd2aa54e426b3044020dd339b8d

@olegggatttor olegggatttor changed the base branch from master to develop April 12, 2024 11:53
@olegggatttor olegggatttor changed the base branch from develop to master April 12, 2024 11:53
@olegggatttor
Copy link
Contributor

Good catch! Could you please rebase it on the develop branch instead of master? The commit will go to the develop and only then to master. Thank you!

@olegggatttor olegggatttor added the bug Something isn't working label Apr 12, 2024
@shortdoom shortdoom changed the base branch from master to develop April 12, 2024 12:18
@shortdoom
Copy link
Contributor Author

Done :)

@olegggatttor
Copy link
Contributor

I still see some strange chages, could you please put your changes on top of the current develop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants