Check the indicators against known whitelists.
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
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()
143713
def allow(self, ip):
        
        self.whitelist.append(ip)
        self.blacklist.clear()
449473
def _is_whitelisted(self, email):
        """"""

        return hasattr(settings, "SAFE_EMAIL_WHITELIST") and \
            any(re.match(m, email) for m in settings.SAFE_EMAIL_WHITELIST)
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
800643
def _server_whitelist(self):
        '''
        
        '''
        whitelist = []
        for server in self.servers:
            if (server not in self.last_error
                    or self.last_error[server] < time.time() - self.PENALTY_BOX_TIME):
                whitelist.append(server)
        if not whitelist:
            whitelist.append(sorted(
                self.last_error.items(), key=lambda kv: kv[1])[0][0])
        return whitelist
746733
def _check_avail(cmd):
    '''
    
    '''
    if isinstance(cmd, list):
        cmd = ' '.join([six.text_type(x) if not isinstance(x, six.string_types) else x
                        for x in cmd])
    bret = True
    wret = False
    if __salt__['config.get']('cmd_blacklist_glob'):
        blist = __salt__['config.get']('cmd_blacklist_glob', [])
        for comp in blist:
            if fnmatch.fnmatch(cmd, comp):
                # BAD! you are blacklisted
                bret = False
    if __salt__['config.get']('cmd_whitelist_glob', []):
        blist = __salt__['config.get']('cmd_whitelist_glob', [])
        for comp in blist:
            if fnmatch.fnmatch(cmd, comp):
                # GOOD! You are whitelisted
                wret = True
                break
    else:
        # If no whitelist set then alls good!
        wret = True
    return bret and wret
948628
def process_whitelists():
    """"""
    import csv
    import grequests
    import os
    import StringIO
    import zipfile
    mapping = {
        'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip': {
            'name': 'alexa.txt'
        }, 'http://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip': {
            'name': 'cisco.txt'
        }
    }
    rs = (grequests.get(u) for u in mapping.keys())
    responses = grequests.map(rs)
    for r in responses:
        data = zipfile.ZipFile(StringIO.StringIO(r.content)).read('top-1m.csv')
        stream = StringIO.StringIO(data)
        reader = csv.reader(stream, delimiter=',', quoting=csv.QUOTE_MINIMAL)
        items = [row[1].strip() for row in reader]
        stream.close()

        config_path = os.path.expanduser('~/.config/blockade')
        file_path = os.path.join(config_path, mapping[r.url]['name'])
        handle = open(file_path, 'w')
        for item in items:
            if item.count('.') == 0:
                continue
            handle.write(item + "\n")
        handle.close()
    return True
565787
def indicator(self, data):
        
        if self._name != 'Bulk' or self._name != 'Indicator':
            self._request_uri = '{}/{}'.format(
                self._api_uri, self.tcex.safe_indicator(data, 'ignore')
            )
476952
def is_client_ip_address_whitelisted(request: AxesHttpRequest):
    

    if settings.AXES_NEVER_LOCKOUT_WHITELIST and is_ip_address_in_whitelist(request.axes_ip_address):
        return True

    if settings.AXES_ONLY_WHITELIST and is_ip_address_in_whitelist(request.axes_ip_address):
        return True

    return False
775689
def _container_whitelist(self):
        """"""
        if self.__container_whitelist is None:
            self.__container_whitelist = \
                set(self.CLOUD_BROWSER_CONTAINER_WHITELIST or [])
        return self.__container_whitelist
663969
private function isIpInWhitelist(array $whitelist, $ipAddress)
    {
        foreach ($whitelist as $ipRange) {
            if ($ipRange->containsIp($ipAddress)) {
                return true;
            }
        }
        return false;
    }
