Skip to content

Commit 10c42fe

Browse files
committed
test(core): generate body nonces with OsRng in poisoned-envelope fixtures
CodeQL flags hard-coded byte arrays used as nonces, even in test fixtures where the value is a fixed test vector. Generate with OsRng instead, matching the production seal path.
1 parent 8b23ad1 commit 10c42fe

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎crates/gitlawb-core/src/encrypt.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ mod tests {
469469
let nonce = ChaChaBox::generate_nonce(&mut OsRng);
470470
let wrap = zero_box.encrypt(&nonce, &content_key[..]).unwrap();
471471

472-
let body_nonce = [0x24u8; 24];
472+
let mut body_nonce: [u8; 24] = Default::default();
473+
OsRng.fill_bytes(&mut body_nonce);
473474
let body_cipher = XChaCha20Poly1305::new_from_slice(&content_key).unwrap();
474475
let body = body_cipher
475476
.encrypt(
@@ -541,7 +542,8 @@ mod tests {
541542
let nonce = ChaChaBox::generate_nonce(&mut OsRng);
542543
let wrap = crypto_box::aead::Aead::encrypt(&zero_box, &nonce, &content_key[..]).unwrap();
543544

544-
let body_nonce = [0x24u8; 24];
545+
let mut body_nonce: [u8; 24] = Default::default();
546+
OsRng.fill_bytes(&mut body_nonce);
545547
let body_cipher = XChaCha20Poly1305::new_from_slice(&content_key).unwrap();
546548
let body = chacha20poly1305::aead::Aead::encrypt(
547549
&body_cipher,

0 commit comments

Comments
 (0)