-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message validation for the rest of Federation messages #1959
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import com.github.dedis.popstellar.model.network.method.message.MessageGeneral | |
import com.github.dedis.popstellar.model.network.method.message.data.Action | ||
import com.github.dedis.popstellar.model.network.method.message.data.Data | ||
import com.github.dedis.popstellar.model.network.method.message.data.Objects | ||
import com.github.dedis.popstellar.utility.MessageValidator | ||
import com.google.gson.annotations.SerializedName | ||
|
||
/** Federation Expect message */ | ||
|
@@ -23,6 +24,14 @@ class FederationExpect | |
val challenge: MessageGeneral | ||
) : Data { | ||
|
||
init { | ||
MessageValidator.verify() | ||
.isNotEmptyBase64(laoId, "lao_id") | ||
.stringNotEmpty(serverAddress, "server_address") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering if it would be a good idea to create a function in MessageValidator to check for server addresses pattern. It is specified in the protocol :
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For that point, the pattern might change as (if I remember well) some addresses didn't fit in the pattern. It will be added once the protocol is updated. |
||
.isNotEmptyBase64(publicKey, "public_key") | ||
.validMessage(challenge) | ||
} | ||
|
||
override val `object`: String | ||
get() = Objects.FEDERATION.`object` | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validation should ideally be before instantiating attributes, since if the input is wrong and it is meant to crash, no need to fill the attribute beforehand.