Skip to content

Commit 8155ff7

Browse files
committed
Rust: Add a few more test cases for constants / constant propagation.
1 parent 3403cff commit 8155ff7

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

rust/ql/test/query-tests/security/CWE-798/test_heuristic.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ fn test(var_string: &str, var_data: &[u8;16], var_u64: u64) {
6868
mc2.set_salt_u64(var_u64);
6969
mc2.set_salt_u64(var_u64 + 1);
7070
mc2.set_salt_u64((var_u64 << 32) ^ (var_u64 & 0xFFFFFFFF));
71+
mc2.set_salt_u64(1 << 4); // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
72+
mc2.set_salt_u64(u64::MAX); // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
73+
mc2.set_salt_u64(u64::MAX / 4); // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
7174

7275
let mut key1 = "foo".to_string(); // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
7376
key1 += "bar"; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
@@ -76,4 +79,8 @@ fn test(var_string: &str, var_data: &[u8;16], var_u64: u64) {
7679
let mut key2 = "foo".to_string();
7780
key2 += var_string;
7881
let _ = MyCryptor::new(&key2);
82+
83+
let mut key3 = var_string.to_string();
84+
key3 += "bar";
85+
let _ = MyCryptor::new(&key3);
7986
}

0 commit comments

Comments
 (0)