Skip to content

Commit deced87

Browse files
refactor(policy): extract shared L7 endpoint validation (#2389)
Move L7 endpoint semantic checks into the openshell-policy crate so both profile lint and the runtime validator share one implementation. This eliminates drift between the two validation paths. The shared validator covers 9 checks: unknown protocol, rules/access mutual exclusivity, JSON-RPC family access rejection, json-rpc requires rules, non-JSON-RPC protocol requires rules or access, MCP requires rules when allow_all is false, rules-would-deny-all detection, deny_rules require protocol, and deny_rules require base allow set. Changes rules/deny_rules fields to Option<Vec<...>> so absent vs empty is distinguishable at lint time. Adds is_effectively_empty() to L7AllowProfile for deny-all detection of allow: {} objects. Makes rules_would_deny_all MCP-aware by checking tool/params.name selectors before classifying a rule as deny-all. Adds params field to L7AllowProfile so MCP tool selectors survive proto round-trip. Signed-off-by: Grace Smith <gsmith@redhat.com> Signed-off-by: Grace Smith <grasmith@redhat.com>
1 parent 01daf3a commit deced87

11 files changed

Lines changed: 2757 additions & 179 deletions

File tree

Cargo.lock

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

crates/openshell-cli/src/run.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5675,6 +5675,17 @@ fn load_profile_import_item(
56755675
}
56765676
.map_err(|err| profile_file_diagnostic(&source, err.to_string()))?;
56775677

5678+
let pre_lower = profile.validate_before_lowering(&source);
5679+
if let Some(diag) = pre_lower.into_iter().find(|d| d.severity == "error") {
5680+
return Err(ProviderProfileDiagnostic {
5681+
source: diag.source,
5682+
profile_id: diag.profile_id,
5683+
field: diag.field,
5684+
message: diag.message,
5685+
severity: diag.severity,
5686+
});
5687+
}
5688+
56785689
Ok(ProviderProfileImportItem {
56795690
profile: Some(profile.to_proto()),
56805691
source,

0 commit comments

Comments
 (0)