|
| 1 | + |
| 2 | +use cookie::{CookieJar, SignedJar, PrivateJar, Key}; |
| 3 | + |
| 4 | +// --- tests --- |
| 5 | + |
| 6 | +fn test_cookie_jar(array_var: &[u8]) { |
| 7 | + let mut jar = CookieJar::new(); |
| 8 | + |
| 9 | + let key_generate = Key::generate(); // good |
| 10 | + _ = jar.signed_mut(&key_generate); |
| 11 | + _ = jar.private_mut(&key_generate); |
| 12 | + |
| 13 | + let key_var = Key::from(array_var); // good |
| 14 | + _ = jar.signed_mut(&key_var); |
| 15 | + _ = jar.private_mut(&key_var); |
| 16 | + |
| 17 | + let array1: [u8; 64] = [0; 64]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value] |
| 18 | + let key1 = Key::from(&array1); |
| 19 | + _ = jar.signed_mut(&key1); // $ MISSING: Sink |
| 20 | + |
| 21 | + let array2: [u8; 64] = [0; 64]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value] |
| 22 | + let key2 = Key::from(&array2); |
| 23 | + _ = jar.private_mut(&key2); // $ MISSING: Sink |
| 24 | +} |
| 25 | + |
| 26 | +fn test_biscotti_crypto(array_var: &[u8]) { |
| 27 | + let mut config1 = biscotti::ProcessorConfig::default(); |
| 28 | + let crypto_rules1 = biscotti::config::CryptoRule { |
| 29 | + cookie_names: vec!["name".to_string()], |
| 30 | + algorithm: biscotti::config::CryptoAlgorithm::Signing, |
| 31 | + key: biscotti::Key::generate(), // good |
| 32 | + fallbacks: vec![], |
| 33 | + }; |
| 34 | + config1.crypto_rules.push(crypto_rules1); |
| 35 | + let processor1: biscotti::Processor = config1.into(); |
| 36 | + |
| 37 | + let mut config2 = biscotti::ProcessorConfig::default(); |
| 38 | + let array2 = Vec::from([0u8; 64]); // $ MISSING: Alert[rust/hard-coded-cryptographic-value] |
| 39 | + let crypto_rules2 = biscotti::config::CryptoRule { |
| 40 | + cookie_names: vec!["name".to_string()], |
| 41 | + algorithm: biscotti::config::CryptoAlgorithm::Signing, |
| 42 | + key: biscotti::Key::from(array2), // $ MISSING: Sink |
| 43 | + fallbacks: vec![], |
| 44 | + }; |
| 45 | + config2.crypto_rules.push(crypto_rules2); |
| 46 | + let processor2: biscotti::Processor = config2.into(); |
| 47 | + |
| 48 | + let mut config3 = biscotti::ProcessorConfig::default(); |
| 49 | + let array3 = vec![0u8; 64]; // $ MISSING: Alert[rust/hard-coded-cryptographic-value] |
| 50 | + let crypto_rules3 = biscotti::config::CryptoRule { |
| 51 | + cookie_names: vec!["name".to_string()], |
| 52 | + algorithm: biscotti::config::CryptoAlgorithm::Signing, |
| 53 | + key: biscotti::Key::from(array3), // $ MISSING: Sink |
| 54 | + fallbacks: vec![], |
| 55 | + }; |
| 56 | + config3.crypto_rules.push(crypto_rules3); |
| 57 | + let processor3: biscotti::Processor = config3.into(); |
| 58 | +} |
0 commit comments