// UnwhitelistUser removes other user to the user whitelist
962979
func (user *User) UnwhitelistUser(other *User) error {
	if other == nil {
		return errors.New("Other user should be a vaid user")
	}
	return Db().Where(&Whitelist{From: user.ID(), To: other.ID()}).Delete(Whitelist{})
}
997686
func (w *Watcher) containsBlacklistedDir(path string) bool {
	return strings.HasPrefix(path, w.deprecatedPath+"/kubernetes.io/") ||
		path == w.deprecatedPath+"/kubernetes.io"
}
1216636
func (db ErroringDB) GetWhitelistForIdentity(c context.Context, ident identity.Identity) (string, error) {
	logging.Errorf(c, "%s", db.Error)
	return "", db.Error
}
734440
func (u *Untar) checkEntryAgainstWhitelist(header *tar.Header) bool {
	if len(u.PathWhitelist) == 0 {
		return true
	}

	name := "/" + filepath.Clean(header.Name)

	for _, p := range u.PathWhitelist {
		// Whitelist: "/foo"  File: "/foo"
		if p == name {
			return true
		}

		if strings.HasSuffix(p, "/") {
			// Whitelist: "/usr/bin/"  Dir: "/usr/bin"
			if p == name+"/" && header.Typeflag == tar.TypeDir {
				return true
			}

			// Whitelist: "/usr/bin/"  File: "/usr/bin/bash"
			if strings.HasPrefix(name, p) {
				return true
			}
		}
	}

	return false
}
877156
func (b *backend) pathIdentityWhitelistRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	instanceID := data.Get("instance_id").(string)
	if instanceID == "" {
		return logical.ErrorResponse("missing instance_id"), nil
	}

	entry, err := whitelistIdentityEntry(ctx, req.Storage, instanceID)
	if err != nil {
		return nil, err
	}
	if entry == nil {
		return nil, nil
	}

	return &logical.Response{
		Data: map[string]interface{}{
			"role":                      entry.Role,
			"client_nonce":              entry.ClientNonce,
			"creation_time":             entry.CreationTime.Format(time.RFC3339Nano),
			"disallow_reauthentication": entry.DisallowReauthentication,
			"pending_time":              entry.PendingTime,
			"expiration_time":           entry.ExpirationTime.Format(time.RFC3339Nano),
			"last_updated_time":         entry.LastUpdatedTime.Format(time.RFC3339Nano),
		},
	}, nil
}
496703
func parseWhitelistFile(whitelistFile string) (*vulnerabilitiesWhitelist, error) {
	whitelistYAML := vulnerabilitiesWhitelistYAML{}
	whitelist := vulnerabilitiesWhitelist{}

	//read the whitelist file
	whitelistBytes, err := ioutil.ReadFile(whitelistFile)
	if err != nil {
		return nil, fmt.Errorf("could not read file %v", err)
	}
	if err = yaml.Unmarshal(whitelistBytes, &whitelistYAML); err != nil {
		return nil, fmt.Errorf("could not unmarshal %v", err)
	}

	//Initialize the whitelist maps
	whitelist.General = make(map[string]bool)
	whitelist.Images = make(map[string]map[string]bool)

	//Populate the maps
	for _, cve := range whitelistYAML.General {
		whitelist.General[cve] = true
	}

	for image, cveList := range whitelistYAML.Images {
		whitelist.Images[image] = make(map[string]bool)
		for _, cve := range cveList {
			whitelist.Images[image][cve] = true
		}
	}

	return &whitelist, nil
}
786794
func (s *UpdateOriginEndpointOutput) SetWhitelist(v []*string) *UpdateOriginEndpointOutput {
	s.Whitelist = v
	return s
}
577466
func proxyWhitelisted(r *http.Request) bool {
	for _, url := range []string{"/raft/promote", "/raft/demote", "/shutdown"} {
		if strings.HasPrefix(r.URL.Path, url) {
			return true
		}
	}
	return false
}
792951
func IsUserInProtectBranchWhitelist(repoID, userID int64, branch string) bool {
	has, err := x.Where("repo_id = ?", repoID).And("user_id = ?", userID).And("name = ?", branch).Get(new(ProtectBranchWhitelist))
	return has && err == nil
}
1045111
func ValidateImageStreamUpdateWithWhitelister(
	whitelister whitelist.RegistryWhitelister,
	newStream, oldStream *imageapi.ImageStream,
) field.ErrorList {
	result := validation.ValidateObjectMetaUpdate(&newStream.ObjectMeta, &oldStream.ObjectMeta, field.NewPath("metadata"))

	if whitelister != nil {
		// whitelist old pull specs no longer present on the whitelist
		whitelister = whitelister.Copy()
		whitelister.WhitelistPullSpecs(collectImageStreamSpecImageReferences(oldStream).List()...)
		for ref := range collectImageStreamStatusImageReferences(oldStream) {
			whitelister.WhitelistPullSpecs(ref)
		}
	}

	result = append(result, ValidateImageStreamWithWhitelister(whitelister, newStream)...)

	return result
}
480513
func isWhitelisted(addr net.Addr) bool {
	if len(cfg.whitelists) == 0 {
		return false
	}

	host, _, err := net.SplitHostPort(addr.String())
	if err != nil {
		srvrLog.Warnf("Unable to SplitHostPort on '%s': %v", addr, err)
		return false
	}
	ip := net.ParseIP(host)
	if ip == nil {
		srvrLog.Warnf("Unable to parse IP '%s'", addr)
		return false
	}

	for _, ipnet := range cfg.whitelists {
		if ipnet.Contains(ip) {
			return true
		}
	}
	return false
}
1079645
func AreLabelsInWhiteList(labels, whitelist Set) bool {
	if len(whitelist) == 0 {
		return true
	}

	for k, v := range labels {
		value, ok := whitelist[k]
		if !ok {
			return false
		}
		if value != v {
			return false
		}
	}
	return true
}
610175
func Whitelist() echo.HandlerFunc {

	// swagger:route GET /me/whitelist me info whitelist getMeWhitelist
	//
	// Shows the whitelist informations for the current user
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile:read
	//
	//	Responses:
	//		default: MeWhitelist

	return func(c echo.Context) error {
		return user.Whitelist()(c)
	}
}
240383
func (user *User) Unlurk(post ExistingPost) error {
	if post == nil {
		return errors.New("Unable to unlurk undefined post!")
	}

	switch post.(type) {
	case *UserPost:
		userPost := post.(*UserPost)
		return Db().Where(&UserPostLurk{From: user.ID(), Hpid: userPost.ID()}).Delete(UserPostLurk{})

	case *ProjectPost:
		projectPost := post.(*ProjectPost)
		return Db().Where(&ProjectPostLurk{From: user.ID(), Hpid: projectPost.ID()}).Delete(ProjectPostLurk{})
	}

	return errors.New("Invalid post type " + reflect.TypeOf(post).String())
}
353895
func (db ErroringDB) IsInWhitelist(c context.Context, ip net.IP, whitelist string) (bool, error) {
	logging.Errorf(c, "%s", db.Error)
	return false, db.Error
}
1367770
func (user *User) BlacklistUser(other *User, motivation string) error {
	if other == nil {
		return errors.New("Other user should be a vaid user")
	}
	return Db().Create(&Blacklist{From: user.ID(), To: other.ID(), Motivation: motivation})
}
655142
func NewFilteredLeaseInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
	return cache.NewSharedIndexInformer(
		&cache.ListWatch{
			ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.CoordinationV1beta1().Leases(namespace).List(options)
			},
			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.CoordinationV1beta1().Leases(namespace).Watch(options)
			},
		},
		&coordinationv1beta1.Lease{},
		resyncPeriod,
		indexers,
	)
}