Skip to content

Commit

Permalink
[audit] 10. Suboptimal usage of optional vectors & 12. Code deduplica…
Browse files Browse the repository at this point in the history
…tion (#868)

* fix cargo errors

* replaced pre-propose submission policy's optional vectors of strings with vectors of addrs

* de-dupe redundant code

* updated schema
  • Loading branch information
NoahSaso authored Aug 11, 2024
1 parent c94194c commit 2cac217
Show file tree
Hide file tree
Showing 20 changed files with 500 additions and 557 deletions.
4 changes: 2 additions & 2 deletions ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ fn main() -> Result<()> {
}),
submission_policy: PreProposeSubmissionPolicy::Specific {
dao_members: true,
allowlist: None,
denylist: None,
allowlist: vec![],
denylist: vec![],
},
extension: Empty::default(),
})
Expand Down
4 changes: 2 additions & 2 deletions ci/integration-tests/src/helpers/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ pub fn create_dao(
}),
submission_policy: PreProposeSubmissionPolicy::Specific {
dao_members: true,
allowlist: None,
denylist: None,
allowlist: vec![],
denylist: vec![],
},
extension: Empty::default(),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
},
"additionalProperties": false,
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"DepositRefundPolicy": {
"oneOf": [
{
Expand Down Expand Up @@ -139,15 +143,15 @@
"properties": {
"anyone": {
"type": "object",
"required": [
"denylist"
],
"properties": {
"denylist": {
"description": "Addresses that may not create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand All @@ -166,17 +170,16 @@
"specific": {
"type": "object",
"required": [
"dao_members"
"allowlist",
"dao_members",
"denylist"
],
"properties": {
"allowlist": {
"description": "Addresses that may create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
},
"dao_members": {
Expand All @@ -185,12 +188,9 @@
},
"denylist": {
"description": "Addresses that may not create proposals, overriding other settings.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand Down Expand Up @@ -531,6 +531,10 @@
}
],
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"oneOf": [
Expand Down Expand Up @@ -1204,15 +1208,15 @@
"properties": {
"anyone": {
"type": "object",
"required": [
"denylist"
],
"properties": {
"denylist": {
"description": "Addresses that may not create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand All @@ -1231,17 +1235,16 @@
"specific": {
"type": "object",
"required": [
"dao_members"
"allowlist",
"dao_members",
"denylist"
],
"properties": {
"allowlist": {
"description": "Addresses that may create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
},
"dao_members": {
Expand All @@ -1250,12 +1253,9 @@
},
"denylist": {
"description": "Addresses that may not create proposals, overriding other settings.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand Down Expand Up @@ -2328,6 +2328,10 @@
}
],
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"Empty": {
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
"type": "object"
Expand All @@ -2344,15 +2348,15 @@
"properties": {
"anyone": {
"type": "object",
"required": [
"denylist"
],
"properties": {
"denylist": {
"description": "Addresses that may not create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand All @@ -2371,17 +2375,16 @@
"specific": {
"type": "object",
"required": [
"dao_members"
"allowlist",
"dao_members",
"denylist"
],
"properties": {
"allowlist": {
"description": "Addresses that may create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
},
"dao_members": {
Expand All @@ -2390,12 +2393,9 @@
},
"denylist": {
"description": "Addresses that may not create proposals, overriding other settings.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand Down Expand Up @@ -2553,15 +2553,15 @@
"properties": {
"anyone": {
"type": "object",
"required": [
"denylist"
],
"properties": {
"denylist": {
"description": "Addresses that may not create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand All @@ -2580,17 +2580,16 @@
"specific": {
"type": "object",
"required": [
"dao_members"
"allowlist",
"dao_members",
"denylist"
],
"properties": {
"allowlist": {
"description": "Addresses that may create proposals.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
},
"dao_members": {
Expand All @@ -2599,12 +2598,9 @@
},
"denylist": {
"description": "Addresses that may not create proposals, overriding other settings.",
"type": [
"array",
"null"
],
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Addr"
}
}
},
Expand Down
Loading

0 comments on commit 2cac217

Please sign in to comment.