greenbone / gvm-tools

Remote control your Greenbone Community Edition or Greenbone Enterprise Appliance
https://greenbone.github.io/gvm-tools/
GNU General Public License v3.0
167 stars 90 forks source link

[v1.4.1] Returns stack traceback instead xml response #77

Closed falegk closed 6 years ago

falegk commented 6 years ago

When I run a command that failed, a traceback displayed before the error message.

Expected behavior

It must be returns an xml response or only the error message.

Current behavior

It returns the python traceback

Traceback (most recent call last): File "/usr/local/bin/gvm-cli", line 9, in load_entry_point('gvm-tools==1.4.1', 'console_scripts', 'gvm-cli')() File "/usr/local/lib/python3.5/dist-packages/gvm_tools-1.4.1-py3.5.egg/gmp/clients/gvm_cli.py", line 209, in main File "/usr/local/lib/python3.5/dist-packages/gvm_tools-1.4.1-py3.5.egg/gmp/gvm_connection.py", line 220, in authenticate File "/usr/local/lib/python3.5/dist-packages/gvm_tools-1.4.1-py3.5.egg/gmp/gvm_connection.py", line 113, in read File "/usr/local/lib/python3.5/dist-packages/gvm_tools-1.4.1-py3.5.egg/gmp/gvm_connection.py", line 166, in checkCommandStatus gmp.gvm_connection.GMPError: Authentication failed

Traceback (most recent call last): File "/usr/local/bin/gvm-cli", line 9, in load_entry_point('gvm-tools==1.4.1', 'console_scripts', 'gvm-cli')() File "/usr/local/lib/python3.5/dist-packages/gvm_tools-1.4.1-py3.5.egg/gmp/clients/gvm_cli.py", line 213, in main File "/usr/local/lib/python3.5/dist-packages/gvm_tools-1.4.1-py3.5.egg/gmp/gvm_connection.py", line 113, in read File "/usr/local/lib/python3.5/dist-packages/gvm_tools-1.4.1-py3.5.egg/gmp/gvm_connection.py", line 166, in checkCommandStatus gmp.gvm_connection.GMPError: Failed to find task '1515'

Steps to reproduce

  1. Run a tls command with wrong pass or user. gvm-cli tls --hostname=localhost --xml "<get_tasks/>" --gmp-username 'admin' --gmp-password 'wrongpass'

or run

gvm-cli tls --hostname=localhost --xml "<get_tasks task_id='1515'/>" --gmp-username 'admin' --gmp-password 'correctpass'

GVM versions

gsa: (gsad --version)

gvm: Greenbone Vulnerability Manager 8.0+beta1 Manager DB revision 191 & OpenVAS Manager 7.0.3 Manager DB revision 184

openvas-scanner: OpenVAS Scanner 6.0+beta1 & OpenVAS Scanner 5.1.2

gvm-libs:

gvm-tools: gvm-cli 1.4.1

Environment

Operating system: Ubuntu 16.04.5 LTS

Installation method / source: source installation

wiegandm commented 6 years ago

The GVMConnection class honors a raw_response attribute which will cause the read method to return the 'raw' XML @falegk describe. With this attribute set, the examples provided should result in

<omp_response status="400" status_text="First command must be AUTHENTICATE, COMMANDS or GET_VERSION"/>

and

<get_tasks_response status="404" status_text="Failed to find task '1515'"/>

respectively.

So to solve this part, it would be sufficient to provide a command line setting to gvm-cli to control the raw_response attribute used when establishing the connection.

And I agree that showing both error and backtrace is a bit weird and should be improved. :)

wiegandm commented 6 years ago

I have created #79 for the raw XML response part.

bjoernricks commented 6 years ago

Should be fixed with #79