KissPeter / APIFuzzer

Fuzz test your application using your OpenAPI or Swagger API definition without coding
GNU General Public License v3.0
417 stars 65 forks source link

Failure when running against the test server according to documentation #22

Closed lobax closed 4 years ago

lobax commented 4 years ago

The fuzzers fails when running against the test server Error in transmit: a bytes-like object is required, not 'str' when running according to the documentation.

This issue has been replicated running directly on Linux and with PR #21 in a docker container.

$ python3 fuzzer.py -s test/test_swagger_definition.json -u http://localhost:5000/ -r /tmp/reports/ 
[INFO    ][fuzzer_target.__init__] Logger initialized
[INFO    ][base._load_session] No session loaded
[INFO    ][base._start_message] 
                 --------------------------------------------------
                 Starting fuzzing session
                 Target: FuzzerTarget
                 UI: WebInterface listening on 127.0.0.1:26000
                 Log: ./kittylogs/kitty_20191002-160156.log

                 Total possible mutation count: 6480
                 --------------------------------------------------
                                 Happy hacking
                 --------------------------------------------------

[INFO    ][base.start] Performing environment test
[INFO    ][base._test_info] Current test: -1
[INFO    ][server_fuzzer._transmit] Transmit place: params
[INFO    ][server_fuzzer._transmit] Transmit place: headers
[INFO    ][server_fuzzer._transmit] Transmit place: data
[INFO    ][server_fuzzer._transmit] Transmit place: path_variables
[INFO    ][fuzzer_target.transmit] URL part: http://localhost:5000/
[INFO    ][fuzzer_target.transmit] URL part: b'/exception/{integer_id}'
[ERROR   ][server_fuzzer._transmit] Error in transmit: a bytes-like object is required, not 'str'
[INFO    ][server_fuzzer._test_environment] Environment test failed
[INFO    ][server._start] should keep running? True
[INFO    ][base._test_info] Current test: 0
[INFO    ][server_fuzzer._transmit] Transmit place: params
[INFO    ][server_fuzzer._transmit] Transmit place: headers
[INFO    ][server_fuzzer._transmit] Transmit place: data
[INFO    ][server_fuzzer._transmit] Transmit place: path_variables
[INFO    ][fuzzer_target.transmit] URL part: http://localhost:5000/
[INFO    ][fuzzer_target.transmit] URL part: b'/exception/{integer_id}'
[ERROR   ][server_fuzzer._transmit] Error in transmit: a bytes-like object is required, not 'str'
[ERROR   ][server._start] Error occurred while fuzzing: TypeError("a bytes-like object is required, not 'str'")
[ERROR   ][server._start] Traceback (most recent call last):
  File "/home/krijor/.local/lib/python3.7/site-packages/kitty/fuzzers/server.py", line 43, in _start
    self._run_sequence(sequence)
  File "/home/krijor/.local/lib/python3.7/site-packages/kitty/fuzzers/server.py", line 74, in _run_sequence
    resp = self._transmit(node)
  File "/home/krijor/kth/APIFuzzer/apifuzzer/server_fuzzer.py", line 60, in _transmit
    return self.target.transmit(**payload)
  File "/home/krijor/kth/APIFuzzer/apifuzzer/fuzzer_target.py", line 66, in transmit
    _req_url.append(url_part.strip('/'))
TypeError: a bytes-like object is required, not 'str'

[INFO    ][base._end_message] 
                         --------------------------------------------------
                         Finished fuzzing session
                         Target: FuzzerTarget

                         Tested 1 mutation
                         Failure count: 0
                         --------------------------------------------------

[INFO    ][server_fuzzer._end_message] Stop fuzzing session_info: {'start_time': 1570024916.855605, 'start_index': 0, 'end_index': 6479, 'current_index': 1, 'failure_count': 0, 'kitty_version': '0.7.4', 'data_model_hash': -7729877241357270196, 'test_list_str': '0-6479'}
lobax commented 4 years ago

Tried it again with the latest commit (c581087), it appears to be able to run the whole test suite now. However it doesn't manage to save the results to the report directory (files are created but they are empty).

A typical error message in the logs:

[ERROR] root: Failed to save report "<kitty.data.report.Report object at 0x7f5b45dc7610>" to /tmp/reports/ because: a bytes-like object is required, not 'str'
KissPeter commented 4 years ago

Thanks for checking, yes I'm working on the report saving issue

KissPeter commented 4 years ago

Should work now @lobax please check

lobax commented 4 years ago

Yes, it works!