How to use the solnlib.utils 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 / modinput_wrapper / base_modinput.py View on Github external
# Only the default stanza. In this case, modinput should exit.
            self.log_warning("No stanza found for input type: " + self.input_type)
            sys.exit(0)

        account_fields = self.get_account_fields()
        checkbox_fields = self.get_checkbox_fields()
        self.input_stanzas = {}
        for stanza in all_stanzas:
            full_stanza_name = '{}://{}'.format(self.input_type, stanza.get('name'))
            if full_stanza_name in inputs.inputs:
                if stanza.get('disabled', False):
                    raise RuntimeError("Running disabled data input!")
                stanza_params = {}
                for k, v in stanza.iteritems():
                    if k in checkbox_fields:
                        stanza_params[k] = sutils.is_true(v)
                    elif k in account_fields:
                        stanza_params[k] = copy.deepcopy(v)
                    else:
                        stanza_params[k] = v
                self.input_stanzas[stanza.get('name')] = stanza_params
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / modular_input / event_writer.py View on Github external
def _get_hec_config(self, hec_input_name, session_key,
                        scheme, host, port, **context):
        hc = HECConfig(
            session_key, scheme=scheme, host=host, port=port, **context)
        settings = hc.get_settings()
        if utils.is_true(settings.get('disabled')):
            # Enable HEC input
            logging.info('Enabling HEC')
            settings['disabled'] = '0'
            settings['enableSSL'] = context.get('hec_enablessl', '1')
            settings['port'] = context.get('hec_port', '8088')
            hc.update_settings(settings)

        hec_input = hc.get_input(hec_input_name)
        if not hec_input:
            # Create HEC input
            logging.info('Create HEC datainput, name=%s', hec_input_name)
            hinput = {
                'index': context.get('index', 'main'),
            }

            if context.get('sourcetype'):
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / server_info.py View on Github external
Usage::

            >>> serverinfo = solnlib.server_info.ServerInfo(session_key)
            >>> while 1:
            >>>    if serverinfo.is_captain_ready():
            >>>        break
            >>>    time.sleep(2)
            >>>
            >>> # If do_stuff can only be executed in SH captain
            >>> if serverinfo.is_captain():
            >>>    do_stuff()
        '''

        cap_info = self.captain_info()
        return utils.is_true(cap_info["service_ready_flag"]) and \
            utils.is_false(cap_info["maintenance_mode"])
github remg427 / misp42splunk / misp42splunk / bin / packages / aob_py2 / splunk_aoblib / setup_util.py View on Github external
def __init__(self, uri, session_key, logger=None):
        self.__uri = uri
        self.__session_key = session_key
        self.__logger = logger
        self.scheme, self.host, self.port = utils.extract_http_scheme_host_port(
            self.__uri)
        self.__cached_global_settings = {}
        self.__global_config = None
github PaloAltoNetworks / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup_util.py View on Github external
def __init__(self, uri, session_key, logger=None):
        self.__uri = uri
        self.__session_key = session_key
        self.__logger = logger
        self.scheme, self.host, self.port = utils.extract_http_scheme_host_port(
            self.__uri)
        self.encrypt_fields_credential = (setup_const.password,)
        self.encrypt_fields_customized = (setup_const.password,)
        self.cred_confs = (
            (setup_const.myta_credential_settings, setup_const.myta_credential_conf),)
        self.__cached_global_settings = None
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup.py View on Github external
def handleList(self, confInfo):
        logger.info("start list setup configure.")
        scheme, host, port = utils.extract_http_scheme_host_port(scc.getMgmtUri())
        conf_mgr = conf.ConfManager(self.getSessionKey(), self.appName, scheme=scheme, host=host, port=port)
        ta_conf_file = get_or_create_conf_file(conf_mgr, setup_const.myta_conf)
        # read globala and proxy settings
        all_settings = ta_conf_file.get_all()
        if not all_settings:
            all_settings = {}
        self._setNoneValues(all_settings.get(setup_const.global_settings, {}))
        # read account credential settings
        for cred, cred_conf in self.cred_confs:
            cred_conf_file = get_or_create_conf_file(conf_mgr, cred_conf)
            creds = cred_conf_file.get_all()
            if creds:
                self._setNoneValues(creds)
                all_settings.update({cred: creds})
        # customized conf
        customized_conf_file = get_or_create_conf_file(conf_mgr, setup_const.myta_customized_conf)
github PaloAltoNetworks / pandevice / install / 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 PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / modinput_wrapper / base_modinput.py View on Github external
def _init_ckpt(self):
        if self.ckpt is None:
            if 'AOB_TEST' in os.environ:
                ckpt_dir = self.context_meta.get('checkpoint_dir', tempfile.mkdtemp())
                if not os.path.exists(ckpt_dir):
                    os.makedirs(ckpt_dir)
                self.ckpt = checkpointer.FileCheckpointer(ckpt_dir)
            else:
                if 'server_uri' not in self.context_meta:
                    raise ValueError('server_uri not found in input meta.')
                if 'session_key' not in self.context_meta:
                    raise ValueError('session_key not found in input meta.')
                dscheme, dhost, dport = sutils.extract_http_scheme_host_port(self.context_meta[
                                                                             'server_uri'])
                self.ckpt = checkpointer.KVStoreCheckpointer(self.app + "_checkpointer", self.context_meta['session_key'], self.app,
                                                             scheme=dscheme, host=dhost, port=dport)
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / server_info.py View on Github external
Usage::

            >>> serverinfo = solnlib.server_info.ServerInfo(session_key)
            >>> while 1:
            >>>    if serverinfo.is_captain_ready():
            >>>        break
            >>>    time.sleep(2)
            >>>
            >>> # If do_stuff can only be executed in SH captain
            >>> if serverinfo.is_captain():
            >>>    do_stuff()
        '''

        cap_info = self.captain_info()
        return utils.is_true(cap_info["service_ready_flag"]) and \
            utils.is_false(cap_info["maintenance_mode"])