validation

package
v0.0.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxIssueContentLen        = 1024 * 8 // 8KB
	MaxIssueTitleLen          = 256
	ErrCannotWriteToClosedRef = fmt.Errorf("cannot write to a closed reference")
)
View Source
var (
	ErrPushedAndSignedHeadMismatch = fmt.Errorf("pushed object hash differs from signed reference hash")
)

Functions

func CheckAnnotatedTag

func CheckAnnotatedTag(tag *object.Tag, txDetail *types.TxDetail, _ core.PushKeyGetter) error

CheckAnnotatedTag validates an annotated tag. tag: The target annotated tag txDetail: The pusher transaction detail getPushKey: Getter function for reading push key public key

func CheckCommit

func CheckCommit(commit *object.Commit, txDetail *types.TxDetail, _ core.PushKeyGetter) error

CheckCommit validates a commit repo: The target repo commit: The target commit object txDetail: The push transaction detail getPushKey: Getter function for fetching push public key

func CheckCommonPostBody

func CheckCommonPostBody(
	repo types.LocalRepo,
	commit types.Commit,
	isNewRef bool,
	fm map[string]interface{},
	content []byte) error

CheckCommonPostBody performs sanity checks on common fields of a post body

func CheckEndorsement

func CheckEndorsement(end *pptyp.PushEndorsement, logic core.Logic, index int) error

CheckEndorsement performs sanity and state consistency checks on the given Endorsement object

func CheckEndorsementConsistency

func CheckEndorsementConsistency(end *pptyp.PushEndorsement, logic core.Logic, noBLSSigCheck bool, index int) error

CheckEndorsementConsistency performs consistency checks on the given Endorsement object against the current state of the network. EXPECT: Sanity check to have been performed using CheckEndorsementSanity

func CheckEndorsementConsistencyUsingHost

func CheckEndorsementConsistencyUsingHost(
	hosts tickettypes.SelectedTickets,
	end *pptyp.PushEndorsement,
	noBLSSigCheck bool, index int) error

CheckEndorsementConsistencyUsingHost performs consistency checks on the given push endorsement object against the current state of the network. EXPECT: Sanity check to have been performed using CheckEndorsementSanity

func CheckEndorsementSanity

func CheckEndorsementSanity(e *pptyp.PushEndorsement, fromPushTx bool, index int) error

CheckEndorsementSanity performs sanity checks on the given Endorsement object. fromPushTx indicates that the endorsement was retrieved from a push transaction. noBLSSigRequiredCheck prevents BLS signature requirement check.

func CheckIssuePostBody

func CheckIssuePostBody(commit types.Commit, fm map[string]interface{}) error

CheckIssuePostBody performs sanity checks on fields of an issue post body

func CheckMergeCompliance

func CheckMergeCompliance(
	repo types.LocalRepo,
	change *types.ItemChange,
	mergeProposalID,
	pushKeyID string,
	keepers core.Logic) error

CheckMergeCompliance checks whether the change satisfies the given merge proposal

func CheckMergeProposalID

func CheckMergeProposalID(id string, index int) error

CheckMergeProposalID performs sanity checks on merge proposal ID

func CheckMergeRequestPostBody

func CheckMergeRequestPostBody(
	keepers core.Keepers,
	repo types.LocalRepo,
	commit types.Commit,
	reference string,
	isNewRef bool,
	body map[string]interface{}) error

CheckMergeRequestPostBody performs sanity and consistency checks on post fields specific to a merge request

func CheckMergeRequestPostBodyConsistency

func CheckMergeRequestPostBodyConsistency(
	keepers core.Keepers,
	repo types.LocalRepo,
	reference string,
	isNewRef bool,
	body map[string]interface{}) error

CheckMergeRequestPostBodyConsistency performs consistency checks on fields of a merge request post body against the network state

func CheckNote

func CheckNote(
	repo types.LocalRepo,
	txDetail *types.TxDetail) error

CheckNote validates a note. repo: The repo where the tag exists in. txDetail: The pusher transaction detail

func CheckPostBody

func CheckPostBody(
	keepers core.Keepers,
	repo types.LocalRepo,
	reference string,
	commit types.Commit,
	isNewRef bool,
	fm map[string]interface{},
	content []byte) error

CheckPostBody checks whether the front matter and content extracted from a post body is ok. keepers: The application state keepers repo: The target repo commit: The commit whose content needs to be checked. isNewRef: indicates that the post reference is new. fm: The front matter data. content: The content from the post commit.

func CheckPostCommit

func CheckPostCommit(repo types.LocalRepo, commit types.Commit, args *CheckPostCommitArgs) (*plumbing2.PostBody, error)

CheckPostCommit validates new commits of a post reference. It returns nil post body and error if validation failed or a post body and nil if validation passed.

func CheckPushNote

func CheckPushNote(note pptyp.PushNote, logic core.Logic) error

CheckPushNote performs validation checks on a push transaction

func CheckPushNoteConsistency

