Check if the minion is exposed, based on the whitelist and blacklist
177493
def _is_exposed(minion):
    '''
    
    '''
    return salt.utils.stringutils.check_whitelist_blacklist(
        minion,
        whitelist=__opts__['minionfs_whitelist'],
        blacklist=__opts__['minionfs_blacklist']
    )
190879
def __set_whitelist(self, whitelist=None):
        
        # add tag's names as key and list of enabled attributes as value for defaults
        self.whitelist = {}
        # tags that removed with contents
        self.sanitizelist = ['script', 'style']
        if isinstance(whitelist, dict) and '*' in whitelist.keys():
            self.isNotPurify = True
            self.whitelist_keys = []
            return
        else:
            self.isNotPurify = False
        self.whitelist.update(whitelist or {})
        self.whitelist_keys = self.whitelist.keys()
808871
def _CheckData(yaml_data):
  """"""
  legal_keys = set(('blacklist', 'whitelist'))
  unknown_keys = set(yaml_data) - legal_keys
  if unknown_keys:
    raise UnknownConfigKeyError(
        'Unknown keys in configuration: %s' % unknown_keys)

  for key, data in six.iteritems(yaml_data):
    _AssertDataIsList(key, data)
368389
def is_not_blocked(self, item: str) -> bool:
        
        assert item is not None
        item = self._encode_item(item)
        connection = self.__get_connection()
        key = self.__redis_conf['blacklist_template'].format(item)
        value = connection.get(key)
        if value is None:
            BlackRed.__release_connection(connection)
            return True
        if self.__redis_conf['blacklist_refresh_ttl']:
            connection.expire(key, self.__redis_conf['blacklist_ttl'])
        BlackRed.__release_connection(connection)
        return False
15014
def check_whitelist(values):
    """"""
    import os
    import tldextract
    whitelisted = list()
    for name in ['alexa.txt', 'cisco.txt']:
        config_path = os.path.expanduser('~/.config/blockade')
        file_path = os.path.join(config_path, name)
        whitelisted += [x.strip() for x in open(file_path, 'r').readlines()]
    output = list()
    for item in values:
        ext = tldextract.extract(item)
        if ext.registered_domain in whitelisted:
            continue
        output.append(item)
    return output
