How to use the qualysapi.settings.defaults function in qualysapi

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 / 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 / deps / qualysapi / qualysapi / config.py View on Github external
def __init__(self, filename=qcs.default_filename, remember_me=False, remember_me_always=False):

        self._cfgfile = None

        # Prioritize local directory filename.
        # Check for file existence.
        if os.path.exists(filename):
            self._cfgfile = filename
        elif os.path.exists(os.path.join(os.path.expanduser("~"), filename)):
            # Set home path for file.
            self._cfgfile = os.path.join(os.path.expanduser("~"), filename)

        # create ConfigParser to combine defaults and input from config file.
        self._cfgparse = ConfigParser(qcs.defaults)

        if self._cfgfile:
            self._cfgfile = os.path.realpath(self._cfgfile)

            mode = stat.S_IMODE(os.stat(self._cfgfile)[stat.ST_MODE])

            # apply bitmask to current mode to check ONLY user access permissions.
            if (mode & (stat.S_IRWXG | stat.S_IRWXO)) != 0:
                logging.warning('%s permissions allows more than user access.' % (filename,))

            self._cfgparse.read(self._cfgfile)

        # if 'info' doesn't exist, create the section.
        if not self._cfgparse.has_section('qualys'):
            self._cfgparse.add_section('qualys')