@@ -829,7 +829,11 @@ fn format_endpoint_summary(endpoint: &NetworkEndpoint) -> String {
829829 endpoint. host . clone ( )
830830 } ;
831831
832- let mut tags = vec ! [ endpoint_layer_label( endpoint) . to_string( ) ] ;
832+ let layer = endpoint_layer_label ( endpoint) ;
833+ if is_transport_endpoint ( endpoint) {
834+ return format ! ( "{host_port} [{layer}]" ) ;
835+ }
836+ let mut tags = vec ! [ layer. to_string( ) ] ;
833837 if endpoint. access != 0 {
834838 tags. push ( format ! (
835839 "access={}" ,
@@ -850,8 +854,9 @@ fn format_endpoint_summary(endpoint: &NetworkEndpoint) -> String {
850854
851855fn format_endpoint_details ( endpoint : & NetworkEndpoint ) -> Vec < String > {
852856 let mut details = Vec :: new ( ) ;
857+ let transport_only = is_transport_endpoint ( endpoint) ;
853858
854- if !endpoint. path . is_empty ( ) {
859+ if !transport_only && ! endpoint. path . is_empty ( ) {
855860 details. push ( format ! ( "Path scope: {}" , endpoint. path) ) ;
856861 }
857862 if endpoint. tls != 0 {
@@ -860,7 +865,7 @@ fn format_endpoint_details(endpoint: &NetworkEndpoint) -> Vec<String> {
860865 openshell_policy:: network_tls_mode_to_str( endpoint. tls) . unwrap_or( "unknown" )
861866 ) ) ;
862867 }
863- if endpoint. enforcement != 0 {
868+ if !transport_only && endpoint. enforcement != 0 {
864869 details. push ( format ! (
865870 "Enforcement: {}" ,
866871 openshell_policy:: network_enforcement_mode_to_str( endpoint. enforcement)
@@ -873,6 +878,10 @@ fn format_endpoint_details(endpoint: &NetworkEndpoint) -> Vec<String> {
873878 if endpoint. websocket_credential_rewrite {
874879 details. push ( "WebSocket credential rewrite" . to_string ( ) ) ;
875880 }
881+ if transport_only {
882+ details. push ( "no HTTP method/path filter" . to_string ( ) ) ;
883+ return details;
884+ }
876885 for rule in & endpoint. rules {
877886 if let Some ( allow) = & rule. allow {
878887 details. push ( format ! ( "Allow: {}" , format_allow_rule( allow) ) ) ;
@@ -885,6 +894,10 @@ fn format_endpoint_details(endpoint: &NetworkEndpoint) -> Vec<String> {
885894 details
886895}
887896
897+ fn is_transport_endpoint ( endpoint : & NetworkEndpoint ) -> bool {
898+ endpoint. protocol . is_empty ( ) || endpoint. protocol . eq_ignore_ascii_case ( "tcp" )
899+ }
900+
888901fn endpoint_layer_label ( endpoint : & NetworkEndpoint ) -> & str {
889902 if endpoint. protocol . eq_ignore_ascii_case ( "rest" ) {
890903 "L7 rest"
@@ -1178,6 +1191,49 @@ mod tests {
11781191 reason
11791192 }
11801193
1194+ #[ test]
1195+ fn approval_detail_explains_l4_request_scope ( ) {
1196+ for ( protocol, summary, unfiltered) in [
1197+ ( "" , "alias.test:80 [L4]" , true ) ,
1198+ ( "tcp" , "alias.test:80 [tcp]" , true ) ,
1199+ ( "rest" , "alias.test:80 [L7 rest, allow GET /orders]" , false ) ,
1200+ ] {
1201+ let mut endpoint = NetworkEndpoint {
1202+ host : "alias.test" . into ( ) ,
1203+ port : 80 ,
1204+ protocol : protocol. into ( ) ,
1205+ ..Default :: default ( )
1206+ } ;
1207+ if unfiltered {
1208+ endpoint. tls = openshell_core:: proto:: NetworkTlsMode :: Skip as i32 ;
1209+ }
1210+ if protocol != "tcp" {
1211+ endpoint. path = "/orders/**" . into ( ) ;
1212+ endpoint. rules . push ( openshell_core:: proto:: L7Rule {
1213+ allow : Some ( L7Allow {
1214+ method : "GET" . into ( ) ,
1215+ path : "/orders" . into ( ) ,
1216+ ..Default :: default ( )
1217+ } ) ,
1218+ } ) ;
1219+ }
1220+ assert_eq ! ( format_endpoint_summary( & endpoint) , summary) ;
1221+ let chunk = PolicyChunk {
1222+ proposed_rule : Some ( openshell_core:: proto:: NetworkPolicyRule {
1223+ endpoints : vec ! [ endpoint] ,
1224+ ..Default :: default ( )
1225+ } ) ,
1226+ ..make_chunk ( "pending" , "" )
1227+ } ;
1228+ let ( screen, _) = render ( & chunk, 80 , 24 , 0 ) ;
1229+ assert ! ( screen. contains( summary) ) ;
1230+ assert_eq ! ( screen. contains( "no HTTP method/path filter" ) , unfiltered) ;
1231+ assert_eq ! ( screen. contains( "Allow: GET /orders" ) , !unfiltered) ;
1232+ assert_eq ! ( screen. contains( "Path scope: /orders/**" ) , !unfiltered) ;
1233+ assert_eq ! ( screen. contains( "TLS: skip" ) , unfiltered) ;
1234+ }
1235+ }
1236+
11811237 #[ test]
11821238 fn long_guidance_head_and_tail_are_both_reachable ( ) {
11831239 let chunk = PolicyChunk {
0 commit comments