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

Circular reference when outputting JSON with starttls #380

Closed
MWedl opened this issue Jun 19, 2019 · 4 comments
Closed

Circular reference when outputting JSON with starttls #380

MWedl opened this issue Jun 19, 2019 · 4 comments

Comments

@MWedl
Copy link

MWedl commented Jun 19, 2019

Describe the bug
When using the JSON output with option --starttls=pop3 or imap and the server does not support STARTTLS, sslyze fails with an error indicating a "circular reference". When using --starttls=smtp no circular reference error occurs.

To Reproduce
Steps to reproduce the behavior:

  1. Install SSLyze using '...' [e.g. pip, git]
  2. Run the following command 'sslyze --regular --json_out=- --starttls=pop3 mail.server.com:110'
  3. See error
Traceback (most recent call last):
  File "/usr/bin/sslyze", line 11, in <module>
    load_entry_point('sslyze==2.0.6', 'console_scripts', 'sslyze')()
  File "/usr/lib/python3/dist-packages/sslyze/__main__.py", line 117, in main
    output_hub.scans_completed(exec_time)
  File "/usr/lib/python3/dist-packages/sslyze/cli/output_hub.py", line 69, in scans_completed
    out_generator.scans_completed(total_scan_time)
  File "/usr/lib/python3/dist-packages/sslyze/cli/json_output.py", line 79, in scans_completed
    self._json_dict, default=_object_to_json_dict, sort_keys=True, indent=4, ensure_ascii=True
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.7/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 439, in _iterencode
    yield from _iterencode(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 436, in _iterencode
    raise ValueError("Circular reference detected")
ValueError: Circular reference detected

Expected behavior
A error message in JSON, like with --starttls=smtp.

Python environment (please complete the following information):

  • OS: Kali Linux
  • Python version: 3.7
@RaheelaKhan1172
Copy link
Contributor

Try upgrading sslyze, I think nabla-c0d3 fixed this error -
default=_object_to_json_dict is removed from json_output.py and ssylze is on version 2.1.3 now instead of 2.0.6

@nabla-c0d3
Copy link
Owner

Yes it was fixed in 2.1.2.

@MWedl
Copy link
Author

MWedl commented Jun 26, 2019

@nabla-c0d3 @RaheelaKhan1172 I updated sslyze to version 2.1.3 but the error still persists.

sslyze --tlsv1_2 --json_out=- --starttls=pop3 mail.server.com:110                                                                                                                                    127 ↵
Traceback (most recent call last):
  File "/usr/local/bin/sslyze", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/sslyze/__main__.py", line 125, in main
    output_hub.scans_completed(exec_time)
  File "/usr/local/lib/python3.7/dist-packages/sslyze/cli/output_hub.py", line 77, in scans_completed
    out_generator.scans_completed(total_scan_time)
  File "/usr/local/lib/python3.7/dist-packages/sslyze/cli/json_output.py", line 69, in scans_completed
    json_out = json.dumps(self._json_dict, cls=_CustomJsonEncoder, sort_keys=True, indent=4, ensure_ascii=True)
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.7/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 439, in _iterencode
    yield from _iterencode(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 436, in _iterencode
    raise ValueError("Circular reference detected")
ValueError: Circular reference detected

@RaheelaKhan1172
Copy link
Contributor

I see, I was able to reproduce this. I have a fix for it!

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

No branches or pull requests

3 participants