Skip to content

Commit 796cb19

Browse files
committed
Rust: Accept test regressions with new format MaD.
1 parent fc8a662 commit 796cb19

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,3 @@ nodes
120120
| test_cipher.rs:74:23:74:44 | ...::new_from_slice | semmle.label | ...::new_from_slice |
121121
| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
122122
subpaths
123-
testFailures
124-
| test_cipher.rs:45:53:45:99 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
125-
| test_cipher.rs:47:88:47:96 | //... | Missing result: Sink |
126-
| test_cipher.rs:66:29:66:75 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
127-
| test_cipher.rs:67:51:67:59 | //... | Missing result: Sink |
128-
| test_cipher.rs:80:29:80:75 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
129-
| test_cipher.rs:81:90:81:98 | //... | Missing result: Sink |
130-
| test_cipher.rs:84:30:84:76 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
131-
| test_cipher.rs:85:91:85:99 | //... | Missing result: Sink |
132-
| test_cipher.rs:124:33:124:79 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
133-
| test_cipher.rs:125:26:125:72 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
134-
| test_cipher.rs:126:49:126:57 | //... | Missing result: Sink |
135-
| test_cipher.rs:127:78:127:86 | //... | Missing result: Sink |
136-
| test_cipher.rs:129:44:129:90 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
137-
| test_cipher.rs:131:38:131:84 | //... | Missing result: Alert[rust/hard-coded-cryptographic-value] |
138-
| test_cipher.rs:132:42:132:50 | //... | Missing result: Sink |
139-
| test_cipher.rs:133:78:133:86 | //... | Missing result: Sink |

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ fn test_stream_cipher_rabbit(
4242
let mut rabbit_cipher8 = RabbitKeyOnly::new(rabbit::Key::from_slice(const8)); // $ Sink
4343
rabbit_cipher8.apply_keystream(&mut data);
4444

45-
let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hard-coded-cryptographic-value]
45+
let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
4646
let const9_conv = unsafe { const9.align_to::<u8>().1 }; // convert [u16;8] -> [u8;8]
47-
let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv)); // $ Sink
47+
let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv)); // $ MISSING: Sink
4848
rabbit_cipher9.apply_keystream(&mut data);
4949

5050
let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ Alert[rust/hard-coded-cryptographic-value]
@@ -63,8 +63,8 @@ fn test_block_cipher_aes(
6363
let aes_cipher1 = Aes256::new(key256.into());
6464
aes_cipher1.encrypt_block(block128.into());
6565

66-
let const2 = &[0u8;32]; // $ Alert[rust/hard-coded-cryptographic-value]
67-
let aes_cipher2 = Aes256::new(const2.into()); // $ Sink
66+
let const2 = &[0u8;32]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
67+
let aes_cipher2 = Aes256::new(const2.into()); // $ MISSING: Sink
6868
aes_cipher2.encrypt_block(block128.into());
6969

7070
let aes_cipher3 = Aes256::new_from_slice(key256).unwrap();
@@ -77,12 +77,12 @@ fn test_block_cipher_aes(
7777
let aes_cipher5 = cfb_mode::Encryptor::<aes::Aes256>::new(key.into(), iv.into());
7878
_ = aes_cipher5.encrypt_b2b(input, output).unwrap();
7979

80-
let const6 = &[0u8;32]; // $ Alert[rust/hard-coded-cryptographic-value]
81-
let aes_cipher6 = cfb_mode::Encryptor::<aes::Aes256>::new(const6.into(), iv.into()); // $ Sink
80+
let const6 = &[0u8;32]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
81+
let aes_cipher6 = cfb_mode::Encryptor::<aes::Aes256>::new(const6.into(), iv.into()); // $ MISSING: Sink
8282
_ = aes_cipher6.encrypt_b2b(input, output).unwrap();
8383

84-
let const7 = &[0u8; 16]; // $ Alert[rust/hard-coded-cryptographic-value]
85-
let aes_cipher7 = cfb_mode::Encryptor::<aes::Aes256>::new(key.into(), const7.into()); // $ Sink
84+
let const7 = &[0u8; 16]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
85+
let aes_cipher7 = cfb_mode::Encryptor::<aes::Aes256>::new(key.into(), const7.into()); // $ MISSING: Sink
8686
_ = aes_cipher7.encrypt_b2b(input, output).unwrap();
8787

8888
// various string conversions
@@ -121,16 +121,16 @@ fn test_aes_gcm(
121121
let cipher1 = Aes256Gcm::new(&key1);
122122
let _ = cipher1.encrypt(&nonce1, b"plaintext".as_ref()).unwrap();
123123

124-
let key2: [u8;32] = [0;32]; // $ Alert[rust/hard-coded-cryptographic-value]
125-
let nonce2 = [0;12]; // $ Alert[rust/hard-coded-cryptographic-value]
126-
let cipher2 = Aes256Gcm::new(&key2.into()); // $ Sink
127-
let _ = cipher2.encrypt(&nonce2.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
124+
let key2: [u8;32] = [0;32]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
125+
let nonce2 = [0;12]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
126+
let cipher2 = Aes256Gcm::new(&key2.into()); // $ MISSING: Sink
127+
let _ = cipher2.encrypt(&nonce2.into(), b"plaintext".as_ref()).unwrap(); // $ MISSING: Sink
128128

129-
let key3_array: &[u8;32] = &[0xff;32]; // $ Alert[rust/hard-coded-cryptographic-value]
129+
let key3_array: &[u8;32] = &[0xff;32]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
130130
let key3 = Key::<Aes256Gcm>::from_slice(key3_array);
131-
let nonce3: [u8;12] = [0xff;12]; // $ Alert[rust/hard-coded-cryptographic-value]
132-
let cipher3 = Aes256Gcm::new(&key3); // $ Sink
133-
let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
131+
let nonce3: [u8;12] = [0xff;12]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
132+
let cipher3 = Aes256Gcm::new(&key3); // $ MISSING: Sink
133+
let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap(); // $ MISSING: Sink
134134

135135
// with barrier
136136

0 commit comments

Comments
 (0)