Grunny/zap-cli

python error on generting html report

mmkumaran opened this issue · 1 comments

When i try to run zap scan and generate html report using zap2docker-weekly/zap2docker-live image i get below python error, works fine on zap2docker-stable image though.

UnicodeEncodeError: 'ascii' codec can't encode character u'\u06f1'

I tried setting the -e LANG=C.UTF-8 on docker run command, still no luck..

Steps to reproduce

Pre-req(on a windows 10 machine)

  1. docker run -u zap -p 2375:2375 -d --name zapTest owasp/zap2docker-live zap.sh -daemon -port 2375 -host 127.0.0.1 -config api.disablekey=true -config scanner.attackOnStart=true -config view.mode=attack
  2. docker exec zapTest zap-cli -p 2375 open-url
  3. docker exec zapTest zap-cli -p 2375 spider
  4. docker exec zapTest zap-cli -p 2375 report --output html-test-report.html --output-format html
  5. get below error
    Traceback (most recent call last):
    File "/usr/local/bin/zap-cli", line 11, in
    sys.exit(cli())
    File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 664, in call
    return self.main(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
    File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 26, in new_func
    return ctx.invoke(f, ctx.obj, *args[1:], **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/zapcli/cli.py", line 248, in report
    zap_helper.html_report(output)
    File "/usr/local/lib/python2.7/dist-packages/zapcli/zap_helper.py", line 392, in html_report
    self._write_report(report, file_path)
    File "/usr/local/lib/python2.7/dist-packages/zapcli/zap_helper.py", line 398, in _write_report
    f.write(report)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\u06f1' in position 49802: ordinal not in range(128)

any thoughts?

I have the same issues, but it occasional, and not reproduce on every run. According to SO, the issue is related to Unicode issues.