Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, config=None):
self.logger = logging.getLogger('qualysWhisperAPI')
self.config = config
try:
self.qgc = qualysapi.connect(config, 'qualys_vuln')
# Fail early if we can't make a request or auth is incorrect
self.qgc.request('about.php')
self.logger.info('Connected to Qualys at {}'.format(self.qgc.server))
except Exception as e:
self.logger.error('Could not connect to Qualys: {}'.format(str(e)))
sys.exit(1)
def __init__(self, config=None):
self.logger = logging.getLogger('qualysWhisperAPI')
self.config = config
try:
self.qgc = qualysapi.connect(config, 'qualys_web')
self.logger.info('Connected to Qualys at {}'.format(self.qgc.server))
except Exception as e:
self.logger.error('Could not connect to Qualys: {}'.format(str(e)))
self.headers = {
#"content-type": "text/xml"}
"Accept" : "application/json",
"Content-Type": "application/json"}
self.config_parse = qcconf.QualysConnectConfig(config, 'qualys_web')
try:
self.template_id = self.config_parse.get_template_id()
except:
self.logger.error('Could not retrieve template ID')
start = time.time()
state = 'success'
scan_type = '{{Scan_Type}}'
template_id = scan_type
report_type = '{{Report_Type}}'
requestor_email = job.owner.user.email
# Allow the user to have the PDF or CSV report sent to additional email addresses
cc_list = '{{Email_List}}'
# Allow the user to add custom text to the bottom of the email
extra_body = '{{Email_Extra_Body}}'
# Verify Cloudbolt know the email address of the requestor
if requestor_email is None or requestor_email == '': return "FAILURE", "Please update your email in your user profile.", ""
server = job.server_set.first()
job_id = job.id
session = qualysapi.connect()
# Determine the TYPE of the Report Template
# If TYPE is 'Manual', assume it is "Scan Based"
# If TYPE is "Auto", assume it is "Host Based"
template_list = session.request('report_template_list.php')
templates = objectify.fromstring(template_list)
template_type = ''
for template in templates.REPORT_TEMPLATE:
if str(template.ID) == scan_type:
template_type = template.TYPE
if template_type == '': return "FAILURE", "Unable to locate Report Template with ID " + scan_type, ""
call = 'scan.php'
ipaddr = ''
error_code = ''
# Build an array to capture a dictionary of Qualys Scanner, Server names and IPs
# And Build and array of the scanners
svr_info = []