// VSCCValidateTx does nothing
196052
func (v *MockVsccValidator) VSCCValidateTx(seq int, payload *common.Payload, envBytes []byte, block *common.Block) (error, peer.TxValidationCode) {
	return nil, peer.TxValidationCode_VALID
}
194437
func validateEtcdTLS(specs []*kops.EtcdClusterSpec, fieldPath *field.Path) *field.Error {
	var usingTLS int
	for _, x := range specs {
		if x.EnableEtcdTLS {
			usingTLS++
		}
	}
	// check both clusters are using tls if one us enabled
	if usingTLS > 0 && usingTLS != len(specs) {
		return field.Invalid(fieldPath.Index(0).Child("EnableEtcdTLS"), false, "Both etcd clusters must have TLS enabled or none at all")
	}

	return nil
}
787654
func ErrorCtx(ctx context.Context, format string, v ...interface{}) {
	if LogLevel >= 1 {
		lc := FromContext(ctx)
		if len(lc) > 0 {
			format = fmt.Sprintf("%s %s", lc, format)
		}
		DoLog(3, ERROR, fmt.Sprintf(format, v...))
	}
}
272227
func (app *PersistentKVStoreApplication) execValidatorTx(tx []byte) types.ResponseDeliverTx {
	tx = tx[len(ValidatorSetChangePrefix):]

	//get the pubkey and power
	pubKeyAndPower := strings.Split(string(tx), "/")
	if len(pubKeyAndPower) != 2 {
		return types.ResponseDeliverTx{
			Code: code.CodeTypeEncodingError,
			Log:  fmt.Sprintf("Expected 'pubkey/power'. Got %v", pubKeyAndPower)}
	}
	pubkeyS, powerS := pubKeyAndPower[0], pubKeyAndPower[1]

	// decode the pubkey
	pubkey, err := hex.DecodeString(pubkeyS)
	if err != nil {
		return types.ResponseDeliverTx{
			Code: code.CodeTypeEncodingError,
			Log:  fmt.Sprintf("Pubkey (%s) is invalid hex", pubkeyS)}
	}

	// decode the power
	power, err := strconv.ParseInt(powerS, 10, 64)
	if err != nil {
		return types.ResponseDeliverTx{
			Code: code.CodeTypeEncodingError,
			Log:  fmt.Sprintf("Power (%s) is not an int", powerS)}
	}

	// update
	return app.updateValidator(types.Ed25519Validator(pubkey, int64(power)))
}
98486
func (vctx *ValidatorContext) Validate(ctx context.Context, target string, signature *SignatureInfo) error {
	if vctx.Consumer == nil {
		vctx.Consumer = &state.Consumer{}
	}

	numWorkers := vctx.NumWorkers
	if numWorkers == 0 {
		numWorkers = runtime.NumCPU() + 1
	}

	vctx.Wounds = make(chan *Wound, 1024)
	workerErrs := make(chan error, numWorkers)
	consumerErrs := make(chan error, 1)
	cancelled := make(chan struct{})

	var woundsStateConsumer *state.Consumer
	var healerProgress float64
	var bytesDone int64
	var progressMutex sync.Mutex

	updateProgress := func() {
		progressMutex.Lock()
		if woundsStateConsumer == nil {
			scanProgress := float64(bytesDone) / float64(signature.Container.Size)
			vctx.Consumer.Progress(scanProgress)
		} else {
			vctx.Consumer.Progress(healerProgress)
		}
		progressMutex.Unlock()
	}

	onProgress := func(delta int64) {
		progressMutex.Lock()
		bytesDone += delta
		progressMutex.Unlock()
		updateProgress()
	}

	if vctx.FailFast {
		if vctx.WoundsPath != "" {
			return fmt.Errorf("ValidatorContext: FailFast is not compatible with WoundsPath")
		}
		if vctx.HealPath != "" {
			return fmt.Errorf("ValidatorContext: FailFast is not compatible with HealPath")
		}

		vctx.WoundsConsumer = &WoundsGuardian{}
	} else if vctx.WoundsPath != "" {
		vctx.WoundsConsumer = &WoundsWriter{
			WoundsPath: vctx.WoundsPath,
		}
	} else if vctx.HealPath != "" {
		// healers can deal with "everything missing"
		err := os.MkdirAll(target, 0755)
		if err != nil {
			return err
		}

		healer, err := NewHealer(vctx.HealPath, target)
		if err != nil {
			return err
		}

		woundsStateConsumer = &state.Consumer{
			OnProgress: func(progress float64) {
				progressMutex.Lock()
				healerProgress = progress
				progressMutex.Unlock()
				updateProgress()
			},
			OnProgressLabel: func(label string) {
				vctx.Consumer.ProgressLabel(label)
			},
		}
		healer.SetConsumer(woundsStateConsumer)

		vctx.WoundsConsumer = healer
	} else {
		vctx.WoundsConsumer = &WoundsPrinter{
			Consumer: vctx.Consumer,
		}
	}

	go func() {
		consumerErrs <- vctx.WoundsConsumer.Do(ctx, signature.Container, vctx.Wounds)

		// throw away wounds until closed
		for range vctx.Wounds {
			// muffin
		}
	}()

	// validate dirs and symlinks first
	for dirIndex, dir := range signature.Container.Dirs {
		path := filepath.Join(target, filepath.FromSlash(dir.Path))
		stats, err := os.Lstat(path)
		if err != nil {
			if IsNotExist(err) {
				vctx.Wounds <- &Wound{
					Kind:  WoundKind_DIR,
					Index: int64(dirIndex),
				}
				continue
			} else {
				return err
			}
		}

		if !stats.IsDir() {
			vctx.Wounds <- &Wound{
				Kind:  WoundKind_DIR,
				Index: int64(dirIndex),
			}
			continue
		}
	}

	for symlinkIndex, symlink := range signature.Container.Symlinks {
		path := filepath.Join(target, filepath.FromSlash(symlink.Path))
		dest, err := os.Readlink(path)
		if err != nil {
			if os.IsNotExist(err) {
				vctx.Wounds <- &Wound{
					Kind:  WoundKind_SYMLINK,
					Index: int64(symlinkIndex),
				}
				continue
			} else {
				return err
			}
		}

		if dest != filepath.FromSlash(symlink.Dest) {
			vctx.Wounds <- &Wound{
				Kind:  WoundKind_SYMLINK,
				Index: int64(symlinkIndex),
			}
			continue
		}
	}

	fileIndices := make(chan int64)

	for i := 0; i < numWorkers; i++ {
		go vctx.validate(target, signature, fileIndices, workerErrs, onProgress, cancelled)
	}

	var retErr error
	sending := true

	for fileIndex := range signature.Container.Files {
		if !sending {
			break
		}

		select {
		case workerErr := <-workerErrs:
			workerErrs <- nil
			retErr = workerErr
			close(cancelled)
			sending = false

		case consumerErr := <-consumerErrs:
			consumerErrs <- nil
			retErr = consumerErr
			close(cancelled)
			sending = false

		case fileIndices <- int64(fileIndex):
			// just queued another file
		}
	}

	close(fileIndices)

	// wait for all workers to finish
	for i := 0; i < numWorkers; i++ {
		err := <-workerErrs
		if err != nil {
			if retErr == nil {
				retErr = err
			}
		}
	}

	close(vctx.Wounds)

	// wait for wound consumer to finish
	cErr := <-consumerErrs
	if cErr != nil {
		if retErr == nil {
			retErr = cErr
		}
	}

	return retErr
}
717540
func (fw *FirewallSSO) InfoToTemplateCtx(ctx context.Context, info map[string]string, timeout int) map[string]string {
	templateCtx := make(map[string]string)
	for k, v := range info {
		templateCtx[sharedutils.UcFirst(k)] = v
	}

	templateCtx["Timeout"] = strconv.Itoa(timeout)

	return templateCtx
}
1122983
func (o *Options) validateFunc() ValidateFunc {
	if o.ValidateFunc == nil {
		return defaultValidateFunc
	}

	return o.ValidateFunc
}
1895
func (iapi *InsightApi) ValidatePostCtx(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		contentLengthString := r.Header.Get("Content-Length")
		contentLength, err := strconv.Atoi(contentLengthString)
		if err != nil {
			writeInsightError(w, "Content-Length Header must be set")
			return
		}
		// Broadcast Tx has the largest possible body.  Cap max content length
		// to iapi.params.MaxTxSize * 2 plus some arbitrary extra for JSON
		// encapsulation.
		maxPayload := (iapi.params.MaxTxSize * 2) + 50
		if contentLength > maxPayload {
			writeInsightError(w, fmt.Sprintf("Maximum Content-Length is %d", maxPayload))
			return
		}
		next.ServeHTTP(w, r)
	})
}
650140
func (ccpack *SignedCDSPackage) ValidateCC(ccdata *ChaincodeData) error {
	if ccpack.sDepSpec == nil {
		return fmt.Errorf("uninitialized package")
	}

	if ccpack.sDepSpec.ChaincodeDeploymentSpec == nil {
		return fmt.Errorf("signed chaincode deployment spec cannot be nil in a package")
	}

	if ccpack.depSpec == nil {
		return fmt.Errorf("chaincode deployment spec cannot be nil in a package")
	}

	// This is a hack. LSCC expects a specific LSCC error when names are invalid so it
	// has its own validation code. We can't use that error because of import cycles.
	// Unfortunately, we also need to check if what have makes some sort of sense as
	// protobuf will gladly deserialize garbage and there are paths where we assume that
	// a successful unmarshal means everything works but, if it fails, we try to unmarshal
	// into something different.
	if !isPrintable(ccdata.Name) {
		return fmt.Errorf("invalid chaincode name: %q", ccdata.Name)
	}

	if ccdata.Name != ccpack.depSpec.ChaincodeSpec.ChaincodeId.Name || ccdata.Version != ccpack.depSpec.ChaincodeSpec.ChaincodeId.Version {
		return fmt.Errorf("invalid chaincode data %v (%v)", ccdata, ccpack.depSpec.ChaincodeSpec.ChaincodeId)
	}

	otherdata := &SignedCDSData{}
	err := proto.Unmarshal(ccdata.Data, otherdata)
	if err != nil {
		return err
	}

	if !ccpack.data.Equals(otherdata) {
		return fmt.Errorf("data mismatch")
	}

	return nil
}
1135070
func (c *Component) ValidateTTNAuthContext(ctx context.Context) (*claims.Claims, error) {
	token, err := ttnctx.TokenFromIncomingContext(ctx)
	if err != nil {
		return nil, err
	}

	if c.TokenKeyProvider == nil {
		return nil, errors.NewErrInternal("No token provider configured")
	}

	claims, err := claims.FromToken(c.TokenKeyProvider, token)
	if err != nil {
		return nil, errors.NewErrPermissionDenied(err.Error())
	}

	return claims, nil
}
882408
func ValidateAuthTokenWithCtxOrReq(
	ctx types.Context,
	config *types.AuthConfig,
	req *http.Request) (*types.AuthToken, error) {

	tok, err := ValidateAuthTokenWithCtx(ctx, config)
	if err != nil {
		return nil, err
	}
	if tok != nil {
		return tok, nil
	}
	return ValidateAuthTokenWithReq(ctx, config, req)
}
508547
func NewTxValidationFlagsSetValue(size int, value peer.TxValidationCode) TxValidationFlags {
	return newTxValidationFlagsSetValue(size, value)
}
1007486
func (m *MockUpgradeMachineSeriesAPI) UpgradeSeriesValidate(arg0, arg1 string) ([]string, error) {
	ret := m.ctrl.Call(m, "UpgradeSeriesValidate", arg0, arg1)
	ret0, _ := ret[0].([]string)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
1182902
func ErrorCtx(ctx context.Context, err error, data Data) {
	correlationKey := common.GetRequestId(ctx)
	ErrorC(correlationKey, err, data)
}
776891
func (iter *Iterator) ValidForPrefix(prefix []byte) bool {
	if C.rocksdb_iter_valid(iter.c) == 0 {
		return false
	}

	key := iter.Key()
	result := bytes.HasPrefix(key.Data(), prefix)
	key.Free()
	return result
}
1107579
func (e *DashAlertExtractor) ValidateAlerts() error {
	_, err := e.extractAlerts(func(alert *m.Alert) bool { return alert.OrgId != 0 && alert.PanelId != 0 })
	return err
}
134890
func newTxValidator(utxoView *UtxoViewpoint, flags txscript.ScriptFlags,
	sigCache *txscript.SigCache, hashCache *txscript.HashCache) *txValidator {
	return &txValidator{
		validateChan: make(chan *txValidateItem),
		quitChan:     make(chan struct{}),
		resultChan:   make(chan error),
		utxoView:     utxoView,
		sigCache:     sigCache,
		hashCache:    hashCache,
		flags:        flags,
	}
}