Run the prover end-to-end and return an exit code. - `0` — pass (no critical/high findings, or all accepted) - `1` — fail (critical or high findings present) - `2` — input error Binary and API capability registries are embedded at compile time. Pass `registry_dir` to override with a custom filesystem registry.
(
policy_path: &str,
credentials_path: &str,
registry_dir: Option<&str>,
accepted_risks_path: Option<&str>,
compact: bool,
)
| 35 | /// Binary and API capability registries are embedded at compile time. |
| 36 | /// Pass `registry_dir` to override with a custom filesystem registry. |
| 37 | pub fn prove( |
| 38 | policy_path: &str, |
| 39 | credentials_path: &str, |
| 40 | registry_dir: Option<&str>, |
| 41 | accepted_risks_path: Option<&str>, |
| 42 | compact: bool, |
| 43 | ) -> Result<i32> { |
| 44 | let policy = parse_policy(Path::new(policy_path))?; |
| 45 | |
| 46 | let (credential_set, binary_registry) = match registry_dir { |
| 47 | Some(dir) => { |
| 48 | let dir = Path::new(dir); |
| 49 | ( |
| 50 | credentials::load_credential_set_from_dir(Path::new(credentials_path), dir)?, |
| 51 | registry::load_binary_registry_from_dir(dir)?, |
| 52 | ) |
| 53 | } |
| 54 | None => ( |
| 55 | credentials::load_credential_set_embedded(Path::new(credentials_path))?, |
| 56 | registry::load_embedded_binary_registry()?, |
| 57 | ), |
| 58 | }; |
| 59 | |
| 60 | let z3_model = build_model(policy, credential_set, binary_registry); |
| 61 | let mut findings = run_all_queries(&z3_model); |
| 62 | |
| 63 | if let Some(ar_path) = accepted_risks_path { |
| 64 | let accepted = load_accepted_risks(Path::new(ar_path))?; |
| 65 | findings = apply_accepted_risks(findings, &accepted); |
| 66 | } |
| 67 | |
| 68 | let exit_code = if compact { |
| 69 | render_compact(&findings, policy_path, credentials_path) |
| 70 | } else { |
| 71 | render_report(&findings, policy_path, credentials_path) |
| 72 | }; |
| 73 | |
| 74 | Ok(exit_code) |
| 75 | } |
| 76 | |
| 77 | // =========================================================================== |
| 78 | // Tests |
no test coverage detected