Skip to content

Commit 40c7472

Browse files
committed
ci: Add security-focused clippy lints to various crates
1 parent b4b1444 commit 40c7472

File tree

8 files changed

+82
-0
lines changed

8 files changed

+82
-0
lines changed

sdk/rust/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,35 @@ serde_repr = "0.1.7"
4141
sha3 = "0.10.4"
4242
base64 = "0.13"
4343
itoa = "1.0.1"
44+
45+
[workspace.lints.clippy]
46+
# === Code Quality: Prevent incomplete/placeholder code ===
47+
todo = "deny"
48+
49+
# === True Bugs: Compiler can prove these are wrong ===
50+
eq_op = "warn" # x == x, x != x, etc.
51+
modulo_one = "warn" # x % 1 (always returns 0)
52+
out_of_bounds_indexing = "warn" # Compiler-checked out of bounds access
53+
54+
# === Security Audit Support ===
55+
undocumented_unsafe_blocks = "warn" # Document why unsafe is needed
56+
57+
# === Potential Runtime Errors ===
58+
unchecked_duration_subtraction = "warn" # Can panic on underflow
59+
panicking_overflow_checks = "warn" # Overflow checks that panic in release
60+
if_let_mutex = "warn" # Can cause deadlocks
61+
62+
# === Performance: Catch accidental inefficiencies ===
63+
or_fun_call = "warn" # Use .unwrap_or_else instead of .unwrap_or
64+
set_contains_or_insert = "warn" # Use .entry() API instead
65+
stable_sort_primitive = "warn" # Unstable sort is faster for primitives
66+
67+
# === Logic Bugs ===
68+
suspicious_operation_groupings = "warn" # Likely copy-paste errors
69+
70+
# === Data Structure Misuse ===
71+
iter_over_hash_type = "warn" # Non-deterministic iteration order
72+
non_send_fields_in_send_ty = "warn" # Breaks thread safety
73+
74+
# === SDK-specific: Help developers avoid common mistakes ===
75+
wildcard_dependencies = "warn" # Prevent supply chain issues in published crates

sdk/rust/serde_wormhole/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ license.workspace = true
88
homepage.workspace = true
99
repository.workspace = true
1010

11+
[lints]
12+
workspace = true
13+
1114
[dependencies]
1215
base64.workspace = true
1316
itoa.workspace = true

sdk/rust/supported-chains/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ license.workspace = true
88
homepage.workspace = true
99
repository.workspace = true
1010

11+
[lints]
12+
workspace = true
13+
1114
[dependencies]
1215
serde.workspace = true
1316
thiserror.workspace = true

sdk/rust/vaas-serde/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ license.workspace = true
88
homepage.workspace = true
99
repository.workspace = true
1010

11+
[lints]
12+
workspace = true
13+
1114
[lib]
1215
name = "wormhole_sdk"
1316

sdk/rust/vaas-serde/src/vaa.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ impl<P> From<(Header, Body<P>)> for Vaa<P> {
213213
}
214214

215215
impl Header {
216+
#[allow(clippy::todo, reason = "VAA body verification not yet implemented - this function is not currently used in the SDK")]
216217
pub fn verify(&self, _body: &[u8], _addrs: &[GuardianAddress]) -> anyhow::Result<Digest> {
217218
todo!("VAA body verification")
218219
}

svm/wormhole-core-shims/Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,37 @@ codegen-units = 1
3232
opt-level = 3
3333
incremental = false
3434
codegen-units = 1
35+
36+
[workspace.lints.clippy]
37+
# === Code Quality: Prevent incomplete/placeholder code ===
38+
todo = "deny"
39+
unimplemented = "deny" # Uncomment if you want to be strict about this too
40+
41+
# === True Bugs: Compiler can prove these are wrong ===
42+
eq_op = "warn" # x == x, x != x, etc.
43+
modulo_one = "warn" # x % 1 (always returns 0)
44+
out_of_bounds_indexing = "warn" # Compiler-checked out of bounds access
45+
46+
# === Stack Management: Critical for Solana (32KB stack limit) ===
47+
large_stack_arrays = "warn"
48+
large_stack_frames = "warn"
49+
50+
# === Security Audit Support ===
51+
undocumented_unsafe_blocks = "warn" # Document why unsafe is needed
52+
53+
# === Potential Runtime Errors ===
54+
unchecked_duration_subtraction = "warn" # Can panic on underflow
55+
panicking_overflow_checks = "warn" # Overflow checks that panic in release
56+
if_let_mutex = "warn" # Can cause deadlocks
57+
58+
# === Performance: Catch accidental inefficiencies ===
59+
or_fun_call = "warn" # Use .unwrap_or_else instead of .unwrap_or
60+
set_contains_or_insert = "warn" # Use .entry() API instead
61+
stable_sort_primitive = "warn" # Unstable sort is faster for primitives
62+
63+
# === Logic Bugs ===
64+
suspicious_operation_groupings = "warn" # Likely copy-paste errors
65+
66+
# === Data Structure Misuse ===
67+
iter_over_hash_type = "warn" # Non-deterministic iteration order
68+
non_send_fields_in_send_ty = "warn" # Breaks thread safety

svm/wormhole-core-shims/crates/definitions/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ repository.workspace = true
99
rust-version.workspace = true
1010
version.workspace = true
1111

12+
[lints]
13+
workspace = true
14+
1215
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1316

1417
[features]

svm/wormhole-core-shims/crates/shim/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ repository.workspace = true
88
rust-version.workspace = true
99
version.workspace = true
1010

11+
[lints]
12+
workspace = true
13+
1114
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1215

1316
[features]

0 commit comments

Comments
 (0)