Skip to content

Commit 5e43d58

Browse files
authored
Merge pull request CactuseSecurity#2857 from CactuseSecurity/CactuseSecurity#2692--Modelling---short-duplication-of-objects-when-saving
PR for CactuseSecurity#2692--Modelling---short-duplication-of-objects-when-saving
2 parents 076e937 + 8c48405 commit 5e43d58

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

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

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class ModellingConnectionHandler : ModellingHandlerBase
8383
public ModellingAppRole DummyAppRole = new();
8484
public int LastWidth = GlobalConst.kGlobLibraryWidth;
8585
public bool LastCollapsed = false;
86+
public bool ActConnNeedsRefresh = true;
8687

8788
private bool SrcFix = false;
8889
private bool DstFix = false;
@@ -156,7 +157,12 @@ public async Task ReInit()
156157
{
157158
try
158159
{
159-
await RefreshActConn();
160+
// exclude the cases where ActConn has to be held (e.g. if there is an ui binding)
161+
if(ActConnNeedsRefresh)
162+
{
163+
await RefreshActConn();
164+
}
165+
160166
await RefreshObjects();
161167
await RefreshParent();
162168
}
@@ -1085,18 +1091,6 @@ public async Task<bool> Save(bool noCheck = false)
10851091
}
10861092
if(noCheck || CheckConn())
10871093
{
1088-
if(!SrcReadOnly)
1089-
{
1090-
SyncSrcChanges();
1091-
}
1092-
if(!DstReadOnly)
1093-
{
1094-
SyncDstChanges();
1095-
}
1096-
if(!SvcReadOnly)
1097-
{
1098-
SyncSvcChanges();
1099-
}
11001094
ActConn.SyncState(DummyAppRole.Id);
11011095
if(AddMode)
11021096
{
@@ -1292,24 +1286,23 @@ await LogChange(ModellingTypes.ChangeType.Insert, ModellingTypes.ModObjectType.C
12921286
$"New {(ActConn.IsInterface? "Interface" : "Connection")}: {ActConn.Name}", AppId);
12931287
if(ActConn.UsedInterfaceId == null || ActConn.DstFromInterface)
12941288
{
1295-
await AddNwObjects(ModellingAppServerWrapper.Resolve(ActConn.SourceAppServers).ToList(),
1296-
ModellingAppRoleWrapper.Resolve(ActConn.SourceAppRoles).ToList(),
1297-
ModellingNetworkAreaWrapper.Resolve(ActConn.SourceAreas).ToList(),
1298-
ModellingNwGroupWrapper.Resolve(ActConn.SourceOtherGroups).ToList(),
1299-
ModellingTypes.ConnectionField.Source);
1289+
await AddNwObjects(SrcAppServerToAdd,
1290+
SrcAppRolesToAdd,
1291+
SrcAreasToAdd,
1292+
SrcNwGroupsToAdd,
1293+
ModellingTypes.ConnectionField.Source);
13001294
}
13011295
if(ActConn.UsedInterfaceId == null || ActConn.SrcFromInterface)
13021296
{
1303-
await AddNwObjects(ModellingAppServerWrapper.Resolve(ActConn.DestinationAppServers).ToList(),
1304-
ModellingAppRoleWrapper.Resolve(ActConn.DestinationAppRoles).ToList(),
1305-
ModellingNetworkAreaWrapper.Resolve(ActConn.DestinationAreas).ToList(),
1306-
ModellingNwGroupWrapper.Resolve(ActConn.DestinationOtherGroups).ToList(),
1307-
ModellingTypes.ConnectionField.Destination);
1297+
await AddNwObjects(DstAppServerToAdd,
1298+
DstAppRolesToAdd,
1299+
DstAreasToAdd,
1300+
DstNwGroupsToAdd,
1301+
ModellingTypes.ConnectionField.Destination);
13081302
}
13091303
if(ActConn.UsedInterfaceId == null)
13101304
{
1311-
await AddSvcObjects(ModellingServiceWrapper.Resolve(ActConn.Services).ToList(),
1312-
ModellingServiceGroupWrapper.Resolve(ActConn.ServiceGroups).ToList());
1305+
await AddSvcObjects(SvcToAdd, SvcGrpToAdd);
13131306
}
13141307
ActConn.Creator = userConfig.User.Name;
13151308
ActConn.CreationDate = DateTime.Now;

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@
206206
}
207207
</div>
208208
</Sidebar>
209-
<EditAppRole @bind-Display="ConnHandler.EditAppRoleMode" @bind-AppRoleHandler="ConnHandler.AppRoleHandler" RefreshParent="async () => await WrapAsync(ConnHandler.ReInit)"/>
209+
<EditAppRole @bind-Display="ConnHandler.EditAppRoleMode" @bind-AppRoleHandler="ConnHandler.AppRoleHandler" RefreshParent="RefreshParentWithoutRefreshingActConn"/>
210210
<ConfirmDelete @bind-Display="ConnHandler.DeleteAppRoleMode" PerformAction="async () => await WrapAsync(ConnHandler.DeleteAppRole)"
211211
Title="@userConfig.GetText("delete_app_role")" DeleteMessage="@ConnHandler.Message" AllowedRoles="@Roles.Modeller" DeleteAllowed="ConnHandler.DeleteAllowed" Enabled="ConnHandler.IsOwner"/>
212212
<EditServiceGroup @bind-Display="ConnHandler.EditSvcGrpMode" @bind-SvcGroupHandler="ConnHandler.SvcGrpHandler"/>
213213
<ConfirmDelete @bind-Display="ConnHandler.DeleteSvcGrpMode" PerformAction="async () => await WrapAsync(ConnHandler.DeleteServiceGroup)"
214214
Title="@userConfig.GetText("delete_service_group")" DeleteMessage="@ConnHandler.Message" AllowedRoles="@Roles.Modeller" DeleteAllowed="ConnHandler.DeleteAllowed" Enabled="ConnHandler.IsOwner"/>
215-
<EditService @bind-Display="ConnHandler.EditServiceMode" ServiceHandler="ConnHandler.ServiceHandler" RefreshParent="async () => await WrapAsync(ConnHandler.ReInit)"/>
215+
<EditService @bind-Display="ConnHandler.EditServiceMode" ServiceHandler="ConnHandler.ServiceHandler" RefreshParent="RefreshParentWithoutRefreshingActConn"/>
216216
<ConfirmDelete @bind-Display="ConnHandler.DeleteServiceMode" PerformAction="async () => await WrapAsync(ConnHandler.DeleteService)"
217217
Title="@userConfig.GetText("delete_service")" DeleteMessage="@ConnHandler.Message" AllowedRoles="@Roles.Modeller" DeleteAllowed="ConnHandler.DeleteAllowed" Enabled="ConnHandler.IsOwner"/>
218218
<SearchInterface @bind-Display="SearchInterfaceMode" @bind-PreselectedInterfaces="ConnHandler.PreselectedInterfaces" Application="ConnHandler.Application"/>
@@ -648,6 +648,16 @@
648648
await ConnHandlerChanged.InvokeAsync(ConnHandler);
649649
}
650650

651+
/// <summary>
652+
/// Executes ReInit without dropping ActConn
653+
/// </summary>
654+
private async Task RefreshParentWithoutRefreshingActConn()
655+
{
656+
ConnHandler.ActConnNeedsRefresh = false;
657+
await WrapAsync(ConnHandler.ReInit);
658+
ConnHandler.ActConnNeedsRefresh = true;
659+
}
660+
651661
private string ColWidthClass()
652662
{
653663
return OverviewMode ? "col-sm-12" : "col-sm-10";

0 commit comments

Comments
 (0)