1250491
function prepareWhitelist(whitelist) {
	if (whitelist) {
        logger.info(colors.bold('Applying whitelist filtering for JUnit reports. Take care to keep the whitelist up to date!'));

		// The white-list is either a list or the old format, which is an object with more
		// complex structures.
	    whitelist = JSON.parse(whitelist);

	    // Ensure whitelist is in the expected format
	    whitelist = simplifyWhitelist(whitelist);
	}

  // Read the whitelist from a config file
  if (config.has('whitelist.ignore')) {
    if(!whitelist) {
      whitelist = [];
    }

    var myWhitelist = config.get('whitelist.ignore');
    for (var i = 0; i < myWhitelist.length; i++) {
      whitelist.push({
        "id": myWhitelist[i]
      });
    }
  }

  // Convert the list to a map for easy lookup
  if (whitelist) {
    var whitelistMap = {};
    for (var i = 0; i < whitelist.length; i++) {
      var key = whitelist[i].id;
      whitelistMap[key] = whitelist[i];
    }
    whitelist = whitelistMap;
  }

	return whitelist;
}
594122
def check(self, radl):
        """"""

        def positive(f, _):
            return f.value >= 0

        def check_ansible_host(f, radl0):
            if radl0.get_ansible_by_id(f.value) is None:
                return False
            return True

        mem_units = ["", "B", "K", "M", "G", "KB", "MB", "GB"]
        SIMPLE_FEATURES = {
            "spot": (str, ["YES", "NO"]),
            "image_type": (str, ["VMDK", "QCOW", "QCOW2", "RAW"]),
            "virtual_system_type": (str, system._check_virtual_system_type),
            "price": ((int, float), positive, None),
            "cpu.count": ((int, float), positive, None),
            "cpu.arch": (str, ['I386', 'X86_64']),
            "cpu.performance": ((int, float), positive, ["ECU", "GCEU", "HRZ"]),
            "memory.size": (int, positive, mem_units),
            "disk.0.os.credentials.new.password": (str, check_password),
            "ansible_host": (str, check_ansible_host),
            SoftFeatures.SOFT: (SoftFeatures, lambda x, r: x.check(r))
        }
        self.check_simple(SIMPLE_FEATURES, radl)

        net_connections = set()

        def check_net_interface_connection(f, radl0):
            if radl0.get_network_by_id(f.value) is None:
                return False
            net_connections.add(f.prop)
            return True

        def check_app(f, x):
            FeaturesApp(f.value.features).check(x)
            return True

        NUM_FEATURES = {
            "net_interface": {
                "connection": (str, check_net_interface_connection),
                "ip": (str, None),
                "dns_name": (str, None)},
            "disk": {
                "image.url": ((str, unicode, list), system._check_disk_image_url),
                "image.name": (str, None),
                "type": (str, None),
                "device": (str, None),
                "mount_path": (str, None),
                "fstype": (str, None),
                "size": (float, positive, mem_units),
                "free_size": (float, positive, mem_units),
                "os.name": (str, ["LINUX", "WINDOWS", "MAC OS X"]),
                "os.flavour": (str, None),
                "os.version": (str, is_version),
                "os.credentials.username": (str, None),
                "os.credentials.password": (str, None),
                "os.credentials.private_key": (str, None),
                "os.credentials.public_key": (str, None),
                "applications": (Features, check_app)
            }
        }
        prefixes = self.check_num(NUM_FEATURES, radl)

        # Check all interfaces
        if len(net_connections) != len(prefixes.get("net_interface", set())):
            raise RADLParseException("Some net_interface does not have a connection")

        return True
950073
def _monitoring_metrics_list(args, _):
  """"""
  project_id = args['project']
  pattern = args['type'] or '*'
  descriptors = gcm.MetricDescriptors(context=_make_context(project_id))
  dataframe = descriptors.as_dataframe(pattern=pattern)
  return _render_dataframe(dataframe)
286446
public static void checkQuery(SpiQuery<?> query, Set<String> whitelist,
                                  Set<String> blacklist, boolean ignoreUnknown) {
        checkQuery(
                query,
                new ListExpressionValidation(
                        query.getBeanDescriptor(), whitelist, blacklist
                ),
                ignoreUnknown
        );
    }
1363173
function simplifyWhitelist(whitelist) {
	var results = [];

	if (Array.isArray(whitelist)) {
	  // whitelist is in Simplified format
	  for (var i = 0; i < whitelist.length; i++) {
	    results.push({
	      "id": whitelist[i]
	    });
	  }
	} else {
	  // whitelist is in Verbose format
	  for (var project in whitelist) {
	    var vlist = whitelist[project];
	    for (var i = 0; i < vlist.length; i++) {
	      var id = vlist[i].id;
	      results.push({
	        "id": id,
	        "dependencyPaths": vlist[i].dependencyPaths
	      });
	    }
	  }
	}

	return results;
}