コード例 #1
1
ファイル: qualys_web.py プロジェクト: xxoxx/VulnWhisperer
 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"}
     self.config_parse = qcconf.QualysConnectConfig(config)
     try:
         self.template_id = self.config_parse.get_template_id()
     except:
         self.logger.error('Could not retrieve template ID')
コード例 #2
0
def connect(
    config_file=qcs.default_filename,
    section="info",
    remember_me=False,
    remember_me_always=False,
    username=None,
    password=None,
    hostname="qualysapi.qualys.com",
    max_retries="3",
    proxies=None,
):
    """ Return a QGAPIConnect object for v1 API pulling settings from config
    file.
    """
    # Use function parameter login credentials.
    if username and password:
        connect = qcconn.QGConnector(auth=(username, password),
                                     server=hostname,
                                     max_retries=max_retries,
                                     proxies=proxies)

    # Retrieve login credentials from config file.
    else:
        conf = qcconf.QualysConnectConfig(
            filename=config_file,
            section=section,
            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
コード例 #3
0
 def test_config(self):
     ''' Pulls a list of maps '''
     qconf = config.QualysConnectConfig(use_ini=True,
                                        filename=self.tcfilename,
                                        username=self.test_username,
                                        password=self.test_password,
                                        remember_me=False)
     self.cache_instance = qcache.APICacheInstance(qconf)
コード例 #4
0
def connect(config_file=qcs.default_filename, section='info', 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, section=section, 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
コード例 #5
0
 def __init__(self, config=None):
     self.config = config
     try:
         self.qgc = qualysapi.connect(config)
         print('[SUCCESS] - Connected to Qualys at %s' % self.qgc.server)
     except Exception as e:
         print('[ERROR] Could not connect to Qualys - %s' % e)
     self.headers = {"content-type": "text/xml"}
     self.config_parse = qcconf.QualysConnectConfig(config)
     try:
         self.template_id = self.config_parse.get_template_id()
     except:
         print('ERROR - Could not retrieve template ID')
コード例 #6
0
    def setUp(self):
        '''
        Sets up a unittest api config file if one doesn't exist already
        '''
        #test from relative...

        #check if we have the required test data for unit tests
        self.tcfilename = os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                'test_data')
        self.tcfilename = os.path.join( self.tcfilename, 'integration-config.cfg')

        # logger.debug('Test Case Config File is ' + self.tcfilename)
        # logger.debug(os.path.isfile(self.tcfilename))

        # if we don't have a unittest configuration file make a temporary
        # file for our unit tests
        if not os.path.isfile(self.tcfilename):
            import getpass

            # right so go ahead up-front for the test and collect a
            # username and password
            self.test_username = input('QualysGuard Username: '******'QualysGuard Password: ')

            # now create a temporary file and save the user/pass for the tests...
            self.tf = tempfile.NamedTemporaryFile(delete=False)
            self.tcfilename = tf.name
            self.tf.close()
            self.tfDestroy = True

        qconf = config.QualysConnectConfig(
                use_ini=True,
                filename=self.tcfilename,
                username=self.test_username,
                password=self.test_password,
                remember_me=True)
        self.cache_instance = qcache.APICacheInstance(qconf)