candlepin / rho

ssh scanner for your network
GNU General Public License v2.0
32 stars 20 forks source link

1395080 - exit gracefully on missing report #30

Closed jmrodri closed 7 years ago

jmrodri commented 7 years ago

if report doesn't exist exit gracefully. If it is pack-scan, the default report, the user didn't run initconfig. Instead of exiting we simply add it to the in-memory config before running the scan. While it seems like a good idea to write the report to the config, we modify the config with other temporary runtime options which would pollute the config if written. For now, we are opting to simply add the report in-memory.

jmrodri commented 7 years ago

Add new auth

[jesusr@transam rho{bz1395080}]$ rho auth add --name myroot --username root
Config Encryption Password:
Password for 'root':

Add a new test profile

[jesusr@transam rho{bz1395080}]$ rho profile add --name deep1 --range "192.168.122.1 - 192.168.122.3" --auth myroot
Config Encryption Password:

TEST: attempt to scan using a non-existent report against a valid auth and profile. RHO will now print out an error message instead of a stack trace.

[jesusr@transam rho{bz1395080}]$ rho scan --profile deep1 --report foobar
Config Encryption Password:
Scanning...
192.168.122.1:22 with auth myroot
192.168.122.3:22 with auth myroot
192.168.122.2:22 with auth myroot
ERROR: Report foobar was not found.

Verify the report list is still empty. Notice there is no default report, pack-scan. This means initconfig was not run. It is too late to run initconfig because it will wipe the config file deleting all of the users profiles and auths.

# empty report list
[jesusr@transam rho{bz1395080}]$ rho report list
Config Encryption Password:
No reports found

TEST: run a pack-scan with an empty report list against a valid profile and auth. RHO will now detect you wanted to run a default report and simply add it to the config in memory. This is better than failing with a stack-trace.

[jesusr@transam rho{bz1395080}]$ rho scan --profile deep1 --report pack-scan
Config Encryption Password:
Scanning...
192.168.122.1:22 with auth myroot
192.168.122.3:22 with auth myroot
192.168.122.2:22 with auth myroot
[jesusr@transam rho{bz1395080}]$ ls pack-scan.csv
pack-scan.csv
awood commented 7 years ago

Looks good to me. @cnsnyder what do you think?

cnsnyder commented 7 years ago

LGTM :+1: Thank you for the fix!