Skip to content

Commit 3de76f7

Browse files
authored
Merge pull request CactuseSecurity#2768 from tpurschke/main
v8.6.2 Hotfix Network Modelling library elements missing
2 parents 7e43ca1 + 0b9f741 commit 3de76f7

File tree

5 files changed

+41
-47
lines changed

5 files changed

+41
-47
lines changed

documentation/revision-history-main.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,7 @@ Fixes network modelling
475475
- UI interface search pop-up transformed into filterable table
476476

477477
Upgrade Hasura API to v2.45.1
478+
479+
# 8.6.2 03.01.2025 MAIN
480+
Hotfix for network modelling:
481+
- fix: when visiting the library for the second time, app servers were missing due to uninitialized area data.

inventory/group_vars/all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### general settings
2-
product_version: "8.6.1"
2+
product_version: "8.6.2"
33
ansible_user: "{{ lookup('env', 'USER') }}"
44
ansible_become_method: sudo
55
ansible_python_interpreter: /usr/bin/python3

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ModellingAppRoleHandler(ApiConnection apiConnection, UserConfig userConfi
3030
AvailableAppServers = availableAppServers;
3131
AvailableNwElems = availableNwElems;
3232
ActAppRole = appRole;
33-
ApplyNamingConvention(application.ExtAppId);
33+
ApplyNamingConvention(application.ExtAppId ?? "");
3434
}
3535

3636
private void ApplyNamingConvention(string extAppId)
@@ -116,7 +116,7 @@ public async Task<bool> Save()
116116
{
117117
await UpdateAppRoleInDb();
118118
}
119-
Close();
119+
CleanUp();
120120
return true;
121121
}
122122
}
@@ -283,7 +283,7 @@ await LogChange(ModellingTypes.ChangeType.Assign, ModellingTypes.ModObjectType.A
283283
}
284284
}
285285

