Skip to content

Commit f8a78cf

Browse files
committed
fix(prover): apply cargo fmt formatting to prover and cli source files
1 parent f093560 commit f8a78cf

7 files changed

Lines changed: 30 additions & 39 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/openshell-cli/src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,13 +1877,14 @@ async fn main() -> Result<()> {
18771877
// Top-level policy (was `sandbox policy`)
18781878
// -----------------------------------------------------------
18791879
Some(Commands::Policy {
1880-
command: Some(PolicyCommands::Prove {
1881-
policy,
1882-
credentials,
1883-
registry,
1884-
accepted_risks,
1885-
compact,
1886-
}),
1880+
command:
1881+
Some(PolicyCommands::Prove {
1882+
policy,
1883+
credentials,
1884+
registry,
1885+
accepted_risks,
1886+
compact,
1887+
}),
18871888
}) => {
18881889
// Prove runs locally — no gateway needed.
18891890
let exit_code = openshell_prover::prove(

crates/openshell-prover/src/accepted_risks.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ fn path_matches_risk(path: &FindingPath, risk: &AcceptedRisk) -> bool {
106106
/// A finding is accepted if **all** of its paths match at least one accepted
107107
/// risk entry for that query. If only some paths match, the finding stays
108108
/// active with the unmatched paths.
109-
pub fn apply_accepted_risks(
110-
findings: Vec<Finding>,
111-
accepted: &[AcceptedRisk],
112-
) -> Vec<Finding> {
109+
pub fn apply_accepted_risks(findings: Vec<Finding>, accepted: &[AcceptedRisk]) -> Vec<Finding> {
113110
if accepted.is_empty() {
114111
return findings;
115112
}

crates/openshell-prover/src/credentials.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,7 @@ fn load_api_registry(path: &Path) -> Result<ApiCapability> {
213213
/// Load credentials and all API registries from the registry directory.
214214
///
215215
/// Expects `{registry_dir}/apis/*.yaml`.
216-
pub fn load_credential_set(
217-
credentials_path: &Path,
218-
registry_dir: &Path,
219-
) -> Result<CredentialSet> {
216+
pub fn load_credential_set(credentials_path: &Path, registry_dir: &Path) -> Result<CredentialSet> {
220217
let creds = load_credentials(credentials_path)?;
221218

222219
let mut api_registries = HashMap::new();

crates/openshell-prover/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ pub fn prove(
5050
if crate_registry.is_dir() {
5151
std::borrow::Cow::Owned(crate_registry)
5252
} else {
53-
std::borrow::Cow::Owned(std::env::current_dir().unwrap_or_default().join("registry"))
53+
std::borrow::Cow::Owned(
54+
std::env::current_dir().unwrap_or_default().join("registry"),
55+
)
5456
}
5557
});
5658

@@ -177,8 +179,7 @@ filesystem_policy:
177179
let reg_dir = registry_dir();
178180

179181
let pol = policy::parse_policy(&policy_path).expect("parse policy");
180-
let cred_set =
181-
credentials::load_credential_set(&creds_path, &reg_dir).expect("load creds");
182+
let cred_set = credentials::load_credential_set(&creds_path, &reg_dir).expect("load creds");
182183
let bin_reg = registry::load_binary_registry(&reg_dir).expect("load registry");
183184

184185
let z3_model = model::build_model(pol, cred_set, bin_reg);
@@ -198,9 +199,10 @@ filesystem_policy:
198199

199200
// At least one critical or high finding.
200201
assert!(
201-
findings
202-
.iter()
203-
.any(|f| matches!(f.risk, finding::RiskLevel::Critical | finding::RiskLevel::High)),
202+
findings.iter().any(|f| matches!(
203+
f.risk,
204+
finding::RiskLevel::Critical | finding::RiskLevel::High
205+
)),
204206
"expected at least one critical/high finding"
205207
);
206208
}
@@ -213,8 +215,7 @@ filesystem_policy:
213215
let reg_dir = registry_dir();
214216

215217
let pol = policy::parse_policy(&policy_path).expect("parse policy");
216-
let cred_set =
217-
credentials::load_credential_set(&creds_path, &reg_dir).expect("load creds");
218+
let cred_set = credentials::load_credential_set(&creds_path, &reg_dir).expect("load creds");
218219
let bin_reg = registry::load_binary_registry(&reg_dir).expect("load registry");
219220

220221
let z3_model = model::build_model(pol, cred_set, bin_reg);

crates/openshell-prover/src/queries.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,10 @@ pub fn check_data_exfiltration(model: &ReachabilityModel) -> Vec<Finding> {
9999
.to_owned(),
100100
);
101101
}
102-
remediation.push(
103-
"Restrict filesystem read access to only the paths the agent needs.".to_owned(),
104-
);
102+
remediation
103+
.push("Restrict filesystem read access to only the paths the agent needs.".to_owned());
105104

106-
let paths: Vec<FindingPath> = exfil_paths
107-
.into_iter()
108-
.map(FindingPath::Exfil)
109-
.collect();
105+
let paths: Vec<FindingPath> = exfil_paths.into_iter().map(FindingPath::Exfil).collect();
110106

111107
let n_paths = paths.len();
112108
vec![Finding {
@@ -142,8 +138,7 @@ pub fn check_write_bypass(model: &ReachabilityModel) -> Vec<Finding> {
142138

143139
// Check: binary bypasses L7 and can write
144140
if cap.bypasses_l7() && cap.can_write() {
145-
let cred_actions =
146-
collect_credential_actions(model, &ep.host, &cap);
141+
let cred_actions = collect_credential_actions(model, &ep.host, &cap);
147142
if !cred_actions.is_empty()
148143
|| model.credentials.credentials_for_host(&ep.host).is_empty()
149144
{
@@ -161,8 +156,7 @@ pub fn check_write_bypass(model: &ReachabilityModel) -> Vec<Finding> {
161156

162157
// Check: L4-only endpoint + binary can construct HTTP + credential has write
163158
if !ep.is_l7_enforced() && cap.can_construct_http {
164-
let cred_actions =
165-
collect_credential_actions(model, &ep.host, &cap);
159+
let cred_actions = collect_credential_actions(model, &ep.host, &cap);
166160
if !cred_actions.is_empty() {
167161
bypass_paths.push(WriteBypassPath {
168162
binary: b.path.clone(),
@@ -193,9 +187,7 @@ pub fn check_write_bypass(model: &ReachabilityModel) -> Vec<Finding> {
193187
vec![Finding {
194188
query: "write_bypass".to_owned(),
195189
title: "Write Bypass Detected — Read-Only Intent Violated".to_owned(),
196-
description: format!(
197-
"{n} path(s) allow write operations despite read-only policy intent."
198-
),
190+
description: format!("{n} path(s) allow write operations despite read-only policy intent."),
199191
risk: RiskLevel::High,
200192
paths,
201193
remediation: vec![

crates/openshell-prover/src/report.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ pub fn render_report(findings: &[Finding], policy_path: &str, credentials_path:
283283
risk_label(finding.risk).dimmed(),
284284
finding.title.dimmed()
285285
);
286-
println!(" {}", format!("Reason: {}", finding.accepted_reason).dimmed());
286+
println!(
287+
" {}",
288+
format!("Reason: {}", finding.accepted_reason).dimmed()
289+
);
287290
println!();
288291
}
289292
}

0 commit comments

Comments
 (0)