From e56606535923e2b539210a3ea5f81382908eda14 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Tue, 3 Dec 2024 11:54:12 +0100 Subject: [PATCH 01/17] [~] Some cleanup [~] Some setup for test --- roles/lib/files/FWO.Services/ModellingAppZoneHandler.cs | 2 +- roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs | 2 +- roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs | 6 ++++++ .../Pages/NetworkModelling/RequestFwChangePopup.razor | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/roles/lib/files/FWO.Services/ModellingAppZoneHandler.cs b/roles/lib/files/FWO.Services/ModellingAppZoneHandler.cs index 9491d4697..231a695fc 100644 --- a/roles/lib/files/FWO.Services/ModellingAppZoneHandler.cs +++ b/roles/lib/files/FWO.Services/ModellingAppZoneHandler.cs @@ -8,7 +8,7 @@ namespace FWO.Services { - public class ModellingAppZoneHandler(ApiConnection apiConnection, UserConfig userConfig, Action displayMessageInUi, FwoOwner owner) : ModellingHandlerBase(apiConnection, userConfig, displayMessageInUi) + public class ModellingAppZoneHandler(ApiConnection apiConnection, UserConfig userConfig, FwoOwner owner, Action? displayMessageInUi = default) : ModellingHandlerBase(apiConnection, userConfig, displayMessageInUi) { private ModellingNamingConvention NamingConvention = new(); diff --git a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs index 8d38d3ad6..16a285a2a 100644 --- a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs +++ b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs @@ -10,7 +10,7 @@ namespace FWO.Services public class ModellingVarianceAnalysis(ApiConnection apiConnection, ExtStateHandler extStateHandler, UserConfig userConfig, FwoOwner owner, Action displayMessageInUi = null) { private ModellingNamingConvention namingConvention = System.Text.Json.JsonSerializer.Deserialize(userConfig.ModNamingConvention) ?? new(); - private ModellingAppZoneHandler AppZoneHandler = new(apiConnection, userConfig, displayMessageInUi, owner); + private ModellingAppZoneHandler AppZoneHandler = new(apiConnection, userConfig, owner, displayMessageInUi); private List managements = []; private List TaskList = []; diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs index 6b1de9475..df7d23f37 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs @@ -3,6 +3,7 @@ using FWO.Api.Data; using FWO.Services; using System.Text; +using FWO.Api.Client.Data; namespace FWO.Test { @@ -19,6 +20,7 @@ internal class ModellingVarianceAnalysisTest static readonly ExtStateTestApiConn extStateApiConnection = new(); readonly ExtStateHandler extStateHandler = new(extStateApiConnection); ModellingVarianceAnalysis varianceAnalysis; + ModellingAppZoneHandler AppZoneHandler; static readonly FwoOwner Application = new() { Id = 1, Name = "App1" }; @@ -35,6 +37,8 @@ internal class ModellingVarianceAnalysisTest static readonly ModellingServiceGroup SvcGrp1 = new(){ Id = 1, Name = "SvcGrp1", Services = [ new(){ Content = Svc2 } ]}; + static readonly ModellingAppRole AZ1 = new() { Id = 1, Name = "AppZone1", IdString = "AZ4711", AppServers = [new() { Content = AS1 }, new() { Content = AS3 }] }; + static readonly ModellingConnection Connection1 = new() { Id = 1, @@ -45,6 +49,7 @@ internal class ModellingVarianceAnalysisTest ServiceGroups = [ new(){ Content = SvcGrp1 } ], Services = [ new(){Content = Svc1 } ] }; + static readonly List Connections = [ Connection1 ]; @@ -53,6 +58,7 @@ public void Initialize() { extStateHandler.Init().Wait(); varianceAnalysis = new (varianceAnalysisApiConnection, extStateHandler, userConfig, Application); + AppZoneHandler = new(varianceAnalysisApiConnection, userConfig, Application); } [Test] diff --git a/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor b/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor index b6626969d..92fe59ee6 100644 --- a/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor +++ b/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor @@ -126,7 +126,7 @@ { try { - ModellingAppZoneHandler appZoneHandler = new(apiConnection, userConfig, DisplayMessageInUi, SelectedApp); + ModellingAppZoneHandler appZoneHandler = new(apiConnection, userConfig, SelectedApp); await appZoneHandler.UpsertAppZone(); if (!await GetActTicketStatus()) From 3fc4f4a124ecd139333e0fa1b0591d5643a87f11 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Tue, 3 Dec 2024 14:17:43 +0100 Subject: [PATCH 02/17] [~] AZ creation Test #2597 --- .../FWO.Api.Client/Data/WfReqTaskBase.cs | 1 + .../FWO.Services/ModellingVarianceAnalysis.cs | 17 ++- .../ModellingAppZoneHandlerTestApiCon.cs | 57 +++++++ .../FWO.Test/ModellingVarianceAnalysisTest.cs | 141 ++++++++++-------- .../ModellingVarianceAnalysisTestApiConn.cs | 43 ++++-- .../files/FWO.Test/SimulatedUserConfig.cs | 4 +- 6 files changed, 181 insertions(+), 82 deletions(-) create mode 100644 roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs diff --git a/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs b/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs index bb864f387..b16552617 100644 --- a/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs +++ b/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs @@ -20,6 +20,7 @@ public struct AdditionalInfoKeys public const string ExtIcketId = "ExtIcketId"; public const string AppRoleId = "AppRoleId"; public const string SvcGrpId = "SvcGrpId"; + public const string AppZoneId = "AppZoneId"; } public class WfReqTaskBase : WfTaskBase diff --git a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs index 16a285a2a..a93b6a0b2 100644 --- a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs +++ b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs @@ -357,14 +357,20 @@ private bool AppChanged(ModellingNwGroup app) private void RequestNewApp(ModellingNwGroup app, Management mgt) { string title = ""; + string additionalInfoKeys = ""; + string groupName = ""; if (app.GetType() == typeof(ModellingAppRole)) { title = userConfig.GetText("new_app_role"); + additionalInfoKeys = AdditionalInfoKeys.AppRoleId; + groupName = app.IdString; } else if (app.GetType() == typeof(ModellingAppZone)) { title = userConfig.GetText("new_app_zone"); + additionalInfoKeys = AdditionalInfoKeys.AppZoneId; + groupName = app.Name; } List groupMembers = []; @@ -378,14 +384,14 @@ private void RequestNewApp(ModellingNwGroup app, Management mgt) Name = appServer.Name, IpString = appServer.Ip, IpEnd = appServer.IpEnd, - GroupName = app.IdString, + GroupName = groupName, NetworkId = networkId }); } - Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, app.IdString }, { AdditionalInfoKeys.AppRoleId, app.Id.ToString() } }; + Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, groupName }, { additionalInfoKeys, app.Id.ToString() } }; TaskList.Add(new() { - Title = title + app.IdString, + Title = title + groupName, TaskType = WfTaskType.group_create.ToString(), RequestAction = RequestAction.create.ToString(), ManagementId = mgt.Id, @@ -398,18 +404,21 @@ private void RequestNewApp(ModellingNwGroup app, Management mgt) private void RequestUpdateApp(ModellingNwGroup app, Management mgt) { string title = ""; + string additionalInfoKeys = ""; if (app.GetType() == typeof(ModellingAppRole)) { title = userConfig.GetText("update_app_role"); + additionalInfoKeys = AdditionalInfoKeys.AppRoleId; } else if (app.GetType() == typeof(ModellingAppZone)) { title = userConfig.GetText("update_app_zone"); + additionalInfoKeys = AdditionalInfoKeys.AppZoneId; } FillGroupMembers(app.IdString, mgt); - Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, app.IdString }, { AdditionalInfoKeys.AppRoleId, app.Id.ToString() } }; + Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, app.IdString }, { additionalInfoKeys, app.Id.ToString() } }; if (newGroupMembers.Count > 0) { newGroupMembers.AddRange(unchangedGroupMembers); diff --git a/roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs b/roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs new file mode 100644 index 000000000..c41948570 --- /dev/null +++ b/roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs @@ -0,0 +1,57 @@ +using FWO.Api.Client.Queries; +using FWO.Api.Data; +using FWO.Basics; +using GraphQL; + +namespace FWO.Test +{ + internal class ModellingAppZoneHandlerTestApiCon : SimulatedApiConnection + { + static readonly NetworkObject NwObj1 = new() { Id = 10, Name = "AppServer1", IP = "1.2.3.4", Type = new() { Name = ObjectType.Host } }; + static readonly NetworkObject NwObj2 = new() { Id = 11, Name = "AppServer2", IP = "1.2.3.5", IpEnd = "1.2.3.10", Type = new() { Name = ObjectType.IPRange } }; + static readonly NetworkObject NwObj3 = new() { Id = 12, Name = "AppServer3", IP = "1.2.4.0/24", Type = new() { Name = ObjectType.Network } }; + static readonly NetworkObject Nwgroup1 = new() { Id = 1, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj3 }] }; + + public override async Task SendQueryAsync(string query, object? variables = null, string? operationName = null) + { + Type responseType = typeof(QueryResponseType); + if (responseType == typeof(List)) + { + List? managements = + [ + new(){ Id = 1, Name = "Checkpoint1", ExtMgtData = "{\"id\":\"1\",\"name\":\"CheckpointExt\"}" } + ]; + GraphQLResponse response = new() { Data = managements }; + return response.Data; + } + else if (responseType == typeof(List)) + { + List? nwObjects = []; + if (query == ObjectQueries.getNetworkObjectsForManagement) + { + if (variables != null) + { + var objTypeIds = variables.GetType().GetProperties().First(o => o.Name == "objTypeIds").GetValue(variables, null); + if (( (int[])objTypeIds )[0] == 2) + { + nwObjects = + [ + Nwgroup1 + ]; + } + else + { + nwObjects = + [ + NwObj1, NwObj2, NwObj3 + ]; + } + } + } + GraphQLResponse response = new() { Data = nwObjects }; + return response.Data; + } + throw new NotImplementedException(); + } + } +} diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs index df7d23f37..bff36f10a 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs @@ -14,10 +14,12 @@ internal class ModellingVarianceAnalysisTest static readonly SimulatedUserConfig userConfig = new() { ModNamingConvention = "{\"networkAreaRequired\":true,\"fixedPartLength\":4,\"freePartLength\":5,\"networkAreaPattern\":\"NA\",\"appRolePattern\":\"AR\"}", - ModRolloutResolveServiceGroups = true + ModRolloutResolveServiceGroups = true, + CreateAppZones = true, }; static readonly ModellingVarianceAnalysisTestApiConn varianceAnalysisApiConnection = new(); static readonly ExtStateTestApiConn extStateApiConnection = new(); + static readonly ModellingAppZoneHandlerTestApiCon AppZoneHandlerTestApiCon = new(); readonly ExtStateHandler extStateHandler = new(extStateApiConnection); ModellingVarianceAnalysis varianceAnalysis; ModellingAppZoneHandler AppZoneHandler; @@ -58,7 +60,7 @@ public void Initialize() { extStateHandler.Init().Wait(); varianceAnalysis = new (varianceAnalysisApiConnection, extStateHandler, userConfig, Application); - AppZoneHandler = new(varianceAnalysisApiConnection, userConfig, Application); + AppZoneHandler = new(AppZoneHandlerTestApiCon, userConfig, Application); } [Test] @@ -66,7 +68,7 @@ public async Task TestAnalyseModelledConnections() { List TaskList = await varianceAnalysis.AnalyseModelledConnections(Connections); - ClassicAssert.AreEqual(4, TaskList.Count); + ClassicAssert.AreEqual(5, TaskList.Count); ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[0].TaskType); ClassicAssert.AreEqual("{\"GrpName\":\"AR504711-001\",\"AppRoleId\":\"1\"}", TaskList[0].AdditionalInfo); ClassicAssert.AreEqual("modify", TaskList[0].RequestAction); @@ -104,77 +106,94 @@ public async Task TestAnalyseModelledConnections() ClassicAssert.AreEqual("source", TaskList[1].Elements[0].Field); ClassicAssert.AreEqual("addAfterCreation", TaskList[1].Elements[0].RequestAction); - ClassicAssert.AreEqual(WfTaskType.access.ToString(), TaskList[2].TaskType); - ClassicAssert.AreEqual("{\"ConnId\":\"1\"}", TaskList[2].AdditionalInfo); + ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); + ClassicAssert.AreEqual("{\"GrpName\":\"AZ4711\",\"AppZoneId\":\"3\"}", TaskList[2].AdditionalInfo); ClassicAssert.AreEqual("create", TaskList[2].RequestAction); ClassicAssert.AreEqual(3, TaskList[2].TaskNumber); - ClassicAssert.AreEqual("New Connection: Conn1", TaskList[2].Title); - ClassicAssert.AreEqual(1, TaskList[2].Owners.Count); - ClassicAssert.AreEqual("App1", TaskList[2].Owners[0].Owner.Name); - ClassicAssert.AreEqual(5, TaskList[2].Elements.Count); - ClassicAssert.AreEqual(null, TaskList[2].Elements[0].Name); - ClassicAssert.AreEqual("AR504711-001", TaskList[2].Elements[0].GroupName); - ClassicAssert.AreEqual(null, TaskList[2].Elements[0].IpString); + ClassicAssert.AreEqual("New AppZone: AZ4711", TaskList[2].Title); + ClassicAssert.AreEqual(2, TaskList[2].Elements.Count); + ClassicAssert.AreEqual("AppServer1", TaskList[2].Elements[0].Name); + ClassicAssert.AreEqual("AppServer2", TaskList[2].Elements[1].Name); + ClassicAssert.AreEqual("AZ4711", TaskList[2].Elements[0].GroupName); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[0].IpString); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[0].IpEnd); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[1].IpString); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[1].IpEnd); ClassicAssert.AreEqual("source", TaskList[2].Elements[0].Field); - ClassicAssert.AreEqual("create", TaskList[2].Elements[0].RequestAction); + ClassicAssert.AreEqual("addAfterCreation", TaskList[2].Elements[0].RequestAction); - ClassicAssert.AreEqual(null, TaskList[2].Elements[1].Name); - ClassicAssert.AreEqual("AR504711-002", TaskList[2].Elements[1].GroupName); - ClassicAssert.AreEqual("destination", TaskList[2].Elements[1].Field); - ClassicAssert.AreEqual("create", TaskList[2].Elements[1].RequestAction); - - ClassicAssert.AreEqual("AppServer4", TaskList[2].Elements[2].Name); - ClassicAssert.AreEqual(null, TaskList[2].Elements[2].GroupName); - ClassicAssert.AreEqual("100.2.3.4", TaskList[2].Elements[2].IpString); - ClassicAssert.AreEqual("destination", TaskList[2].Elements[2].Field); - ClassicAssert.AreEqual("create", TaskList[2].Elements[2].RequestAction); - - ClassicAssert.AreEqual("Service2", TaskList[2].Elements[3].Name); - ClassicAssert.AreEqual(null, TaskList[2].Elements[3].GroupName); - ClassicAssert.AreEqual(6, TaskList[2].Elements[3].ProtoId); - ClassicAssert.AreEqual(4000, TaskList[2].Elements[3].Port); - ClassicAssert.AreEqual("service", TaskList[2].Elements[3].Field); - ClassicAssert.AreEqual("create", TaskList[2].Elements[3].RequestAction); - ClassicAssert.AreEqual("Service1", TaskList[2].Elements[4].Name); - ClassicAssert.AreEqual(null, TaskList[2].Elements[4].GroupName); - ClassicAssert.AreEqual(6, TaskList[2].Elements[4].ProtoId); - ClassicAssert.AreEqual(1000, TaskList[2].Elements[4].Port); - ClassicAssert.AreEqual(2000, TaskList[2].Elements[4].PortEnd); - ClassicAssert.AreEqual("service", TaskList[2].Elements[4].Field); - ClassicAssert.AreEqual("create", TaskList[2].Elements[4].RequestAction); - - ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[3].TaskType); - ClassicAssert.AreEqual("{\"GrpName\":\"AR504711-001\",\"AppRoleId\":\"1\"}", TaskList[3].AdditionalInfo); - ClassicAssert.AreEqual("modify", TaskList[3].RequestAction); + ClassicAssert.AreEqual(WfTaskType.access.ToString(), TaskList[3].TaskType); + ClassicAssert.AreEqual("{\"ConnId\":\"1\"}", TaskList[3].AdditionalInfo); + ClassicAssert.AreEqual("create", TaskList[3].RequestAction); ClassicAssert.AreEqual(4, TaskList[3].TaskNumber); - ClassicAssert.AreEqual("Update AppRole: AR504711-001: Remove Members", TaskList[3].Title); - ClassicAssert.AreEqual(1, TaskList[3].ManagementId); - ClassicAssert.AreEqual("Checkpoint1", TaskList[3].OnManagement?.Name); - ClassicAssert.AreEqual(3, TaskList[3].Elements.Count); - ClassicAssert.AreEqual("AppServer3", TaskList[3].Elements[0].Name); + ClassicAssert.AreEqual("New Connection: Conn1", TaskList[3].Title); + ClassicAssert.AreEqual(1, TaskList[3].Owners.Count); + ClassicAssert.AreEqual("App1", TaskList[3].Owners[0].Owner.Name); + ClassicAssert.AreEqual(5, TaskList[3].Elements.Count); + ClassicAssert.AreEqual(null, TaskList[3].Elements[0].Name); ClassicAssert.AreEqual("AR504711-001", TaskList[3].Elements[0].GroupName); - ClassicAssert.AreEqual("1.2.4.0/24", TaskList[3].Elements[0].IpString); + ClassicAssert.AreEqual(null, TaskList[3].Elements[0].IpString); ClassicAssert.AreEqual("source", TaskList[3].Elements[0].Field); - ClassicAssert.AreEqual("delete", TaskList[3].Elements[0].RequestAction); - ClassicAssert.AreEqual("AppServer1", TaskList[3].Elements[1].Name); - ClassicAssert.AreEqual("AR504711-001", TaskList[3].Elements[1].GroupName); - ClassicAssert.AreEqual("1.2.3.4", TaskList[3].Elements[1].IpString); - ClassicAssert.AreEqual("source", TaskList[3].Elements[1].Field); - ClassicAssert.AreEqual("unchanged", TaskList[3].Elements[1].RequestAction); - ClassicAssert.AreEqual("AppServerNew", TaskList[3].Elements[2].Name); - ClassicAssert.AreEqual("AR504711-001", TaskList[3].Elements[2].GroupName); - ClassicAssert.AreEqual("10.10.10.10", TaskList[3].Elements[2].IpString); - ClassicAssert.AreEqual("source", TaskList[3].Elements[2].Field); - ClassicAssert.AreEqual("unchanged", TaskList[3].Elements[2].RequestAction); + ClassicAssert.AreEqual("create", TaskList[3].Elements[0].RequestAction); + + ClassicAssert.AreEqual(null, TaskList[3].Elements[1].Name); + ClassicAssert.AreEqual("AR504711-002", TaskList[3].Elements[1].GroupName); + ClassicAssert.AreEqual("destination", TaskList[3].Elements[1].Field); + ClassicAssert.AreEqual("create", TaskList[3].Elements[1].RequestAction); + + ClassicAssert.AreEqual("AppServer4", TaskList[3].Elements[2].Name); + ClassicAssert.AreEqual(null, TaskList[3].Elements[2].GroupName); + ClassicAssert.AreEqual("100.2.3.4", TaskList[3].Elements[2].IpString); + ClassicAssert.AreEqual("destination", TaskList[3].Elements[2].Field); + ClassicAssert.AreEqual("create", TaskList[3].Elements[2].RequestAction); + + ClassicAssert.AreEqual("Service2", TaskList[3].Elements[3].Name); + ClassicAssert.AreEqual(null, TaskList[3].Elements[3].GroupName); + ClassicAssert.AreEqual(6, TaskList[3].Elements[3].ProtoId); + ClassicAssert.AreEqual(4000, TaskList[3].Elements[3].Port); + ClassicAssert.AreEqual("service", TaskList[3].Elements[3].Field); + ClassicAssert.AreEqual("create", TaskList[3].Elements[3].RequestAction); + ClassicAssert.AreEqual("Service1", TaskList[3].Elements[4].Name); + ClassicAssert.AreEqual(null, TaskList[3].Elements[4].GroupName); + ClassicAssert.AreEqual(6, TaskList[3].Elements[4].ProtoId); + ClassicAssert.AreEqual(1000, TaskList[3].Elements[4].Port); + ClassicAssert.AreEqual(2000, TaskList[3].Elements[4].PortEnd); + ClassicAssert.AreEqual("service", TaskList[3].Elements[4].Field); + ClassicAssert.AreEqual("create", TaskList[3].Elements[4].RequestAction); + + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[4].TaskType); + ClassicAssert.AreEqual("{\"GrpName\":\"AR504711-001\",\"AppRoleId\":\"1\"}", TaskList[4].AdditionalInfo); + ClassicAssert.AreEqual("modify", TaskList[4].RequestAction); + ClassicAssert.AreEqual(5, TaskList[4].TaskNumber); + ClassicAssert.AreEqual("Update AppRole: AR504711-001: Remove Members", TaskList[4].Title); + ClassicAssert.AreEqual(1, TaskList[4].ManagementId); + ClassicAssert.AreEqual("Checkpoint1", TaskList[4].OnManagement?.Name); + ClassicAssert.AreEqual(3, TaskList[4].Elements.Count); + ClassicAssert.AreEqual("AppServer3", TaskList[4].Elements[0].Name); + ClassicAssert.AreEqual("AR504711-001", TaskList[4].Elements[0].GroupName); + ClassicAssert.AreEqual("1.2.4.0/24", TaskList[4].Elements[0].IpString); + ClassicAssert.AreEqual("source", TaskList[4].Elements[0].Field); + ClassicAssert.AreEqual("delete", TaskList[4].Elements[0].RequestAction); + ClassicAssert.AreEqual("AppServer1", TaskList[4].Elements[1].Name); + ClassicAssert.AreEqual("AR504711-001", TaskList[4].Elements[1].GroupName); + ClassicAssert.AreEqual("1.2.3.4", TaskList[4].Elements[1].IpString); + ClassicAssert.AreEqual("source", TaskList[4].Elements[1].Field); + ClassicAssert.AreEqual("unchanged", TaskList[4].Elements[1].RequestAction); + ClassicAssert.AreEqual("AppServerNew", TaskList[4].Elements[2].Name); + ClassicAssert.AreEqual("AR504711-001", TaskList[4].Elements[2].GroupName); + ClassicAssert.AreEqual("10.10.10.10", TaskList[4].Elements[2].IpString); + ClassicAssert.AreEqual("source", TaskList[4].Elements[2].Field); + ClassicAssert.AreEqual("unchanged", TaskList[4].Elements[2].RequestAction); userConfig.ModRolloutResolveServiceGroups = false; TaskList = await varianceAnalysis.AnalyseModelledConnections(Connections); - ClassicAssert.AreEqual(5, TaskList.Count); + ClassicAssert.AreEqual(6, TaskList.Count); ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[0].TaskType); ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[1].TaskType); ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); - ClassicAssert.AreEqual(WfTaskType.access.ToString(), TaskList[3].TaskType); - ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[4].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[3].TaskType); + ClassicAssert.AreEqual(WfTaskType.access.ToString(), TaskList[4].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[5].TaskType); ClassicAssert.AreEqual("{\"GrpName\":\"SvcGrp1\",\"SvcGrpId\":\"1\"}", TaskList[2].AdditionalInfo); ClassicAssert.AreEqual("create", TaskList[2].RequestAction); diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs index 16ec1e9d3..ce928af52 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs @@ -2,54 +2,65 @@ using GraphQL; using FWO.Api.Data; using FWO.Basics; +using FWO.Api.Client.Data; +using Org.BouncyCastle.Utilities; namespace FWO.Test { internal class ModellingVarianceAnalysisTestApiConn : SimulatedApiConnection { - static readonly NetworkObject NwObj1 = new(){ Id = 10, Name = "AppServer1", IP = "1.2.3.4", Type = new(){ Name = ObjectType.Host } }; - static readonly NetworkObject NwObj2 = new(){ Id = 11, Name = "AppServer2", IP = "1.2.3.5", IpEnd = "1.2.3.10", Type = new(){ Name = ObjectType.IPRange } }; - static readonly NetworkObject NwObj3 = new(){ Id = 12, Name = "AppServer3", IP = "1.2.4.0/24", Type = new(){ Name = ObjectType.Network } }; - static readonly NetworkObject Nwgroup1 = new(){ Id = 1, Name = "AR504711-001", Type = new(){ Name = ObjectType.Group }, ObjectGroupFlats = [ new(){ Object = NwObj1}, new(){ Object = NwObj3} ] }; - - + static readonly NetworkObject NwObj1 = new() { Id = 10, Name = "AppServer1", IP = "1.2.3.4", Type = new() { Name = ObjectType.Host } }; + static readonly NetworkObject NwObj2 = new() { Id = 11, Name = "AppServer2", IP = "1.2.3.5", IpEnd = "1.2.3.10", Type = new() { Name = ObjectType.IPRange } }; + static readonly NetworkObject NwObj3 = new() { Id = 12, Name = "AppServer3", IP = "1.2.4.0/24", Type = new() { Name = ObjectType.Network } }; + static readonly NetworkObject Nwgroup1 = new() { Id = 1, Name = "AR504711-001", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj3 }] }; + static readonly ModellingAppServer AppServer1 = new() { Id = 13, Name = "AppServer1", Ip = "1.1.1.1/32", IpEnd = "1.1.1.1/32" }; + static readonly ModellingAppServer AppServer2 = new() { Id = 14, Name = "AppServer2", Ip = "2.2.2.2/32", IpEnd = "2.2.2.2/32" }; + static readonly NetworkObject AZProd = new() { Id = 2, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj2 }] }; + static readonly ModellingAppZone AZExist = new() { Id = 3, Name = "AZ4711", AppServers = new() { new() { Content = AppServer1 }, new() { Content = AppServer2 } } }; + public override async Task SendQueryAsync(string query, object? variables = null, string? operationName = null) { Type responseType = typeof(QueryResponseType); - if(responseType == typeof(List)) + if (responseType == typeof(List)) { List? managements = [ new(){ Id = 1, Name = "Checkpoint1", ExtMgtData = "{\"id\":\"1\",\"name\":\"CheckpointExt\"}" } ]; - GraphQLResponse response = new(){ Data = managements }; + GraphQLResponse response = new() { Data = managements }; return response.Data; } - else if(responseType == typeof(List)) + else if (responseType == typeof(List)) { List? nwObjects = []; - if(query == ObjectQueries.getNetworkObjectsForManagement) + if (query == ObjectQueries.getNetworkObjectsForManagement) { - if(variables != null) + if (variables != null) { var objTypeIds = variables.GetType().GetProperties().First(o => o.Name == "objTypeIds").GetValue(variables, null); - if(((int[])objTypeIds)[0] == 2) + if (( (int[])objTypeIds )[0] == 2) { - nwObjects = + nwObjects = [ - Nwgroup1 + Nwgroup1, AZProd ]; } else { - nwObjects = + nwObjects = [ NwObj1, NwObj2, NwObj3 ]; } } } - GraphQLResponse response = new(){ Data = nwObjects }; + GraphQLResponse response = new() { Data = nwObjects }; + return response.Data; + } + else if (responseType == typeof(List)) + { + GraphQLResponse response = new() { Data = new List(){ AZExist }}; + return response.Data; } throw new NotImplementedException(); diff --git a/roles/test/files/FWO.Test/SimulatedUserConfig.cs b/roles/test/files/FWO.Test/SimulatedUserConfig.cs index e78d0d22c..db9fa4e56 100644 --- a/roles/test/files/FWO.Test/SimulatedUserConfig.cs +++ b/roles/test/files/FWO.Test/SimulatedUserConfig.cs @@ -80,7 +80,9 @@ internal class SimulatedUserConfig : UserConfig {"update_app_role","Update AppRole: "}, {"new_svc_grp","New Servicegroup: "}, {"add_members",": Add Members"}, - {"remove_members",": Remove Members"} + {"remove_members",": Remove Members"}, + {"new_app_zone", "New AppZone: " }, + {"update_app_zone", "Update AppZone: " } }; public override string GetText(string key) From 69b4d25eb8a3b7839732aa630c3dad4295f7d8fc Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Tue, 3 Dec 2024 15:56:06 +0100 Subject: [PATCH 03/17] [~] AZ creation test bugfix #2597 --- .../FWO.Services/ModellingVarianceAnalysis.cs | 19 ++++++++++-------- .../FWO.Test/ModellingVarianceAnalysisTest.cs | 20 +++++++++---------- .../ModellingVarianceAnalysisTestApiConn.cs | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs index a93b6a0b2..1cceb8069 100644 --- a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs +++ b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs @@ -241,9 +241,9 @@ private async Task AnalyseAppZone(Management mgt) if (existingAppZone is not null) { - WfReqTask? taskEntryNewAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("new_app_zone") + existingAppZone.IdString && x.OnManagement?.Id == mgt.Id); - WfReqTask? taskEntryUpdateAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.IdString + userConfig.GetText("add_members") && x.OnManagement?.Id == mgt.Id); - WfReqTask? taskEntryDeleteAppZone = DeleteTasksList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.IdString + userConfig.GetText("remove_members") && x.OnManagement?.Id == mgt.Id); + WfReqTask? taskEntryNewAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("new_app_zone") + existingAppZone.Name && x.OnManagement?.Id == mgt.Id); + WfReqTask? taskEntryUpdateAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.Name + userConfig.GetText("add_members") && x.OnManagement?.Id == mgt.Id); + WfReqTask? taskEntryDeleteAppZone = DeleteTasksList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.Name + userConfig.GetText("remove_members") && x.OnManagement?.Id == mgt.Id); if (!ResolveExistingApp(existingAppZone, mgt) && taskEntryNewAppZone is null) { @@ -275,7 +275,7 @@ private bool ResolveExistingApp(ModellingNwGroup app, Management mgt) string sanitizedARName = Sanitizer.SanitizeJsonFieldMand(app.IdString, ref shortened); if (allExistingAppRoles.ContainsKey(mgt.Id)) { - existingApp = allExistingAppRoles[mgt.Id].FirstOrDefault(a => a.Name == app.IdString || a.Name == sanitizedARName); + existingApp = allExistingAppRoles[mgt.Id].FirstOrDefault(a => a.Name == app.IdString || a.Name == sanitizedARName || a.Name == app.Name); } if (existingApp != null) { @@ -405,27 +405,30 @@ private void RequestUpdateApp(ModellingNwGroup app, Management mgt) { string title = ""; string additionalInfoKeys = ""; + string groupName = ""; if (app.GetType() == typeof(ModellingAppRole)) { title = userConfig.GetText("update_app_role"); additionalInfoKeys = AdditionalInfoKeys.AppRoleId; + groupName = app.IdString; } else if (app.GetType() == typeof(ModellingAppZone)) { title = userConfig.GetText("update_app_zone"); additionalInfoKeys = AdditionalInfoKeys.AppZoneId; + groupName = app.Name; } - FillGroupMembers(app.IdString, mgt); - Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, app.IdString }, { additionalInfoKeys, app.Id.ToString() } }; + FillGroupMembers(groupName, mgt); + Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, groupName }, { additionalInfoKeys, app.Id.ToString() } }; if (newGroupMembers.Count > 0) { newGroupMembers.AddRange(unchangedGroupMembers); newGroupMembers.AddRange(unchangedGroupMembersDuringCreate); // will be deleted later TaskList.Add(new() { - Title = title + app.IdString + userConfig.GetText("add_members"), + Title = title + groupName + userConfig.GetText("add_members"), TaskType = WfTaskType.group_modify.ToString(), RequestAction = RequestAction.modify.ToString(), ManagementId = mgt.Id, @@ -440,7 +443,7 @@ private void RequestUpdateApp(ModellingNwGroup app, Management mgt) deletedGroupMembers.AddRange(newCreatedGroupMembers); DeleteTasksList.Add(new() { - Title = title + app.IdString + userConfig.GetText("remove_members"), + Title = title + groupName + userConfig.GetText("remove_members"), TaskType = WfTaskType.group_modify.ToString(), RequestAction = RequestAction.modify.ToString(), ManagementId = mgt.Id, diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs index bff36f10a..95de2e7b8 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs @@ -106,19 +106,19 @@ public async Task TestAnalyseModelledConnections() ClassicAssert.AreEqual("source", TaskList[1].Elements[0].Field); ClassicAssert.AreEqual("addAfterCreation", TaskList[1].Elements[0].RequestAction); - ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[2].TaskType); ClassicAssert.AreEqual("{\"GrpName\":\"AZ4711\",\"AppZoneId\":\"3\"}", TaskList[2].AdditionalInfo); - ClassicAssert.AreEqual("create", TaskList[2].RequestAction); + ClassicAssert.AreEqual("modify", TaskList[2].RequestAction); ClassicAssert.AreEqual(3, TaskList[2].TaskNumber); - ClassicAssert.AreEqual("New AppZone: AZ4711", TaskList[2].Title); + ClassicAssert.AreEqual("Update AppZone: AZ4711: Add Members", TaskList[2].Title); ClassicAssert.AreEqual(2, TaskList[2].Elements.Count); - ClassicAssert.AreEqual("AppServer1", TaskList[2].Elements[0].Name); - ClassicAssert.AreEqual("AppServer2", TaskList[2].Elements[1].Name); + ClassicAssert.AreEqual("AppServer2", TaskList[2].Elements[0].Name); + ClassicAssert.AreEqual("AppServer1", TaskList[2].Elements[1].Name); ClassicAssert.AreEqual("AZ4711", TaskList[2].Elements[0].GroupName); - ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[0].IpString); - ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[0].IpEnd); - ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[1].IpString); - ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[1].IpEnd); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[1].IpString); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[1].IpEnd); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[0].IpString); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[0].IpEnd); ClassicAssert.AreEqual("source", TaskList[2].Elements[0].Field); ClassicAssert.AreEqual("addAfterCreation", TaskList[2].Elements[0].RequestAction); @@ -191,7 +191,7 @@ public async Task TestAnalyseModelledConnections() ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[0].TaskType); ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[1].TaskType); ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); - ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[3].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[3].TaskType); ClassicAssert.AreEqual(WfTaskType.access.ToString(), TaskList[4].TaskType); ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[5].TaskType); diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs index ce928af52..741aea4bd 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs @@ -15,7 +15,7 @@ internal class ModellingVarianceAnalysisTestApiConn : SimulatedApiConnection static readonly NetworkObject Nwgroup1 = new() { Id = 1, Name = "AR504711-001", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj3 }] }; static readonly ModellingAppServer AppServer1 = new() { Id = 13, Name = "AppServer1", Ip = "1.1.1.1/32", IpEnd = "1.1.1.1/32" }; static readonly ModellingAppServer AppServer2 = new() { Id = 14, Name = "AppServer2", Ip = "2.2.2.2/32", IpEnd = "2.2.2.2/32" }; - static readonly NetworkObject AZProd = new() { Id = 2, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj2 }] }; + static readonly NetworkObject AZProd = new() { Id = 2, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }] }; static readonly ModellingAppZone AZExist = new() { Id = 3, Name = "AZ4711", AppServers = new() { new() { Content = AppServer1 }, new() { Content = AppServer2 } } }; public override async Task SendQueryAsync(string query, object? variables = null, string? operationName = null) From 6bb5803413898ad72312274c57d8479446c83606 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Wed, 4 Dec 2024 14:26:11 +0100 Subject: [PATCH 04/17] [-] Remove System.Text.Encodings.Web NuGet #2597 --- roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj | 4 ---- roles/lib/files/FWO.Mail/FWO.Mail.csproj | 1 - .../lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj | 5 +++-- roles/lib/files/FWO.Report/FWO.Report.csproj | 1 - roles/lib/files/FWO.Services/FWO.Services.csproj | 5 +++-- .../FWO.Middleware.Server/FWO.Middleware.Server.csproj | 1 - roles/test/files/FWO.Test/FWO.Test.csproj | 9 ++++++--- roles/ui/files/FWO.UI/FWO.Ui.csproj | 5 +++-- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj b/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj index a11050501..48ceb7666 100644 --- a/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj +++ b/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj @@ -6,10 +6,6 @@ enable - - - - diff --git a/roles/lib/files/FWO.Mail/FWO.Mail.csproj b/roles/lib/files/FWO.Mail/FWO.Mail.csproj index db9f8c234..fb15c291e 100644 --- a/roles/lib/files/FWO.Mail/FWO.Mail.csproj +++ b/roles/lib/files/FWO.Mail/FWO.Mail.csproj @@ -10,7 +10,6 @@ - diff --git a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj index 0f4052b9c..45880d106 100644 --- a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj +++ b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj @@ -7,8 +7,9 @@ - - + + true + diff --git a/roles/lib/files/FWO.Report/FWO.Report.csproj b/roles/lib/files/FWO.Report/FWO.Report.csproj index 337ef3db8..7cbc12e1d 100644 --- a/roles/lib/files/FWO.Report/FWO.Report.csproj +++ b/roles/lib/files/FWO.Report/FWO.Report.csproj @@ -8,7 +8,6 @@ - diff --git a/roles/lib/files/FWO.Services/FWO.Services.csproj b/roles/lib/files/FWO.Services/FWO.Services.csproj index 76c15c786..a9cc59a9b 100644 --- a/roles/lib/files/FWO.Services/FWO.Services.csproj +++ b/roles/lib/files/FWO.Services/FWO.Services.csproj @@ -8,7 +8,6 @@ - @@ -16,7 +15,9 @@ - + + true + diff --git a/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj b/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj index 1dd2d646f..517d6a642 100644 --- a/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj +++ b/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj @@ -11,7 +11,6 @@ - diff --git a/roles/test/files/FWO.Test/FWO.Test.csproj b/roles/test/files/FWO.Test/FWO.Test.csproj index ceb7b3011..58e1b3faa 100644 --- a/roles/test/files/FWO.Test/FWO.Test.csproj +++ b/roles/test/files/FWO.Test/FWO.Test.csproj @@ -8,12 +8,15 @@ - + + true + - - + + true + diff --git a/roles/ui/files/FWO.UI/FWO.Ui.csproj b/roles/ui/files/FWO.UI/FWO.Ui.csproj index 8fdf2cb77..8f544981d 100644 --- a/roles/ui/files/FWO.UI/FWO.Ui.csproj +++ b/roles/ui/files/FWO.UI/FWO.Ui.csproj @@ -7,9 +7,10 @@ - + + true + - From 4321d10392d6084535ac65f3baab2cf6da36808a Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Thu, 5 Dec 2024 10:23:33 +0100 Subject: [PATCH 05/17] . --- .../test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs index 741aea4bd..0dcce1d8a 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs @@ -3,7 +3,6 @@ using FWO.Api.Data; using FWO.Basics; using FWO.Api.Client.Data; -using Org.BouncyCastle.Utilities; namespace FWO.Test { From d2f6ed72d1811146575fe3503080cb3170d756ad Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Mon, 9 Dec 2024 11:08:17 +0100 Subject: [PATCH 06/17] [~] Resolve nuget security risks --- roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj | 2 ++ roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj | 6 ++++++ .../lib/files/FWO.Config.File/FWO.Config.File.csproj | 3 ++- .../FWO.DeviceAutoDiscovery.csproj | 3 +++ roles/lib/files/FWO.Mail/FWO.Mail.csproj | 1 + .../FWO.Middleware.Client.csproj | 2 ++ roles/lib/files/FWO.Middleware/FWO.Middleware.csproj | 3 ++- roles/lib/files/FWO.Recert/FWO.Recert.csproj | 5 +++++ .../files/FWO.Report.Filter/FWO.Report.Filter.csproj | 7 ++++--- roles/lib/files/FWO.Report/FWO.Report.csproj | 3 +++ roles/lib/files/FWO.Services/FWO.Services.csproj | 7 ++++--- .../FWO.Tufin.SecureChange.csproj | 5 ++++- .../FWO.Middleware.Server.csproj | 5 ++++- roles/test/files/FWO.Test/FWO.Test.csproj | 12 +++++------- roles/ui/files/FWO.UI/FWO.Ui.csproj | 7 ++++--- 15 files changed, 51 insertions(+), 20 deletions(-) diff --git a/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj b/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj index bc85bf649..d6c228717 100644 --- a/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj +++ b/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj @@ -12,6 +12,8 @@ + + diff --git a/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj b/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj index 48ceb7666..975e20ce2 100644 --- a/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj +++ b/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj @@ -6,6 +6,12 @@ enable + + + + + + diff --git a/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj b/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj index e91cf1c52..4a4744bd0 100644 --- a/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj +++ b/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj @@ -7,7 +7,8 @@ - + + diff --git a/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj b/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj index 1fae62a98..3070e164c 100644 --- a/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj +++ b/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj @@ -7,9 +7,12 @@ + + + diff --git a/roles/lib/files/FWO.Mail/FWO.Mail.csproj b/roles/lib/files/FWO.Mail/FWO.Mail.csproj index fb15c291e..db9f8c234 100644 --- a/roles/lib/files/FWO.Mail/FWO.Mail.csproj +++ b/roles/lib/files/FWO.Mail/FWO.Mail.csproj @@ -10,6 +10,7 @@ + diff --git a/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj b/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj index 128b4f529..943729499 100644 --- a/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj +++ b/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj @@ -7,9 +7,11 @@ + + diff --git a/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj b/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj index 956c9ec84..fae898d8c 100644 --- a/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj +++ b/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj @@ -7,7 +7,8 @@ - + + diff --git a/roles/lib/files/FWO.Recert/FWO.Recert.csproj b/roles/lib/files/FWO.Recert/FWO.Recert.csproj index 357ae3b17..4fb47bdc6 100644 --- a/roles/lib/files/FWO.Recert/FWO.Recert.csproj +++ b/roles/lib/files/FWO.Recert/FWO.Recert.csproj @@ -6,6 +6,11 @@ enable + + + + + diff --git a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj index 45880d106..8084dd29b 100644 --- a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj +++ b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj @@ -7,9 +7,10 @@ - - true - + + + + diff --git a/roles/lib/files/FWO.Report/FWO.Report.csproj b/roles/lib/files/FWO.Report/FWO.Report.csproj index 7cbc12e1d..b38fe5673 100644 --- a/roles/lib/files/FWO.Report/FWO.Report.csproj +++ b/roles/lib/files/FWO.Report/FWO.Report.csproj @@ -8,6 +8,9 @@ + + + diff --git a/roles/lib/files/FWO.Services/FWO.Services.csproj b/roles/lib/files/FWO.Services/FWO.Services.csproj index a9cc59a9b..37d647a46 100644 --- a/roles/lib/files/FWO.Services/FWO.Services.csproj +++ b/roles/lib/files/FWO.Services/FWO.Services.csproj @@ -8,6 +8,9 @@ + + + @@ -15,9 +18,7 @@ - - true - + diff --git a/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj b/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj index f2f550d58..f9854f636 100644 --- a/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj +++ b/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -7,9 +7,12 @@ + + + diff --git a/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj b/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj index 517d6a642..6e01de38e 100644 --- a/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj +++ b/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj @@ -9,8 +9,11 @@ + - + + + diff --git a/roles/test/files/FWO.Test/FWO.Test.csproj b/roles/test/files/FWO.Test/FWO.Test.csproj index 58e1b3faa..eb1f7812b 100644 --- a/roles/test/files/FWO.Test/FWO.Test.csproj +++ b/roles/test/files/FWO.Test/FWO.Test.csproj @@ -8,15 +8,13 @@ - - true - + - - - true - + + + + diff --git a/roles/ui/files/FWO.UI/FWO.Ui.csproj b/roles/ui/files/FWO.UI/FWO.Ui.csproj index 8f544981d..a05c68171 100644 --- a/roles/ui/files/FWO.UI/FWO.Ui.csproj +++ b/roles/ui/files/FWO.UI/FWO.Ui.csproj @@ -7,10 +7,11 @@ - - true - + + + + From ccd9394f98c44b303f593df0b3a900113fa4b0eb Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Tue, 10 Dec 2024 13:37:02 +0100 Subject: [PATCH 07/17] [~] Null check for ip1 parameter #2698 --- .../files/FWO.Api.Client/Data/DisplayBase.cs | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs index cf13837d9..1a73628a5 100644 --- a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs +++ b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs @@ -10,7 +10,7 @@ public static class DisplayBase { public static StringBuilder DisplayService(NetworkService service, bool isTechReport, string? serviceName = null) { - StringBuilder result = new (); + StringBuilder result = new(); string ports = service.DestinationPortEnd == null || service.DestinationPortEnd == 0 || service.DestinationPort == service.DestinationPortEnd ? $"{service.DestinationPort}" : $"{service.DestinationPort}-{service.DestinationPortEnd}"; if (isTechReport) @@ -62,24 +62,24 @@ public static List CustomSortProtocols(List ListIn) { List ListOut = []; IpProtocol? tcp = ListIn.Find(x => x.Name.ToLower() == "tcp"); - if(tcp != null) + if (tcp != null) { ListOut.Add(tcp); ListIn.Remove(tcp); } IpProtocol? udp = ListIn.Find(x => x.Name.ToLower() == "udp"); - if(udp != null) + if (udp != null) { ListOut.Add(udp); ListIn.Remove(udp); } IpProtocol? icmp = ListIn.Find(x => x.Name.ToLower() == "icmp"); - if(icmp != null) + if (icmp != null) { ListOut.Add(icmp); ListIn.Remove(icmp); } - foreach(var proto in ListIn.OrderBy(x => x.Name).ToList()) + foreach (var proto in ListIn.OrderBy(x => x.Name).ToList()) { if (proto.Name.ToLower() != "unassigned") { @@ -91,7 +91,7 @@ public static List CustomSortProtocols(List ListIn) public static string DisplayIpWithName(NetworkObject elem) { - if(elem.Name != null && elem.Name != "") + if (elem.Name != null && elem.Name != "") { return elem.Name + DisplayIp(elem.IP, elem.IpEnd, true); } @@ -109,7 +109,7 @@ public static string DisplayIp(string ip1, string ip2, bool inBrackets = false) string nwObjType = AutoDetectType(ip1, ip2); return DisplayIp(ip1, ip2, nwObjType, inBrackets); } - catch(Exception exc) + catch (Exception exc) { Log.WriteError("Ip displaying", $"Exception thrown: {exc.Message}"); return ""; @@ -121,7 +121,17 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in string result = ""; if (nwObjType != ObjectType.Group) { - if (!IsV4Address(ip1) && !IsV6Address(ip1)) + + if (string.IsNullOrEmpty(ip2)) + { + ip2 = ip1; + } + + if (string.IsNullOrEmpty(ip1)) + { + Log.WriteDebug("Ip displaying", $"Parameter {nameof(ip1)} is empty."); + } + else if (!IsV4Address(ip1) && !IsV6Address(ip1)) { Log.WriteError("Ip displaying", $"Found undefined IP family: {ip1} - {ip2}"); } @@ -131,10 +141,6 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in } else { - if (ip2 == "") - { - ip2 = ip1; - } string IpStart = StripOffUnnecessaryNetmask(ip1); string IpEnd = StripOffUnnecessaryNetmask(ip2); @@ -143,9 +149,9 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in result = inBrackets ? " (" : ""; if (nwObjType == ObjectType.Network) { - if(GetNetmask(IpStart) == "") + if (GetNetmask(IpStart) == "") { - IPAddressRange ipRange = new (IPAddress.Parse(IpStart), IPAddress.Parse(IpEnd)); + IPAddressRange ipRange = new(IPAddress.Parse(IpStart), IPAddress.Parse(IpEnd)); if (ipRange != null) { result += ipRange.ToCidrString(); @@ -240,7 +246,7 @@ public static string GetNetmask(string ip) int pos = ip.LastIndexOf('/'); if (pos > -1 && ip.Length > pos + 1) { - return ip[(pos + 1)..]; + return ip[( pos + 1 )..]; } return ""; } @@ -288,7 +294,7 @@ public static string AutoDetectType(string ip1, string ip2) if (ip1 == ip2 || ip2 == "") { string netmask = GetNetmask(ip1); - if(netmask != "") + if (netmask != "") { return ObjectType.Network; } From 93989b606646eb354b869969ade41aef7d27b547 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Tue, 10 Dec 2024 13:41:32 +0100 Subject: [PATCH 08/17] Revert "[~] Resolve nuget security risks" This reverts commit d2f6ed72d1811146575fe3503080cb3170d756ad. --- roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj | 2 -- roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj | 6 ------ .../lib/files/FWO.Config.File/FWO.Config.File.csproj | 3 +-- .../FWO.DeviceAutoDiscovery.csproj | 3 --- roles/lib/files/FWO.Mail/FWO.Mail.csproj | 1 - .../FWO.Middleware.Client.csproj | 2 -- roles/lib/files/FWO.Middleware/FWO.Middleware.csproj | 3 +-- roles/lib/files/FWO.Recert/FWO.Recert.csproj | 5 ----- .../files/FWO.Report.Filter/FWO.Report.Filter.csproj | 7 +++---- roles/lib/files/FWO.Report/FWO.Report.csproj | 3 --- roles/lib/files/FWO.Services/FWO.Services.csproj | 7 +++---- .../FWO.Tufin.SecureChange.csproj | 5 +---- .../FWO.Middleware.Server.csproj | 5 +---- roles/test/files/FWO.Test/FWO.Test.csproj | 12 +++++++----- roles/ui/files/FWO.UI/FWO.Ui.csproj | 7 +++---- 15 files changed, 20 insertions(+), 51 deletions(-) diff --git a/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj b/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj index d6c228717..bc85bf649 100644 --- a/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj +++ b/roles/lib/files/FWO.Api.Client/FWO.Api.Client.csproj @@ -12,8 +12,6 @@ - - diff --git a/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj b/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj index 975e20ce2..48ceb7666 100644 --- a/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj +++ b/roles/lib/files/FWO.Config.Api/FWO.Config.Api.csproj @@ -6,12 +6,6 @@ enable - - - - - - diff --git a/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj b/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj index 4a4744bd0..e91cf1c52 100644 --- a/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj +++ b/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj @@ -7,8 +7,7 @@ - - + diff --git a/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj b/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj index 3070e164c..1fae62a98 100644 --- a/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj +++ b/roles/lib/files/FWO.DeviceAutoDiscovery/FWO.DeviceAutoDiscovery.csproj @@ -7,12 +7,9 @@ - - - diff --git a/roles/lib/files/FWO.Mail/FWO.Mail.csproj b/roles/lib/files/FWO.Mail/FWO.Mail.csproj index db9f8c234..fb15c291e 100644 --- a/roles/lib/files/FWO.Mail/FWO.Mail.csproj +++ b/roles/lib/files/FWO.Mail/FWO.Mail.csproj @@ -10,7 +10,6 @@ - diff --git a/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj b/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj index 943729499..128b4f529 100644 --- a/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj +++ b/roles/lib/files/FWO.Middleware.Client/FWO.Middleware.Client.csproj @@ -7,11 +7,9 @@ - - diff --git a/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj b/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj index fae898d8c..956c9ec84 100644 --- a/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj +++ b/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj @@ -7,8 +7,7 @@ - - + diff --git a/roles/lib/files/FWO.Recert/FWO.Recert.csproj b/roles/lib/files/FWO.Recert/FWO.Recert.csproj index 4fb47bdc6..357ae3b17 100644 --- a/roles/lib/files/FWO.Recert/FWO.Recert.csproj +++ b/roles/lib/files/FWO.Recert/FWO.Recert.csproj @@ -6,11 +6,6 @@ enable - - - - - diff --git a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj index 8084dd29b..45880d106 100644 --- a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj +++ b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj @@ -7,10 +7,9 @@ - - - - + + true + diff --git a/roles/lib/files/FWO.Report/FWO.Report.csproj b/roles/lib/files/FWO.Report/FWO.Report.csproj index b38fe5673..7cbc12e1d 100644 --- a/roles/lib/files/FWO.Report/FWO.Report.csproj +++ b/roles/lib/files/FWO.Report/FWO.Report.csproj @@ -8,9 +8,6 @@ - - - diff --git a/roles/lib/files/FWO.Services/FWO.Services.csproj b/roles/lib/files/FWO.Services/FWO.Services.csproj index 37d647a46..a9cc59a9b 100644 --- a/roles/lib/files/FWO.Services/FWO.Services.csproj +++ b/roles/lib/files/FWO.Services/FWO.Services.csproj @@ -8,9 +8,6 @@ - - - @@ -18,7 +15,9 @@ - + + true + diff --git a/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj b/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj index f9854f636..f2f550d58 100644 --- a/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj +++ b/roles/lib/files/FWO.Tufin.SecureChange/FWO.Tufin.SecureChange.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -7,12 +7,9 @@ - - - diff --git a/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj b/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj index 6e01de38e..517d6a642 100644 --- a/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj +++ b/roles/middleware/files/FWO.Middleware.Server/FWO.Middleware.Server.csproj @@ -9,11 +9,8 @@ - - - - + diff --git a/roles/test/files/FWO.Test/FWO.Test.csproj b/roles/test/files/FWO.Test/FWO.Test.csproj index eb1f7812b..58e1b3faa 100644 --- a/roles/test/files/FWO.Test/FWO.Test.csproj +++ b/roles/test/files/FWO.Test/FWO.Test.csproj @@ -8,13 +8,15 @@ - + + true + - - - - + + + true + diff --git a/roles/ui/files/FWO.UI/FWO.Ui.csproj b/roles/ui/files/FWO.UI/FWO.Ui.csproj index a05c68171..8f544981d 100644 --- a/roles/ui/files/FWO.UI/FWO.Ui.csproj +++ b/roles/ui/files/FWO.UI/FWO.Ui.csproj @@ -7,11 +7,10 @@ - + + true + - - - From fe33b1e5473f5ab936eccbd144e0930df402ca0b Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Tue, 10 Dec 2024 13:42:59 +0100 Subject: [PATCH 09/17] Revert "[~] Null check for ip1 parameter" This reverts commit ccd9394f98c44b303f593df0b3a900113fa4b0eb. --- .../files/FWO.Api.Client/Data/DisplayBase.cs | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs index 1a73628a5..cf13837d9 100644 --- a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs +++ b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs @@ -10,7 +10,7 @@ public static class DisplayBase { public static StringBuilder DisplayService(NetworkService service, bool isTechReport, string? serviceName = null) { - StringBuilder result = new(); + StringBuilder result = new (); string ports = service.DestinationPortEnd == null || service.DestinationPortEnd == 0 || service.DestinationPort == service.DestinationPortEnd ? $"{service.DestinationPort}" : $"{service.DestinationPort}-{service.DestinationPortEnd}"; if (isTechReport) @@ -62,24 +62,24 @@ public static List CustomSortProtocols(List ListIn) { List ListOut = []; IpProtocol? tcp = ListIn.Find(x => x.Name.ToLower() == "tcp"); - if (tcp != null) + if(tcp != null) { ListOut.Add(tcp); ListIn.Remove(tcp); } IpProtocol? udp = ListIn.Find(x => x.Name.ToLower() == "udp"); - if (udp != null) + if(udp != null) { ListOut.Add(udp); ListIn.Remove(udp); } IpProtocol? icmp = ListIn.Find(x => x.Name.ToLower() == "icmp"); - if (icmp != null) + if(icmp != null) { ListOut.Add(icmp); ListIn.Remove(icmp); } - foreach (var proto in ListIn.OrderBy(x => x.Name).ToList()) + foreach(var proto in ListIn.OrderBy(x => x.Name).ToList()) { if (proto.Name.ToLower() != "unassigned") { @@ -91,7 +91,7 @@ public static List CustomSortProtocols(List ListIn) public static string DisplayIpWithName(NetworkObject elem) { - if (elem.Name != null && elem.Name != "") + if(elem.Name != null && elem.Name != "") { return elem.Name + DisplayIp(elem.IP, elem.IpEnd, true); } @@ -109,7 +109,7 @@ public static string DisplayIp(string ip1, string ip2, bool inBrackets = false) string nwObjType = AutoDetectType(ip1, ip2); return DisplayIp(ip1, ip2, nwObjType, inBrackets); } - catch (Exception exc) + catch(Exception exc) { Log.WriteError("Ip displaying", $"Exception thrown: {exc.Message}"); return ""; @@ -121,17 +121,7 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in string result = ""; if (nwObjType != ObjectType.Group) { - - if (string.IsNullOrEmpty(ip2)) - { - ip2 = ip1; - } - - if (string.IsNullOrEmpty(ip1)) - { - Log.WriteDebug("Ip displaying", $"Parameter {nameof(ip1)} is empty."); - } - else if (!IsV4Address(ip1) && !IsV6Address(ip1)) + if (!IsV4Address(ip1) && !IsV6Address(ip1)) { Log.WriteError("Ip displaying", $"Found undefined IP family: {ip1} - {ip2}"); } @@ -141,6 +131,10 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in } else { + if (ip2 == "") + { + ip2 = ip1; + } string IpStart = StripOffUnnecessaryNetmask(ip1); string IpEnd = StripOffUnnecessaryNetmask(ip2); @@ -149,9 +143,9 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in result = inBrackets ? " (" : ""; if (nwObjType == ObjectType.Network) { - if (GetNetmask(IpStart) == "") + if(GetNetmask(IpStart) == "") { - IPAddressRange ipRange = new(IPAddress.Parse(IpStart), IPAddress.Parse(IpEnd)); + IPAddressRange ipRange = new (IPAddress.Parse(IpStart), IPAddress.Parse(IpEnd)); if (ipRange != null) { result += ipRange.ToCidrString(); @@ -246,7 +240,7 @@ public static string GetNetmask(string ip) int pos = ip.LastIndexOf('/'); if (pos > -1 && ip.Length > pos + 1) { - return ip[( pos + 1 )..]; + return ip[(pos + 1)..]; } return ""; } @@ -294,7 +288,7 @@ public static string AutoDetectType(string ip1, string ip2) if (ip1 == ip2 || ip2 == "") { string netmask = GetNetmask(ip1); - if (netmask != "") + if(netmask != "") { return ObjectType.Network; } From bbaf32f010a4f1f79a0198ba9c6f45e24fc064e1 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Tue, 10 Dec 2024 13:55:58 +0100 Subject: [PATCH 10/17] [~] null check ip1 parameter #2698 --- .../files/FWO.Api.Client/Data/DisplayBase.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs index cf13837d9..5512310b2 100644 --- a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs +++ b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs @@ -121,6 +121,17 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in string result = ""; if (nwObjType != ObjectType.Group) { + + if (string.IsNullOrEmpty(ip2)) + { + ip2 = ip1; + } + + if (string.IsNullOrEmpty(ip1)) + { + Log.WriteDebug("Ip displaying", $"Parameter {nameof(ip1)} is empty."); + } + if (!IsV4Address(ip1) && !IsV6Address(ip1)) { Log.WriteError("Ip displaying", $"Found undefined IP family: {ip1} - {ip2}"); @@ -130,11 +141,7 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in Log.WriteError("Ip displaying", $"Found mixed IP family: {ip1} - {ip2}"); } else - { - if (ip2 == "") - { - ip2 = ip1; - } + { string IpStart = StripOffUnnecessaryNetmask(ip1); string IpEnd = StripOffUnnecessaryNetmask(ip2); From 6f0a21dad27bd0dbbbddca971a7fbc93fcd0a6c6 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Wed, 11 Dec 2024 08:53:27 +0100 Subject: [PATCH 11/17] [~] If statement typo #2698 --- roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs index 5512310b2..4806a6d28 100644 --- a/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs +++ b/roles/lib/files/FWO.Api.Client/Data/DisplayBase.cs @@ -129,10 +129,8 @@ public static string DisplayIp(string ip1, string ip2, string nwObjType, bool in if (string.IsNullOrEmpty(ip1)) { - Log.WriteDebug("Ip displaying", $"Parameter {nameof(ip1)} is empty."); - } - - if (!IsV4Address(ip1) && !IsV6Address(ip1)) + Log.WriteDebug("Ip displaying", $"Nessessary parameter {nameof(ip1)} is empty."); + }else if (!IsV4Address(ip1) && !IsV6Address(ip1)) { Log.WriteError("Ip displaying", $"Found undefined IP family: {ip1} - {ip2}"); } From f6a0adeda804182f4656762b3ec47eb3496a00f8 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Wed, 11 Dec 2024 11:46:43 +0100 Subject: [PATCH 12/17] [~] Fix AZ unit test --- .../FWO.Services/ModellingVarianceAnalysis.cs | 12 +- .../FWO.Test/ModellingVarianceAnalysisTest.cs | 111 +++++++++--------- .../ModellingVarianceAnalysisTestApiConn.cs | 2 +- .../RequestFwChangePopup.razor | 2 +- 4 files changed, 58 insertions(+), 69 deletions(-) diff --git a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs index bfa6d2cef..729441155 100644 --- a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs +++ b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs @@ -10,7 +10,7 @@ namespace FWO.Services public class ModellingVarianceAnalysis(ApiConnection apiConnection, ExtStateHandler extStateHandler, UserConfig userConfig, FwoOwner owner, Action displayMessageInUi) { private readonly ModellingNamingConvention namingConvention = System.Text.Json.JsonSerializer.Deserialize(userConfig.ModNamingConvention) ?? new(); - private readonly ModellingAppZoneHandler AppZoneHandler = new(apiConnection, userConfig, displayMessageInUi, owner); + private readonly ModellingAppZoneHandler AppZoneHandler = new(apiConnection, userConfig, owner, displayMessageInUi); private AppServerComparer appServerComparer = new(new()); private List managements = []; @@ -333,20 +333,15 @@ private bool NwGroupChanged(ModellingNwGroup nwGroup) private void RequestNewNwGroup(ModellingNwGroup nwGroup, Management mgt) { string title = ""; - string additionalInfoKeys = ""; string groupName = ""; if (nwGroup.GetType() == typeof(ModellingAppRole)) { title = userConfig.GetText("new_app_role"); - additionalInfoKeys = AdditionalInfoKeys.AppRoleId; - groupName = app.IdString; } else if (nwGroup.GetType() == typeof(ModellingAppZone)) { title = userConfig.GetText("new_app_zone"); - additionalInfoKeys = AdditionalInfoKeys.AppZoneId; - groupName = app.Name; } List groupMembers = []; @@ -380,20 +375,15 @@ private void RequestNewNwGroup(ModellingNwGroup nwGroup, Management mgt) private void RequestUpdateNwGroup(ModellingNwGroup nwGroup, Management mgt) { string title = ""; - string additionalInfoKeys = ""; string groupName = ""; if (nwGroup.GetType() == typeof(ModellingAppRole)) { title = userConfig.GetText("update_app_role"); - additionalInfoKeys = AdditionalInfoKeys.AppRoleId; - groupName = app.IdString; } else if (nwGroup.GetType() == typeof(ModellingAppZone)) { title = userConfig.GetText("update_app_zone"); - additionalInfoKeys = AdditionalInfoKeys.AppZoneId; - groupName = app.Name; } FillGroupMembers(nwGroup.IdString, mgt); diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs index f1f2c1958..f7de07f4d 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs @@ -39,8 +39,6 @@ internal class ModellingVarianceAnalysisTest static readonly ModellingServiceGroup SvcGrp1 = new(){ Id = 1, Name = "SvcGrp1", Services = [ new(){ Content = Svc2 } ]}; - static readonly ModellingAppRole AZ1 = new() { Id = 1, Name = "AppZone1", IdString = "AZ4711", AppServers = [new() { Content = AS1 }, new() { Content = AS3 }] }; - static readonly ModellingConnection Connection1 = new() { Id = 1, @@ -68,56 +66,57 @@ public async Task TestAnalyseModelledConnections() List TaskList = await varianceAnalysis.AnalyseModelledConnections(Connections); ClassicAssert.AreEqual(5, TaskList.Count); + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[0].TaskType); - ClassicAssert.AreEqual("{\"GrpName\":\"AR504711-001\",\"AppRoleId\":\"1\"}", TaskList[0].AdditionalInfo); + ClassicAssert.AreEqual("{\"GrpName\":\"AZ4711\",\"AppRoleId\":\"3\"}", TaskList[0].AdditionalInfo); ClassicAssert.AreEqual("modify", TaskList[0].RequestAction); ClassicAssert.AreEqual(1, TaskList[0].TaskNumber); - ClassicAssert.AreEqual("Update AppRole: AR504711-001: Add Members", TaskList[0].Title); - ClassicAssert.AreEqual(1, TaskList[0].ManagementId); - ClassicAssert.AreEqual("Checkpoint1", TaskList[0].OnManagement?.Name); - ClassicAssert.AreEqual(3, TaskList[0].Elements.Count); - ClassicAssert.AreEqual("AppServerNew", TaskList[0].Elements[0].Name); - ClassicAssert.AreEqual("AR504711-001", TaskList[0].Elements[0].GroupName); - ClassicAssert.AreEqual("10.10.10.10", TaskList[0].Elements[0].IpString); - ClassicAssert.AreEqual("source", TaskList[0].Elements[0].Field); - ClassicAssert.AreEqual("create", TaskList[0].Elements[0].RequestAction); + ClassicAssert.AreEqual("Update AppZone: AZ4711: Add Members", TaskList[0].Title); + ClassicAssert.AreEqual(2, TaskList[0].Elements.Count); + ClassicAssert.AreEqual("AppServer2", TaskList[0].Elements[0].Name); ClassicAssert.AreEqual("AppServer1", TaskList[0].Elements[1].Name); - ClassicAssert.AreEqual("AR504711-001", TaskList[0].Elements[1].GroupName); - ClassicAssert.AreEqual("1.2.3.4", TaskList[0].Elements[1].IpString); - ClassicAssert.AreEqual("source", TaskList[0].Elements[1].Field); - ClassicAssert.AreEqual("unchanged", TaskList[0].Elements[1].RequestAction); - ClassicAssert.AreEqual("AppServer3", TaskList[0].Elements[2].Name); - ClassicAssert.AreEqual("AR504711-001", TaskList[0].Elements[2].GroupName); - ClassicAssert.AreEqual("1.2.4.0/24", TaskList[0].Elements[2].IpString); - ClassicAssert.AreEqual("source", TaskList[0].Elements[2].Field); - ClassicAssert.AreEqual("unchanged", TaskList[0].Elements[2].RequestAction); - - ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[1].TaskType); - ClassicAssert.AreEqual("{\"GrpName\":\"AR504711-002\",\"AppRoleId\":\"2\"}", TaskList[1].AdditionalInfo); - ClassicAssert.AreEqual("create", TaskList[1].RequestAction); + ClassicAssert.AreEqual("AZ4711", TaskList[0].Elements[0].GroupName); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[0].Elements[1].IpString); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[0].Elements[1].IpEnd); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[0].Elements[0].IpString); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[0].Elements[0].IpEnd); + ClassicAssert.AreEqual("source", TaskList[0].Elements[0].Field); + ClassicAssert.AreEqual("addAfterCreation", TaskList[0].Elements[0].RequestAction); + + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[1].TaskType); + ClassicAssert.AreEqual("{\"GrpName\":\"AR504711-001\",\"AppRoleId\":\"1\"}", TaskList[1].AdditionalInfo); + ClassicAssert.AreEqual("modify", TaskList[1].RequestAction); ClassicAssert.AreEqual(2, TaskList[1].TaskNumber); - ClassicAssert.AreEqual("New AppRole: AR504711-002", TaskList[1].Title); - ClassicAssert.AreEqual(1, TaskList[1].Elements.Count); - ClassicAssert.AreEqual("AppServer2", TaskList[1].Elements[0].Name); - ClassicAssert.AreEqual("AR504711-002", TaskList[1].Elements[0].GroupName); - ClassicAssert.AreEqual("1.2.3.5", TaskList[1].Elements[0].IpString); - ClassicAssert.AreEqual("1.2.3.10", TaskList[1].Elements[0].IpEnd); + ClassicAssert.AreEqual("Update AppRole: AR504711-001: Add Members", TaskList[1].Title); + ClassicAssert.AreEqual(1, TaskList[1].ManagementId); + ClassicAssert.AreEqual("Checkpoint1", TaskList[1].OnManagement?.Name); + ClassicAssert.AreEqual(3, TaskList[1].Elements.Count); + ClassicAssert.AreEqual("AppServerNew", TaskList[1].Elements[0].Name); + ClassicAssert.AreEqual("AR504711-001", TaskList[1].Elements[0].GroupName); + ClassicAssert.AreEqual("10.10.10.10", TaskList[1].Elements[0].IpString); ClassicAssert.AreEqual("source", TaskList[1].Elements[0].Field); - ClassicAssert.AreEqual("addAfterCreation", TaskList[1].Elements[0].RequestAction); + ClassicAssert.AreEqual("create", TaskList[1].Elements[0].RequestAction); + ClassicAssert.AreEqual("AppServer1", TaskList[1].Elements[1].Name); + ClassicAssert.AreEqual("AR504711-001", TaskList[1].Elements[1].GroupName); + ClassicAssert.AreEqual("1.2.3.4", TaskList[1].Elements[1].IpString); + ClassicAssert.AreEqual("source", TaskList[1].Elements[1].Field); + ClassicAssert.AreEqual("unchanged", TaskList[1].Elements[1].RequestAction); + ClassicAssert.AreEqual("AppServer3", TaskList[1].Elements[2].Name); + ClassicAssert.AreEqual("AR504711-001", TaskList[1].Elements[2].GroupName); + ClassicAssert.AreEqual("1.2.4.0/24", TaskList[1].Elements[2].IpString); + ClassicAssert.AreEqual("source", TaskList[1].Elements[2].Field); + ClassicAssert.AreEqual("unchanged", TaskList[1].Elements[2].RequestAction); - ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[2].TaskType); - ClassicAssert.AreEqual("{\"GrpName\":\"AZ4711\",\"AppZoneId\":\"3\"}", TaskList[2].AdditionalInfo); - ClassicAssert.AreEqual("modify", TaskList[2].RequestAction); + ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); + ClassicAssert.AreEqual("{\"GrpName\":\"AR504711-002\",\"AppRoleId\":\"2\"}", TaskList[2].AdditionalInfo); + ClassicAssert.AreEqual("create", TaskList[2].RequestAction); ClassicAssert.AreEqual(3, TaskList[2].TaskNumber); - ClassicAssert.AreEqual("Update AppZone: AZ4711: Add Members", TaskList[2].Title); - ClassicAssert.AreEqual(2, TaskList[2].Elements.Count); + ClassicAssert.AreEqual("New AppRole: AR504711-002", TaskList[2].Title); + ClassicAssert.AreEqual(1, TaskList[2].Elements.Count); ClassicAssert.AreEqual("AppServer2", TaskList[2].Elements[0].Name); - ClassicAssert.AreEqual("AppServer1", TaskList[2].Elements[1].Name); - ClassicAssert.AreEqual("AZ4711", TaskList[2].Elements[0].GroupName); - ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[1].IpString); - ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[1].IpEnd); - ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[0].IpString); - ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[0].IpEnd); + ClassicAssert.AreEqual("AR504711-002", TaskList[2].Elements[0].GroupName); + ClassicAssert.AreEqual("1.2.3.5", TaskList[2].Elements[0].IpString); + ClassicAssert.AreEqual("1.2.3.10", TaskList[2].Elements[0].IpEnd); ClassicAssert.AreEqual("source", TaskList[2].Elements[0].Field); ClassicAssert.AreEqual("addAfterCreation", TaskList[2].Elements[0].RequestAction); @@ -188,23 +187,23 @@ public async Task TestAnalyseModelledConnections() TaskList = await varianceAnalysis.AnalyseModelledConnections(Connections); ClassicAssert.AreEqual(6, TaskList.Count); ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[0].TaskType); - ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[1].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[1].TaskType); ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); - ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[3].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[3].TaskType); ClassicAssert.AreEqual(WfTaskType.access.ToString(), TaskList[4].TaskType); ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[5].TaskType); - ClassicAssert.AreEqual("{\"GrpName\":\"SvcGrp1\",\"SvcGrpId\":\"1\"}", TaskList[2].AdditionalInfo); - ClassicAssert.AreEqual("create", TaskList[2].RequestAction); - ClassicAssert.AreEqual(3, TaskList[2].TaskNumber); - ClassicAssert.AreEqual("New Servicegroup: SvcGrp1", TaskList[2].Title); - ClassicAssert.AreEqual(1, TaskList[2].Elements.Count); - ClassicAssert.AreEqual("Service2", TaskList[2].Elements[0].Name); - ClassicAssert.AreEqual("SvcGrp1", TaskList[2].Elements[0].GroupName); - ClassicAssert.AreEqual(6, TaskList[2].Elements[0].ProtoId); - ClassicAssert.AreEqual(4000, TaskList[2].Elements[0].Port); - ClassicAssert.AreEqual("service", TaskList[2].Elements[0].Field); - ClassicAssert.AreEqual("create", TaskList[2].Elements[0].RequestAction); + ClassicAssert.AreEqual("{\"GrpName\":\"SvcGrp1\",\"SvcGrpId\":\"1\"}", TaskList[3].AdditionalInfo); + ClassicAssert.AreEqual("create", TaskList[3].RequestAction); + ClassicAssert.AreEqual(4, TaskList[3].TaskNumber); + ClassicAssert.AreEqual("New Servicegroup: SvcGrp1", TaskList[3].Title); + ClassicAssert.AreEqual(1, TaskList[3].Elements.Count); + ClassicAssert.AreEqual("Service2", TaskList[3].Elements[0].Name); + ClassicAssert.AreEqual("SvcGrp1", TaskList[3].Elements[0].GroupName); + ClassicAssert.AreEqual(6, TaskList[3].Elements[0].ProtoId); + ClassicAssert.AreEqual(4000, TaskList[3].Elements[0].Port); + ClassicAssert.AreEqual("service", TaskList[3].Elements[0].Field); + ClassicAssert.AreEqual("create", TaskList[3].Elements[0].RequestAction); } } diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs index 0dcce1d8a..fda23cd9b 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs @@ -15,7 +15,7 @@ internal class ModellingVarianceAnalysisTestApiConn : SimulatedApiConnection static readonly ModellingAppServer AppServer1 = new() { Id = 13, Name = "AppServer1", Ip = "1.1.1.1/32", IpEnd = "1.1.1.1/32" }; static readonly ModellingAppServer AppServer2 = new() { Id = 14, Name = "AppServer2", Ip = "2.2.2.2/32", IpEnd = "2.2.2.2/32" }; static readonly NetworkObject AZProd = new() { Id = 2, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }] }; - static readonly ModellingAppZone AZExist = new() { Id = 3, Name = "AZ4711", AppServers = new() { new() { Content = AppServer1 }, new() { Content = AppServer2 } } }; + static readonly ModellingAppZone AZExist = new() { Id = 3, Name = "AZ4711", IdString = "AZ4711", AppServers = new() { new() { Content = AppServer1 }, new() { Content = AppServer2 } } }; public override async Task SendQueryAsync(string query, object? variables = null, string? operationName = null) { diff --git a/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor b/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor index a35690bfb..903e4b878 100644 --- a/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor +++ b/roles/ui/files/FWO.UI/Pages/NetworkModelling/RequestFwChangePopup.razor @@ -131,7 +131,7 @@ { if (!await GetActTicketStatus()) { - ModellingAppZoneHandler appZoneHandler = new(apiConnection, userConfig, DisplayMessageInUi, SelectedApp); + ModellingAppZoneHandler appZoneHandler = new(apiConnection, userConfig, SelectedApp, DisplayMessageInUi); await appZoneHandler.UpsertAppZone(); ModellingVarianceAnalysis varianceAnalysis = new(apiConnection, extStateHandler, userConfig, SelectedApp, DisplayMessageInUi); TaskList = await varianceAnalysis.AnalyseModelledConnections(Connections); From 39f4fa15e1855ff282b010027ba574f813277b08 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Wed, 11 Dec 2024 11:52:41 +0100 Subject: [PATCH 13/17] [-] Unused code --- roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs index 729441155..041f91404 100644 --- a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs +++ b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs @@ -333,7 +333,6 @@ private bool NwGroupChanged(ModellingNwGroup nwGroup) private void RequestNewNwGroup(ModellingNwGroup nwGroup, Management mgt) { string title = ""; - string groupName = ""; if (nwGroup.GetType() == typeof(ModellingAppRole)) { @@ -375,7 +374,6 @@ private void RequestNewNwGroup(ModellingNwGroup nwGroup, Management mgt) private void RequestUpdateNwGroup(ModellingNwGroup nwGroup, Management mgt) { string title = ""; - string groupName = ""; if (nwGroup.GetType() == typeof(ModellingAppRole)) { From 9f85e87f147bb3410c2fb363dee1d74058703f5d Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Wed, 11 Dec 2024 11:55:41 +0100 Subject: [PATCH 14/17] [-] Removed ModellingAppZoneHandlerTestApiCon because it's not needed --- .../ModellingAppZoneHandlerTestApiCon.cs | 57 ------------------- .../FWO.Test/ModellingVarianceAnalysisTest.cs | 2 - 2 files changed, 59 deletions(-) delete mode 100644 roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs diff --git a/roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs b/roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs deleted file mode 100644 index c41948570..000000000 --- a/roles/test/files/FWO.Test/ModellingAppZoneHandlerTestApiCon.cs +++ /dev/null @@ -1,57 +0,0 @@ -using FWO.Api.Client.Queries; -using FWO.Api.Data; -using FWO.Basics; -using GraphQL; - -namespace FWO.Test -{ - internal class ModellingAppZoneHandlerTestApiCon : SimulatedApiConnection - { - static readonly NetworkObject NwObj1 = new() { Id = 10, Name = "AppServer1", IP = "1.2.3.4", Type = new() { Name = ObjectType.Host } }; - static readonly NetworkObject NwObj2 = new() { Id = 11, Name = "AppServer2", IP = "1.2.3.5", IpEnd = "1.2.3.10", Type = new() { Name = ObjectType.IPRange } }; - static readonly NetworkObject NwObj3 = new() { Id = 12, Name = "AppServer3", IP = "1.2.4.0/24", Type = new() { Name = ObjectType.Network } }; - static readonly NetworkObject Nwgroup1 = new() { Id = 1, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj3 }] }; - - public override async Task SendQueryAsync(string query, object? variables = null, string? operationName = null) - { - Type responseType = typeof(QueryResponseType); - if (responseType == typeof(List)) - { - List? managements = - [ - new(){ Id = 1, Name = "Checkpoint1", ExtMgtData = "{\"id\":\"1\",\"name\":\"CheckpointExt\"}" } - ]; - GraphQLResponse response = new() { Data = managements }; - return response.Data; - } - else if (responseType == typeof(List)) - { - List? nwObjects = []; - if (query == ObjectQueries.getNetworkObjectsForManagement) - { - if (variables != null) - { - var objTypeIds = variables.GetType().GetProperties().First(o => o.Name == "objTypeIds").GetValue(variables, null); - if (( (int[])objTypeIds )[0] == 2) - { - nwObjects = - [ - Nwgroup1 - ]; - } - else - { - nwObjects = - [ - NwObj1, NwObj2, NwObj3 - ]; - } - } - } - GraphQLResponse response = new() { Data = nwObjects }; - return response.Data; - } - throw new NotImplementedException(); - } - } -} diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs index f7de07f4d..7137f0c70 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs @@ -19,10 +19,8 @@ internal class ModellingVarianceAnalysisTest }; static readonly ModellingVarianceAnalysisTestApiConn varianceAnalysisApiConnection = new(); static readonly ExtStateTestApiConn extStateApiConnection = new(); - static readonly ModellingAppZoneHandlerTestApiCon AppZoneHandlerTestApiCon = new(); readonly ExtStateHandler extStateHandler = new(extStateApiConnection); ModellingVarianceAnalysis varianceAnalysis; - ModellingAppZoneHandler AppZoneHandler; static readonly FwoOwner Application = new() { Id = 1, Name = "App1" }; From 55cac179b0d7e51ebcd4a76c7c9a79ea82a8ec0e Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Wed, 11 Dec 2024 16:24:52 +0100 Subject: [PATCH 15/17] [~] Bumps System.IdentityModel.Tokens.Jwt from 8.2.0 to 8.3.0. --- roles/lib/files/FWO.Config.File/FWO.Config.File.csproj | 2 +- roles/lib/files/FWO.Middleware/FWO.Middleware.csproj | 2 +- roles/test/files/FWO.Test/FWO.Test.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj b/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj index e91cf1c52..dad295e24 100644 --- a/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj +++ b/roles/lib/files/FWO.Config.File/FWO.Config.File.csproj @@ -7,7 +7,7 @@ - + diff --git a/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj b/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj index 956c9ec84..b5e19d0c0 100644 --- a/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj +++ b/roles/lib/files/FWO.Middleware/FWO.Middleware.csproj @@ -7,7 +7,7 @@ - + diff --git a/roles/test/files/FWO.Test/FWO.Test.csproj b/roles/test/files/FWO.Test/FWO.Test.csproj index 4e2de3475..af55387fc 100644 --- a/roles/test/files/FWO.Test/FWO.Test.csproj +++ b/roles/test/files/FWO.Test/FWO.Test.csproj @@ -14,7 +14,7 @@ - + true From 349e3accf4c2023ac1a09f1be3d9384c927bc9c4 Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Wed, 11 Dec 2024 17:06:38 +0100 Subject: [PATCH 16/17] [-] Remove 'treatAsUsed' from projects --- .../FWO.Report.Filter.csproj | 4 +- .../files/FWO.Services/FWO.Services.csproj | 34 ++++++------ roles/test/files/FWO.Test/FWO.Test.csproj | 8 +-- roles/ui/files/FWO.UI/FWO.Ui.csproj | 52 +++++++++---------- 4 files changed, 44 insertions(+), 54 deletions(-) diff --git a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj index 45880d106..4f7c2daab 100644 --- a/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj +++ b/roles/lib/files/FWO.Report.Filter/FWO.Report.Filter.csproj @@ -7,9 +7,7 @@ - - true - + diff --git a/roles/lib/files/FWO.Services/FWO.Services.csproj b/roles/lib/files/FWO.Services/FWO.Services.csproj index a9cc59a9b..edf68c9ff 100644 --- a/roles/lib/files/FWO.Services/FWO.Services.csproj +++ b/roles/lib/files/FWO.Services/FWO.Services.csproj @@ -1,24 +1,22 @@ - - net8.0 - enable - enable - + + net8.0 + enable + enable + - - - + + + - - - - - - - true - - - + + + + + + + + diff --git a/roles/test/files/FWO.Test/FWO.Test.csproj b/roles/test/files/FWO.Test/FWO.Test.csproj index af55387fc..07da59862 100644 --- a/roles/test/files/FWO.Test/FWO.Test.csproj +++ b/roles/test/files/FWO.Test/FWO.Test.csproj @@ -8,15 +8,11 @@ - - true - + - - true - + diff --git a/roles/ui/files/FWO.UI/FWO.Ui.csproj b/roles/ui/files/FWO.UI/FWO.Ui.csproj index 8f544981d..bbcd2b389 100644 --- a/roles/ui/files/FWO.UI/FWO.Ui.csproj +++ b/roles/ui/files/FWO.UI/FWO.Ui.csproj @@ -1,33 +1,31 @@  - - net8.0 - enable - enable - + + net8.0 + enable + enable + - - - true - - - + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file From d4c9bdeeed041d7492a233617578b02aa33c35ee Mon Sep 17 00:00:00 2001 From: "luca.weidmann@gmx.de" Date: Mon, 16 Dec 2024 12:10:34 +0100 Subject: [PATCH 17/17] [-] Removed AppZoneId variable(unused) --- roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs b/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs index b16552617..bb864f387 100644 --- a/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs +++ b/roles/lib/files/FWO.Api.Client/Data/WfReqTaskBase.cs @@ -20,7 +20,6 @@ public struct AdditionalInfoKeys public const string ExtIcketId = "ExtIcketId"; public const string AppRoleId = "AppRoleId"; public const string SvcGrpId = "SvcGrpId"; - public const string AppZoneId = "AppZoneId"; } public class WfReqTaskBase : WfTaskBase