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

slither fails with no detectors results and sarif output #1228

Closed
sveitser opened this issue Jun 7, 2022 · 0 comments · Fixed by #1229
Closed

slither fails with no detectors results and sarif output #1228

sveitser opened this issue Jun 7, 2022 · 0 comments · Fixed by #1229
Labels
bug-candidate Bugs reports that are not yet confirmed

Comments

@sveitser
Copy link
Contributor

sveitser commented Jun 7, 2022

Describe the issue:

Running for example

slither --exclude-informational tests/test_node_modules/node_modules/@openzeppelin/contracts/utils/math/Math.sol --sarif slither.sarif

Leads to a crash

tests/test_node_modules/node_modules/@openzeppelin/contracts/utils/math/Math.sol analyzed (1 contracts with 61 detectors), 0 result(s) found
Traceback (most recent call last):
  File "/home/lulu/r/crytic/slither/venv/bin/slither", line 33, in <module>
    sys.exit(load_entry_point('slither-analyzer', 'console_scripts', 'slither')())
  File "/home/lulu/r/crytic/slither/slither/__main__.py", line 643, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/home/lulu/r/crytic/slither/slither/__main__.py", line 831, in main_impl
    output_to_sarif(
  File "/home/lulu/r/crytic/slither/slither/utils/output.py", line 163, in output_to_sarif
    for detector in results["detectors"]:
KeyError: 'detectors'

The "detectors" key is missing because it's not added if empty:

slither/slither/__main__.py

Lines 769 to 770 in 168e962

if results_detectors and "detectors" in args.json_types:
json_results["detectors"] = results_detectors

Code example to reproduce the issue:

slither --exclude-informational tests/test_node_modules/node_modules/@openzeppelin/contracts/utils/math/Math.sol --sarif slither.sarif

Version:

0.8.3 or fba37f2

Relevant log output:

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-candidate Bugs reports that are not yet confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants