Skip to content

Commit

Permalink
add msg check
Browse files Browse the repository at this point in the history
  • Loading branch information
skyargos committed Nov 14, 2023
1 parent 4dd7fa2 commit d894da8
Showing 1 changed file with 52 additions and 5 deletions.
57 changes: 52 additions & 5 deletions x/bounty/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ func (msg MsgCreateProgram) ValidateBasic() error {
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid issuer address (%s)", err.Error())
}
if len(msg.ProgramId) == 0 {
return errors.New("empty programId is not allowed")
}
if len(msg.Name) == 0 {
return errors.New("empty name is not allowed")
}
if len(msg.Detail) == 0 {
return errors.New("empty detail is not allowed")
}
return nil
}

Expand Down Expand Up @@ -115,6 +124,9 @@ func (msg MsgEditProgram) ValidateBasic() error {
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid issuer address (%s)", err.Error())
}
if len(msg.ProgramId) == 0 {
return errors.New("empty programId is not allowed")
}
return nil
}

Expand Down Expand Up @@ -164,7 +176,19 @@ func (msg MsgSubmitFinding) ValidateBasic() error {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid issuer address (%s)", err.Error())
}
if len(msg.ProgramId) == 0 {
return errors.New("empty pid is not allowed")
return errors.New("empty programId is not allowed")
}
if len(msg.FindingId) == 0 {
return errors.New("empty findingId is not allowed")
}
if len(msg.Title) == 0 {
return errors.New("empty title is not allowed")
}
if len(msg.FindingHash) == 0 {
return errors.New("empty findingHash is not allowed")
}
if !ValidFindingSeverityLevel(msg.SeverityLevel) {
return sdkerrors.Wrap(ErrFindingSeverityLevelInvalid, msg.SeverityLevel.String())
}
return nil
}
Expand Down Expand Up @@ -216,6 +240,15 @@ func (msg MsgEditFinding) ValidateBasic() error {
if len(msg.FindingId) == 0 {
return errors.New("empty fid is not allowed")
}
if len(msg.Title) == 0 {
return errors.New("empty title is not allowed")
}
if len(msg.FindingHash) == 0 {
return errors.New("empty findingHash is not allowed")
}
if !ValidFindingSeverityLevel(msg.SeverityLevel) {
return sdkerrors.Wrap(ErrFindingSeverityLevelInvalid, msg.SeverityLevel.String())
}
return nil
}

Expand Down Expand Up @@ -251,6 +284,9 @@ func (msg MsgActivateProgram) ValidateBasic() error {
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err.Error())
}
if len(msg.ProgramId) == 0 {
return errors.New("empty programId is not allowed")
}
return nil
}

Expand Down Expand Up @@ -286,6 +322,9 @@ func (msg MsgCloseProgram) ValidateBasic() error {
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err.Error())
}
if len(msg.ProgramId) == 0 {
return errors.New("empty programId is not allowed")
}
return nil
}

Expand Down Expand Up @@ -327,9 +366,11 @@ func (msg MsgConfirmFinding) ValidateBasic() error {
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid issuer address (%s)", err.Error())
}

if len(msg.FindingId) == 0 {
return errors.New("empty finding-id is not allowed")
return errors.New("empty findingId is not allowed")
}
if len(msg.Fingerprint) == 0 {
return errors.New("empty fingerprint is not allowed")
}
return nil
}
Expand Down Expand Up @@ -373,7 +414,7 @@ func (msg MsgConfirmFindingPaid) ValidateBasic() error {
}

if len(msg.FindingId) == 0 {
return errors.New("empty finding-id is not allowed")
return errors.New("empty findingId is not allowed")
}
return nil
}
Expand Down Expand Up @@ -417,7 +458,7 @@ func (msg MsgCloseFinding) ValidateBasic() error {
}

if len(msg.FindingId) == 0 {
return errors.New("empty finding-id is not allowed")
return errors.New("empty findingId is not allowed")
}
return nil
}
Expand Down Expand Up @@ -465,5 +506,11 @@ func (msg MsgReleaseFinding) ValidateBasic() error {
if len(msg.FindingId) == 0 {
return errors.New("empty fid is not allowed")
}
if len(msg.Description) == 0 {
return errors.New("empty description is not allowed")
}
if len(msg.ProofOfConcept) == 0 {
return errors.New("empty proofOfConcept is not allowed")
}
return nil
}

0 comments on commit d894da8

Please sign in to comment.