Feature error codes (#165)
* Use error codes for failed scans * Fix indentations * Fix more indentation * Continue after failed download * Add tests for failed scans * Add more tests * move definition * Update nessus.py This function was used by function `print_scans` which at the same time was an unused one that had been deleted in the PR itself.
This commit is contained in:
@ -11,12 +11,14 @@ import argparse
|
||||
import sys
|
||||
import logging
|
||||
|
||||
|
||||
def isFileValid(parser, arg):
|
||||
if not os.path.exists(arg):
|
||||
parser.error("The file %s does not exist!" % arg)
|
||||
else:
|
||||
return arg
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description=""" VulnWhisperer is designed to create actionable data from\
|
||||
@ -31,8 +33,10 @@ def main():
|
||||
help='JIRA required only! Scan name from scan to report')
|
||||
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=True,
|
||||
help='Prints status out to screen (defaults to True)')
|
||||
parser.add_argument('-u', '--username', dest='username', required=False, default=None, type=lambda x: x.strip(), help='The NESSUS username')
|
||||
parser.add_argument('-p', '--password', dest='password', required=False, default=None, type=lambda x: x.strip(), help='The NESSUS password')
|
||||
parser.add_argument('-u', '--username', dest='username', required=False, default=None,
|
||||
help='The NESSUS username', type=lambda x: x.strip())
|
||||
parser.add_argument('-p', '--password', dest='password', required=False, default=None,
|
||||
help='The NESSUS password', type=lambda x: x.strip())
|
||||
parser.add_argument('-F', '--fancy', action='store_true', help='Enable colourful logging output')
|
||||
parser.add_argument('-d', '--debug', action='store_true', help='Enable debugging messages')
|
||||
parser.add_argument('--mock', action='store_true', help='Enable mocked API responses')
|
||||
@ -62,30 +66,28 @@ def main():
|
||||
mock_api = mockAPI(args.mock_dir, args.verbose)
|
||||
mock_api.mock_endpoints()
|
||||
|
||||
exit_code = 0
|
||||
|
||||
try:
|
||||
if args.config and not args.section:
|
||||
# this remains a print since we are in the main binary
|
||||
print('WARNING: {warning}'.format(warning='No section was specified, vulnwhisperer will scrape enabled modules from config file. \
|
||||
\nPlease specify a section using -s. \
|
||||
\nPlease specify a section using -s. \
|
||||
\nExample vuln_whisperer -c config.ini -s nessus'))
|
||||
logger.info('No section was specified, vulnwhisperer will scrape enabled modules from the config file.')
|
||||
config = vwConfig(config_in=args.config)
|
||||
enabled_sections = config.get_sections_with_attribute('enabled')
|
||||
|
||||
for section in enabled_sections:
|
||||
vw = vulnWhisperer(config=args.config,
|
||||
profile=section,
|
||||
verbose=args.verbose,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
source=args.source,
|
||||
scanname=args.scanname)
|
||||
|
||||
exit_code = vw.whisper_vulnerabilities()
|
||||
# TODO: fix this to NOT be exit 1 unless in error
|
||||
close_logging_handlers(logger)
|
||||
sys.exit(exit_code)
|
||||
|
||||
config = vwConfig(config_in=args.config)
|
||||
enabled_sections = config.get_sections_with_attribute('enabled')
|
||||
|
||||
for section in enabled_sections:
|
||||
vw = vulnWhisperer(config=args.config,
|
||||
profile=section,
|
||||
verbose=args.verbose,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
source=args.source,
|
||||
scanname=args.scanname)
|
||||
exit_code += vw.whisper_vulnerabilities()
|
||||
else:
|
||||
logger.info('Running vulnwhisperer for section {}'.format(args.section))
|
||||
vw = vulnWhisperer(config=args.config,
|
||||
@ -95,11 +97,10 @@ def main():
|
||||
password=args.password,
|
||||
source=args.source,
|
||||
scanname=args.scanname)
|
||||
exit_code += vw.whisper_vulnerabilities()
|
||||
|
||||
exit_code = vw.whisper_vulnerabilities()
|
||||
# TODO: fix this to NOT be exit 1 unless in error
|
||||
close_logging_handlers(logger)
|
||||
sys.exit(exit_code)
|
||||
close_logging_handlers(logger)
|
||||
sys.exit(exit_code)
|
||||
|
||||
except Exception as e:
|
||||
if args.verbose:
|
||||
|
Reference in New Issue
Block a user