OpenSCAP / openscap-daemon

Manages continuous scans of your infrastructure
https://www.open-scap.org/tools/openscap-daemon
GNU Lesser General Public License v2.1
106 stars 32 forks source link

oscapd-cli should not traceback when a prameter is missing on the command line #54

Closed jan-cerny closed 8 years ago

jan-cerny commented 8 years ago

For example here, I forgot to specify the title and I got a traceback:

[root@localhost ~]# oscapd-cli task 1 set-title 
Traceback (most recent call last):
  File "/usr/bin/oscapd-cli", line 742, in <module>
    main()
  File "/usr/bin/oscapd-cli", line 728, in main
    cli_task(dbus_iface, task_accessor, args)
  File "/usr/bin/oscapd-cli", line 251, in cli_task
    dbus_iface, args.task_action, args.task_id, args.parameters[0]
  File "/usr/bin/oscapd-cli", line 92, in eval
    casted_args = TaskAccessor.get_string(args)
  File "/usr/bin/oscapd-cli", line 71, in get_string
    raise ValueError("Not expected parameters")
ValueError: Not expected parameters

the same for oscapd-cli task 1 set-input, oscapd-cli task 1 set-target etc.

I think that the ValueError exception should be catched and displayed a message to user. I have recent deamon from git on Fedora 23 Python3.

mpreisler commented 8 years ago

Furthermore, "Not expected parameters" is not quite what we wanted to say there, is it? :D

mpreisler commented 8 years ago

Fixed in 7e38a3df4eaf5745cfff52f8b021d33bacb68586

$ python2 ./oscapd-cli task 1 set-title
Expected 1 parameters, but 0 were provided.
$ python2 ./oscapd-cli task 1 set-title asdf a a a 
Expected 1 parameters, but 4 were provided.
$ python3 ./oscapd-cli task 1 set-title
Expected 1 parameters, but 0 were provided.
$ python3 ./oscapd-cli task 1 set-title asdfasdff f f f 
Expected 1 parameters, but 4 were provided.