// MatchingScopes takes the input specified list of scopes and input object. Returns the set of scopes resource matches.
320061
func (p *serviceEvaluator) MatchingScopes(item runtime.Object, scopes []corev1.ScopedResourceSelectorRequirement) ([]corev1.ScopedResourceSelectorRequirement, error) {
	return []corev1.ScopedResourceSelectorRequirement{}, nil
}
726807
func (r *Matcher) Matches() bool {
	return r.scope() &&
		r.operation() &&
		r.group() &&
		r.version() &&
		r.resource()
}
636855
func (p *podEvaluator) MatchingScopes(item runtime.Object, scopeSelectors []corev1.ScopedResourceSelectorRequirement) ([]corev1.ScopedResourceSelectorRequirement, error) {
	matchedScopes := []corev1.ScopedResourceSelectorRequirement{}
	for _, selector := range scopeSelectors {
		match, err := podMatchesScopeFunc(selector, item)
		if err != nil {
			return []corev1.ScopedResourceSelectorRequirement{}, fmt.Errorf("error on matching scope %v: %v", selector, err)
		}
		if match {
			matchedScopes = append(matchedScopes, selector)
		}
	}
	return matchedScopes, nil
}
1044316
func SplitScopeString(scopestring string) (scopeList []string) {
	scopeList = []string{}
	for _, value := range strings.Split(scopestring, ",") {
		scope := strings.TrimSpace(value)
		if scope != "" {
			scopeList = append(scopeList, scope)
		}
	}
	return
}
48999
func (m *equalsMatcher) Matches(candidate interface{}) error {
	e := m.expectedValue
	c := reflect.ValueOf(candidate)
	ek := e.Kind()

	switch {
	case ek == reflect.Bool:
		return checkAgainstBool(e.Bool(), c)

	case isSignedInteger(e):
		return checkAgainstInt64(e.Int(), c)

	case isUnsignedInteger(e):
		return checkAgainstUint64(e.Uint(), c)

	case ek == reflect.Float32:
		return checkAgainstFloat32(float32(e.Float()), c)

	case ek == reflect.Float64:
		return checkAgainstFloat64(e.Float(), c)

	case ek == reflect.Complex64:
		return checkAgainstComplex64(complex64(e.Complex()), c)

	case ek == reflect.Complex128:
		return checkAgainstComplex128(complex128(e.Complex()), c)

	case ek == reflect.Chan:
		return checkAgainstChan(e, c)

	case ek == reflect.Func:
		return checkAgainstFunc(e, c)

	case ek == reflect.Map:
		return checkAgainstMap(e, c)

	case ek == reflect.Ptr:
		return checkAgainstPtr(e, c)

	case ek == reflect.Slice:
		return checkAgainstSlice(e, c)

	case ek == reflect.String:
		return checkAgainstString(e, c)

	case ek == reflect.Array:
		return checkAgainstArray(e, c)

	case ek == reflect.UnsafePointer:
		return checkAgainstUnsafePointer(e, c)

	case ek == reflect.Invalid:
		return checkForNil(c)
	}

	panic(fmt.Sprintf("equalsMatcher.Matches: unexpected kind: %v", ek))
}
687355
func (p *parser) elementInScope(s scope, matchTags ...a.Atom) bool {
	return p.indexOfElementInScope(s, matchTags...) != -1
}
704537
func findScopes(tokens []tagInfo) [][]tagInfo {
	level := 0
	scope := []tagInfo{}
	scopes := [][]tagInfo{}
	for _, token := range tokens {
		// we will clear empty tagged tokens from the array
		txt := strings.TrimSpace(token.txt)
		tag := strings.TrimSpace(token.tag)
		if len(txt) == 0 && len(tag) == 0 {
			continue
		}

		scope = append(scope, token)

		// If it is a closing tag then we check what level
		// we are on. If it is 0, then that means we have found a
		// scoped block.
		if token.closingTag {
			level--
			if level == 0 {
				scopes = append(scopes, scope)
				scope = []tagInfo{}
			}
			// Check opening tags and increment the level
		} else if token.txt == "" {
			level++
		}
	}
	// In this case, we did not run into a closing tag. This would mean
	// we have plaintext for documentation.
	if len(scopes) == 0 {
		scopes = append(scopes, scope)
	}
	return scopes
}
1154694
func ExactScopeMatch(addr Address, addrScopes ...Scope) bool {
	for _, scope := range addrScopes {
		if addr.Scope == scope {
			return true
		}
	}
	return false
}
671726
func (p *podEvaluator) Matches(resourceQuota *corev1.ResourceQuota, item runtime.Object) (bool, error) {
	return generic.Matches(resourceQuota, item, p.MatchingResources, podMatchesScopeFunc)
}
663797
func MemberMatchesPredicates(member Member, predicates ...MemberPredicate) bool {
	for _, p := range predicates {
		if !p(member) {
			return false
		}
	}
	return true
}
338408
func (claims *Claims) HasScope(scope string) bool {
	return claims != nil && contains(claims.Scope, scope)
}
525098
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) {
	if c.Next == nil {
		return false, NewErrNoMoreConnector()
	}
	return c.Next.ScopeExists(ctx, scope)
}
284659
func (ctx *Context) PopScope() {
	l := len(ctx.scopes)
	if l == 0 {
		panic("no scopes")
	}

	ctx.scopes = ctx.scopes[:l-1]
}
514505
func DefaultScopes(dataDir string) map[string]*ScopeCfg {
	if dataDir != "" {
		defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db"
		return defaultScopes
	}

	defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db"
	return defaultScopes
}
1075822
func (r *RuleSet) matchingFuncs(c context.Context, configSet, path string) ([]Func, error) {
	r.l.RLock()
	defer r.l.RUnlock()

	out := []Func{}
	for _, rule := range r.r {
		switch pat, err := r.renderedConfigPattern(c, rule); {
		case err != nil:
			return nil, err
		case pat.ConfigSet.Match(configSet) && pat.Path.Match(path):
			out = append(out, rule.cb)
		}
	}

	return out, nil
}
1095067
func MatchesMap(buf []byte, matchers matchers.Map) bool {
	return MatchMap(buf, matchers) != types.Unknown
}
489184
func (r *RDBDriver) getMatchingCpes(uri string) ([]models.Cpe, error) {

	// parse wfn, get vendor, product
	specified, err := naming.UnbindURI(uri)
	if err != nil {
		return nil, err
	}
	// sleect from cpe by vendor, product
	cpes := []models.Cpe{}
	err = r.conn.Where(&models.Cpe{
		CpeBase: models.CpeBase{
			CpeWFN: models.CpeWFN{
				Vendor:  fmt.Sprintf("%s", specified.Get(common.AttributeVendor)),
				Product: fmt.Sprintf("%s", specified.Get(common.AttributeProduct)),
			},
		}}).Find(&cpes).Error
	if err != nil && err != gorm.ErrRecordNotFound {
		return nil, err
	}

	log.Debugf("specified: %s", uri)
	filtered := []models.Cpe{}
	checkedIDs := map[uint]bool{}
	for _, cpe := range cpes {
		match, err := match(uri, cpe)
		if err != nil {
			log.Debugf("Failed to compare the version:%s %s cpe_id:%d %#v",
				err, uri, cpe.ID, cpe)

			// Try to exact match by vendor, product and version if the version in CPE is not a semVer style.
			if cpe.NvdJSONID != 0 {
				if _, ok := checkedIDs[cpe.NvdJSONID]; ok {
					continue
				}
				affects := []models.Affect{}
				result := r.conn.Where(&models.Affect{NvdJSONID: cpe.NvdJSONID}).Find(&affects)
				if result.Error != nil && result.Error != gorm.ErrRecordNotFound {
					return nil, result.Error
				}

				ok, err := matchExactByAffects(uri, affects)
				if err != nil {
					return nil, err
				}
				if ok {
					filtered = append(filtered, cpe)
				}
				checkedIDs[cpe.NvdJSONID] = true
			}
		} else if match {
			filtered = append(filtered, cpe)
		}
	}

	return filtered, nil
}