func CheckPushNoteConsistency(note pptyp.PushNote, logic core.Logic) error

CheckPushNoteConsistency performs consistency checks against the state of the repository as seen by the node. If the target repo object is not set in tx, local reference hash comparison is not performed.

func CheckPushNoteSanity

func CheckPushNoteSanity(note pptyp.PushNote) error

CheckPushNoteSanity performs syntactic checks on the fields of a push transaction

func CheckPushedReferenceConsistency

func CheckPushedReferenceConsistency(targetRepo remotetypes.LocalRepo,
	ref *pptyp.PushedReference,
	repoState *state.Repository) error

CheckPushedReferenceConsistency validates pushed references.

targetRepo is a reference to the local repo. If unset, the pushed reference's old hash will not be compared to the corresponding local and network reference current hash.

ref is the pushed reference.

repoState is the repository's network state.

func CheckTxDetail

func CheckTxDetail(params *types.TxDetail, keepers core.Keepers, index int) error

CheckTxDetail performs sanity and consistency checks on a transaction's parameters.

func CheckTxDetailConsistency

func CheckTxDetailConsistency(txd *types.TxDetail, keepers core.Keepers, index int) error

CheckTxDetailConsistency performs consistency checks on a transaction's parameters.

func CheckTxDetailSanity

func CheckTxDetailSanity(params *types.TxDetail, index int) error

CheckTxDetailSanity performs sanity checks on a transaction's parameters. When authScope is true, only fields necessary for authentication are validated.

func GetTxDetailsFromNote

func GetTxDetailsFromNote(note pptyp.PushNote, targetRefs ...string) (details []*remotetypes.TxDetail)

GetTxDetailsFromNote creates a slice of TxDetail objects from a push note. Limit to references specified in targetRefs

func IsBlockedByScope

func IsBlockedByScope(scopes []string, params *types.TxDetail, namespaceFromParams *state.Namespace) bool

IsBlockedByScope checks whether the given tx parameter satisfy a given scope

func ValidateChange

func ValidateChange(
	keepers core.Keepers,
	localRepo types.LocalRepo,
	oldHash string,
	change *types.ItemChange,
	detail *types.TxDetail,
	getPushKey core.PushKeyGetter) error

ValidateChange validates a change to a repository repo: The target repository oldHash: The hash of the old reference change: The change to the reference txDetail: The pusher transaction detail getPushKey: Getter function for reading push key public key

func ValidatePostCommit

func ValidatePostCommit(repo types.LocalRepo, commit types.Commit, args *ValidatePostCommitArg) error

ValidatePostCommit validate a pushed post commit. commit is the recent post commit in the post reference.

Types

type ChangeValidatorFunc

type ChangeValidatorFunc func(
	keepers core.Keepers,
	repo types.LocalRepo,
	oldHash string,
	change *types.ItemChange,
	txDetail *types.TxDetail,
	getPushKey core.PushKeyGetter) error

type CheckEndorsementFunc

type CheckEndorsementFunc func(end *pptyp.PushEndorsement, logic core.Logic, index int) error

CheckEndorsementFunc describes a function for validating a push endorsement

type CheckOptions

type CheckOptions struct {
	AllowNonceGap bool
}

type CheckPostCommitArgs

type CheckPostCommitArgs struct {
	Keepers   core.Keepers
	Reference string
	OldHash   string
	IsNew     bool
}

CheckPostCommitArgs includes arguments for CheckPostCommit function

type CheckPushNoteFunc

type CheckPushNoteFunc func(tx pptyp.PushNote, logic core.Logic) error

CheckPushNoteFunc describes a function for checking a push note

type CommitChecker

type CommitChecker func(commit *object.Commit, txDetail *types.TxDetail, getPushKey core.PushKeyGetter) error

CommitChecker describes a function for checking a standard commit

type MergeComplianceCheckFunc

type MergeComplianceCheckFunc func(
	repo types.LocalRepo,
	change *types.ItemChange,
	mergeProposalID,
	pushKeyID string,
	keepers core.Logic) error

type PostCommitChecker

type PostCommitChecker func(
	repo types.LocalRepo,
	commit types.Commit,
	args *CheckPostCommitArgs) (*plumbing2.PostBody, error)

PostCommitChecker describes a function for validating a post commit.

type RefMismatchErr

type RefMismatchErr struct {
	MismatchLocal bool
	MismatchNet   bool
	Ref           string
}

RefMismatchErr describe a reference mismatch error

type TxDetailChecker

type TxDetailChecker func(params *types.TxDetail, keepers core.Keepers, index int) error

TxDetailChecker describes a function for checking a transaction detail

type ValidatePostCommitArg

type ValidatePostCommitArg struct {
	Keepers         core.Keepers
	OldHash         string
	Change          *types.ItemChange
	TxDetail        *types.TxDetail
	PushKeyGetter   core.PushKeyGetter
	CheckPostCommit PostCommitChecker
	CheckCommit     CommitChecker
}

ValidatePostCommitArg contains arguments for ValidatePostCommit

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL