Skip to content

model-checking/kani

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

37bcc09 · Sep 24, 2024
Mar 8, 2023
Sep 6, 2024
Sep 4, 2024
Sep 24, 2024
Aug 4, 2021
Sep 8, 2024
Sep 4, 2024
Sep 4, 2024
Sep 7, 2024
Sep 4, 2024
Sep 6, 2024
Sep 24, 2024
Jul 23, 2024
Sep 24, 2024
Sep 24, 2024
Sep 27, 2021
Apr 18, 2022
Apr 27, 2022
Jan 21, 2022
Apr 18, 2024
Apr 5, 2024
Sep 4, 2024
Apr 20, 2022
Oct 28, 2022
Sep 24, 2024
Sep 4, 2024
Apr 27, 2022
Apr 27, 2022
Jun 16, 2023
May 2, 2022
Aug 26, 2024
May 4, 2022
Jul 31, 2024
May 4, 2022
Apr 29, 2022
Sep 9, 2024
Apr 5, 2024

Kani regression Nightly: CBMC Latest

The Kani Rust Verifier is a bit-precise model checker for Rust.

Kani is particularly useful for verifying unsafe code blocks in Rust, where the "unsafe superpowers" are unchecked by the compiler.


Kani verifies:

  • Memory safety (e.g., null pointer dereferences)
  • User-specified assertions (i.e., assert!(...))
  • The absence of panics (e.g., unwrap() on None values)
  • The absence of some types of unexpected behavior (e.g., arithmetic overflows)

Installation

To install the latest version of Kani (Rust 1.58+; Linux or Mac), run:

cargo install --locked kani-verifier
cargo kani setup

See the installation guide for more details.

How to use Kani

Similar to testing, you write a harness, but with Kani you can check all possible values using kani::any():

use my_crate::{function_under_test, meets_specification, precondition};

#[kani::proof]
fn check_my_property() {
   // Create a nondeterministic input
   let input = kani::any();

   // Constrain it according to the function's precondition
   kani::assume(precondition(input));

   // Call the function under verification
   let output = function_under_test(input);

   // Check that it meets the specification
   assert!(meets_specification(input, output));
}

Kani will then try to prove that all valid inputs produce acceptable outputs, without panicking or executing unexpected behavior. Otherwise Kani will generate a trace that points to the failure. We recommend following the tutorial to learn more about how to use Kani.

GitHub Action

Use Kani in your CI with model-checking/kani-github-action@VERSION. See the GitHub Action section in the Kani book for details.

Security

See SECURITY for more information.

Contributing

If you are interested in contributing to Kani, please take a look at the developer documentation.

License

Kani

Kani is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Rust

Kani contains code from the Rust project. Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See the Rust repository for details.