Skip to content

Commit 4a47b9e

Browse files
committed
fix(tui): correct the unscoped-endpoint warning for proxy transport
The warning called an endpoint with no protocol an "L4 rule" that "allows every connection to this host and port". That was accurate when this branch was written, but NVIDIA#3136 changed what omitting the protocol means: per openshell_policy::agent_authored_transport_rejection, an omitted protocol keeps the explicit proxy, which terminates TLS and canonicalizes the HTTP authority, and protocol: tcp and tls: skip can no longer be agent-authored at all. Calling that path L4 and describing it as raw connections overstates the exposure and mislabels the mode. Describe what is actually broad about it instead: no method or path constraint, so every request to the host and port is allowed rather than only the denied one. The two REST branches are unchanged, and the docs paragraph now matches the transport vocabulary the advisor page uses. Part of NVIDIA#1098. Signed-off-by: Vyncint Ng <[email protected]>
1 parent 28c14f4 commit 4a47b9e

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

‎crates/openshell-tui/src/ui/sandbox_draft.rs‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -870,15 +870,20 @@ fn format_endpoint_details(endpoint: &NetworkEndpoint) -> Vec<String> {
870870

871871
/// Why a proposed endpoint is broader than the denial that prompted it.
872872
///
873-
/// An L4 endpoint allows the whole TCP port. A REST endpoint with no allow
874-
/// rules, or with an allow rule that leaves the method or path unset — rendered
875-
/// as `*` by `format_allow_rule` — still permits far more than the single
876-
/// request that was denied. Protocols other than REST scope on `command`
877-
/// instead, so they are left alone rather than warned about incorrectly.
873+
/// An endpoint with no protocol is not a raw tunnel: per
874+
/// `openshell_policy::agent_authored_transport_rejection`, omitting the protocol
875+
/// keeps the explicit proxy, which terminates TLS and canonicalizes the HTTP
876+
/// authority, while `protocol: tcp` and `tls: skip` cannot be agent-authored at
877+
/// all. What it lacks is any method or path constraint, so every request to the
878+
/// host and port is permitted. A REST endpoint with no allow rules, or with an
879+
/// allow rule that leaves the method or path unset — rendered as `*` by
880+
/// `format_allow_rule` — is broad for the same reason. Protocols other than REST
881+
/// scope on `command` instead, so they are left alone rather than warned about
882+
/// incorrectly.
878883
fn scope_warning(endpoint: &NetworkEndpoint) -> Option<&'static str> {
879884
if endpoint.protocol.trim().is_empty() {
880885
return Some(
881-
"L4 rule: allows every connection to this host and port, not only the denied request",
886+
"no protocol set: every request to this host and port is allowed, not only the denied one",
882887
);
883888
}
884889
if !endpoint.protocol.eq_ignore_ascii_case("rest") {
@@ -1455,9 +1460,9 @@ mod tests {
14551460
}
14561461

14571462
#[test]
1458-
fn l4_endpoint_is_flagged_as_unscoped() {
1463+
fn endpoint_without_a_protocol_is_flagged_as_unscoped() {
14591464
let warning = scope_warning(&scoped_endpoint("", vec![]));
1460-
assert!(warning.is_some_and(|w| w.starts_with("L4 rule:")));
1465+
assert!(warning.is_some_and(|w| w.starts_with("no protocol set:")));
14611466
}
14621467

14631468
#[test]
@@ -1494,8 +1499,8 @@ mod tests {
14941499
fn scope_warning_is_rendered_in_the_detail_popup() {
14951500
let (screen, _) = render(&chunk_with(scoped_endpoint("", vec![])), 80, 24, 0);
14961501
assert!(
1497-
squash(&screen).contains("allows every connection to this host and port"),
1498-
"L4 warning should appear in the popup"
1502+
squash(&screen).contains("every request to this host and port is allowed"),
1503+
"missing-protocol warning should appear in the popup"
14991504
);
15001505
}
15011506

@@ -1504,7 +1509,10 @@ mod tests {
15041509
let endpoint = scoped_endpoint("rest", vec![allow_rule("GET", "/repos/**")]);
15051510
let (screen, _) = render(&chunk_with(endpoint), 80, 24, 0);
15061511
let seen = squash(&screen);
1507-
assert!(!seen.contains("allows every"), "unexpected warning: {seen}");
1512+
assert!(
1513+
!seen.contains("every request to this"),
1514+
"unexpected warning: {seen}"
1515+
);
15081516
assert!(!seen.contains("no method or path scope"));
15091517
}
15101518
}

‎docs/sandboxes/policy-advisor.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ The output shows the chunk ID, status, rationale, binary, endpoint summary, prov
232232
Endpoints: api.github.com:443 [L7 rest, allow PUT /repos/NVIDIA/OpenShell/contents/docs/**]
233233
```
234234

235-
The terminal UI flags proposals that are broader than the request that was denied. In the detail popup, `openshell term` shows a warning under any endpoint that is L4, that is REST with no allow rules, or whose allow rule leaves the method or path unset. Protocols other than REST scope on `command`, so they are not flagged.
235+
The terminal UI flags proposals that are broader than the request that was denied. In the detail popup, `openshell term` shows a warning under any endpoint that omits `protocol`, that is REST with no allow rules, or whose allow rule leaves the method or path unset. Omitting `protocol` still routes through the explicit proxy, so the warning is about the missing method and path scope rather than raw transport. Protocols other than REST scope on `command`, so they are not flagged.
236236

237237
Approve only when the structured rule matches the access you intend to grant:
238238

0 commit comments

Comments
 (0)