How to use the solnlib.utils.is_true function in solnlib

To help you get started, we’ve selected a few solnlib 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 PaloAltoNetworks / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup_util.py View on Github external
def get_proxy_settings(self):
        proxy_settings = self._parse_conf().get('proxy_settings', None)
        if not proxy_settings:
            self.log_info("Proxy is not set!")
            return {}
        proxy_enabled = utils.is_true(proxy_settings.get("proxy_enabled", '0'))
        if not proxy_enabled:
            return {}
        proxy_settings = {
            "proxy_url": proxy_settings.get("proxy_url", ""),
            "proxy_port": proxy_settings.get("proxy_port", ""),
            "proxy_username": proxy_settings.get("proxy_username", ""),
            "proxy_password": proxy_settings.get("proxy_password", ""),
            "proxy_type": proxy_settings.get("proxy_type", ""),
            "proxy_rdns": utils.is_true(proxy_settings.get("proxy_rdns", '0'))
        }
        return proxy_settings
github remg427 / misp42splunk / misp42splunk / bin / packages / aob_py2 / cloudconnectlib / core / http.py View on Github external
if not all((user, password)):
        _logger.info('Proxy has no credentials found')
        user, password = None, None

    proxy_type = proxy_config.get('proxy_type')
    proxy_type = proxy_type.lower() if proxy_type else 'http'

    if proxy_type in _PROXY_TYPE_MAP:
        ptv = _PROXY_TYPE_MAP[proxy_type]
    elif proxy_type in list(_PROXY_TYPE_MAP.values()):
        ptv = proxy_type
    else:
        ptv = socks.PROXY_TYPE_HTTP
        _logger.info('Proxy type not found, set to "HTTP"')

    rdns = is_true(proxy_config.get('proxy_rdns'))

    proxy_info = ProxyInfo(
        proxy_host=url,
        proxy_port=int(port),
        proxy_type=ptv,
        proxy_user=user,
        proxy_pass=password,
        proxy_rdns=rdns
    )
    return proxy_info
github remg427 / misp42splunk / misp42splunk / bin / packages / aob_py2 / splunk_aoblib / setup_util.py View on Github external
def _parse_conf_from_env(self, global_settings):
        '''
        this is run in test env
        '''
        if not self.__cached_global_settings:
            # format the settings, the setting from env is from global_setting
            # meta
            self.__cached_global_settings = {}
            for s_k, s_v in list(global_settings.items()):
                if s_k == PROXY_SETTINGS:
                    proxy_enabled = s_v.get(PROXY_ENABLE_KEY)
                    proxy_rdns = s_v.get(PROXY_RDNS_KEY)
                    if type(proxy_enabled) != bool:
                        s_v[PROXY_ENABLE_KEY] = utils.is_true(proxy_enabled)
                    if type(proxy_rdns) != bool:
                        s_v[PROXY_RDNS_KEY] = utils.is_true(proxy_rdns)
                    self.__cached_global_settings[PROXY_SETTINGS] = s_v
                elif s_k == LOG_SETTINGS:
                    self.__cached_global_settings[LOG_SETTINGS] = {
                        LOG_LEVEL_KEY: s_v.get(LOG_LEVEL_KEY_ENV)
                    }
                elif s_k == CREDENTIAL_SETTINGS:
                    # add account id to accounts
                    for i in range(0, len(s_v)):
                        s_v[i]['name'] = 'account' + str(i)
                    self.__cached_global_settings[CREDENTIAL_SETTINGS] = s_v
                else:  # should be customized settings
                    self.__cached_global_settings[CUSTOMIZED_SETTINGS] = {}
                    for s in s_v:
                        field_type = s.get('type')
                        if not field_type:
                            self.log_error(
github PaloAltoNetworks / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup_util.py View on Github external
customized_settings = self._parse_conf().get(
            setup_const.myta_customized_settings, None)

        if not customized_settings:
            self.log_info("Customized setting is not set")
            return None
        if not key in customized_settings:
            self.log_info("Customized key can not be found")
            return None
        customized_setting = customized_settings.get(key, {})
        _type = customized_setting.get("type", None)
        if not _type:
            self.__logger.error("Type of this customized setting is not set")
            return None
        if _type == "bool":
            return utils.is_true(customized_setting.get("bool", '0'))
        elif _type == "text":
            return customized_setting.get("content", "")
        elif _type == "password":
            return customized_setting.get("password", "")
        else:
            raise Exception("Type of this customized setting is corrupted")
github remg427 / misp42splunk / misp42splunk / bin / packages / aob_py2 / splunk_aoblib / setup_util.py View on Github external
settings = self.__global_config.settings.load()
            self.__cached_global_settings.update({UCC_PROXY: None, UCC_LOGGING: None, UCC_CUSTOMIZED: None})
            customized_setting = {}
            for setting in settings.get('settings', []):
                # filter out disabled setting page and 'disabled' field
                if setting.get('disabled', False):
                    continue
                if setting['name'] == UCC_LOGGING:
                    self.__cached_global_settings[LOG_SETTINGS] = {
                        LOG_LEVEL_KEY: setting.get(LOG_LEVEL_KEY)
                    }
                elif setting['name'] == UCC_PROXY:
                    if 'disabled' in setting:
                        del setting['disabled']
                    setting[PROXY_ENABLE_KEY] = utils.is_true(setting.get(PROXY_ENABLE_KEY, '0'))
                    setting[PROXY_RDNS_KEY] = utils.is_true(setting.get(PROXY_RDNS_KEY, '0'))
                    self.__cached_global_settings[PROXY_SETTINGS] = setting
                else:  # should be customized settings
                    if 'disabled' in setting:
                        del setting['disabled']
                    customized_setting.update(setting)
            self.__cached_global_settings[CUSTOMIZED_SETTINGS] = customized_setting

        return self.__cached_global_settings.get(key)