Skip to content

Commit 5450c98

Browse files
Merge pull request #10 from triblespace/codex/use-kani-config-limits-from-tribles-rust
Add default Kani unwinding limits
2 parents 273c51e + bd47269 commit 5450c98

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## Unreleased
4+
- limit Kani loop unwind by default and set per-harness bounds
5+
- increase unwind for prefix/suffix overflow proofs

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ pyo3 = ["dep:pyo3"]
2626

2727
[lints.rust]
2828
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] }
29+
30+
[package.metadata.kani.flags]
31+
default-unwind = "1"
32+
33+
[workspace.metadata.kani.flags]
34+
default-unwind = "1"

src/bytes.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ mod verification {
360360
use kani::BoundedArbitrary;
361361

362362
#[kani::proof]
363+
#[kani::unwind(16)]
363364
pub fn check_take_prefix_ok() {
364365
let data: Vec<u8> = Vec::bounded_any::<16>();
365366
kani::assume(data.len() >= 5);
@@ -371,6 +372,7 @@ mod verification {
371372
}
372373

373374
#[kani::proof]
375+
#[kani::unwind(32)]
374376
pub fn check_take_prefix_too_large() {
375377
let data: Vec<u8> = Vec::bounded_any::<16>();
376378
let mut bytes = Bytes::from_source(data.clone());
@@ -381,6 +383,7 @@ mod verification {
381383
}
382384

383385
#[kani::proof]
386+
#[kani::unwind(16)]
384387
pub fn check_take_suffix_ok() {
385388
let data: Vec<u8> = Vec::bounded_any::<16>();
386389
kani::assume(data.len() >= 4);
@@ -392,6 +395,7 @@ mod verification {
392395
}
393396

394397
#[kani::proof]
398+
#[kani::unwind(32)]
395399
pub fn check_take_suffix_too_large() {
396400
let data: Vec<u8> = Vec::bounded_any::<16>();
397401
let mut bytes = Bytes::from_source(data.clone());
@@ -402,6 +406,7 @@ mod verification {
402406
}
403407

404408
#[kani::proof]
409+
#[kani::unwind(16)]
405410
pub fn check_slice_to_bytes_ok() {
406411
let data: Vec<u8> = Vec::bounded_any::<16>();
407412
kani::assume(data.len() >= 8);
@@ -412,6 +417,7 @@ mod verification {
412417
}
413418

414419
#[kani::proof]
420+
#[kani::unwind(16)]
415421
pub fn check_slice_to_bytes_unrelated() {
416422
let data: Vec<u8> = Vec::bounded_any::<16>();
417423
let bytes = Bytes::from_source(data.clone());

0 commit comments

Comments
 (0)