// CalcHoneyScore calculates a honeypot probability score ranging from
// 0 (not a honeypot) to 1.0 (is a honeypot).
555152
func (c *Client) CalcHoneyScore(ctx context.Context, ip net.IP) (float64, error) {
	var score float64

	path := fmt.Sprintf(honeyscorePath, ip.String())
	req, err := c.NewRequest("GET", path, nil, nil)
	if err != nil {
		return 0.0, err
	}

	if err := c.Do(ctx, req, &score); err != nil {
		return 0.0, err
	}

	return score, err
}
422477
func (t *SecureTrie) getSecKeyCache() map[string][]byte {
	if t != t.secKeyCacheOwner {
		t.secKeyCacheOwner = t
		t.secKeyCache = make(map[string][]byte)
	}
	return t.secKeyCache
}
229238
func checkCache(method string, url string, bctx BuiltinContext) ast.Value {
	key := getCtxKey(method, url)

	val, ok := bctx.Cache.Get(key)
	if ok {
		return val.(ast.Value)
	}
	return nil
}
367674
func (s *SearchSource) MinScore(minScore float64) *SearchSource {
	s.minScore = &minScore
	return s
}
222395
func CompareChainCryptoSuite(chain1, chain2 []*x509.Certificate) int {
	cs1 := HashPriority(chain1) + KeyAlgoPriority(chain1)
	cs2 := HashPriority(chain2) + KeyAlgoPriority(chain2)
	return cs1 - cs2
}
522943
func (db *DB) ZScore(key []byte, member []byte) (int64, error) {
	if err := checkZSetKMSize(key, member); err != nil {
		return InvalidScore, err
	}

	score := InvalidScore

	k := db.zEncodeSetKey(key, member)
	if v, err := db.bucket.Get(k); err != nil {
		return InvalidScore, err
	} else if v == nil {
		return InvalidScore, ErrScoreMiss
	} else {
		if score, err = Int64(v, nil); err != nil {
			return InvalidScore, err
		}
	}

	return score, nil
}
397853
func (m *Miniredis) ZScore(k, member string) (float64, error) {
	return m.DB(m.selectedDB).ZScore(k, member)
}
1223413
func (eng *engine) IndexScore(index Index, key interface{}) (int64, error) {
	s := eng.newSession()
	defer s.Close()
	action, score, err := s.indexScore(index, key)
	if err != nil {
		return score, s.catch("IndexScore: "+action, err)
	}
	return score, nil
}
349335
func (impl *SortImpl) CalcCost(outCount float64, childCosts []float64, children ...*memo.Group) float64 {
	cnt := math.Min(children[0].Prop.Stats.RowCount, impl.plan.GetChildReqProps(0).ExpectedCnt)
	sort := impl.plan.(*plannercore.PhysicalSort)
	impl.cost = sort.GetCost(cnt) + childCosts[0]
	return impl.cost
}
1055376
func ExtractSumOrFiltersScores(opts ...interface{}) *opt.SumOrFiltersScoresOption {
	for _, o := range opts {
		if v, ok := o.(*opt.SumOrFiltersScoresOption); ok {
			return v
		}
	}
	return nil
}
1097581
func ParseKeyValueCookie(val string, cb func(key, val string)) {
	val, _ = url.QueryUnescape(val)
	if matches := cookieKeyValueParser.FindAllStringSubmatch(val, -1); matches != nil {
		for _, match := range matches {
			cb(match[1], match[2])
		}
	}
}
712209
func (i *Index) calcScore(index int, matchline string) int {

	// This is currently tied to the fact that sep is a single char.
	splits := []int{}
	s := rune(sep[0])
	for i, ch := range matchline {
		if ch == s {
			splits = append(splits, i)
		}
	}

	for i, pos := range splits {
		if index > pos {
			continue
		}
		return i
	}
	return len(splits)
}
1037059
func (s *SearchService) MinScore(minScore float64) *SearchService {
	s.searchSource = s.searchSource.MinScore(minScore)
	return s
}
482558
func certificateCheckCallback(_cert *C.git_cert, _valid C.int, _host *C.char, data unsafe.Pointer) int {
	callbacks, _ := pointerHandles.Get(data).(*RemoteCallbacks)
	// if there's no callback set, we need to make sure we fail if the library didn't consider this cert valid
	if callbacks.CertificateCheckCallback == nil {
		if _valid == 1 {
			return 0
		} else {
			return C.GIT_ECERTIFICATE
		}
	}
	host := C.GoString(_host)
	valid := _valid != 0

	var cert Certificate
	if _cert.cert_type == C.GIT_CERT_X509 {
		cert.Kind = CertificateX509
		ccert := (*C.git_cert_x509)(unsafe.Pointer(_cert))
		x509_certs, err := x509.ParseCertificates(C.GoBytes(ccert.data, C.int(ccert.len)))
		if err != nil {
			return C.GIT_EUSER
		}

		// we assume there's only one, which should hold true for any web server we want to talk to
		cert.X509 = x509_certs[0]
	} else if _cert.cert_type == C.GIT_CERT_HOSTKEY_LIBSSH2 {
		cert.Kind = CertificateHostkey
		ccert := (*C.git_cert_hostkey)(unsafe.Pointer(_cert))
		cert.Hostkey.Kind = HostkeyKind(ccert._type)
		C.memcpy(unsafe.Pointer(&cert.Hostkey.HashMD5[0]), unsafe.Pointer(&ccert.hash_md5[0]), C.size_t(len(cert.Hostkey.HashMD5)))
		C.memcpy(unsafe.Pointer(&cert.Hostkey.HashSHA1[0]), unsafe.Pointer(&ccert.hash_sha1[0]), C.size_t(len(cert.Hostkey.HashSHA1)))
	} else {
		cstr := C.CString("Unsupported certificate type")
		C.giterr_set_str(C.GITERR_NET, cstr)
		C.free(unsafe.Pointer(cstr))
		return -1 // we don't support anything else atm
	}

	return int(callbacks.CertificateCheckCallback(&cert, valid, host))
}
1363366
func PrecomputeKeys(count int) KeygenOption {
	return func(k *Keygen) error {
		k.precomputeCount = count
		return nil
	}
}
174362
func (rf *requestForwardingHandler) CALookup(ctx context.Context) (*x509.Certificate, error) {
	parsedCert := rf.core.localClusterParsedCert.Load().(*x509.Certificate)

	if parsedCert == nil {
		return nil, fmt.Errorf("forwarding connection client but no local cert")
	}

	return parsedCert, nil
}
503671
func (s *session) IndexScore(index Index, key interface{}) (int64, error) {
	action, score, err := s.indexScore(index, key)
	if err != nil {
		return score, s.catch("IndexScore: "+action, err)
	}
	return score, nil
}