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() - PotentialArithmOverflow detector fail #153

Merged

Conversation

shortdoom
Copy link
Contributor

Note: Sorry for the mess, rebase somehow went wrong on my side in the old PR

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 merged commit 49a7ef6 into pessimistic-io:develop Apr 15, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants