Skip to content

Commit abc4f85

Browse files
[+] Check opposite direction for existing NA CactuseSecurity#2949
1 parent a9c2362 commit abc4f85

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

roles/lib/files/FWO.Services/ModellingConnectionHandler.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,12 +1020,12 @@ public bool CalcVisibility()
10201020
return true;
10211021
}
10221022

1023-
public bool IsAreaForbiddenInDirection(List<ModellingNetworkArea> oppositeNetworkAreas, Direction direction)
1023+
public bool IsAreaForbiddenInDirection(Direction direction)
10241024
{
10251025
return direction switch
10261026
{
1027-
Direction.Source => oppositeNetworkAreas.Count > 0,
1028-
Direction.Destination => oppositeNetworkAreas.Count > 0,
1027+
Direction.Source => ActConn.DestinationAreas.Count > 0 || DstAreasToAdd.Count > 0,
1028+
Direction.Destination => ActConn.SourceAreas.Count > 0 || SrcAreasToAdd.Count > 0,
10291029
_ => false,
10301030
};
10311031
}
@@ -1053,11 +1053,11 @@ public bool NetworkAreaUseAllowed(List<ModellingNetworkArea> networkAreas, Direc
10531053
reason.Title = userConfig.GetText("edit_connection");
10541054
}
10551055

1056-
//if (IsAreaForbiddenInDirection(direction))
1057-
//{
1058-
// reason.Text = userConfig.GetText("direction_contain_nwarea");
1059-
// return false;
1060-
//}
1056+
if (IsAreaForbiddenInDirection(direction))
1057+
{
1058+
reason.Text = userConfig.GetText("direction_contain_nwarea");
1059+
return false;
1060+
}
10611061

10621062
if (ActConn.IsInterface)
10631063
{

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditConn.razor

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -506,16 +506,14 @@
506506
}
507507
if(Container.AreaElements.Count > 0)
508508
{
509-
509+
ConnHandler?.AreasToSource(Container.AreaElements);
510510

511511
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, Direction.Source, out (string Title, string Text) reason))
512512
{
513513
DisplayMessageInUi(default, reason.Title, reason.Text, true);
514514
Container.Clear();
515515
return;
516516
}
517-
518-
ConnHandler?.AreasToSource(Container.AreaElements);
519517
}
520518
if(Container.NwGroupElements.Count > 0)
521519
{
@@ -549,17 +547,15 @@
549547
ConnHandler?.AppRolesToDestination(Container.AppRoleElements);
550548
}
551549
if(Container.AreaElements.Count > 0)
552-
{
553-
//var bla = ConnHandler.IsAreaForbiddenInDirection(, Direction.Destination);
550+
{
551+
ConnHandler?.AreasToDestination(Container.AreaElements);
554552

555553
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, Direction.Destination, out (string Title, string Text) reason))
556554
{
557555
DisplayMessageInUi(default, reason.Title, reason.Text, true);
558556
Container.Clear();
559557
return;
560558
}
561-
562-
ConnHandler?.AreasToDestination(Container.AreaElements);
563559
}
564560
if(Container.NwGroupElements.Count > 0)
565561
{

0 commit comments

Comments
 (0)