How to use qualysapi - 10 common examples

To help you get started, we’ve selected a few qualysapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HASecuritySolutions / VulnWhisperer / vulnwhisp / frameworks / qualys_vuln.py View on Github external
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)
github HASecuritySolutions / VulnWhisperer / deps / qualysapi / qualysapi / config.py View on Github external
if not self._cfgparse.has_option('qualys', 'max_retries'):
            self.max_retries = qcs.defaults['max_retries']
        else:
            self.max_retries = self._cfgparse.get('qualys', 'max_retries')
            try:
                self.max_retries = int(self.max_retries)
            except Exception:
                logger.error('Value max_retries must be an integer.')
                print('Value max_retries must be an integer.')
                exit(1)
            self._cfgparse.set('qualys', 'max_retries', str(self.max_retries))
        self.max_retries = int(self.max_retries)

        #Get template ID... user will need to set this to pull back CSV reports
        if not self._cfgparse.has_option('qualys', 'template_id'):
            self.report_template_id = qcs.defaults['template_id']
        else:
            self.report_template_id = self._cfgparse.get('qualys', 'template_id')
            try:
                self.report_template_id = int(self.report_template_id)
            except Exception:
                logger.error('Report Template ID Must be set and be an integer')
                print('Value template ID must be an integer.')
                exit(1)
            self._cfgparse.set('qualys', 'template_id', str(self.report_template_id))
        self.report_template_id = int(self.report_template_id)

        # Proxy support
        proxy_config = proxy_url = proxy_protocol = proxy_port = proxy_username = proxy_password = None
        # User requires proxy?
        if self._cfgparse.has_option('proxy', 'proxy_url'):
            proxy_url = self._cfgparse.get('proxy', 'proxy_url')
github HASecuritySolutions / VulnWhisperer / deps / qualysapi / qualysapi / config.py View on Github external
# if 'info' doesn't exist, create the section.
        if not self._cfgparse.has_section('qualys'):
            self._cfgparse.add_section('qualys')

        # Use default hostname (if one isn't provided).
        if not self._cfgparse.has_option('qualys', 'hostname'):
            if self._cfgparse.has_option('DEFAULT', 'hostname'):
                hostname = self._cfgparse.get('DEFAULT', 'hostname')
                self._cfgparse.set('qualys', 'hostname', hostname)
            else:
                raise Exception("No 'hostname' set. QualysConnect does not know who to connect to.")

        # Use default max_retries (if one isn't provided).
        if not self._cfgparse.has_option('qualys', 'max_retries'):
            self.max_retries = qcs.defaults['max_retries']
        else:
            self.max_retries = self._cfgparse.get('qualys', 'max_retries')
            try:
                self.max_retries = int(self.max_retries)
            except Exception:
                logger.error('Value max_retries must be an integer.')
                print('Value max_retries must be an integer.')
                exit(1)
            self._cfgparse.set('qualys', 'max_retries', str(self.max_retries))
        self.max_retries = int(self.max_retries)

        #Get template ID... user will need to set this to pull back CSV reports
        if not self._cfgparse.has_option('qualys', 'template_id'):
            self.report_template_id = qcs.defaults['template_id']
        else:
            self.report_template_id = self._cfgparse.get('qualys', 'template_id')
github HASecuritySolutions / VulnWhisperer / vulnwhisp / frameworks / qualys_web.py View on Github external
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')
github CloudBoltSoftware / cloudbolt-forge / actions / server / qualys_scan / qualys_scan.py View on Github external
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 = []
github HASecuritySolutions / VulnWhisperer / deps / qualysapi / qualysapi / util.py View on Github external
def connect(config_file=qcs.default_filename, remember_me=False, remember_me_always=False):
    """ Return a QGAPIConnect object for v1 API pulling settings from config
    file.
    """
    # Retrieve login credentials.
    conf = qcconf.QualysConnectConfig(filename=config_file, remember_me=remember_me, 
                                      remember_me_always=remember_me_always)
    connect = qcconn.QGConnector(conf.get_auth(),
                                 conf.get_hostname(),
                                 conf.proxies,
                                 conf.max_retries)
    logger.info("Finished building connector.")
    return connect
github HASecuritySolutions / VulnWhisperer / vulnwhisp / frameworks / qualys_web.py View on Github external
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')
github HASecuritySolutions / VulnWhisperer / deps / qualysapi / qualysapi / util.py View on Github external
def connect(config_file=qcs.default_filename, remember_me=False, remember_me_always=False):
    """ Return a QGAPIConnect object for v1 API pulling settings from config
    file.
    """
    # Retrieve login credentials.
    conf = qcconf.QualysConnectConfig(filename=config_file, remember_me=remember_me, 
                                      remember_me_always=remember_me_always)
    connect = qcconn.QGConnector(conf.get_auth(),
                                 conf.get_hostname(),
                                 conf.proxies,
                                 conf.max_retries)
    logger.info("Finished building connector.")
    return connect
github StackStorm / st2contrib / packs / qualys / actions / lib / base.py View on Github external
def __init__(self, config):
        super(QualysBaseAction, self).__init__(config)
        self.connection = QGConnector(
            (config['username'],
             config['password']),
            config['hostname']
        )
        self.resultsets = ResultSets()
github HASecuritySolutions / VulnWhisperer / deps / qualysapi / qualysapi / util.py View on Github external
def connect(config_file=qcs.default_filename, remember_me=False, remember_me_always=False):
    """ Return a QGAPIConnect object for v1 API pulling settings from config
    file.
    """
    # Retrieve login credentials.
    conf = qcconf.QualysConnectConfig(filename=config_file, remember_me=remember_me, 
                                      remember_me_always=remember_me_always)
    connect = qcconn.QGConnector(conf.get_auth(),
                                 conf.get_hostname(),
                                 conf.proxies,
                                 conf.max_retries)
    logger.info("Finished building connector.")
    return connect