Skip to content
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

governance: validate client ID earlier than component/view.rs #4859

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/core/component/governance/src/proposal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Context;
use bytes::Bytes;
use ibc_types::core::client::ClientId;
use serde::{Deserialize, Serialize};
use std::str::FromStr;

Expand Down Expand Up @@ -144,6 +145,9 @@ impl TryFrom<pb::Proposal> for Proposal {
if freeze_ibc_client.client_id.len() > 128 {
anyhow::bail!("client ID must be less than 128 bytes");
}
// Validation: Check the client ID is valid using the validation inside `ClientId::from_str`.
ClientId::from_str(&freeze_ibc_client.client_id)
.map_err(|e| anyhow::anyhow!("invalid client id: {e}"))?;
ProposalPayload::FreezeIbcClient {
client_id: freeze_ibc_client.client_id,
}
Expand All @@ -153,6 +157,9 @@ impl TryFrom<pb::Proposal> for Proposal {
if unfreeze_ibc_client.client_id.len() > 128 {
anyhow::bail!("client ID must be less than 128 bytes");
}
// Validation: Check the client ID is valid using the validation inside `ClientId::from_str`.
ClientId::from_str(&unfreeze_ibc_client.client_id)
.map_err(|e| anyhow::anyhow!("invalid client id: {e}"))?;
ProposalPayload::UnfreezeIbcClient {
client_id: unfreeze_ibc_client.client_id,
}
Expand Down
Loading