782703
def _check_blacklisted_module(self, node, mod_path):
        ''''''
        for mod_name in self.blacklisted_modules:
            if mod_path == mod_name or mod_path.startswith(mod_name + '.'):
                names = []
                for name, name_as in node.names:
                    if name_as:
                        names.append('{0} as {1}'.format(name, name_as))
                    else:
                        names.append(name)
                try:
                    import_from_module = node.modname
                    if import_from_module == 'salttesting.helpers':
                        for name in names:
                            if name == 'ensure_in_syspath':
                                self.add_message('blacklisted-syspath-update', node=node)
                                continue
                            msg = 'Please use \'from tests.support.helpers import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module in ('salttesting.mock', 'mock', 'unittest.mock', 'unittest2.mock'):
                        for name in names:
                            msg = 'Please use \'from tests.support.mock import {0}\''.format(name)
                            if import_from_module in ('salttesting.mock', 'unittest.mock', 'unittest2.mock'):
                                message_id = 'blacklisted-module'
                            else:
                                message_id = 'blacklisted-external-module'
                            self.add_message(message_id, node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.parser':
                        for name in names:
                            msg = 'Please use \'from tests.support.parser import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.case':
                        for name in names:
                            msg = 'Please use \'from tests.support.case import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.unit':
                        for name in names:
                            msg = 'Please use \'from tests.support.unit import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module.startswith(('unittest', 'unittest2')):
                        for name in names:
                            msg = 'Please use \'from tests.support.unit import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.mixins':
                        for name in names:
                            msg = 'Please use \'from tests.support.mixins import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'six':
                        for name in names:
                            msg = 'Please use \'from salt.ext.six import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'distutils.version':
                        for name in names:
                            msg = 'Please use \'from salt.utils.versions import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if names:
                        for name in names:
                            if name in ('TestLoader', 'TextTestRunner', 'TestCase', 'expectedFailure',
                                        'TestSuite', 'skipIf', 'TestResult'):
                                msg = 'Please use \'from tests.support.unit import {0}\''.format(name)
                                self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                                continue
                            if name in ('SaltReturnAssertsMixin', 'SaltMinionEventAssertsMixin'):
                                msg = 'Please use \'from tests.support.mixins import {0}\''.format(name)
                                self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                                continue
                            if name in ('ModuleCase', 'SyndicCase', 'ShellCase', 'SSHCase'):
                                msg = 'Please use \'from tests.support.case import {0}\''.format(name)
                                self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                                continue
                            if name == 'run_tests':
                                msg = 'Please remove the \'if __name__ == "__main__":\' section from the end of the module'
                                self.add_message('blacklisted-test-module-execution', node=node, args=msg)
                                continue
                            if mod_name in ('integration', 'unit'):
                                if name in ('SYS_TMP_DIR',
                                            'TMP',
                                            'FILES',
                                            'PYEXEC',
                                            'MOCKBIN',
                                            'SCRIPT_DIR',
                                            'TMP_STATE_TREE',
                                            'TMP_PRODENV_STATE_TREE',
                                            'TMP_CONF_DIR',
                                            'TMP_SUB_MINION_CONF_DIR',
                                            'TMP_SYNDIC_MINION_CONF_DIR',
                                            'TMP_SYNDIC_MASTER_CONF_DIR',
                                            'CODE_DIR',
                                            'TESTS_DIR',
                                            'CONF_DIR',
                                            'PILLAR_DIR',
                                            'TMP_SCRIPT_DIR',
                                            'ENGINES_DIR',
                                            'LOG_HANDLERS_DIR',
                                            'INTEGRATION_TEST_DIR'):
                                    msg = 'Please use \'from tests.support.paths import {0}\''.format(name)
                                    self.add_message('blacklisted-import', node=node, args=(mod_path, msg))
                                    continue
                                msg = 'Please use \'from tests.{0} import {1}\''.format(mod_path, name)
                                self.add_message('blacklisted-import', node=node, args=(mod_path, msg))
                                continue
                            msg = 'Please report this error to SaltStack so we can fix it: Trying to import {0} from {1}'.format(name, mod_path)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                except AttributeError:
                    if mod_name in ('integration', 'unit', 'mock', 'six', 'distutils.version',
                                    'unittest', 'unittest2'):
                        if mod_name in ('integration', 'unit'):
                            msg = 'Please use \'import tests.{0} as {0}\''.format(mod_name)
                            message_id = 'blacklisted-import'
                        elif mod_name == 'mock':
                            msg = 'Please use \'import tests.support.{0} as {0}\''.format(mod_name)
                            message_id = 'blacklisted-external-import'
                        elif mod_name == 'six':
                            msg = 'Please use \'import salt.ext.{0} as {0}\''.format(name)
                            message_id = 'blacklisted-external-import'
                        elif mod_name == 'distutils.version':
                            msg = 'Please use \'import salt.utils.versions\' instead'
                            message_id = 'blacklisted-import'
                        elif mod_name.startswith(('unittest', 'unittest2')):
                            msg = 'Please use \'import tests.support.unit as {}\' instead'.format(mod_name)
                            message_id = 'blacklisted-import'
                        self.add_message(message_id, node=node, args=(mod_path, msg))
                        continue
                    msg = 'Please report this error to SaltStack so we can fix it: Trying to import {0}'.format(mod_path)
                    self.add_message('blacklisted-import', node=node, args=(mod_path, msg))
1332519
def _check_minions_directories(pki_dir):
    '''
    
    '''
    minions_accepted = os.path.join(pki_dir, salt.key.Key.ACC)
    minions_pre = os.path.join(pki_dir, salt.key.Key.PEND)
    minions_rejected = os.path.join(pki_dir, salt.key.Key.REJ)
    minions_denied = os.path.join(pki_dir, salt.key.Key.DEN)

    return minions_accepted, minions_pre, minions_rejected, minions_denied
1372549
def _env_is_exposed(env):
    '''
    
    '''
    if __opts__['svnfs_env_whitelist']:
        salt.utils.versions.warn_until(
            'Neon',
            'The svnfs_env_whitelist config option has been renamed to '
            'svnfs_saltenv_whitelist. Please update your configuration.'
        )
        whitelist = __opts__['svnfs_env_whitelist']
    else:
        whitelist = __opts__['svnfs_saltenv_whitelist']

    if __opts__['svnfs_env_blacklist']:
        salt.utils.versions.warn_until(
            'Neon',
            'The svnfs_env_blacklist config option has been renamed to '
            'svnfs_saltenv_blacklist. Please update your configuration.'
        )
        blacklist = __opts__['svnfs_env_blacklist']
    else:
        blacklist = __opts__['svnfs_saltenv_blacklist']

    return salt.utils.stringutils.check_whitelist_blacklist(
        env,
        whitelist=whitelist,
        blacklist=blacklist,
    )
753269
def validate_env(self, envname):
        
        if self.whitelist_envs and envname in self.whitelist_envs:
            return True
        elif self.whitelist_envs:
            return False

        if self.blacklist_envs and envname not in self.blacklist_envs:
            return True
        elif self.blacklist_envs:
            # If there is just a True, all envs are blacklisted
            return False
        else:
            return True
10870
def _check_pcre_minions(self, expr, greedy):  # pylint: disable=unused-argument
        '''
        
        '''
        reg = re.compile(expr)
        return {'minions': [m for m in self._pki_minions() if reg.match(m)],
                'missing': []}
1035189
def ignore_path(path, ignore_list=None, whitelist=None):
    
    if ignore_list is None:
        return True

    should_ignore = matches_glob_list(path, ignore_list)
    if whitelist is None:
        return should_ignore

    return should_ignore and not matches_glob_list(path, whitelist)
227855
def _filter(self, event):
        '''
        
        '''
        tag = event['tag']
        if self.opts['event_return_whitelist']:
            ret = False
        else:
            ret = True
        for whitelist_match in self.opts['event_return_whitelist']:
            if fnmatch.fnmatch(tag, whitelist_match):
                ret = True
                break
        for blacklist_match in self.opts['event_return_blacklist']:
            if fnmatch.fnmatch(tag, blacklist_match):
                ret = False
                break
        return ret
236450
function isWhitelisted(moduleId)
{
  var i;

  // check if its empty
  if (!this.whiteList.length)
  {
    return true;
  }

  // strip basePath
  moduleId = moduleId.replace(this.basePathRegexp, '');

  for (i = 0; i < this.whiteList.length; i++)
  {
    if (minimatch(moduleId, this.whiteList[i]))
    {
      return true;
    }
  }

  return false;
}
1157530
def is_whitelisted(self, request: AxesHttpRequest, credentials: dict = None) -> bool:  # pylint: disable=unused-argument
        

        if is_client_ip_address_whitelisted(request):
            return True

        if is_client_method_whitelisted(request):
            return True

        return False
1319410
def blacklist(ctx, blacklist_account, account):
    
    account = Account(account, blockchain_instance=ctx.blockchain)
    print_tx(account.blacklist(blacklist_account))
1011174
def should_send(self, request):
        """"""
        if self.filters.get('whitelist', None):
            return request.tree.type in self.filters['whitelist']
        elif self.filters.get('blacklist', None):
            return request.tree.type not in self.filters['blacklist']
        else:
            return True
210568
def _whitelist_blacklist(self, os_name):
        '''
        
        '''
        return napalm_logs.ext.check_whitelist_blacklist(os_name,
                                                         whitelist=self.device_whitelist,
                                                         blacklist=self.device_blacklist)