286-
public void Close()
286+
public void CleanUp()
287287
{
288288
AppServerToAdd = [];
289289
AppServerToDelete = [];
@@ -404,6 +404,7 @@ public static bool OverlapExists(IPAddressRange a, IPAddressRange b)
404404
{
405405
return IpToUint(a.Begin) <= IpToUint(b.End) && IpToUint(b.Begin) <= IpToUint(a.End);
406406
}
407+
407408
private static uint IpToUint(IPAddress ipAddress)
408409
{
409410
byte[] bytes = ipAddress.GetAddressBytes();

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@inject ApiConnection apiConnection
66
@inject UserConfig userConfig
77

8-
@if (Display)
8+
@if (AppRoleHandler != null && Display)
99
{
1010
<PopUp Title="@(AppRoleHandler.ReadOnly ? "" : (AppRoleHandler.AddMode ? userConfig.GetText("add_app_role") : userConfig.GetText("edit_app_role")))"
1111
Size="@(AppRoleHandler.ReadOnly ? PopupSize.Small : PopupSize.XLarge)" Show="@Display" OnClose="Close">
@@ -37,7 +37,7 @@
3737
}
3838
else
3939
{
40-
<label class="col-sm-8 bg-secondary">@AppRoleHandler.ActAppRole.Area.Display()</label>
40+
<label class="col-sm-8 bg-secondary">@AppRoleHandler.ActAppRole.Area?.Display()</label>
4141
}
4242
</div>
4343
}
@@ -137,7 +137,7 @@
137137
</PopUp>
138138
<InProgress Display="workInProgress" />
139139
<Confirm @bind-Display="ShowAreaChangeConfirmation" AllowedRoles="@Roles.Modeller" RenderMessageAsHtml="true"
140-
Message="@(userConfig.GetText("nwareachange_clear_app_servers"))" PerformAction="async () => await AreaChangeConfirmation()" Title="@(userConfig.GetText("confirm"))" />
140+
Message="@(userConfig.GetText("nwareachange_clear_app_servers"))" PerformAction="AreaChangeConfirmation" Title="@(userConfig.GetText("confirm"))" />
141141
}
142142
@code
143143
{
@@ -154,7 +154,7 @@
154154
public EventCallback<bool> DisplayChanged { get; set; }
155155

156156
[Parameter]
157-
public ModellingAppRoleHandler AppRoleHandler { get; set; }
157+
public ModellingAppRoleHandler? AppRoleHandler { get; set; }
158158

159159
[Parameter]
160160
public EventCallback<ModellingAppRoleHandler> AppRoleHandlerChanged { get; set; }
@@ -169,7 +169,7 @@
169169
private List<ModellingNetworkArea> areas = [];
170170
private bool firstTry = true;
171171
private bool workInProgress = false;
172-
private bool ShowAreaChangeConfirmation { get; set; }
172+
private bool ShowAreaChangeConfirmation { get; set; } = false;
173173

174174
private ModellingNetworkArea? LastSelectedNetworkArea;
175175

@@ -190,7 +190,7 @@
190190

191191
protected override async Task OnParametersSetAsync()
192192
{
193-
if (Display && firstTry)
193+
if (AppRoleHandler != null && Display && firstTry)
194194
{
195195
firstTry = false;
196196
if (AppRoleHandler.NamingConvention.NetworkAreaRequired)
@@ -233,7 +233,7 @@
233233

234234
private void HandleServerDrop()
235235
{
236-
if (Container.AppServerElements.Count > 0)
236+
if (AppRoleHandler != null && Container.AppServerElements.Count > 0)
237237
{
238238
AppRoleHandler.AppServerToAppRole(Container.AppServerElements);
239239
}
@@ -242,7 +242,7 @@
242242

243243
private async Task Save()
244244
{
245-
if (await AppRoleHandler.Save())
245+
if (AppRoleHandler != null && await AppRoleHandler.Save())
246246
{
247247
await RefreshParent();
248248
Close();
@@ -251,8 +251,11 @@
251251

252252
private async Task AreaChangeConfirmation()
253253
{
254-
AppRoleHandler.Close();
255-
await AppRoleHandler.InitAppRole(LastSelectedNetworkArea);
254+
if(AppRoleHandler != null)
255+
{
256+
AppRoleHandler.CleanUp();
257+
await AppRoleHandler.InitAppRole(LastSelectedNetworkArea);
258+
}
256259
ShowAreaChangeConfirmation = false;
257260
StateHasChanged();
258261
}
@@ -269,16 +272,9 @@
269272
{
270273
try
271274
{
272-
if (!workInProgress && !ShowAreaChangeConfirmation)
275+
if (AppRoleHandler != null && !workInProgress && !ShowAreaChangeConfirmation && newArea != null)
273276
{
274-
if (newArea is null)
275-
return;
276-
277-
if (LastSelectedNetworkArea is not null && LastSelectedNetworkArea.Equals(newArea))
278-
return;
279-
280277
LastSelectedNetworkArea = newArea;
281-
282278
if (AppRoleHandler.AppServerToAdd.Count > 0)
283279
{
284280
ShowAreaChangeConfirmation = true;

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

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,23 @@
1010
</div>
1111
<div class="col-sm-11 border rounded m-2 p-2">
1212
<h5>@(userConfig.GetText("app_server"))</h5>
13-
<div class="form-group row">
14-
<div class="col-sm-10">
15-
<DraggableList AllElements="AppRoleHandler.AppServersInArea" @bind-SelectedElements="selectedAppServers"
16-
HandleDragStart="HandleDragStart" Display="@(x => x.DisplayWithIcon())" MaxHeight="50"/>
17-
</div>
18-
@if(selectedAppServers.Count > 0)
19-
{
20-
<div class="col-sm-2">
21-
<button type="button" class="btn btn-sm btn-primary w-100" @onclick="() =>
22-
{AppRoleHandler.AppServerToAppRole(selectedAppServers); selectedAppServers = new();
23-
AppRoleHandlerChanged.InvokeAsync(AppRoleHandler);}">@(AppRoleHandler.DisplayButton("to_app_role", Icons.Use))</button>
13+
@if(AppRoleHandler != null)
14+
{
15+
<div class="form-group row">
16+
<div class="col-sm-10">
17+
<DraggableList AllElements="AppRoleHandler.AppServersInArea" @bind-SelectedElements="selectedAppServers"
18+
HandleDragStart="HandleDragStart" Display="@(x => x.DisplayWithIcon())" MaxHeight="50"/>
2419
</div>
25-
}
26-
</div>
27-
@* <AuthorizeView Roles="@($"{Roles.Admin}, {Roles.Auditor}")">
28-
<NotAuthorized>
29-
<button type="button" class="btn btn-sm btn-danger" @onclick="DataInconsistent">@(userConfig.GetText("data_inconsistent"))</button>
30-
</NotAuthorized>
31-
</AuthorizeView> *@
20+
@if(selectedAppServers.Count > 0)
21+
{
22+
<div class="col-sm-2">
23+
<button type="button" class="btn btn-sm btn-primary w-100" @onclick="() =>
24+
{AppRoleHandler.AppServerToAppRole(selectedAppServers); selectedAppServers = [];
25+
AppRoleHandlerChanged.InvokeAsync(AppRoleHandler);}">@(AppRoleHandler.DisplayButton("to_app_role", Icons.Use))</button>
26+
</div>
27+
}
28+
</div>
29+
}
3230
</div>
3331

3432

@@ -50,12 +48,12 @@
5048
public EventCallback<int> WidthChanged { get; set; }
5149

5250
[Parameter]
53-
public ModellingAppRoleHandler AppRoleHandler { get; set; }
51+
public ModellingAppRoleHandler? AppRoleHandler { get; set; }
5452

5553
[Parameter]
5654
public EventCallback<ModellingAppRoleHandler> AppRoleHandlerChanged { get; set; }
5755

58-
private List<ModellingAppServer> selectedAppServers = new();
56+
private List<ModellingAppServer> selectedAppServers = [];
5957
private int sidebarLeftWidth { get { return Width; } set { Width = value; WidthChanged.InvokeAsync(Width);}}
6058

6159

@@ -70,9 +68,4 @@
7068
selectedAppServers = new();
7169
return true;
7270
}
73-
74-
private async Task DataInconsistent()
75-
{
76-
77-
}
7871
}

0 commit comments

Comments
 (0)