Skip to content

Commit 4318fe3

Browse files
committed
style: apply cargo fmt formatting
1 parent ab6ba38 commit 4318fe3

2 files changed

Lines changed: 28 additions & 25 deletions

File tree

crates/openshell-sandbox/src/opa.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -921,10 +921,12 @@ mod tests {
921921
let config = engine.query_sandbox_config().unwrap();
922922
assert!(config.filesystem.include_workdir);
923923
assert!(config.filesystem.read_only.contains(&PathBuf::from("/usr")));
924-
assert!(config
925-
.filesystem
926-
.read_write
927-
.contains(&PathBuf::from("/tmp")));
924+
assert!(
925+
config
926+
.filesystem
927+
.read_write
928+
.contains(&PathBuf::from("/tmp"))
929+
);
928930
}
929931

930932
#[test]
@@ -1283,10 +1285,12 @@ network_policies:
12831285
let config = engine.query_sandbox_config().unwrap();
12841286
assert!(config.filesystem.include_workdir);
12851287
assert!(config.filesystem.read_only.contains(&PathBuf::from("/usr")));
1286-
assert!(config
1287-
.filesystem
1288-
.read_write
1289-
.contains(&PathBuf::from("/tmp")));
1288+
assert!(
1289+
config
1290+
.filesystem
1291+
.read_write
1292+
.contains(&PathBuf::from("/tmp"))
1293+
);
12901294
assert_eq!(config.process.run_as_user.as_deref(), Some("sandbox"));
12911295
assert_eq!(config.process.run_as_group.as_deref(), Some("sandbox"));
12921296
}

crates/openshell-server/src/grpc.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,18 +2539,21 @@ async fn merge_chunk_into_policy(
25392539
let merge_key = if policy.network_policies.contains_key(&chunk.rule_name) {
25402540
Some(chunk.rule_name.clone())
25412541
} else {
2542-
policy.network_policies.iter().find_map(|(key, existing_rule)| {
2543-
let has_match = existing_rule.endpoints.iter().any(|ep| {
2544-
let host_match = ep.host.to_lowercase() == chunk_host_lc;
2545-
let port_match = if ep.ports.is_empty() {
2546-
ep.port == chunk_port
2547-
} else {
2548-
ep.ports.contains(&chunk_port)
2549-
};
2550-
host_match && port_match
2551-
});
2552-
has_match.then(|| key.clone())
2553-
})
2542+
policy
2543+
.network_policies
2544+
.iter()
2545+
.find_map(|(key, existing_rule)| {
2546+
let has_match = existing_rule.endpoints.iter().any(|ep| {
2547+
let host_match = ep.host.to_lowercase() == chunk_host_lc;
2548+
let port_match = if ep.ports.is_empty() {
2549+
ep.port == chunk_port
2550+
} else {
2551+
ep.ports.contains(&chunk_port)
2552+
};
2553+
host_match && port_match
2554+
});
2555+
has_match.then(|| key.clone())
2556+
})
25542557
};
25552558

25562559
if let Some(key) = merge_key {
@@ -5567,11 +5570,7 @@ mod tests {
55675570
.unwrap();
55685571
assert_eq!(version, 2);
55695572

5570-
let latest = store
5571-
.get_latest_policy(sandbox_id)
5572-
.await
5573-
.unwrap()
5574-
.unwrap();
5573+
let latest = store.get_latest_policy(sandbox_id).await.unwrap().unwrap();
55755574
let policy = SandboxPolicy::decode(latest.policy_payload.as_slice()).unwrap();
55765575

55775576
// Should have two entries now.

0 commit comments

Comments
 (0)