diff --git a/Samples/SampleExtensions/ExtensionLibrary.cs b/Samples/SampleExtensions/ExtensionLibrary.cs index 0afe5834..bb003cc5 100644 --- a/Samples/SampleExtensions/ExtensionLibrary.cs +++ b/Samples/SampleExtensions/ExtensionLibrary.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Samples/SampleExtensions/SampleExtensions.csproj b/Samples/SampleExtensions/SampleExtensions.csproj index 7f20f789..6b50a824 100644 --- a/Samples/SampleExtensions/SampleExtensions.csproj +++ b/Samples/SampleExtensions/SampleExtensions.csproj @@ -75,20 +75,20 @@ - - ..\packages\ThreatsManager.AutoGenRules.2.1.1\lib\net481\ThreatsManager.AutoGenRules.dll + + ..\packages\ThreatsManager.AutoGenRules.2.1.2\lib\net481\ThreatsManager.AutoGenRules.dll - - ..\packages\ThreatsManager.AutoThreatGeneration.2.1.1\lib\net481\ThreatsManager.AutoThreatGeneration.dll + + ..\packages\ThreatsManager.AutoThreatGeneration.2.1.2\lib\net481\ThreatsManager.AutoThreatGeneration.dll - ..\packages\ThreatsManager.Utilities.2.1.1\lib\net481\ThreatsManager.Icons.dll + ..\packages\ThreatsManager.Utilities.2.1.2\lib\net481\ThreatsManager.Icons.dll - - ..\packages\ThreatsManager.Interfaces.2.1.1\lib\net481\ThreatsManager.Interfaces.dll + + ..\packages\ThreatsManager.Interfaces.2.1.2\lib\net481\ThreatsManager.Interfaces.dll - - ..\packages\ThreatsManager.Utilities.2.1.1\lib\net481\ThreatsManager.Utilities.dll + + ..\packages\ThreatsManager.Utilities.2.1.2\lib\net481\ThreatsManager.Utilities.dll diff --git a/Samples/SampleExtensions/packages.config b/Samples/SampleExtensions/packages.config index 9a65476a..78ed711b 100644 --- a/Samples/SampleExtensions/packages.config +++ b/Samples/SampleExtensions/packages.config @@ -10,8 +10,8 @@ - - - - + + + + \ No newline at end of file diff --git a/Samples/SampleWinFormExtensions/ExtensionLibrary.cs b/Samples/SampleWinFormExtensions/ExtensionLibrary.cs index 0afe5834..bb003cc5 100644 --- a/Samples/SampleWinFormExtensions/ExtensionLibrary.cs +++ b/Samples/SampleWinFormExtensions/ExtensionLibrary.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Samples/SampleWinFormExtensions/SampleWinFormExtensions.csproj b/Samples/SampleWinFormExtensions/SampleWinFormExtensions.csproj index 8d3d1b27..eb85078e 100644 --- a/Samples/SampleWinFormExtensions/SampleWinFormExtensions.csproj +++ b/Samples/SampleWinFormExtensions/SampleWinFormExtensions.csproj @@ -47,7 +47,7 @@ ..\packages\Fizzler.1.3.0\lib\netstandard2.0\Fizzler.dll - ..\packages\ThreatsManager.Utilities.WinForms.2.1.1\lib\net481\Keyoti.RapidSpell.NET4.dll + ..\packages\ThreatsManager.Utilities.WinForms.2.1.2\lib\net481\Keyoti.RapidSpell.NET4.dll @@ -106,23 +106,23 @@ - - ..\packages\ThreatsManager.Utilities.WinForms.2.1.1\lib\net481\ThreatsManager.AutoGenRules.dll + + ..\packages\ThreatsManager.Utilities.WinForms.2.1.2\lib\net481\ThreatsManager.AutoGenRules.dll - - ..\packages\ThreatsManager.Extensions.Client.2.1.1\lib\net481\ThreatsManager.Extensions.Client.dll + + ..\packages\ThreatsManager.Extensions.Client.2.1.2\lib\net481\ThreatsManager.Extensions.Client.dll - ..\packages\ThreatsManager.Utilities.2.1.1\lib\net481\ThreatsManager.Icons.dll + ..\packages\ThreatsManager.Utilities.2.1.2\lib\net481\ThreatsManager.Icons.dll - - ..\packages\ThreatsManager.Interfaces.2.1.1\lib\net481\ThreatsManager.Interfaces.dll + + ..\packages\ThreatsManager.Interfaces.2.1.2\lib\net481\ThreatsManager.Interfaces.dll - - ..\packages\ThreatsManager.Utilities.2.1.1\lib\net481\ThreatsManager.Utilities.dll + + ..\packages\ThreatsManager.Utilities.2.1.2\lib\net481\ThreatsManager.Utilities.dll - - ..\packages\ThreatsManager.Utilities.WinForms.2.1.1\lib\net481\ThreatsManager.Utilities.WinForms.dll + + ..\packages\ThreatsManager.Utilities.WinForms.2.1.2\lib\net481\ThreatsManager.Utilities.WinForms.dll diff --git a/Samples/SampleWinFormExtensions/packages.config b/Samples/SampleWinFormExtensions/packages.config index 41f6a3ca..bfd291ca 100644 --- a/Samples/SampleWinFormExtensions/packages.config +++ b/Samples/SampleWinFormExtensions/packages.config @@ -18,8 +18,8 @@ - - - - + + + + \ No newline at end of file diff --git a/Samples/SimpleThreatModelAnalyzer/ExtensionLibrary.cs b/Samples/SimpleThreatModelAnalyzer/ExtensionLibrary.cs index 0afe5834..bb003cc5 100644 --- a/Samples/SimpleThreatModelAnalyzer/ExtensionLibrary.cs +++ b/Samples/SimpleThreatModelAnalyzer/ExtensionLibrary.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Samples/SimpleThreatModelAnalyzer/SimpleThreatModelAnalyzer.csproj b/Samples/SimpleThreatModelAnalyzer/SimpleThreatModelAnalyzer.csproj index c6b7e9b2..854dd62c 100644 --- a/Samples/SimpleThreatModelAnalyzer/SimpleThreatModelAnalyzer.csproj +++ b/Samples/SimpleThreatModelAnalyzer/SimpleThreatModelAnalyzer.csproj @@ -93,17 +93,17 @@ - - ..\packages\ThreatsManager.Engine.2.1.1\lib\net481\ThreatsManager.Engine.dll + + ..\packages\ThreatsManager.Engine.2.1.2\lib\net481\ThreatsManager.Engine.dll - ..\packages\ThreatsManager.Utilities.2.1.1\lib\net481\ThreatsManager.Icons.dll + ..\packages\ThreatsManager.Utilities.2.1.2\lib\net481\ThreatsManager.Icons.dll - - ..\packages\ThreatsManager.Interfaces.2.1.1\lib\net481\ThreatsManager.Interfaces.dll + + ..\packages\ThreatsManager.Interfaces.2.1.2\lib\net481\ThreatsManager.Interfaces.dll - - ..\packages\ThreatsManager.Utilities.2.1.1\lib\net481\ThreatsManager.Utilities.dll + + ..\packages\ThreatsManager.Utilities.2.1.2\lib\net481\ThreatsManager.Utilities.dll diff --git a/Samples/SimpleThreatModelAnalyzer/packages.config b/Samples/SimpleThreatModelAnalyzer/packages.config index 9c2042f1..37f6ee69 100644 --- a/Samples/SimpleThreatModelAnalyzer/packages.config +++ b/Samples/SimpleThreatModelAnalyzer/packages.config @@ -15,7 +15,7 @@ - - - + + + \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.AutoGenRules/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.AutoGenRules/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.AutoGenRules/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.AutoGenRules/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.AutoGenRules/ThreatsManager.AutoGenRules.csproj b/Sources/Extensions/ThreatsManager.AutoGenRules/ThreatsManager.AutoGenRules.csproj index d79c1a24..ccdeca39 100644 --- a/Sources/Extensions/ThreatsManager.AutoGenRules/ThreatsManager.AutoGenRules.csproj +++ b/Sources/Extensions/ThreatsManager.AutoGenRules/ThreatsManager.AutoGenRules.csproj @@ -2,15 +2,15 @@ net481 Threats Manager Platform Auto Generation Rules library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ThreatsManager.AutoThreatGeneration.csproj b/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ThreatsManager.AutoThreatGeneration.csproj index e4d45afa..b9a59a9a 100644 --- a/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ThreatsManager.AutoThreatGeneration.csproj +++ b/Sources/Extensions/ThreatsManager.AutoThreatGeneration/ThreatsManager.AutoThreatGeneration.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform Auto Threat Generation library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/Extensions/ThreatsManager.DevOps/DevOpsManager.cs b/Sources/Extensions/ThreatsManager.DevOps/DevOpsManager.cs index 1bf1cc7a..e2cb4a46 100644 --- a/Sources/Extensions/ThreatsManager.DevOps/DevOpsManager.cs +++ b/Sources/Extensions/ThreatsManager.DevOps/DevOpsManager.cs @@ -6,16 +6,13 @@ using ThreatsManager.DevOps.Schemas; using ThreatsManager.Interfaces.ObjectModel; using ThreatsManager.Interfaces.ObjectModel.ThreatsMitigations; +using ThreatsManager.Utilities; namespace ThreatsManager.DevOps { public static class DevOpsManager { #region Private member variables. - private static int _intervalMins; - private static Task _updater; - private static bool _stopUpdater; - private static NotificationType _notificationType; private static readonly Dictionary _connectors = new Dictionary(); #endregion @@ -71,13 +68,13 @@ public static IDevOpsConnector GetConnector([NotNull] IThreatModel model) return result; } - public static async Task UpdateAsync([NotNull] IThreatModel model) + public static int Update([NotNull] IThreatModel model) { int result = 0; if (_connectors.TryGetValue(model.Id, out var connector) && (connector?.IsConnected() ?? false)) { - result = await UpdateMitigationsAsync(model, connector); + result = UpdateMitigations(model, connector); } return result; @@ -111,7 +108,7 @@ public static IDictionary GetMitigationsSummary([N return result; } - public static async Task SetMitigationsStatusAsync([NotNull] IMitigation mitigation, WorkItemStatus status) + public static bool SetMitigationsStatus([NotNull] IMitigation mitigation, WorkItemStatus status) { bool result = false; @@ -122,13 +119,13 @@ public static async Task SetMitigationsStatusAsync([NotNull] IMitigation m var connector = GetConnector(model); if (connector?.IsConnected() ?? false) { - var workItemInfo = await connector.GetWorkItemInfoAsync(mitigation).ConfigureAwait(false); + var workItemInfo = connector.GetWorkItemInfoAsync(mitigation).Result; int id; if (workItemInfo == null) { - id = await connector.CreateWorkItemAsync(mitigation).ConfigureAwait(false); + id = connector.CreateWorkItemAsync(mitigation).Result; if (id >= 0) - workItemInfo = await connector.GetWorkItemInfoAsync(id).ConfigureAwait(false); + workItemInfo = connector.GetWorkItemInfoAsync(id).Result; } else { @@ -137,10 +134,14 @@ public static async Task SetMitigationsStatusAsync([NotNull] IMitigation m if (id >= 0) { - if (await connector.SetWorkItemStateAsync(id, status).ConfigureAwait(false)) + if (connector.SetWorkItemStateAsync(id, status).Result) { - var schemaManager = new DevOpsPropertySchemaManager(model); - schemaManager.SetDevOpsStatus(mitigation, connector, id, workItemInfo?.Url, status); + using (var scope = UndoRedoManager.OpenScope("Set DevOps Mitigation status")) + { + var schemaManager = new DevOpsPropertySchemaManager(model); + schemaManager.SetDevOpsStatus(mitigation, connector, id, workItemInfo?.Url, status); + scope?.Complete(); + } result = true; } else @@ -159,27 +160,7 @@ public static async Task SetMitigationsStatusAsync([NotNull] IMitigation m return result; } - public static void StartAutomaticUpdater([NotNull] IThreatModel model, [Range(1, 120)] int intervalMins, NotificationType notificationType) - { - _stopUpdater = false; - _intervalMins = intervalMins; - _notificationType = notificationType; - - if (_updater == null) - { -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - _updater = AutomaticUpdater(model); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - } - } - - public static bool StopAutomaticUpdater() - { - _stopUpdater = true; - return _updater?.Wait(3000) ?? true; - } - - private static async Task UpdateMitigationsAsync([NotNull] IThreatModel model, [NotNull] IDevOpsConnector connector) + private static int UpdateMitigations([NotNull] IThreatModel model, [NotNull] IDevOpsConnector connector) { int result = 0; @@ -190,95 +171,79 @@ private static async Task UpdateMitigationsAsync([NotNull] IThreatModel mod .ToArray(); if (mitigations?.Any() ?? false) { - var infos = await connector + var infos = connector .GetWorkItemsInfoAsync(mitigations .Select(x => x.Value?.Id ?? -1) .Where(x => x >= 0) - ); + ).Result; - if (infos != null) + using (var scope = UndoRedoManager.OpenScope("Update Mitigations from DevOps")) { - foreach (var info in infos) + if (infos != null) { - var pairs = mitigations - .Where(x => x.Value != null && x.Value.Id == info.Id) - .ToArray(); - - if (pairs.Any()) + foreach (var info in infos) { - var pair = pairs.FirstOrDefault(); + var pairs = mitigations + .Where(x => x.Value != null && x.Value.Id == info.Id) + .ToArray(); - if (pair.Value.Status != info.Status || - string.CompareOrdinal(pair.Value.AssignedTo, info.AssignedTo) != 0) + if (pairs.Any()) { - schemaManager.SetDevOpsStatus(pair.Key, connector, info.Id, info.Url, info.Status, info.AssignedTo); - result++; - } + var pair = pairs.FirstOrDefault(); - MitigationStatus status; - switch (info.Status) - { - case WorkItemStatus.Created: - status = MitigationStatus.Approved; - break; - case WorkItemStatus.Planned: - status = MitigationStatus.Planned; - break; - case WorkItemStatus.InProgress: - status = MitigationStatus.Planned; - break; - case WorkItemStatus.Done: - status = MitigationStatus.Implemented; - break; - default: - status = MitigationStatus.Proposed; - break; - } + if (pair.Value.Status != info.Status || + string.CompareOrdinal(pair.Value.AssignedTo, info.AssignedTo) != 0) + { + schemaManager.SetDevOpsStatus(pair.Key, connector, info.Id, info.Url, info.Status, info.AssignedTo); + result++; + } - var tems = model.GetThreatEventMitigations(pair.Key); - if (tems?.Any() ?? false) - { - foreach (var tem in tems) + MitigationStatus status; + switch (info.Status) { - if (tem.Status != status) - tem.Status = status; + case WorkItemStatus.Created: + status = MitigationStatus.Approved; + break; + case WorkItemStatus.Planned: + status = MitigationStatus.Planned; + break; + case WorkItemStatus.InProgress: + status = MitigationStatus.Planned; + break; + case WorkItemStatus.Done: + status = MitigationStatus.Implemented; + break; + default: + status = MitigationStatus.Proposed; + break; + } + + var tems = model.GetThreatEventMitigations(pair.Key); + if (tems?.Any() ?? false) + { + foreach (var tem in tems) + { + if (tem.Status != status) + tem.Status = status; + } } } } } - } - var missing = mitigations.Where(x => x.Value != null && (infos?.All(y => y.Id != x.Value.Id) ?? true)).ToArray(); - if (missing.Any()) - { - foreach (var m in missing) - schemaManager.RemoveDevOpsInfos(m.Key); - } - } - - return result; - } - - private static async Task AutomaticUpdater([NotNull] IThreatModel model) - { - if (_intervalMins > 0 && _intervalMins <= 120) - { - do - { - var connector = GetConnector(model); - if (connector != null) + var missing = mitigations.Where(x => x.Value != null && (infos?.All(y => y.Id != x.Value.Id) ?? true)).ToArray(); + if (missing.Any()) { - var changes = await UpdateAsync(model); - if (_notificationType == NotificationType.Full || - (_notificationType == NotificationType.SuccessOnly && changes > 0)) - RefreshDone?.Invoke(model, changes); + foreach (var m in missing) + schemaManager.RemoveDevOpsInfos(m.Key); } - await Task.Delay(_intervalMins * 60000); - } while (!_stopUpdater); - _updater = null; + scope?.Complete(); + } } + + return result; } } } diff --git a/Sources/Extensions/ThreatsManager.DevOps/Engines/AzureDevOps.cs b/Sources/Extensions/ThreatsManager.DevOps/Engines/AzureDevOps.cs index 9b9f87f6..0e8a85f4 100644 --- a/Sources/Extensions/ThreatsManager.DevOps/Engines/AzureDevOps.cs +++ b/Sources/Extensions/ThreatsManager.DevOps/Engines/AzureDevOps.cs @@ -660,7 +660,6 @@ public async Task> GetWorkItemCommentsAsync(int id) return result; } - #endregion #region Auxiliary methods. diff --git a/Sources/Extensions/ThreatsManager.DevOps/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.DevOps/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.DevOps/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.DevOps/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.DevOps/IDevOpsConnector.cs b/Sources/Extensions/ThreatsManager.DevOps/IDevOpsConnector.cs index b652c34a..5c62b00d 100644 --- a/Sources/Extensions/ThreatsManager.DevOps/IDevOpsConnector.cs +++ b/Sources/Extensions/ThreatsManager.DevOps/IDevOpsConnector.cs @@ -46,7 +46,6 @@ public interface IDevOpsConnector /// /// Gets the projects associated to the current connection. /// - /// /// List of Projects that the user can connect to. Task> GetProjectsAsync(); diff --git a/Sources/Extensions/ThreatsManager.DevOps/NotificationType.cs b/Sources/Extensions/ThreatsManager.DevOps/NotificationType.cs deleted file mode 100644 index 63fe3898..00000000 --- a/Sources/Extensions/ThreatsManager.DevOps/NotificationType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ThreatsManager.DevOps -{ - public enum NotificationType - { - None, - SuccessOnly, - Full - } -} diff --git a/Sources/Extensions/ThreatsManager.DevOps/ThreatsManager.DevOps.csproj b/Sources/Extensions/ThreatsManager.DevOps/ThreatsManager.DevOps.csproj index 1765b632..fbcc5faf 100644 --- a/Sources/Extensions/ThreatsManager.DevOps/ThreatsManager.DevOps.csproj +++ b/Sources/Extensions/ThreatsManager.DevOps/ThreatsManager.DevOps.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform DevOps Integration library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/Extensions/ThreatsManager.Extensions.Client/Diagrams/PaletteItem.cs b/Sources/Extensions/ThreatsManager.Extensions.Client/Diagrams/PaletteItem.cs index f1e8724e..e02f1ca6 100644 --- a/Sources/Extensions/ThreatsManager.Extensions.Client/Diagrams/PaletteItem.cs +++ b/Sources/Extensions/ThreatsManager.Extensions.Client/Diagrams/PaletteItem.cs @@ -20,8 +20,11 @@ public abstract class PaletteItem /// Constructor. /// /// Name of the item. - public PaletteItem([Required] string name) + public PaletteItem(string name) { + if (string.IsNullOrWhiteSpace(name)) + name = ""; + Name = name; } diff --git a/Sources/Extensions/ThreatsManager.Extensions.Client/ThreatsManager.Extensions.Client.csproj b/Sources/Extensions/ThreatsManager.Extensions.Client/ThreatsManager.Extensions.Client.csproj index b4d5888a..a1b7b412 100644 --- a/Sources/Extensions/ThreatsManager.Extensions.Client/ThreatsManager.Extensions.Client.csproj +++ b/Sources/Extensions/ThreatsManager.Extensions.Client/ThreatsManager.Extensions.Client.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform Extensions Client library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk ThreatsManager.Extensions diff --git a/Sources/Extensions/ThreatsManager.Extensions/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.Extensions/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.Extensions/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.Extensions/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.Extensions/ThreatsManager.Extensions.csproj b/Sources/Extensions/ThreatsManager.Extensions/ThreatsManager.Extensions.csproj index 3b1d0cd6..785556b9 100644 --- a/Sources/Extensions/ThreatsManager.Extensions/ThreatsManager.Extensions.csproj +++ b/Sources/Extensions/ThreatsManager.Extensions/ThreatsManager.Extensions.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform Extensions library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/Extensions/ThreatsManager.Mitre/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.Mitre/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.Mitre/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.Mitre/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.Mitre/ThreatsManager.Mitre.csproj b/Sources/Extensions/ThreatsManager.Mitre/ThreatsManager.Mitre.csproj index 3b2194cd..26672f12 100644 --- a/Sources/Extensions/ThreatsManager.Mitre/ThreatsManager.Mitre.csproj +++ b/Sources/Extensions/ThreatsManager.Mitre/ThreatsManager.Mitre.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform MITRE Extensions library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/Extensions/ThreatsManager.MsTmt/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.MsTmt/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.MsTmt/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.MsTmt/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.MsTmt/Model/ThreatModel.Load.cs b/Sources/Extensions/ThreatsManager.MsTmt/Model/ThreatModel.Load.cs index 88c4fa1c..14834be4 100644 --- a/Sources/Extensions/ThreatsManager.MsTmt/Model/ThreatModel.Load.cs +++ b/Sources/Extensions/ThreatsManager.MsTmt/Model/ThreatModel.Load.cs @@ -95,6 +95,10 @@ private void GetEntityTypes(bool isTemplate, bool isGeneric, IEnumerable net481 Threats Manager Platform Microsoft Threat Modeling Tool Import library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505;CS3021 diff --git a/Sources/Extensions/ThreatsManager.PackageManagers/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.PackageManagers/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.PackageManagers/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.PackageManagers/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.PackageManagers/ThreatsManager.PackageManagers.csproj b/Sources/Extensions/ThreatsManager.PackageManagers/ThreatsManager.PackageManagers.csproj index 3588fa64..7c222968 100644 --- a/Sources/Extensions/ThreatsManager.PackageManagers/ThreatsManager.PackageManagers.csproj +++ b/Sources/Extensions/ThreatsManager.PackageManagers/ThreatsManager.PackageManagers.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform Package Managers library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/Extensions/ThreatsManager.Quality/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.Quality/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.Quality/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.Quality/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.Quality/ThreatsManager.Quality.csproj b/Sources/Extensions/ThreatsManager.Quality/ThreatsManager.Quality.csproj index 5a360abb..16437df4 100644 --- a/Sources/Extensions/ThreatsManager.Quality/ThreatsManager.Quality.csproj +++ b/Sources/Extensions/ThreatsManager.Quality/ThreatsManager.Quality.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform Quality library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/Extensions/ThreatsManager.QuantitativeRisk/ExtensionsContainer.cs b/Sources/Extensions/ThreatsManager.QuantitativeRisk/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Sources/Extensions/ThreatsManager.QuantitativeRisk/ExtensionsContainer.cs +++ b/Sources/Extensions/ThreatsManager.QuantitativeRisk/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Sources/Extensions/ThreatsManager.QuantitativeRisk/ThreatsManager.QuantitativeRisk.csproj b/Sources/Extensions/ThreatsManager.QuantitativeRisk/ThreatsManager.QuantitativeRisk.csproj index 18ed7f7e..c65c2d96 100644 --- a/Sources/Extensions/ThreatsManager.QuantitativeRisk/ThreatsManager.QuantitativeRisk.csproj +++ b/Sources/Extensions/ThreatsManager.QuantitativeRisk/ThreatsManager.QuantitativeRisk.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform Quantitative Risk Extensions library. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ..\..\ThreatsManager.Engine\ThreatsManager.snk $(NoWarn);NU1505 diff --git a/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json b/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json index a0d68829..3357a648 100644 --- a/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json +++ b/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json @@ -2,8 +2,8 @@ "files": [], "packages": [ { - "name": "System.Drawing.Common", - "SPDXID": "SPDXRef-Package-1E3F0DE5419CF41CE7DA18907406D8618A23E73477CED8A0A5B96FABC4B00C8E", + "name": "PostSharp", + "SPDXID": "SPDXRef-Package-4144998C3036BFEC1FEA421C96CDE225AB66255248559821A06971479C33432D", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -12,12 +12,12 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "7.0.0", + "versionInfo": "2023.0.8", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.Drawing.Common%407.0.0" + "referenceLocator": "pkg:nuget/PostSharp%402023.0.8" } ], "supplier": "NOASSERTION" @@ -44,8 +44,8 @@ "supplier": "NOASSERTION" }, { - "name": "PostSharp.Redist", - "SPDXID": "SPDXRef-Package-BCFE9DA1E7CC86449FBC297FD5E46DE5F25F81F44FDCF934D81AE16272872CDE", + "name": "Newtonsoft.Json", + "SPDXID": "SPDXRef-Package-B886264C88915A93892AFBE3D28CD5B3C8B7990F0C6A47AD506184440C46436E", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -54,19 +54,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "2023.0.8", + "versionInfo": "13.0.3", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/PostSharp.Redist%402023.0.8" + "referenceLocator": "pkg:nuget/Newtonsoft.Json%4013.0.3" } ], "supplier": "NOASSERTION" }, { - "name": "HtmlAgilityPack", - "SPDXID": "SPDXRef-Package-C55EFD6CE543D43B7F9795E55B6CA46123F1759CF0A19BCC538E7160163FADA0", + "name": "Microsoft.AspNet.WebApi.Client", + "SPDXID": "SPDXRef-Package-FB8EF87A04ABBDDE238C1B9302C41D39A089FDC8A755C4F352B2784CD890726B", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -75,19 +75,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "1.11.52", + "versionInfo": "5.2.7", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/HtmlAgilityPack%401.11.52" + "referenceLocator": "pkg:nuget/Microsoft.AspNet.WebApi.Client%405.2.7" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.IdentityModel.Logging", - "SPDXID": "SPDXRef-Package-7586D09A8638B087A9EAF8CB69F57344F906C42E0170B08E6D77EAB745F30092", + "name": "Microsoft.TeamFoundation.DistributedTask.Common.Contracts", + "SPDXID": "SPDXRef-Package-2D9FB638C8BBE3526B66E56E9B7C7A9977FB3A4A298A0B4BE68ACAEE7A19289E", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -96,19 +96,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "5.6.0", + "versionInfo": "16.205.1", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.Logging%405.6.0" + "referenceLocator": "pkg:nuget/Microsoft.TeamFoundation.DistributedTask.Common.Contracts%4016.205.1" } ], "supplier": "NOASSERTION" }, { - "name": "PostSharp.Patterns.Aggregation", - "SPDXID": "SPDXRef-Package-645F4B71D4113C3DCFFBDD2B605CA3CA6803A4C69C4EA4F556B87089D1A90CCE", + "name": "System.Memory", + "SPDXID": "SPDXRef-Package-BA5D8D1B5043A468B09DDBF48DCFC7DDD44949EE05A23A14F02AE8AA5183745C", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -117,19 +117,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "2023.0.8", + "versionInfo": "4.5.4", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/PostSharp.Patterns.Aggregation%402023.0.8" + "referenceLocator": "pkg:nuget/System.Memory%404.5.4" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.IdentityModel.JsonWebTokens", - "SPDXID": "SPDXRef-Package-0C8546CE2314CF899D167AFF76F9BD8A06486145BF8140335621323B26CE3211", + "name": "Microsoft.VisualStudio.Services.Client", + "SPDXID": "SPDXRef-Package-E9BC86A4FA227FAC309ACDBB94C7EB26CC82F04FCE538A0C9FFF7F7D4E5BAA01", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -138,19 +138,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "5.6.0", + "versionInfo": "16.205.1", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.JsonWebTokens%405.6.0" + "referenceLocator": "pkg:nuget/Microsoft.VisualStudio.Services.Client%4016.205.1" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.VisualStudio.Services.InteractiveClient", - "SPDXID": "SPDXRef-Package-96B5CDA69EC229F8890368C7FD907A10B449F813F071104E7F870121A128DE62", + "name": "PostSharp.Redist", + "SPDXID": "SPDXRef-Package-BCFE9DA1E7CC86449FBC297FD5E46DE5F25F81F44FDCF934D81AE16272872CDE", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -159,19 +159,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "16.205.1", + "versionInfo": "2023.0.8", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.VisualStudio.Services.InteractiveClient%4016.205.1" + "referenceLocator": "pkg:nuget/PostSharp.Redist%402023.0.8" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.IdentityModel.Clients.ActiveDirectory", - "SPDXID": "SPDXRef-Package-DDF4BFE18445397B3B932FABBE666DB6312B84C2A9E5EBD0E7E5D1771ADD507B", + "name": "Microsoft.VisualStudio.Services.InteractiveClient", + "SPDXID": "SPDXRef-Package-96B5CDA69EC229F8890368C7FD907A10B449F813F071104E7F870121A128DE62", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -180,19 +180,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "5.2.6", + "versionInfo": "16.205.1", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.Clients.ActiveDirectory%405.2.6" + "referenceLocator": "pkg:nuget/Microsoft.VisualStudio.Services.InteractiveClient%4016.205.1" } ], "supplier": "NOASSERTION" }, { - "name": "PostSharp.Patterns.Threading", - "SPDXID": "SPDXRef-Package-697815BD7D972ED14DE5BC80D93F622C78E844BB253F6D71E1D9DBA91049F942", + "name": "Azure.Core", + "SPDXID": "SPDXRef-Package-B627A9A962CA4EC270A6BB33055B6D932D9140ED98F117C25A3ACCD02894A5DE", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -201,19 +201,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "2023.0.8", + "versionInfo": "1.35.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/PostSharp.Patterns.Threading%402023.0.8" + "referenceLocator": "pkg:nuget/Azure.Core%401.35.0" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.AspNet.WebApi.Core", - "SPDXID": "SPDXRef-Package-0036185CFC5D903DD9210D1FA4BAF6EACE18C961FBCA96B55969F2D0ADD1006E", + "name": "Microsoft.AspNet.WebApi.WebHost", + "SPDXID": "SPDXRef-Package-B6EB77607AF75F718E21D28F4BA0EE84239C8DE9830FF9719907EE090332AADF", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -227,14 +227,14 @@ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.AspNet.WebApi.Core%405.2.7" + "referenceLocator": "pkg:nuget/Microsoft.AspNet.WebApi.WebHost%405.2.7" } ], "supplier": "NOASSERTION" }, { - "name": "PostSharp.Patterns.Model.Redist", - "SPDXID": "SPDXRef-Package-B2AD20C5DE6A3C17B50991CF6455943C6279EFFAA7399398D712EB3FAED31A32", + "name": "System.ValueTuple", + "SPDXID": "SPDXRef-Package-C1475C5380732C85127A15B8BADF74D2619786E90578875B650082AE4497BC14", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -243,19 +243,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "2023.0.8", + "versionInfo": "4.5.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/PostSharp.Patterns.Model.Redist%402023.0.8" + "referenceLocator": "pkg:nuget/System.ValueTuple%404.5.0" } ], "supplier": "NOASSERTION" }, { - "name": "System.Security.Cryptography.ProtectedData", - "SPDXID": "SPDXRef-Package-3E4ADA476CE4806493CB930B6302267AF817A496FCBC9259BC06584EF5194CC8", + "name": "System.Memory.Data", + "SPDXID": "SPDXRef-Package-836302A10D83B34AB15735A3BD20F9E5195E5C19F576DD54B2A803F042B4449F", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -264,19 +264,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "7.0.1", + "versionInfo": "1.0.2", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.Security.Cryptography.ProtectedData%407.0.1" + "referenceLocator": "pkg:nuget/System.Memory.Data%401.0.2" } ], "supplier": "NOASSERTION" }, { - "name": "PostSharp.Patterns.Common.Redist", - "SPDXID": "SPDXRef-Package-C452BF3C81B9ADDC3235B781278151D496D329BC14ABCDB02E9DCFB34FCBFF96", + "name": "PostSharp.Patterns.Model.Redist", + "SPDXID": "SPDXRef-Package-B2AD20C5DE6A3C17B50991CF6455943C6279EFFAA7399398D712EB3FAED31A32", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -290,14 +290,14 @@ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/PostSharp.Patterns.Common.Redist%402023.0.8" + "referenceLocator": "pkg:nuget/PostSharp.Patterns.Model.Redist%402023.0.8" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.VisualStudio.Services.Client", - "SPDXID": "SPDXRef-Package-E9BC86A4FA227FAC309ACDBB94C7EB26CC82F04FCE538A0C9FFF7F7D4E5BAA01", + "name": "System.Security.AccessControl", + "SPDXID": "SPDXRef-Package-BD5D3E09B5B6D3451EDDD1D32105D059705408E4BF509FF6EA91ABE0158BBCFC", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -306,19 +306,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "16.205.1", + "versionInfo": "6.0.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.VisualStudio.Services.Client%4016.205.1" + "referenceLocator": "pkg:nuget/System.Security.AccessControl%406.0.0" } ], "supplier": "NOASSERTION" }, { - "name": "System.Configuration.ConfigurationManager", - "SPDXID": "SPDXRef-Package-EAF50BE3959D920EC2C2A32D425E53F74856FE11325143BF0B2DECA87CBDC2E5", + "name": "HtmlAgilityPack", + "SPDXID": "SPDXRef-Package-C55EFD6CE543D43B7F9795E55B6CA46123F1759CF0A19BCC538E7160163FADA0", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -327,19 +327,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "7.0.0", + "versionInfo": "1.11.52", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.Configuration.ConfigurationManager%407.0.0" + "referenceLocator": "pkg:nuget/HtmlAgilityPack%401.11.52" } ], "supplier": "NOASSERTION" }, { - "name": "System.IO.Packaging", - "SPDXID": "SPDXRef-Package-178812B3397597FE89124B4827B1851DF91F7E83B0010838961B8110D42EB299", + "name": "System.Security.Cryptography.ProtectedData", + "SPDXID": "SPDXRef-Package-3E4ADA476CE4806493CB930B6302267AF817A496FCBC9259BC06584EF5194CC8", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -348,19 +348,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "7.0.0", + "versionInfo": "7.0.1", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.IO.Packaging%407.0.0" + "referenceLocator": "pkg:nuget/System.Security.Cryptography.ProtectedData%407.0.1" } ], "supplier": "NOASSERTION" }, { - "name": "PostSharp", - "SPDXID": "SPDXRef-Package-4144998C3036BFEC1FEA421C96CDE225AB66255248559821A06971479C33432D", + "name": "PostSharp.Patterns.Threading", + "SPDXID": "SPDXRef-Package-697815BD7D972ED14DE5BC80D93F622C78E844BB253F6D71E1D9DBA91049F942", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -374,14 +374,14 @@ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/PostSharp%402023.0.8" + "referenceLocator": "pkg:nuget/PostSharp.Patterns.Threading%402023.0.8" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.IdentityModel.Tokens", - "SPDXID": "SPDXRef-Package-ED5C898F1E7300DE0FEC9EB7CF43C5F47EAAD11CA05AEE8953D34EFF973D2506", + "name": "Microsoft.IdentityModel.Clients.ActiveDirectory", + "SPDXID": "SPDXRef-Package-DDF4BFE18445397B3B932FABBE666DB6312B84C2A9E5EBD0E7E5D1771ADD507B", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -390,19 +390,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "5.6.0", + "versionInfo": "5.2.6", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.Tokens%405.6.0" + "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.Clients.ActiveDirectory%405.2.6" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.AspNet.WebApi.Client", - "SPDXID": "SPDXRef-Package-FB8EF87A04ABBDDE238C1B9302C41D39A089FDC8A755C4F352B2784CD890726B", + "name": "System.Runtime.CompilerServices.Unsafe", + "SPDXID": "SPDXRef-Package-1B140F7FA3F784DD56CC7A8B4145E9AD58D8CDD4C249A0F27F2262E47C9B41AF", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -411,19 +411,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "5.2.7", + "versionInfo": "6.0.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.AspNet.WebApi.Client%405.2.7" + "referenceLocator": "pkg:nuget/System.Runtime.CompilerServices.Unsafe%406.0.0" } ], "supplier": "NOASSERTION" }, { - "name": "PostSharp.Patterns.Model", - "SPDXID": "SPDXRef-Package-6C98FCF82448239281EA77808E1A4AC1B02DCF078F47514CF8862085C31AE90A", + "name": "System.Security.Permissions", + "SPDXID": "SPDXRef-Package-D0AFA1135DD70C4BE3A426699A4BD772762C066CB05E34A798BFD36D89643F02", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -432,12 +432,12 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "2023.0.8", + "versionInfo": "7.0.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/PostSharp.Patterns.Model%402023.0.8" + "referenceLocator": "pkg:nuget/System.Security.Permissions%407.0.0" } ], "supplier": "NOASSERTION" @@ -464,8 +464,8 @@ "supplier": "NOASSERTION" }, { - "name": "Antlr4.Runtime.Standard", - "SPDXID": "SPDXRef-Package-3EC882CE0436EDA06A573EA24AD2C1BD42AD258EB54A76BDE6C1CA61DA2DEA67", + "name": "PostSharp.Patterns.Common.Redist", + "SPDXID": "SPDXRef-Package-C452BF3C81B9ADDC3235B781278151D496D329BC14ABCDB02E9DCFB34FCBFF96", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -474,19 +474,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "4.13.0", + "versionInfo": "2023.0.8", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Antlr4.Runtime.Standard%404.13.0" + "referenceLocator": "pkg:nuget/PostSharp.Patterns.Common.Redist%402023.0.8" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.TeamFoundation.DistributedTask.Common.Contracts", - "SPDXID": "SPDXRef-Package-2D9FB638C8BBE3526B66E56E9B7C7A9977FB3A4A298A0B4BE68ACAEE7A19289E", + "name": "Microsoft.IdentityModel.JsonWebTokens", + "SPDXID": "SPDXRef-Package-0C8546CE2314CF899D167AFF76F9BD8A06486145BF8140335621323B26CE3211", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -495,19 +495,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "16.205.1", + "versionInfo": "5.6.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.TeamFoundation.DistributedTask.Common.Contracts%4016.205.1" + "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.JsonWebTokens%405.6.0" } ], "supplier": "NOASSERTION" }, { - "name": "System.ValueTuple", - "SPDXID": "SPDXRef-Package-C1475C5380732C85127A15B8BADF74D2619786E90578875B650082AE4497BC14", + "name": "System.Text.Encodings.Web", + "SPDXID": "SPDXRef-Package-79635115AF84D923E985A49E76247A70F70FB8798FC292158F9B6D6B4E2A0336", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -516,12 +516,12 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "4.5.0", + "versionInfo": "4.7.2", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.ValueTuple%404.5.0" + "referenceLocator": "pkg:nuget/System.Text.Encodings.Web%404.7.2" } ], "supplier": "NOASSERTION" @@ -547,6 +547,27 @@ ], "supplier": "NOASSERTION" }, + { + "name": "System.ComponentModel.Composition", + "SPDXID": "SPDXRef-Package-791ADDC07D4C95BB88711D14AE7B99C521745030630794FD90A053A9CF0DB0FA", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "7.0.0", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/System.ComponentModel.Composition%407.0.0" + } + ], + "supplier": "NOASSERTION" + }, { "name": "PostSharp.Patterns.Common", "SPDXID": "SPDXRef-Package-4EEE7F70804936948133A07CF19E40C3B05BFB3E678172FEF939C9265998230B", @@ -590,8 +611,8 @@ "supplier": "NOASSERTION" }, { - "name": "System.ComponentModel.Composition", - "SPDXID": "SPDXRef-Package-791ADDC07D4C95BB88711D14AE7B99C521745030630794FD90A053A9CF0DB0FA", + "name": "System.IdentityModel.Tokens.Jwt", + "SPDXID": "SPDXRef-Package-F8BA4E7EFF02C9D947FB09B3A9632CC70EA2CE2CD1678741703E172AC4D83620", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -600,19 +621,40 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "7.0.0", + "versionInfo": "5.6.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.ComponentModel.Composition%407.0.0" + "referenceLocator": "pkg:nuget/System.IdentityModel.Tokens.Jwt%405.6.0" } ], "supplier": "NOASSERTION" }, { - "name": "System.Security.Permissions", - "SPDXID": "SPDXRef-Package-D0AFA1135DD70C4BE3A426699A4BD772762C066CB05E34A798BFD36D89643F02", + "name": "Azure.AI.OpenAI", + "SPDXID": "SPDXRef-Package-862E9A22FAE549CD97CBE81F8E67DB96A1FAFA78EA6B24BFD39C34B067014678", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "1.0.0-beta.9", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/Azure.AI.OpenAI%401.0.0-beta.9" + } + ], + "supplier": "NOASSERTION" + }, + { + "name": "System.Configuration.ConfigurationManager", + "SPDXID": "SPDXRef-Package-EAF50BE3959D920EC2C2A32D425E53F74856FE11325143BF0B2DECA87CBDC2E5", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -626,14 +668,14 @@ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.Security.Permissions%407.0.0" + "referenceLocator": "pkg:nuget/System.Configuration.ConfigurationManager%407.0.0" } ], "supplier": "NOASSERTION" }, { - "name": "Newtonsoft.Json", - "SPDXID": "SPDXRef-Package-B886264C88915A93892AFBE3D28CD5B3C8B7990F0C6A47AD506184440C46436E", + "name": "Antlr4.Runtime.Standard", + "SPDXID": "SPDXRef-Package-3EC882CE0436EDA06A573EA24AD2C1BD42AD258EB54A76BDE6C1CA61DA2DEA67", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -642,19 +684,19 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "13.0.3", + "versionInfo": "4.13.0", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Newtonsoft.Json%4013.0.3" + "referenceLocator": "pkg:nuget/Antlr4.Runtime.Standard%404.13.0" } ], "supplier": "NOASSERTION" }, { - "name": "System.IdentityModel.Tokens.Jwt", - "SPDXID": "SPDXRef-Package-F8BA4E7EFF02C9D947FB09B3A9632CC70EA2CE2CD1678741703E172AC4D83620", + "name": "Microsoft.IdentityModel.Tokens", + "SPDXID": "SPDXRef-Package-ED5C898F1E7300DE0FEC9EB7CF43C5F47EAAD11CA05AEE8953D34EFF973D2506", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -668,14 +710,98 @@ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.IdentityModel.Tokens.Jwt%405.6.0" + "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.Tokens%405.6.0" } ], "supplier": "NOASSERTION" }, { - "name": "Microsoft.AspNet.WebApi.WebHost", - "SPDXID": "SPDXRef-Package-B6EB77607AF75F718E21D28F4BA0EE84239C8DE9830FF9719907EE090332AADF", + "name": "Microsoft.IdentityModel.Logging", + "SPDXID": "SPDXRef-Package-7586D09A8638B087A9EAF8CB69F57344F906C42E0170B08E6D77EAB745F30092", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "5.6.0", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/Microsoft.IdentityModel.Logging%405.6.0" + } + ], + "supplier": "NOASSERTION" + }, + { + "name": "Microsoft.Bcl.AsyncInterfaces", + "SPDXID": "SPDXRef-Package-6B6117AB3417AA50C1DF8B47DB834F43608FA2A493BD063B0DCD0310BE1691FC", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "1.1.1", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/Microsoft.Bcl.AsyncInterfaces%401.1.1" + } + ], + "supplier": "NOASSERTION" + }, + { + "name": "PostSharp.Patterns.Model", + "SPDXID": "SPDXRef-Package-6C98FCF82448239281EA77808E1A4AC1B02DCF078F47514CF8862085C31AE90A", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "2023.0.8", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/PostSharp.Patterns.Model%402023.0.8" + } + ], + "supplier": "NOASSERTION" + }, + { + "name": "System.Drawing.Common", + "SPDXID": "SPDXRef-Package-1E3F0DE5419CF41CE7DA18907406D8618A23E73477CED8A0A5B96FABC4B00C8E", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "7.0.0", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/System.Drawing.Common%407.0.0" + } + ], + "supplier": "NOASSERTION" + }, + { + "name": "Microsoft.AspNet.WebApi.Core", + "SPDXID": "SPDXRef-Package-0036185CFC5D903DD9210D1FA4BAF6EACE18C961FBCA96B55969F2D0ADD1006E", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -689,14 +815,14 @@ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/Microsoft.AspNet.WebApi.WebHost%405.2.7" + "referenceLocator": "pkg:nuget/Microsoft.AspNet.WebApi.Core%405.2.7" } ], "supplier": "NOASSERTION" }, { - "name": "System.Security.AccessControl", - "SPDXID": "SPDXRef-Package-BD5D3E09B5B6D3451EDDD1D32105D059705408E4BF509FF6EA91ABE0158BBCFC", + "name": "System.Text.Json", + "SPDXID": "SPDXRef-Package-5D96F0103707CBCFF84B28D306BD0C6F4464B149E2C79A6D1218CC1E093FFD25", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "NOASSERTION", @@ -705,12 +831,54 @@ ], "licenseDeclared": "NOASSERTION", "copyrightText": "NOASSERTION", - "versionInfo": "6.0.0", + "versionInfo": "4.7.2", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", - "referenceLocator": "pkg:nuget/System.Security.AccessControl%406.0.0" + "referenceLocator": "pkg:nuget/System.Text.Json%404.7.2" + } + ], + "supplier": "NOASSERTION" + }, + { + "name": "PostSharp.Patterns.Aggregation", + "SPDXID": "SPDXRef-Package-645F4B71D4113C3DCFFBDD2B605CA3CA6803A4C69C4EA4F556B87089D1A90CCE", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "2023.0.8", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/PostSharp.Patterns.Aggregation%402023.0.8" + } + ], + "supplier": "NOASSERTION" + }, + { + "name": "System.IO.Packaging", + "SPDXID": "SPDXRef-Package-178812B3397597FE89124B4827B1851DF91F7E83B0010838961B8110D42EB299", + "downloadLocation": "NOASSERTION", + "filesAnalyzed": false, + "licenseConcluded": "NOASSERTION", + "licenseInfoFromFiles": [ + "NOASSERTION" + ], + "licenseDeclared": "NOASSERTION", + "copyrightText": "NOASSERTION", + "versionInfo": "7.0.0", + "externalRefs": [ + { + "referenceCategory": "PACKAGE-MANAGER", + "referenceType": "purl", + "referenceLocator": "pkg:nuget/System.IO.Packaging%407.0.0" } ], "supplier": "NOASSERTION" @@ -743,17 +911,47 @@ }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-3E4ADA476CE4806493CB930B6302267AF817A496FCBC9259BC06584EF5194CC8", + "relatedSpdxElement": "SPDXRef-Package-EAF50BE3959D920EC2C2A32D425E53F74856FE11325143BF0B2DECA87CBDC2E5", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-0036185CFC5D903DD9210D1FA4BAF6EACE18C961FBCA96B55969F2D0ADD1006E", + "relatedSpdxElement": "SPDXRef-Package-862E9A22FAE549CD97CBE81F8E67DB96A1FAFA78EA6B24BFD39C34B067014678", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-96B5CDA69EC229F8890368C7FD907A10B449F813F071104E7F870121A128DE62", + "relatedSpdxElement": "SPDXRef-Package-F8BA4E7EFF02C9D947FB09B3A9632CC70EA2CE2CD1678741703E172AC4D83620", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-FFF37EB028C40ED3328C8F4D8D0B9DC47D473EB856E9351A10B10AC420CAF2C9", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-4EEE7F70804936948133A07CF19E40C3B05BFB3E678172FEF939C9265998230B", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-178812B3397597FE89124B4827B1851DF91F7E83B0010838961B8110D42EB299", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-645F4B71D4113C3DCFFBDD2B605CA3CA6803A4C69C4EA4F556B87089D1A90CCE", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-5D96F0103707CBCFF84B28D306BD0C6F4464B149E2C79A6D1218CC1E093FFD25", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-0036185CFC5D903DD9210D1FA4BAF6EACE18C961FBCA96B55969F2D0ADD1006E", "spdxElementId": "SPDXRef-RootPackage" }, { @@ -768,17 +966,22 @@ }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-6C98FCF82448239281EA77808E1A4AC1B02DCF078F47514CF8862085C31AE90A", + "relatedSpdxElement": "SPDXRef-Package-D0AFA1135DD70C4BE3A426699A4BD772762C066CB05E34A798BFD36D89643F02", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-FB8EF87A04ABBDDE238C1B9302C41D39A089FDC8A755C4F352B2784CD890726B", + "relatedSpdxElement": "SPDXRef-Package-1B140F7FA3F784DD56CC7A8B4145E9AD58D8CDD4C249A0F27F2262E47C9B41AF", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-ED5C898F1E7300DE0FEC9EB7CF43C5F47EAAD11CA05AEE8953D34EFF973D2506", + "relatedSpdxElement": "SPDXRef-Package-DDF4BFE18445397B3B932FABBE666DB6312B84C2A9E5EBD0E7E5D1771ADD507B", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-C55EFD6CE543D43B7F9795E55B6CA46123F1759CF0A19BCC538E7160163FADA0", "spdxElementId": "SPDXRef-RootPackage" }, { @@ -793,82 +996,82 @@ }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-645F4B71D4113C3DCFFBDD2B605CA3CA6803A4C69C4EA4F556B87089D1A90CCE", + "relatedSpdxElement": "SPDXRef-Package-BD5D3E09B5B6D3451EDDD1D32105D059705408E4BF509FF6EA91ABE0158BBCFC", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-7586D09A8638B087A9EAF8CB69F57344F906C42E0170B08E6D77EAB745F30092", + "relatedSpdxElement": "SPDXRef-Package-836302A10D83B34AB15735A3BD20F9E5195E5C19F576DD54B2A803F042B4449F", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-C55EFD6CE543D43B7F9795E55B6CA46123F1759CF0A19BCC538E7160163FADA0", + "relatedSpdxElement": "SPDXRef-Package-C1475C5380732C85127A15B8BADF74D2619786E90578875B650082AE4497BC14", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-681B78A232303686681BD818B0D190BE6C105857B1F5C087E2FC1952A264EA58", + "relatedSpdxElement": "SPDXRef-Package-B6EB77607AF75F718E21D28F4BA0EE84239C8DE9830FF9719907EE090332AADF", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-D0AFA1135DD70C4BE3A426699A4BD772762C066CB05E34A798BFD36D89643F02", + "relatedSpdxElement": "SPDXRef-Package-BCFE9DA1E7CC86449FBC297FD5E46DE5F25F81F44FDCF934D81AE16272872CDE", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-791ADDC07D4C95BB88711D14AE7B99C521745030630794FD90A053A9CF0DB0FA", + "relatedSpdxElement": "SPDXRef-Package-6C98FCF82448239281EA77808E1A4AC1B02DCF078F47514CF8862085C31AE90A", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-FFF37EB028C40ED3328C8F4D8D0B9DC47D473EB856E9351A10B10AC420CAF2C9", + "relatedSpdxElement": "SPDXRef-Package-6B6117AB3417AA50C1DF8B47DB834F43608FA2A493BD063B0DCD0310BE1691FC", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-4EEE7F70804936948133A07CF19E40C3B05BFB3E678172FEF939C9265998230B", + "relatedSpdxElement": "SPDXRef-Package-7586D09A8638B087A9EAF8CB69F57344F906C42E0170B08E6D77EAB745F30092", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-BD5D3E09B5B6D3451EDDD1D32105D059705408E4BF509FF6EA91ABE0158BBCFC", + "relatedSpdxElement": "SPDXRef-Package-ED5C898F1E7300DE0FEC9EB7CF43C5F47EAAD11CA05AEE8953D34EFF973D2506", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-B6EB77607AF75F718E21D28F4BA0EE84239C8DE9830FF9719907EE090332AADF", + "relatedSpdxElement": "SPDXRef-Package-3EC882CE0436EDA06A573EA24AD2C1BD42AD258EB54A76BDE6C1CA61DA2DEA67", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-F8BA4E7EFF02C9D947FB09B3A9632CC70EA2CE2CD1678741703E172AC4D83620", + "relatedSpdxElement": "SPDXRef-Package-3E4ADA476CE4806493CB930B6302267AF817A496FCBC9259BC06584EF5194CC8", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-B886264C88915A93892AFBE3D28CD5B3C8B7990F0C6A47AD506184440C46436E", + "relatedSpdxElement": "SPDXRef-Package-BA5D8D1B5043A468B09DDBF48DCFC7DDD44949EE05A23A14F02AE8AA5183745C", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-178812B3397597FE89124B4827B1851DF91F7E83B0010838961B8110D42EB299", + "relatedSpdxElement": "SPDXRef-Package-2D9FB638C8BBE3526B66E56E9B7C7A9977FB3A4A298A0B4BE68ACAEE7A19289E", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-EAF50BE3959D920EC2C2A32D425E53F74856FE11325143BF0B2DECA87CBDC2E5", + "relatedSpdxElement": "SPDXRef-Package-FB8EF87A04ABBDDE238C1B9302C41D39A089FDC8A755C4F352B2784CD890726B", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-E9BC86A4FA227FAC309ACDBB94C7EB26CC82F04FCE538A0C9FFF7F7D4E5BAA01", + "relatedSpdxElement": "SPDXRef-Package-681B78A232303686681BD818B0D190BE6C105857B1F5C087E2FC1952A264EA58", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-C452BF3C81B9ADDC3235B781278151D496D329BC14ABCDB02E9DCFB34FCBFF96", + "relatedSpdxElement": "SPDXRef-Package-791ADDC07D4C95BB88711D14AE7B99C521745030630794FD90A053A9CF0DB0FA", "spdxElementId": "SPDXRef-RootPackage" }, { @@ -878,17 +1081,17 @@ }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-C1475C5380732C85127A15B8BADF74D2619786E90578875B650082AE4497BC14", + "relatedSpdxElement": "SPDXRef-Package-79635115AF84D923E985A49E76247A70F70FB8798FC292158F9B6D6B4E2A0336", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-2D9FB638C8BBE3526B66E56E9B7C7A9977FB3A4A298A0B4BE68ACAEE7A19289E", + "relatedSpdxElement": "SPDXRef-Package-0C8546CE2314CF899D167AFF76F9BD8A06486145BF8140335621323B26CE3211", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-3EC882CE0436EDA06A573EA24AD2C1BD42AD258EB54A76BDE6C1CA61DA2DEA67", + "relatedSpdxElement": "SPDXRef-Package-C452BF3C81B9ADDC3235B781278151D496D329BC14ABCDB02E9DCFB34FCBFF96", "spdxElementId": "SPDXRef-RootPackage" }, { @@ -898,17 +1101,22 @@ }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-DDF4BFE18445397B3B932FABBE666DB6312B84C2A9E5EBD0E7E5D1771ADD507B", + "relatedSpdxElement": "SPDXRef-Package-B627A9A962CA4EC270A6BB33055B6D932D9140ED98F117C25A3ACCD02894A5DE", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-0C8546CE2314CF899D167AFF76F9BD8A06486145BF8140335621323B26CE3211", + "relatedSpdxElement": "SPDXRef-Package-96B5CDA69EC229F8890368C7FD907A10B449F813F071104E7F870121A128DE62", "spdxElementId": "SPDXRef-RootPackage" }, { "relationshipType": "DEPENDS_ON", - "relatedSpdxElement": "SPDXRef-Package-BCFE9DA1E7CC86449FBC297FD5E46DE5F25F81F44FDCF934D81AE16272872CDE", + "relatedSpdxElement": "SPDXRef-Package-E9BC86A4FA227FAC309ACDBB94C7EB26CC82F04FCE538A0C9FFF7F7D4E5BAA01", + "spdxElementId": "SPDXRef-RootPackage" + }, + { + "relationshipType": "DEPENDS_ON", + "relatedSpdxElement": "SPDXRef-Package-B886264C88915A93892AFBE3D28CD5B3C8B7990F0C6A47AD506184440C46436E", "spdxElementId": "SPDXRef-RootPackage" } ], @@ -916,9 +1124,9 @@ "dataLicense": "CC0-1.0", "SPDXID": "SPDXRef-DOCUMENT", "name": "Threats Manager Platform 2.0.0", - "documentNamespace": "https://github.com/simonec73/threatsmanager/Threats%20Manager%20Platform/2.0.0/0MTpIlbDykWmAKkpTw71ZQ", + "documentNamespace": "https://github.com/simonec73/threatsmanager/Threats%20Manager%20Platform/2.0.0/_FmtwHT1I0iY8mDGSkGT1w", "creationInfo": { - "created": "2023-11-26T13:52:03Z", + "created": "2023-12-30T10:46:59Z", "creators": [ "Organization: Simone Curzi", "Tool: Microsoft.SBOMTool-0.2.7" diff --git a/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json.sha256 b/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json.sha256 index 3e6912de..ddf68e29 100644 Binary files a/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json.sha256 and b/Sources/SBOM/_manifest/spdx_2.2/manifest.spdx.json.sha256 differ diff --git a/Sources/ThreatsManager.Engine/Aspects/EntityShapesContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/EntityShapesContainerAspect.cs index f69d79b0..c1ce417d 100644 --- a/Sources/ThreatsManager.Engine/Aspects/EntityShapesContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/EntityShapesContainerAspect.cs @@ -195,11 +195,11 @@ public bool RemoveShape(IEntityShape entityShape) { UndoRedoManager.Detach(es); scope?.Complete(); - - if (es.Identity is IEntity entity && Instance is IEntityShapesContainer container) - _entityShapeRemoved?.Invoke(container, entity); } } + + if (result && es.Identity is IEntity entity && Instance is IEntityShapesContainer container) + _entityShapeRemoved?.Invoke(container, entity); } else throw new ArgumentNullException(nameof(entityShape)); diff --git a/Sources/ThreatsManager.Engine/Aspects/GroupElementAspect.cs b/Sources/ThreatsManager.Engine/Aspects/GroupElementAspect.cs index 0c17a9c8..873ff69e 100644 --- a/Sources/ThreatsManager.Engine/Aspects/GroupElementAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/GroupElementAspect.cs @@ -89,11 +89,11 @@ public void SetParent(IGroup parent) _parentId.Set(parent?.Id ?? Guid.Empty); _parent.Set(parent); scope?.Complete(); - - if (Instance is IGroupElement groupElement) - _parentChanged?.Invoke(groupElement, oldParent, parent); } - } + + if (Instance is IGroupElement groupElement) + _parentChanged?.Invoke(groupElement, oldParent, parent); + } } #endregion } diff --git a/Sources/ThreatsManager.Engine/Aspects/GroupShapesContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/GroupShapesContainerAspect.cs index 9852c888..cdfd20c6 100644 --- a/Sources/ThreatsManager.Engine/Aspects/GroupShapesContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/GroupShapesContainerAspect.cs @@ -106,11 +106,11 @@ public void Add(IGroupShape groupShape) UndoRedoManager.Attach(gs, gs.Model); groups.Add(gs); scope?.Complete(); + } - if (Instance is IGroupShapesContainer container) - { - _groupShapeAdded?.Invoke(container, gs); - } + if (Instance is IGroupShapesContainer container) + { + _groupShapeAdded?.Invoke(container, gs); } } else @@ -194,11 +194,11 @@ public bool RemoveShape(IGroupShape groupShape) { UndoRedoManager.Detach(gs); scope?.Complete(); - - if (groupShape.Identity is IGroup group && Instance is IGroupShapesContainer container) - _groupShapeRemoved?.Invoke(container, group); } } + + if (result && groupShape.Identity is IGroup group && Instance is IGroupShapesContainer container) + _groupShapeRemoved?.Invoke(container, group); } else throw new ArgumentNullException(nameof(groupShape)); diff --git a/Sources/ThreatsManager.Engine/Aspects/LinksContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/LinksContainerAspect.cs index d1c124b4..1c71facd 100644 --- a/Sources/ThreatsManager.Engine/Aspects/LinksContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/LinksContainerAspect.cs @@ -97,11 +97,11 @@ public void Add(ILink link) UndoRedoManager.Attach(l, l.Model); links.Add(l); scope?.Complete(); + } - if (Instance is ILinksContainer container) - { - _linkAdded?.Invoke(container, l); - } + if (Instance is ILinksContainer container) + { + _linkAdded?.Invoke(container, l); } } else @@ -142,11 +142,11 @@ public bool RemoveLink(Guid dataFlowId) { UndoRedoManager.Detach(link); scope?.Complete(); - - if (link.DataFlow is IDataFlow flow && Instance is ILinksContainer container) - _linkRemoved?.Invoke(container, flow); } } + + if (result && link.DataFlow is IDataFlow flow && Instance is ILinksContainer container) + _linkRemoved?.Invoke(container, flow); } return result; diff --git a/Sources/ThreatsManager.Engine/Aspects/ThreatEventMitigationsContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/ThreatEventMitigationsContainerAspect.cs index c6f6a896..02ca0b69 100644 --- a/Sources/ThreatsManager.Engine/Aspects/ThreatEventMitigationsContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/ThreatEventMitigationsContainerAspect.cs @@ -96,11 +96,11 @@ public void Add(IThreatEventMitigation mitigation) UndoRedoManager.Attach(tem, tem.Model); mitigations.Add(tem); scope?.Complete(); + } - if (Instance is IThreatEventMitigationsContainer container) - { - _threatEventMitigationAdded?.Invoke(container, tem); - } + if (Instance is IThreatEventMitigationsContainer container) + { + _threatEventMitigationAdded?.Invoke(container, tem); } } else @@ -144,11 +144,11 @@ public bool RemoveMitigation(Guid mitigationId) { UndoRedoManager.Detach(mitigation); scope?.Complete(); - - if (Instance is IThreatEventMitigationsContainer container) - _threatEventMitigationRemoved?.Invoke(container, mitigation); } } + + if (result && Instance is IThreatEventMitigationsContainer container) + _threatEventMitigationRemoved?.Invoke(container, mitigation); } return result; diff --git a/Sources/ThreatsManager.Engine/Aspects/ThreatEventScenariosContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/ThreatEventScenariosContainerAspect.cs index 3d0061cd..fdd6023f 100644 --- a/Sources/ThreatsManager.Engine/Aspects/ThreatEventScenariosContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/ThreatEventScenariosContainerAspect.cs @@ -144,11 +144,11 @@ public bool RemoveScenario(Guid id) { UndoRedoManager.Detach(scenario); scope?.Complete(); - - if (Instance is IThreatEvent threatEvent) - _threatEventScenarioRemoved?.Invoke(threatEvent, scenario); } } + + if (result && Instance is IThreatEvent threatEvent) + _threatEventScenarioRemoved?.Invoke(threatEvent, scenario); } return result; diff --git a/Sources/ThreatsManager.Engine/Aspects/ThreatEventsContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/ThreatEventsContainerAspect.cs index 5b8845fa..93929961 100644 --- a/Sources/ThreatsManager.Engine/Aspects/ThreatEventsContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/ThreatEventsContainerAspect.cs @@ -111,10 +111,10 @@ public void Add(IThreatEvent threatEvent) UndoRedoManager.Attach(te, te.Model); threatEvents.Add(te); scope?.Complete(); - - if (Instance is IThreatEventsContainer container) - _threatEventAdded?.Invoke(container, te); } + + if (Instance is IThreatEventsContainer container) + _threatEventAdded?.Invoke(container, te); } else throw new ArgumentNullException(nameof(threatEvent)); @@ -157,11 +157,11 @@ public bool RemoveThreatEvent(Guid id) { UndoRedoManager.Detach(threatEvent); scope?.Complete(); - - if (Instance is IThreatEventsContainer container) - _threatEventRemoved?.Invoke(container, threatEvent); } } + + if (result && Instance is IThreatEventsContainer container) + _threatEventRemoved?.Invoke(container, threatEvent); } return result; diff --git a/Sources/ThreatsManager.Engine/Aspects/VulnerabilitiesContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/VulnerabilitiesContainerAspect.cs index 38877efb..2862a07d 100644 --- a/Sources/ThreatsManager.Engine/Aspects/VulnerabilitiesContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/VulnerabilitiesContainerAspect.cs @@ -111,10 +111,10 @@ public void Add(IVulnerability vulnerability) UndoRedoManager.Attach(v, v.Model); vulnerabilities.Add(v); scope?.Complete(); - - if (Instance is IVulnerabilitiesContainer container) - _vulnerabilityAdded?.Invoke(container, v); } + + if (Instance is IVulnerabilitiesContainer container) + _vulnerabilityAdded?.Invoke(container, v); } else throw new ArgumentNullException(nameof(vulnerability)); @@ -157,11 +157,11 @@ public bool RemoveVulnerability(Guid id) { UndoRedoManager.Detach(vulnerability); scope?.Complete(); - - if (Instance is IVulnerabilitiesContainer container) - _vulnerabilityRemoved?.Invoke(container, vulnerability); } } + + if (result && Instance is IVulnerabilitiesContainer container) + _vulnerabilityRemoved?.Invoke(container, vulnerability); } return result; diff --git a/Sources/ThreatsManager.Engine/Aspects/VulnerabilityMitigationsContainerAspect.cs b/Sources/ThreatsManager.Engine/Aspects/VulnerabilityMitigationsContainerAspect.cs index d0f2d45d..ecf32712 100644 --- a/Sources/ThreatsManager.Engine/Aspects/VulnerabilityMitigationsContainerAspect.cs +++ b/Sources/ThreatsManager.Engine/Aspects/VulnerabilityMitigationsContainerAspect.cs @@ -99,11 +99,11 @@ public void Add(IVulnerabilityMitigation mitigation) UndoRedoManager.Attach(vm, vm.Model); mitigations.Add(vm); scope?.Complete(); + } - if (Instance is IVulnerabilityMitigationsContainer container) - { - _vulnerabilityMitigationAdded?.Invoke(container, vm); - } + if (Instance is IVulnerabilityMitigationsContainer container) + { + _vulnerabilityMitigationAdded?.Invoke(container, vm); } } else @@ -146,11 +146,11 @@ public bool RemoveMitigation(Guid mitigationId) { UndoRedoManager.Detach(mitigation); scope?.Complete(); - - if (Instance is IVulnerabilityMitigationsContainer container) - _vulnerabilityMitigationRemoved?.Invoke(container, mitigation); } } + + if (result && Instance is IVulnerabilityMitigationsContainer container) + _vulnerabilityMitigationRemoved?.Invoke(container, mitigation); } return result; diff --git a/Sources/ThreatsManager.Engine/ExtensionsManager.cs b/Sources/ThreatsManager.Engine/ExtensionsManager.cs index 93ba0450..86b59c16 100644 --- a/Sources/ThreatsManager.Engine/ExtensionsManager.cs +++ b/Sources/ThreatsManager.Engine/ExtensionsManager.cs @@ -12,6 +12,8 @@ using ThreatsManager.Utilities; using ThreatsManager.Utilities.Help; using PostSharp.Patterns.Threading; +using ThreatsManager.Engine.Policies; +using ThreatsManager.Utilities.Policies; namespace ThreatsManager.Engine { @@ -36,7 +38,13 @@ public void AddExtensionsAssembly([Required] string path) public void SetExecutionMode(ExecutionMode executionMode) { - _executionMode = executionMode; + var policy = new MaxExecutionModePolicy(); + var maxExecutionMode = policy.MaxExecutionMode ?? ExecutionMode.Pioneer; + + if (executionMode > maxExecutionMode) + _executionMode = executionMode; + else + _executionMode = maxExecutionMode; } public void Load(bool loadHelp) @@ -79,9 +87,7 @@ public string GetExtensionName([Required] string id) public IEnumerable GetExtensionIds() { - return _extensions? - .Where(x => x?.Metadata != null && IsExecutionModeCompliant(x.Metadata.Mode)) - .OrderBy(x => x.Metadata.Priority) + return GetExtensions()? .Select(x => x.Metadata.Id) .Distinct() .ToArray(); @@ -96,8 +102,7 @@ public string GetExtensionType([Required] string id) { string result = null; - var extension = _extensions? - .FirstOrDefault(x => (x.Metadata != null) && string.CompareOrdinal(id, x.Metadata.Id) == 0); + var extension = GetExtension(id); if (extension != null) { @@ -115,39 +120,33 @@ public string GetExtensionType([Required] string id) public string GetExtensionAssemblyTitle([Required] string id) { - return _extensions? - .FirstOrDefault(x => (x.Metadata != null) && string.CompareOrdinal(id, x.Metadata.Id) == 0)? + return GetExtension(id)? .Value? .GetExtensionAssemblyTitle(); } public IExtensionMetadata GetExtensionMetadata([Required] string id) { - return _extensions? - .FirstOrDefault(x => (x.Metadata != null) && string.CompareOrdinal(id, x.Metadata.Id) == 0)? - .Metadata; + return GetExtension(id)?.Metadata; } public IEnumerable> GetExtensions() where T : class, IExtension { - return _extensions? - .Where(x => x?.Metadata != null && IsExecutionModeCompliant(x.Metadata.Mode) && x.Value is T) - .OrderBy(x => x.Metadata.Priority) + return GetExtensions()? .Distinct(new ExtensionMetadataEqualityComparer()) - .Select(x => new KeyValuePair(x.Metadata, x.Value as T)); + .Select(x => new KeyValuePair(x.Metadata, x.Value as T)) + .Where(x => x.Value != null); } public T GetExtension([Required] string id) where T : class, IExtension { - return _extensions? - .FirstOrDefault(x => (x?.Metadata != null) && string.CompareOrdinal(id, x.Metadata.Id) == 0)? - .Value as T; + return GetExtension(id)?.Value as T; } public T GetExtensionByLabel([Required] string label) where T : class, IExtension { - return _extensions? - .FirstOrDefault(x => (x?.Metadata != null) && string.CompareOrdinal(label, x.Metadata.Label) == 0)? + return GetExtensions()? + .FirstOrDefault(x => string.CompareOrdinal(label, x.Metadata.Label) == 0)? .Value as T; } @@ -165,6 +164,67 @@ public T GetExtensionByUniversalId([Required] string universalId) where T : c return result; } + #region Private member functions. + private void LoadUniversalIDs() + { + var extensions = _extensions?.Select(x => x.Value)?.ToArray(); + if (extensions?.Any() ?? false) + { + var dict = new Dictionary(); + foreach (var extension in extensions) + { + var universalId = extension.GetExtensionUniversalId(); + if (!string.IsNullOrWhiteSpace(universalId)) + { + dict.Add(universalId, extension.GetExtensionId()); + } + } + + if (dict.Any()) + { + _extensionsByUniversalId = dict; + } + } + } + + [Background] + private void LoadHelpConfiguration() + { + var policy = new HelpTroubleshootPolicy(); + if (policy.HelpTroubleshoot ?? true) + { + var assemblies = _catalog.Catalogs.OfType().Select(x => x.Assembly).ToArray(); + if (assemblies.Any()) + { + foreach (var assembly in assemblies) + { + LearningManager.Instance.Add(assembly); + TroubleshootingManager.Instance.Add(assembly); + } + LearningManager.Instance.AnalyzeSources(); + TroubleshootingManager.Instance.AnalyzeSources(); + } + } + } + + private IEnumerable> GetExtensions() + { + var policy = new DisabledExtensionsPolicy(); + var disabled = policy.DisabledExtensions?.ToArray(); + + return _extensions? + .Where(x => x?.Metadata != null && + IsExecutionModeCompliant(x.Metadata.Mode) && + !(disabled?.Any(y => string.CompareOrdinal(y, x.Metadata.Label) == 0) ?? false)) + .OrderBy(x => x.Metadata.Priority); + } + + private Lazy GetExtension([Required] string id) + { + return GetExtensions()? + .FirstOrDefault(x => string.CompareOrdinal(id, x.Metadata.Id) == 0); + } + private bool IsExecutionModeCompliant(ExecutionMode requiredMode) { bool result; @@ -199,44 +259,6 @@ private bool IsExecutionModeCompliant(ExecutionMode requiredMode) return result; } - private void LoadUniversalIDs() - { - var extensions = _extensions?.Select(x => x.Value)?.ToArray(); - if (extensions?.Any() ?? false) - { - var dict = new Dictionary(); - foreach (var extension in extensions) - { - var universalId = extension.GetExtensionUniversalId(); - if (!string.IsNullOrWhiteSpace(universalId)) - { - dict.Add(universalId, extension.GetExtensionId()); - } - } - - if (dict.Any()) - { - _extensionsByUniversalId = dict; - } - } - } - - [Background] - private void LoadHelpConfiguration() - { - var assemblies = _catalog.Catalogs.OfType().Select(x => x.Assembly).ToArray(); - if (assemblies.Any()) - { - foreach (var assembly in assemblies) - { - LearningManager.Instance.Add(assembly); - TroubleshootingManager.Instance.Add(assembly); - } - LearningManager.Instance.AnalyzeSources(); - TroubleshootingManager.Instance.AnalyzeSources(); - } - } - // From https://stackoverflow.com/questions/540749/can-a-c-sharp-class-inherit-attributes-from-its-interface. private static IEnumerable GetCustomAttributesIncludingBaseInterfaces(Type type) { @@ -246,5 +268,6 @@ private static IEnumerable GetCustomAttributesIncludingBaseInterfaces(Type SelectMany(interfaceType => interfaceType.GetCustomAttributes(attributeType, true))). Distinct().Cast(); } + #endregion } } diff --git a/Sources/ThreatsManager.Engine/Manager.cs b/Sources/ThreatsManager.Engine/Manager.cs index 53628670..4dd9ab80 100644 --- a/Sources/ThreatsManager.Engine/Manager.cs +++ b/Sources/ThreatsManager.Engine/Manager.cs @@ -5,9 +5,11 @@ using System.Reflection; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; +using System.Xml; using Newtonsoft.Json; using PostSharp.Patterns.Contracts; using ThreatsManager.Engine.Config; +using ThreatsManager.Engine.Policies; using ThreatsManager.Interfaces; using ThreatsManager.Interfaces.Extensions; using ThreatsManager.Interfaces.Extensions.Actions; @@ -86,6 +88,49 @@ private Manager() { } + #region Public members. + public static Manager Instance => _instance; + + public ExtensionsConfigurationManager Configuration => _configuration; + + public void LoadExtensions(ExecutionMode mode, Func except = null) + { + AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve; + +#pragma warning disable SecurityIntelliSenseCS // MS Security rules violation + var dir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Extensions"); + if (Directory.Exists(dir)) + { + var assemblies = + Directory.GetFiles(dir, "ThreatsManager.*.dll"); + if (assemblies.Any()) + { + foreach (var assembly in assemblies) + { + _extensionsManager.AddExtensionsAssembly(assembly); + } + } + } +#pragma warning restore SecurityIntelliSenseCS // MS Security rules violation + + InitializeEngineKnownTypes(); + + _configuration = new ExtensionsConfigurationManager(); + var folders = GetFolders(); + var prefixes = GetPrefixes(); + var certificates = GetCertificates(); + AddAssemblies(folders, prefixes, certificates, except); + + var config = ExtensionsConfigurationManager.GetConfigurationSection(); + _extensionsManager.Load(!(config?.DisableHelp ?? false)); + _extensionsManager.SetExecutionMode(mode); + _configuration.Initialize(_extensionsManager); + + RegisterContextAwareActionsEventHandlers(); + RegisterPostLoadProcessorsEventHandlers(); + } + #endregion + #region Extensions loading. static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args) { @@ -111,13 +156,16 @@ static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve(object sender, Resol return result; } - private void AddAssemblies(IEnumerable folders, IEnumerable prefixes, + private void AddAssemblies(IEnumerable folders, IEnumerable prefixes, IEnumerable certificates, Func except) { if (folders?.Any() ?? false) { var platformVersion = Assembly.GetExecutingAssembly().GetName().Version; + var policy = new DisabledLibrariesPolicy(); + var disabled = policy.DisabledLibraries?.ToArray(); + foreach (var folder in folders) { var dlls = GetDlls(folder, prefixes)?.ToArray(); @@ -137,6 +185,17 @@ private void AddAssemblies(IEnumerable folders, IEnumerable pref bool skip = false; + var assemblyTitle = CustomAttributeData.GetCustomAttributes(assembly) + .Where(x => x.AttributeType == typeof(AssemblyTitleAttribute)) + .FirstOrDefault()? + .ConstructorArguments[0].Value? + .ToString().Replace("ThreatsManager.", ""); + if (disabled?.Any(x => string.CompareOrdinal(assemblyTitle, x) == 0) ?? false) + { + skip = true; + _showWarning?.Invoke($"Extension library {assembly.FullName} has not been loaded due to a Policy."); + } + if (except != null && except(assembly)) { skip = true; @@ -224,27 +283,27 @@ private VersionCheckOutcome CheckVersion([NotNull] Version platformVersion, [Not switch (attribute.ConstructorArguments.Count) { case 1: - attrib = new ExtensionsContainerAttribute((string) attribute.ConstructorArguments[0].Value); + attrib = new ExtensionsContainerAttribute((string)attribute.ConstructorArguments[0].Value); break; case 2: if (attribute.ConstructorArguments[1].ArgumentType == typeof(string)) { attrib = new ExtensionsContainerAttribute( - (string) attribute.ConstructorArguments[0].Value, - (string) attribute.ConstructorArguments[1].Value); + (string)attribute.ConstructorArguments[0].Value, + (string)attribute.ConstructorArguments[1].Value); } else { attrib = new ExtensionsContainerAttribute( - (string) attribute.ConstructorArguments[0].Value, - (uint) attribute.ConstructorArguments[1].Value); + (string)attribute.ConstructorArguments[0].Value, + (uint)attribute.ConstructorArguments[1].Value); } break; case 3: attrib = new ExtensionsContainerAttribute( - (string) attribute.ConstructorArguments[0].Value, - (string) attribute.ConstructorArguments[1].Value, - (uint) attribute.ConstructorArguments[2].Value); + (string)attribute.ConstructorArguments[0].Value, + (string)attribute.ConstructorArguments[1].Value, + (uint)attribute.ConstructorArguments[2].Value); break; } @@ -330,46 +389,92 @@ private void InitializeKnownTypes([NotNull] Type type) } #endregion - #region Public members. - public static Manager Instance => _instance; + #region Policies. + private IEnumerable GetFolders() + { + IEnumerable result = null; - public ExtensionsConfigurationManager Configuration => _configuration; + var list = new List(); + var folders = _configuration.Folders?.ToArray(); + if (folders?.Any() ?? false) + { + list.AddRange(folders); + } - public void LoadExtensions(ExecutionMode mode, Func except = null) + var policy = new FoldersPolicy(); + var additional = policy.Folders?.ToArray(); + + if (additional?.Any() ?? false) + { + foreach (var item in additional) + { + if (!list.Any(x => string.CompareOrdinal(item?.ToLower(), x?.ToLower()) == 0)) + list.Add(item); + } + } + + if (list.Any()) + result = list.AsEnumerable(); + + return result; + } + + private IEnumerable GetPrefixes() { - AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve; + IEnumerable result = null; -#pragma warning disable SecurityIntelliSenseCS // MS Security rules violation - var dir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Extensions"); - if (Directory.Exists(dir)) + var list = new List(); + var prefixes = _configuration.Prefixes?.ToArray(); + if (prefixes?.Any() ?? false) { - var assemblies = - Directory.GetFiles(dir, "ThreatsManager.*.dll"); - if (assemblies.Any()) + list.AddRange(prefixes); + } + + var policy = new PrefixesPolicy(); + var additional = policy.Prefixes?.ToArray(); + + if (additional?.Any() ?? false) + { + foreach (var item in additional) { - foreach (var assembly in assemblies) - { - _extensionsManager.AddExtensionsAssembly(assembly); - } + if (!list.Any(x => string.CompareOrdinal(item?.ToLower(), x?.ToLower()) == 0)) + list.Add(item); } } -#pragma warning restore SecurityIntelliSenseCS // MS Security rules violation - InitializeEngineKnownTypes(); + if (list.Any()) + result = list.AsEnumerable(); - _configuration = new ExtensionsConfigurationManager(); - var folders = _configuration.Folders; - var prefixes = _configuration.Prefixes; - var certificates = _configuration.Certificates; - AddAssemblies(folders, prefixes, certificates, except); + return result; + } - var config = ExtensionsConfigurationManager.GetConfigurationSection(); - _extensionsManager.Load(!(config?.DisableHelp ?? false)); - _extensionsManager.SetExecutionMode(mode); - _configuration.Initialize(_extensionsManager); + private IEnumerable GetCertificates() + { + IEnumerable result = null; - RegisterContextAwareActionsEventHandlers(); - RegisterPostLoadProcessorsEventHandlers(); + var requireCertsPolicy = new RequireCertsPolicy(); + if (requireCertsPolicy.RequireCerts ?? true) + { + var list = new List(); + var certificates = _configuration.Certificates?.ToArray(); + if (certificates?.Any() ?? false) + { + list.AddRange(certificates); + } + + var policy = new CertificatesPolicy(); + var additional = policy.Certificates?.ToArray(); + + if (additional?.Any() ?? false) + { + list.AddRange(additional); + } + + if (list.Any()) + result = list.AsEnumerable(); + } + + return result; } #endregion diff --git a/Sources/ThreatsManager.Engine/ObjectModel/Properties/PropertySchema.PropertyTypes.cs b/Sources/ThreatsManager.Engine/ObjectModel/Properties/PropertySchema.PropertyTypes.cs index d005ed39..3d892abb 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/Properties/PropertySchema.PropertyTypes.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/Properties/PropertySchema.PropertyTypes.cs @@ -61,10 +61,11 @@ public IPropertyType AddPropertyType([Required] string name, PropertyValueType t UndoRedoManager.Attach(result, Model); _propertyTypes.Add(result); scope?.Complete(); - - PropertyTypeAdded?.Invoke(this, result); } } + + if (result != null) + PropertyTypeAdded?.Invoke(this, result); } return result; @@ -85,10 +86,10 @@ public bool RemovePropertyType(Guid id) { UndoRedoManager.Detach(propertyType); scope?.Complete(); - - PropertyTypeRemoved?.Invoke(this, propertyType); } } + if (result) + PropertyTypeRemoved?.Invoke(this, propertyType); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Actors.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Actors.cs index 1c7c1120..fb47708e 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Actors.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Actors.cs @@ -49,9 +49,9 @@ public void Add([NotNull] IThreatActor actor) UndoRedoManager.Attach(a, this); _actors.Add(a); scope?.Complete(); - - ChildCreated?.Invoke(a); } + + ChildCreated?.Invoke(a); } else throw new ArgumentException(nameof(actor)); diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Entities.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Entities.cs index 3b694fb7..8825f1dd 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Entities.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Entities.cs @@ -269,11 +269,13 @@ public bool RemoveEntity(Guid id) UndoRedoManager.Detach(entity); UnregisterEvents(entity); - ChildRemoved?.Invoke(entity); } scope?.Complete(); } + + if (result) + ChildRemoved?.Invoke(entity); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.EntityTemplates.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.EntityTemplates.cs index 54b0db21..a8a6f59c 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.EntityTemplates.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.EntityTemplates.cs @@ -49,9 +49,9 @@ public void Add([NotNull] IEntityTemplate entityTemplate) UndoRedoManager.Attach(entityTemplate, this); _entityTemplates.Add(entityTemplate); scope?.Complete(); - - ChildCreated?.Invoke(entityTemplate); } + + ChildCreated?.Invoke(entityTemplate); } [InitializationRequired] @@ -150,10 +150,11 @@ public bool RemoveEntityTemplate(Guid id) { UndoRedoManager.Detach(template); scope?.Complete(); - - ChildRemoved?.Invoke(template); } } + + if (result) + ChildRemoved?.Invoke(template); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.FlowTemplates.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.FlowTemplates.cs index 8afa0b85..05674825 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.FlowTemplates.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.FlowTemplates.cs @@ -42,9 +42,9 @@ public void Add([NotNull] IFlowTemplate flowTemplate) UndoRedoManager.Attach(ft, this); _flowTemplates.Add(ft); scope?.Complete(); - - ChildCreated?.Invoke(ft); } + + ChildCreated?.Invoke(ft); } else throw new ArgumentException(nameof(flowTemplate)); @@ -80,10 +80,11 @@ public bool RemoveFlowTemplate(Guid id) { UndoRedoManager.Detach(template); scope?.Complete(); - - ChildRemoved?.Invoke(template); } } + + if (result) + ChildRemoved?.Invoke(template); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Groups.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Groups.cs index 45e3c1b9..c458fdb2 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Groups.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Groups.cs @@ -172,11 +172,13 @@ public bool RemoveGroup(Guid id) UndoRedoManager.Detach(item); UnregisterEvents(item); - ChildRemoved?.Invoke(item); } scope?.Complete(); } + + if (result) + ChildRemoved?.Invoke(item); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Mitigations.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Mitigations.cs index 4750137a..46b4b506 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Mitigations.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Mitigations.cs @@ -49,9 +49,9 @@ public void Add([NotNull] IMitigation mitigation) UndoRedoManager.Attach(m, this); _mitigations.Add(m); scope?.Complete(); - - ChildCreated?.Invoke(m); } + + ChildCreated?.Invoke(m); } else throw new ArgumentException(nameof(mitigation)); @@ -89,11 +89,13 @@ public bool RemoveMitigation(Guid id, bool force = false) { UndoRedoManager.Detach(mitigation); UnregisterEvents(mitigation); - ChildRemoved?.Invoke(mitigation); } scope?.Complete(); } + + if (result) + ChildRemoved?.Invoke(mitigation); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.PropertySchemas.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.PropertySchemas.cs index 6d6d1c8e..eee0839e 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.PropertySchemas.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.PropertySchemas.cs @@ -978,10 +978,12 @@ public IPropertySchema AddSchema([Required] string name, [Required] string nspac Add(result); RegisterEvents(result); scope?.Complete(); - ChildCreated?.Invoke(result); } } + if (result != null) + ChildCreated?.Invoke(result); + return result; } @@ -1028,11 +1030,13 @@ private bool RemoveSchema([NotNull] IPropertySchema schema, bool force) { UndoRedoManager.Detach(s); UnregisterEvents(s); - ChildRemoved?.Invoke(s); } scope?.Complete(); } + + if (result) + ChildRemoved?.Invoke(s); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Severities.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Severities.cs index 3afff8a0..e294cf5e 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Severities.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Severities.cs @@ -100,9 +100,9 @@ public void Add([NotNull] ISeverity severity) UndoRedoManager.Attach(sd, this); _severities.Add(sd); scope?.Complete(); - - _severityCreated?.Invoke(sd); } + + _severityCreated?.Invoke(sd); } else throw new ArgumentException(nameof(severity)); @@ -151,11 +151,11 @@ public bool RemoveSeverity(int id) { UndoRedoManager.Detach(definition); scope?.Complete(); - - UnregisterEvents(definition); - _severityRemoved?.Invoke(definition); } } + + UnregisterEvents(definition); + _severityRemoved?.Invoke(definition); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Strengths.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Strengths.cs index e1b7bc53..c1c44877 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Strengths.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Strengths.cs @@ -99,9 +99,9 @@ public void Add([NotNull] IStrength strength) UndoRedoManager.Attach(sd, this); _strengths.Add(sd); scope?.Complete(); - - _strengthCreated?.Invoke(sd); } + + _strengthCreated?.Invoke(sd); } else throw new ArgumentException(nameof(strength)); @@ -149,10 +149,11 @@ public bool RemoveStrength(int id) { UndoRedoManager.Detach(definition); scope?.Complete(); - - _strengthRemoved?.Invoke(definition); } } + + if (result) + _strengthRemoved?.Invoke(definition); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.ThreatTypes.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.ThreatTypes.cs index 2d4836a1..ad4b5513 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.ThreatTypes.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.ThreatTypes.cs @@ -107,9 +107,9 @@ public void Add([NotNull] IThreatType threatType) UndoRedoManager.Attach(tt, this); _threatTypes.Add(tt); scope?.Complete(); - - ChildCreated?.Invoke(tt); } + + ChildCreated?.Invoke(tt); } else throw new ArgumentException(nameof(threatType)); @@ -148,11 +148,13 @@ public bool RemoveThreatType(Guid id, bool force = false) { UndoRedoManager.Detach(threatType); UnregisterEvents(threatType); - ChildRemoved?.Invoke(threatType); } scope?.Complete(); } + + if (result) + ChildRemoved?.Invoke(threatType); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.TrustBoundaryTemplates.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.TrustBoundaryTemplates.cs index 8bca6e3c..37345e00 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.TrustBoundaryTemplates.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.TrustBoundaryTemplates.cs @@ -40,9 +40,9 @@ public void Add([NotNull] ITrustBoundaryTemplate trustBoundaryTemplate) UndoRedoManager.Attach(tbt, this); _trustBoundaryTemplates.Add(tbt); scope?.Complete(); - - ChildCreated?.Invoke(trustBoundaryTemplate); } + + ChildCreated?.Invoke(trustBoundaryTemplate); } else throw new ArgumentException(nameof(trustBoundaryTemplate)); @@ -77,10 +77,11 @@ public bool RemoveTrustBoundaryTemplate(Guid id) { UndoRedoManager.Detach(template); scope?.Complete(); - - ChildRemoved?.Invoke(template); } } + + if (result) + ChildRemoved?.Invoke(template); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Weaknesses.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Weaknesses.cs index 653cb49a..026b17b4 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Weaknesses.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.Weaknesses.cs @@ -107,9 +107,9 @@ public void Add([NotNull] IWeakness weakness) UndoRedoManager.Attach(w, this); _weaknesses.Add(w); scope?.Complete(); - - ChildCreated?.Invoke(w); } + + ChildCreated?.Invoke(w); } else throw new ArgumentException(nameof(weakness)); @@ -148,11 +148,13 @@ public bool RemoveWeakness(Guid id, bool force = false) { UndoRedoManager.Detach(weakness); UnregisterEvents(weakness); - ChildRemoved?.Invoke(weakness); } scope?.Complete(); } + + if (result) + ChildRemoved?.Invoke(weakness); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.cs index 5858d9bb..1e42b2ff 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatModel.cs @@ -262,49 +262,53 @@ public bool ChangeDependency([Required] string oldText, [Required] string newTex public void ExecutePostDeserialization() { - if (_legacyContributors?.Any() ?? false) + using (var scope = UndoRedoManager.OpenScope("Execute Post Deserialization")) { - if (_contributors == null) - _contributors = new AdvisableCollection(); - - foreach (var contrib in _legacyContributors) + if (_legacyContributors?.Any() ?? false) { - var r = new RecordableString(contrib); - UndoRedoManager.Attach(r, this); - _contributors.Add(r); - } + if (_contributors == null) + _contributors = new AdvisableCollection(); - _legacyContributors.Clear(); - } + foreach (var contrib in _legacyContributors) + { + var r = new RecordableString(contrib); + UndoRedoManager.Attach(r, this); + _contributors.Add(r); + } - if (_legacyAssumptions?.Any() ?? false) - { - if (_assumptions == null) - _assumptions = new AdvisableCollection(); + _legacyContributors.Clear(); + } - foreach (var assump in _legacyAssumptions) + if (_legacyAssumptions?.Any() ?? false) { - var r = new RecordableString(assump); - UndoRedoManager.Attach(r, this); - _assumptions.Add(r); - } + if (_assumptions == null) + _assumptions = new AdvisableCollection(); - _legacyAssumptions.Clear(); - } + foreach (var assump in _legacyAssumptions) + { + var r = new RecordableString(assump); + UndoRedoManager.Attach(r, this); + _assumptions.Add(r); + } - if (_legacyDependencies?.Any() ?? false) - { - if (_dependencies == null) - _dependencies = new AdvisableCollection(); + _legacyAssumptions.Clear(); + } - foreach (var depend in _legacyDependencies) + if (_legacyDependencies?.Any() ?? false) { - var r = new RecordableString(depend); - UndoRedoManager.Attach(r, this); - _dependencies.Add(r); - } + if (_dependencies == null) + _dependencies = new AdvisableCollection(); + + foreach (var depend in _legacyDependencies) + { + var r = new RecordableString(depend); + UndoRedoManager.Attach(r, this); + _dependencies.Add(r); + } - _legacyDependencies.Clear(); + _legacyDependencies.Clear(); + } + scope?.Complete(); } } diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Mitigations.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Mitigations.cs index 89422e8e..7f30faf8 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Mitigations.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Mitigations.cs @@ -108,10 +108,11 @@ public bool RemoveMitigation(Guid mitigationId) { UndoRedoManager.Detach(mitigation); scope?.Complete(); - - _threatTypeMitigationRemoved?.Invoke(this, mitigation); } } + + if (result) + _threatTypeMitigationRemoved?.Invoke(this, mitigation); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Weaknesses.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Weaknesses.cs index 15cd48a2..537a4643 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Weaknesses.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/ThreatType.Weaknesses.cs @@ -108,10 +108,11 @@ public bool RemoveWeakness(Guid weaknessId) { UndoRedoManager.Detach(weakness); scope?.Complete(); - - _threatTypeWeaknessRemoved?.Invoke(this, weakness); } } + + if (result) + _threatTypeWeaknessRemoved?.Invoke(this, weakness); } return result; diff --git a/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/Weakness.Mitigations.cs b/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/Weakness.Mitigations.cs index 291b7a08..789147af 100644 --- a/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/Weakness.Mitigations.cs +++ b/Sources/ThreatsManager.Engine/ObjectModel/ThreatsMitigations/Weakness.Mitigations.cs @@ -108,10 +108,11 @@ public bool RemoveMitigation(Guid mitigationId) { UndoRedoManager.Detach(mitigation); scope?.Complete(); - - _weaknessMitigationRemoved?.Invoke(this, mitigation); } } + + if (result) + _weaknessMitigationRemoved?.Invoke(this, mitigation); } return result; diff --git a/Sources/ThreatsManager.Engine/Policies/CertificatesPolicy.cs b/Sources/ThreatsManager.Engine/Policies/CertificatesPolicy.cs new file mode 100644 index 00000000..9e855300 --- /dev/null +++ b/Sources/ThreatsManager.Engine/Policies/CertificatesPolicy.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using ThreatsManager.Engine.Config; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Engine.Policies +{ + public class CertificatesPolicy : Policy + { + protected override string PolicyName => "Certificates"; + + public IEnumerable Certificates + { + get + { + IEnumerable result = null; + + var rows = StringArrayValue; + if (rows?.Any() ?? false) + { + List certificates = null; + Regex regex = new Regex(@"(); + + var cert = new CertificateConfig() + { + Thumbprint = match.Groups["thumbprint"]?.Value, + Subject = match.Groups["subject"]?.Value, + Issuer = match.Groups["issuer"]?.Value, + ExpirationDate = match.Groups["expiration"]?.Value + }; + certificates.Add(cert); + } + } + + result = certificates?.ToArray(); + } + + return result; + } + } + } +} diff --git a/Sources/ThreatsManager.Engine/Policies/DisabledExtensionsPolicy.cs b/Sources/ThreatsManager.Engine/Policies/DisabledExtensionsPolicy.cs new file mode 100644 index 00000000..6fa629ca --- /dev/null +++ b/Sources/ThreatsManager.Engine/Policies/DisabledExtensionsPolicy.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Engine.Policies +{ + public class DisabledExtensionsPolicy : Policy + { + protected override string PolicyName => "DisabledExtensions"; + + public IEnumerable DisabledExtensions => StringArrayValue; + } +} diff --git a/Sources/ThreatsManager.Engine/Policies/DisabledLibrariesPolicy.cs b/Sources/ThreatsManager.Engine/Policies/DisabledLibrariesPolicy.cs new file mode 100644 index 00000000..f22045ef --- /dev/null +++ b/Sources/ThreatsManager.Engine/Policies/DisabledLibrariesPolicy.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Engine.Policies +{ + public class DisabledLibrariesPolicy : Policy + { + protected override string PolicyName => "DisabledLibraries"; + + public IEnumerable DisabledLibraries => StringArrayValue; + } +} diff --git a/Sources/ThreatsManager.Engine/Policies/FoldersPolicy.cs b/Sources/ThreatsManager.Engine/Policies/FoldersPolicy.cs new file mode 100644 index 00000000..f8895716 --- /dev/null +++ b/Sources/ThreatsManager.Engine/Policies/FoldersPolicy.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Engine.Policies +{ + /// + /// Additional folders where the Extension libraries must be searched. + /// + /// It includes a folder in each line.Do not include quotes or double quotes. + /// This policy integrates and extends the corresponding setting in TMS, it does not replace it. + /// + public class FoldersPolicy : Policy + { + protected override string PolicyName => "Folders"; + + public IEnumerable Folders => StringArrayValue; + } +} diff --git a/Sources/ThreatsManager.Engine/Policies/MaxExecutionModePolicy.cs b/Sources/ThreatsManager.Engine/Policies/MaxExecutionModePolicy.cs new file mode 100644 index 00000000..e040bd5e --- /dev/null +++ b/Sources/ThreatsManager.Engine/Policies/MaxExecutionModePolicy.cs @@ -0,0 +1,27 @@ +using System; +using ThreatsManager.Interfaces; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Engine.Policies +{ + public class MaxExecutionModePolicy : Policy + { + protected override string PolicyName => "MaxExecutionMode"; + + public ExecutionMode? MaxExecutionMode + { + get + { + ExecutionMode? result = null; + + var fromRegistry = Value as string; + if (fromRegistry != null && Enum.TryParse(fromRegistry, out var maxExecutionMode)) + { + result = maxExecutionMode; + } + + return result; + } + } + } +} diff --git a/Sources/ThreatsManager.Engine/Policies/PrefixesPolicy.cs b/Sources/ThreatsManager.Engine/Policies/PrefixesPolicy.cs new file mode 100644 index 00000000..056e7792 --- /dev/null +++ b/Sources/ThreatsManager.Engine/Policies/PrefixesPolicy.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Engine.Policies +{ + /// + /// Additional prefixes allowed for the Extension libraries. + /// + /// + /// It is not necessary to configure Prefixes for the default prefix used for the standard Extension libraries(“ThreatsManager”). + /// It includes an allowed prefix in each line. Do not include quotes or double quotes. + /// This policy integrates and extends the corresponding setting in TMS, it does not replace it. + /// + public class PrefixesPolicy : Policy + { + protected override string PolicyName => "Prefixes"; + + public IEnumerable Prefixes => StringArrayValue; + } +} diff --git a/Sources/ThreatsManager.Engine/Policies/RequireCertsPolicy.cs b/Sources/ThreatsManager.Engine/Policies/RequireCertsPolicy.cs new file mode 100644 index 00000000..5c4c1271 --- /dev/null +++ b/Sources/ThreatsManager.Engine/Policies/RequireCertsPolicy.cs @@ -0,0 +1,11 @@ +using ThreatsManager.Utilities; + +namespace ThreatsManager.Engine.Policies +{ + public class RequireCertsPolicy : Policy + { + protected override string PolicyName => "RequireCerts"; + + public bool? RequireCerts => BoolValue; + } +} diff --git a/Sources/ThreatsManager.Engine/ThreatsManager.Engine.csproj b/Sources/ThreatsManager.Engine/ThreatsManager.Engine.csproj index 02146fac..fd6d2f6f 100644 --- a/Sources/ThreatsManager.Engine/ThreatsManager.Engine.csproj +++ b/Sources/ThreatsManager.Engine/ThreatsManager.Engine.csproj @@ -3,15 +3,15 @@ net481 Threats Manager Platform Engine. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Engine/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 true ThreatsManager.snk false diff --git a/Sources/ThreatsManager.Interfaces/Extensions/IPolicy.cs b/Sources/ThreatsManager.Interfaces/Extensions/IPolicy.cs new file mode 100644 index 00000000..f07eb7b3 --- /dev/null +++ b/Sources/ThreatsManager.Interfaces/Extensions/IPolicy.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ThreatsManager.Interfaces.Extensions +{ + /// + /// Policies are used to enforce settings defined by the organization. + /// + /// The actual value of the setting is specific to the Policy itself, and must be read-only + /// from some protected source. Policies will typically use values in the Registry + /// under "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Simone Curzi\Threats Manager Studio\Policies". + /// The recommended way to create a Policy is to create a class derived from ThreatsManager.Utilities.Policy. + [ExtensionDescription("Extension Initializer")] + public interface IPolicy : IExtension + { + /// + /// Property returning true if the Policy is defined. + /// + bool IsDefined { get; } + + /// + /// Value of the Policy. + /// + object Value { get; } + } +} diff --git a/Sources/ThreatsManager.Interfaces/ThreatsManager.Interfaces.csproj b/Sources/ThreatsManager.Interfaces/ThreatsManager.Interfaces.csproj index dd0dff3a..c51de857 100644 --- a/Sources/ThreatsManager.Interfaces/ThreatsManager.Interfaces.csproj +++ b/Sources/ThreatsManager.Interfaces/ThreatsManager.Interfaces.csproj @@ -3,15 +3,15 @@ net481 Common Interfaces used to define the object, entities and extensions that compose the Threats Manager Platform and allow to extend it. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Interfaces/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 false false $(NoWarn);NU1505 diff --git a/Sources/ThreatsManager.Utilities/Aspects/Engine/PropertiesContainerAspect.cs b/Sources/ThreatsManager.Utilities/Aspects/Engine/PropertiesContainerAspect.cs index 00b7ed26..bf0b5cbe 100644 --- a/Sources/ThreatsManager.Utilities/Aspects/Engine/PropertiesContainerAspect.cs +++ b/Sources/ThreatsManager.Utilities/Aspects/Engine/PropertiesContainerAspect.cs @@ -7,7 +7,6 @@ using PostSharp.Aspects.Advices; using PostSharp.Aspects.Dependencies; using PostSharp.Patterns.Collections; -using PostSharp.Patterns.Model; using PostSharp.Reflection; using PostSharp.Serialization; using ThreatsManager.Interfaces; @@ -229,13 +228,16 @@ private IProperty InternalAddProperty(IPropertyType propertyType, string value) UndoRedoManager.Attach(result, model); properties?.Add(result); scope?.Complete(); - - if (Instance is IPropertiesContainer container) - _propertyAdded?.Invoke(container, result); - result.Changed += OnPropertyChanged; } } + if (result != null) + { + if (Instance is IPropertiesContainer container) + _propertyAdded?.Invoke(container, result); + result.Changed += OnPropertyChanged; + } + return result; } diff --git a/Sources/ThreatsManager.Utilities/CloningExtensions.cs b/Sources/ThreatsManager.Utilities/CloningExtensions.cs index 9ece6eea..8ceb6930 100644 --- a/Sources/ThreatsManager.Utilities/CloningExtensions.cs +++ b/Sources/ThreatsManager.Utilities/CloningExtensions.cs @@ -1,7 +1,4 @@ -using System; -using System.Linq; -using System.Reflection; -using System.Xml.Linq; +using System.Linq; using PostSharp.Patterns.Contracts; using ThreatsManager.Interfaces.ObjectModel; using ThreatsManager.Interfaces.ObjectModel.Entities; @@ -27,43 +24,48 @@ public static void CloneProperties(this IPropertiesContainer source, if ((properties?.Any() ?? false) && target is IThreatModelChild child) { - if (child.Model is IThreatModel model && - properties.FirstOrDefault()?.Model is IThreatModel sourceModel) + using (var scope = UndoRedoManager.OpenScope("Clone Properties")) { - foreach (var property in properties) + if (child.Model is IThreatModel model && + properties.FirstOrDefault()?.Model is IThreatModel sourceModel) { - if (property.PropertyType is IPropertyType sourcePropertyType && - sourceModel.GetSchema(sourcePropertyType.SchemaId) is IPropertySchema sourceSchema) + foreach (var property in properties) { - if (model.GetSchema(sourceSchema.Name, sourceSchema.Namespace) is IPropertySchema targetSchema && - (model.Id == sourceModel.Id || !targetSchema.NotExportable)) + if (property.PropertyType is IPropertyType sourcePropertyType && + sourceModel.GetSchema(sourcePropertyType.SchemaId) is IPropertySchema sourceSchema) { - var propertyType = targetSchema.GetPropertyType(sourcePropertyType.Name); - if (propertyType != null) + if (model.GetSchema(sourceSchema.Name, sourceSchema.Namespace) is IPropertySchema targetSchema && + (model.Id == sourceModel.Id || !sourceSchema.NotExportable)) { - var propertyTarget = target.GetProperty(propertyType); - if (propertyTarget == null) - target.AddProperty(propertyType, property.StringValue); - else - propertyTarget.StringValue = property.StringValue; + var propertyType = targetSchema.GetPropertyType(sourcePropertyType.Name); + if (propertyType != null) + { + var propertyTarget = target.GetProperty(propertyType); + if (propertyTarget == null) + target.AddProperty(propertyType, property.StringValue); + else + propertyTarget.StringValue = property.StringValue; + } } } } } - } - else - { - foreach (var property in properties) + else { - if (property.PropertyType is IPropertyType propertyType) + foreach (var property in properties) { - var propertyTarget = target.GetProperty(propertyType); - if (propertyTarget == null) - target.AddProperty(propertyType, property.StringValue); - else - propertyTarget.StringValue = property.StringValue; + if (property.PropertyType is IPropertyType propertyType) + { + var propertyTarget = target.GetProperty(propertyType); + if (propertyTarget == null) + target.AddProperty(propertyType, property.StringValue); + else + propertyTarget.StringValue = property.StringValue; + } } } + + scope?.Complete(); } } } @@ -79,9 +81,13 @@ public static void CloneThreatEvents(this IThreatEventsContainer source, var threatEvents = source?.ThreatEvents?.ToArray(); if (threatEvents?.Any() ?? false) { - foreach (var threatEvent in threatEvents) + using (var scope = UndoRedoManager.OpenScope("Clone Threat Events")) { - threatEvent.Clone(target); + foreach (var threatEvent in threatEvents) + { + threatEvent.Clone(target); + } + scope?.Complete(); } } } @@ -97,9 +103,13 @@ public static void ClonePropertyTypes(this IPropertyTypesContainer source, var propertyTypes = source?.PropertyTypes?.ToArray(); if (propertyTypes?.Any() ?? false) { - foreach (var propertyType in propertyTypes) + using (var scope = UndoRedoManager.OpenScope("Clone Property Types")) { - propertyType.Clone(target); + foreach (var propertyType in propertyTypes) + { + propertyType.Clone(target); + } + scope?.Complete(); } } } @@ -115,11 +125,15 @@ public static void MergePropertyTypes(this IPropertyTypesContainer target, var propertyTypes = source?.PropertyTypes?.ToArray(); if (propertyTypes?.Any() ?? false) { - foreach (var propertyType in propertyTypes) + using (var scope = UndoRedoManager.OpenScope("Merge Property Types")) { - var targetPropertyType = target.GetPropertyType(propertyType.Name); - if (targetPropertyType == null) - propertyType.Clone(target); + foreach (var propertyType in propertyTypes) + { + var targetPropertyType = target.GetPropertyType(propertyType.Name); + if (targetPropertyType == null) + propertyType.Clone(target); + } + scope?.Complete(); } } } @@ -139,37 +153,42 @@ sourceChild.Model is IThreatModel sourceModel && target is IThreatModelChild targetChild && targetChild.Model is IThreatModel targetModel) { - foreach (var property in properties) + using (var scope = UndoRedoManager.OpenScope("Merge Property Types")) { - var sourcePropertyType = property.PropertyType; - if (sourcePropertyType != null) + foreach (var property in properties) { - var sourceSchema = sourceModel.GetSchema(sourcePropertyType.SchemaId); - if (sourceSchema != null) + var sourcePropertyType = property.PropertyType; + if (sourcePropertyType != null) { - var targetSchema = targetModel.GetSchema(sourceSchema.Name, sourceSchema.Namespace) ?? - sourceSchema.Clone(targetModel); + var sourceSchema = sourceModel.GetSchema(sourcePropertyType.SchemaId); + if (sourceSchema != null) + { + var targetSchema = targetModel.GetSchema(sourceSchema.Name, sourceSchema.Namespace) ?? + sourceSchema.Clone(targetModel); - var targetPropertyType = targetSchema.GetPropertyType(sourcePropertyType.Name) ?? - sourcePropertyType.Clone(targetSchema); + var targetPropertyType = targetSchema.GetPropertyType(sourcePropertyType.Name) ?? + sourcePropertyType.Clone(targetSchema); - var targetProperty = target.GetProperty(targetPropertyType); - if (targetProperty == null) - { - target.AddProperty(targetPropertyType, property.StringValue); - } - else - { - if (targetProperty is IPropertyJsonSerializableObject jsonSerializableObject && - jsonSerializableObject.Value is IMergeable mergeable && - property is IPropertyJsonSerializableObject sourceJsonSerializableObject && - sourceJsonSerializableObject.Value is IMergeable sourceMergeable) + var targetProperty = target.GetProperty(targetPropertyType); + if (targetProperty == null) + { + target.AddProperty(targetPropertyType, property.StringValue); + } + else { - mergeable.Merge(sourceMergeable); + if (targetProperty is IPropertyJsonSerializableObject jsonSerializableObject && + jsonSerializableObject.Value is IMergeable mergeable && + property is IPropertyJsonSerializableObject sourceJsonSerializableObject && + sourceJsonSerializableObject.Value is IMergeable sourceMergeable) + { + mergeable.Merge(sourceMergeable); + } } } } } + + scope?.Complete(); } } } @@ -188,35 +207,42 @@ public static IEntity CloneAndConvert(this IEntity source, if (source != null && source.Model is IThreatModel model) { + var newName = $"{source.Name} (copy)"; using (var scope = UndoRedoManager.OpenScope("Clone and convert Entity")) { if (template != null && template.EntityType == entityType) { + // Creation of a clone of the source entity eventually changing its type and applied template. + switch (entityType) { case EntityType.ExternalInteractor: - result = model.AddEntity(source.Name, template); + result = model.AddEntity(newName, template); break; case EntityType.Process: - result = model.AddEntity(source.Name, template); + result = model.AddEntity(newName, template); break; case EntityType.DataStore: - result = model.AddEntity(source.Name, template); + result = model.AddEntity(newName, template); break; } } else { + // Creation of a clone of the source entity eventually changing its type. + var existingTemplate = source.GetEntityType() == entityType ? + source.Template : null; + switch (entityType) { case EntityType.ExternalInteractor: - result = model.AddEntity(source.Name); + result = model.AddEntity(newName, existingTemplate); break; case EntityType.Process: - result = model.AddEntity(source.Name); + result = model.AddEntity(newName, existingTemplate); break; case EntityType.DataStore: - result = model.AddEntity(source.Name); + result = model.AddEntity(newName, existingTemplate); break; } } @@ -229,47 +255,262 @@ public static IEntity CloneAndConvert(this IEntity source, result.BigImage = source.BigImage; result.Image = source.Image; result.SmallImage = source.SmallImage; + source.CopyProperties(result); + source.CopyThreatEvents(result); + source.CopyVulnerabilities(result); + source.CopyFlows(result); - var threatEvents = source.ThreatEvents?.ToArray(); - if (threatEvents?.Any() ?? false) + scope?.Complete(); + } + } + } + + return result; + } + + /// + /// Copy Properties between Containers. + /// + /// Source Container. + /// Target Container. + /// This function differs from + /// in that it checks if the target container is supported by the Property Schema, before copying the properties. + public static void CopyProperties(this IPropertiesContainer source, + [NotNull] IPropertiesContainer target) + { + var properties = source?.Properties?.ToArray(); + if ((properties?.Any() ?? false) && + target is IThreatModelChild child) + { + if (child.Model is IThreatModel model && + properties.FirstOrDefault()?.Model is IThreatModel sourceModel) + { + using (var scope = UndoRedoManager.OpenScope("Copy Properties")) + { + foreach (var property in properties) { - foreach (var threatEvent in threatEvents) + if (property.PropertyType is IPropertyType sourcePropertyType && + sourceModel.GetSchema(sourcePropertyType.SchemaId) is IPropertySchema sourceSchema) { - var newTe = result.AddThreatEvent(threatEvent.ThreatType); - if (newTe != null) + if (model.GetSchema(sourceSchema.Name, sourceSchema.Namespace) is IPropertySchema targetSchema && + (model.Id == sourceModel.Id || !sourceSchema.NotExportable) && + targetSchema.AppliesTo.HasFlag(target.PropertiesScope)) { - newTe.Name = threatEvent.Name; - newTe.Description = threatEvent.Description; - - // TODO: copy threat event data. + var propertyType = targetSchema.GetPropertyType(sourcePropertyType.Name); + if (propertyType != null) + { + var propertyTarget = target.GetProperty(propertyType); + if (propertyTarget == null) + target.AddProperty(propertyType, property.StringValue); + else + propertyTarget.StringValue = property.StringValue; + } } } } + scope?.Complete(); + } + } + } + } - var vulnerabilities = source.Vulnerabilities?.ToArray(); - if (vulnerabilities?.Any() ?? false) + /// + /// Copy Threat Events between Containers. + /// + /// Source Container. + /// Target Container. + private static void CopyThreatEvents(this IThreatEventsContainer source, + [NotNull] IThreatEventsContainer target) + { + var threatEvents = source.ThreatEvents?.ToArray(); + if (threatEvents?.Any() ?? false) + { + using (var scope = UndoRedoManager.OpenScope("Copy Threat Events")) + { + foreach (var threatEvent in threatEvents) + { + var newTe = target.AddThreatEvent(threatEvent.ThreatType); + if (newTe != null) { - foreach (var vulnerability in vulnerabilities) - { - var newV = result.AddVulnerability(vulnerability.Weakness); - if (newV != null) - { - newV.Name = vulnerability.Name; - newV.Description = vulnerability.Description; + newTe.Name = threatEvent.Name; + newTe.Description = threatEvent.Description; + newTe.Severity = threatEvent.Severity; + threatEvent.CopyThreatEventMitigations(newTe); + threatEvent.CopyThreatEventScenarios(newTe); + threatEvent.CopyVulnerabilities(newTe); + threatEvent.CopyProperties(newTe); + } + } + scope?.Complete(); + } + } + } - // TODO: copy vulnerability details. - } - } + /// + /// Copy Threat Event Mitigations between Containers. + /// + /// Source Container. + /// Target Container. + public static void CopyThreatEventMitigations(this IThreatEventMitigationsContainer source, + [NotNull] IThreatEventMitigationsContainer target) + { + var mitigations = source.Mitigations?.ToArray(); + if (mitigations?.Any() ?? false) + { + using (var scope = UndoRedoManager.OpenScope("Copy Threat Event Mitigations")) + { + foreach (var mitigation in mitigations) + { + var newM = target.AddMitigation(mitigation.Mitigation, mitigation.Strength, + mitigation.Status, mitigation.Directives); + if (newM != null) + { + mitigation.CopyProperties(newM); } + } + scope?.Complete(); + } + } + } - // TODO: copy properties ensuring that their compatibility with the target object. + /// + /// Copy Threat Event Scenarios between Containers. + /// + /// Source Container. + /// Target Container. + public static void CopyThreatEventScenarios(this IThreatEventScenariosContainer source, + [NotNull] IThreatEventScenariosContainer target) + { + var scenarios = source.Scenarios?.ToArray(); + if (scenarios?.Any() ?? false) + { + using (var scope = UndoRedoManager.OpenScope("Copy Threat Event Scenarios")) + { + foreach (var scenario in scenarios) + { + var newS = target.AddScenario(scenario.Actor, scenario.Severity, scenario.Name); + if (newS != null) + { + newS.Description = scenario.Description; + newS.Motivation = scenario.Motivation; + scenario.CopyProperties(newS); + } + } + scope?.Complete(); + } + } + } - scope?.Complete(); + /// + /// Copy Vulnerabilities between Containers. + /// + /// Source Container. + /// Target Container. + public static void CopyVulnerabilities(this IVulnerabilitiesContainer source, + [NotNull] IVulnerabilitiesContainer target) + { + var vulnerabilities = source.Vulnerabilities?.ToArray(); + if (vulnerabilities?.Any() ?? false) + { + using (var scope = UndoRedoManager.OpenScope("Copy Vulnerabilities")) + { + foreach (var vulnerability in vulnerabilities) + { + var newVuln = target.AddVulnerability(vulnerability.Weakness); + if (newVuln != null) + { + newVuln.Name = vulnerability.Name; + newVuln.Description = vulnerability.Description; + newVuln.Severity = vulnerability.Severity; + vulnerability.CopyVulnerabilityMitigations(newVuln); + vulnerability.CopyProperties(newVuln); + } } + scope?.Complete(); } } + } - return result; + /// + /// Copy Vulnerabilities Mitigations between Containers. + /// + /// Source Container. + /// Target Container. + public static void CopyVulnerabilityMitigations(this IVulnerabilityMitigationsContainer source, + [NotNull] IVulnerabilityMitigationsContainer target) + { + var mitigations = source.Mitigations?.ToArray(); + if (mitigations?.Any() ?? false) + { + using (var scope = UndoRedoManager.OpenScope("Copy Vulnerability Mitigations")) + { + foreach (var mitigation in mitigations) + { + var newM = target.AddMitigation(mitigation.Mitigation, mitigation.Strength, + mitigation.Status, mitigation.Directives); + if (newM != null) + { + mitigation.CopyProperties(newM); + } + } + scope?.Complete(); + } + } + } + + /// + /// Copy all Flows involving the Source Entity to the Target Entity. + /// + /// Source Entity. + /// Target Entity + public static void CopyFlows(this IEntity source, [NotNull] IEntity target) + { + if (source != null && source.Model is IThreatModel model) + { + var outFlows = model.DataFlows? + .Where(x => x.SourceId == source.Id) + .ToArray(); + if (outFlows?.Any() ?? false) + { + foreach (var flow in outFlows) + { + IDataFlow newFlow = null; + if (flow.Template == null) + newFlow = model.AddDataFlow(flow.Name, target.Id, flow.TargetId); + else + newFlow = model.AddDataFlow(flow.Name, target.Id, flow.TargetId, flow.Template); + if (newFlow != null) + { + newFlow.FlowType = flow.FlowType; + flow.CopyThreatEvents(newFlow); + flow.CopyVulnerabilities(newFlow); + flow.CopyProperties(newFlow); + } + } + } + + var inFlows = model.DataFlows? + .Where(x => x.TargetId == source.Id) + .ToArray(); + if (inFlows?.Any() ?? false) + { + foreach (var flow in inFlows) + { + IDataFlow newFlow = null; + if (flow.Template == null) + newFlow = model.AddDataFlow(flow.Name, flow.SourceId, target.Id); + else + newFlow = model.AddDataFlow(flow.Name, flow.SourceId, target.Id, flow.Template); + if (newFlow != null) + { + newFlow.FlowType = flow.FlowType; + flow.CopyThreatEvents(newFlow); + flow.CopyVulnerabilities(newFlow); + flow.CopyProperties(newFlow); + } + } + } + } } } } diff --git a/Sources/ThreatsManager.Utilities/EnumExtensions.cs b/Sources/ThreatsManager.Utilities/EnumExtensions.cs index 6bb7a65b..5eb854e2 100644 --- a/Sources/ThreatsManager.Utilities/EnumExtensions.cs +++ b/Sources/ThreatsManager.Utilities/EnumExtensions.cs @@ -130,6 +130,38 @@ public static T GetEnumValue([Required] this string text, T defaultValue) return result; } + /// + /// Try get the value of the enumeration from a string. + /// + /// Type of the enumeration. + /// String that needs to be parsed to get the value of the enumeration + /// [Out] Value of the enumeration. + /// True if the value has been retrieved correctly, false otherwise. + public static bool TryGetEnumValue([Required] this string text, out T enumValue) + { + bool result = false; + + enumValue = default(T); + + Type type = typeof(T); + + var fields = type.GetFields(); + foreach (var field in fields) + { + var attribs = field.GetCustomAttributes().ToArray(); + + if (attribs.Any(x => string.CompareOrdinal(x.Label, text) == 0) || + string.CompareOrdinal(text, field.Name) == 0) + { + enumValue = (T)field.GetValue(type); + result = true; + break; + } + } + + return result; + } + public static string GetXmlEnumLabel(this Enum value) { Type type = value.GetType(); diff --git a/Sources/ThreatsManager.Utilities/Policies/HelpTroubleshootPolicy.cs b/Sources/ThreatsManager.Utilities/Policies/HelpTroubleshootPolicy.cs new file mode 100644 index 00000000..4a70074b --- /dev/null +++ b/Sources/ThreatsManager.Utilities/Policies/HelpTroubleshootPolicy.cs @@ -0,0 +1,9 @@ +namespace ThreatsManager.Utilities.Policies +{ + public class HelpTroubleshootPolicy : Policy + { + protected override string PolicyName => "HelpTroubleshoot"; + + public bool? HelpTroubleshoot => BoolValue; + } +} diff --git a/Sources/ThreatsManager.Utilities/Policy.cs b/Sources/ThreatsManager.Utilities/Policy.cs new file mode 100644 index 00000000..1ac06a76 --- /dev/null +++ b/Sources/ThreatsManager.Utilities/Policy.cs @@ -0,0 +1,80 @@ +using Microsoft.Win32; +using PostSharp.Patterns.Contracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ThreatsManager.Interfaces.Extensions; + +namespace ThreatsManager.Utilities +{ + /// + /// Abstract Policy class. + /// + /// This is the recommemded starting point to create your own Policies. + /// It stores the policies configuration in the Registry, under a location that by default is + /// "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Simone Curzi\Threats Manager Studio\Policies". + public abstract class Policy : IPolicy + { + /// + /// Get a Policy given its identifier. + /// + /// Extension Identifier of the Policy. + /// Instanec of the Policy, if found, otherwise null. + public static Policy GetPolicy([Required] string id) + { + return ExtensionUtils.GetExtension(id) as Policy; + } + + /// + /// Location of the Key in the Registry containing the Policies. + /// + protected virtual string Location => @"HKEY_LOCAL_MACHINE\SOFTWARE\Simone Curzi\Threats Manager Studio\Policies"; + + /// + /// Name of the Policy in the Registry. + /// + protected abstract string PolicyName { get; } + + /// + /// Property returning true if the Policy is defined. + /// + public bool IsDefined => Value != null; + + /// + /// Value of the Policy. + /// + public object Value => Registry.GetValue(Location, PolicyName, null); + + /// + /// Provides the Value as boolean. + /// + protected bool? BoolValue + { + get + { + bool? result = null; + + var fromRegistry = (int?)Value; + if (fromRegistry.HasValue) + { + result = fromRegistry.Value != 0; + } + + return result; + } + } + + /// + /// Provides the Value as enumeration of strings. + /// + public IEnumerable StringArrayValue + { + get + { + return Value as string[]; + } + } + } +} diff --git a/Sources/ThreatsManager.Utilities/ThreatsManager.Utilities.csproj b/Sources/ThreatsManager.Utilities/ThreatsManager.Utilities.csproj index 8f0bdd7d..6edac7f6 100644 --- a/Sources/ThreatsManager.Utilities/ThreatsManager.Utilities.csproj +++ b/Sources/ThreatsManager.Utilities/ThreatsManager.Utilities.csproj @@ -3,15 +3,15 @@ net481 Library to manage the solution files at a low level. - 2.1.1.0 + 2.1.2.0 Simone Curzi Simone Curzi Threats Manager Platform Copyright © Simone Curzi, 2018-2023. All Rights Reserved. https://www.nuget.org/packages/ThreatsManager.Utilities/ https://github.com/simonec73/threatsmanager - 2.1.1.0 - 2.1.1 + 2.1.2.0 + 2.1.2 $(NoWarn);NU1505 diff --git a/Studio/ThreatsManager.AutoThreatGeneration.WinForms/ExtensionsContainer.cs b/Studio/ThreatsManager.AutoThreatGeneration.WinForms/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Studio/ThreatsManager.AutoThreatGeneration.WinForms/ExtensionsContainer.cs +++ b/Studio/ThreatsManager.AutoThreatGeneration.WinForms/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Studio/ThreatsManager.DevOps.WinForms/ExtensionConfigurationManager.cs b/Studio/ThreatsManager.DevOps.WinForms/ExtensionConfigurationManager.cs deleted file mode 100644 index 54978e81..00000000 --- a/Studio/ThreatsManager.DevOps.WinForms/ExtensionConfigurationManager.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using PostSharp.Patterns.Contracts; -using ThreatsManager.Interfaces.Extensions; -using ThreatsManager.Interfaces.ObjectModel; -using ThreatsManager.Utilities; - -namespace ThreatsManager.DevOps -{ - class ExtensionConfigurationManager - { - private readonly IThreatModel _model; - private readonly string _extensionId; - private readonly ExtensionConfiguration _configuration; - private bool _dirty; - - public ExtensionConfigurationManager([NotNull] IThreatModel model, [Required] string extensionId) - { - _model = model; - _extensionId = extensionId; - _configuration = model.GetExtensionConfiguration(extensionId); - } - - public void Apply() - { - if (_dirty) - _model.SetExtensionConfiguration(_extensionId, _configuration); - if (ScheduledRefreshes) - DevOpsManager.StartAutomaticUpdater(_model, RefreshInterval, NotificationStrategy); - else - DevOpsManager.StopAutomaticUpdater(); - } - - public IEnumerable Data => _configuration?.Data; - - public bool ScheduledRefreshes - { - get => _configuration?.GlobalGet("scheduledRefreshes") ?? false; - - set - { - _configuration?.GlobalSet("scheduledRefreshes", value); - _dirty = true; - } - } - - public int RefreshInterval - { - get => _configuration?.GlobalGet("refreshInterval", 10) ?? 0; - - set - { - _configuration?.GlobalSet("refreshInterval", value); - _dirty = true; - } - } - - public NotificationType NotificationStrategy - { - get => Enum.TryParse(_configuration?.GlobalGet("notification", - NotificationType.None.ToString()), out var result) ? result : NotificationType.None; - - set - { - _configuration?.GlobalSet("notification", value.ToString()); - _dirty = true; - } - } - } -} diff --git a/Studio/ThreatsManager.DevOps.WinForms/ExtensionsContainer.cs b/Studio/ThreatsManager.DevOps.WinForms/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Studio/ThreatsManager.DevOps.WinForms/ExtensionsContainer.cs +++ b/Studio/ThreatsManager.DevOps.WinForms/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Studio/ThreatsManager.DevOps.WinForms/Initializers/AutoConnector.cs b/Studio/ThreatsManager.DevOps.WinForms/Initializers/AutoConnector.cs index 881bca5d..85f2332a 100644 --- a/Studio/ThreatsManager.DevOps.WinForms/Initializers/AutoConnector.cs +++ b/Studio/ThreatsManager.DevOps.WinForms/Initializers/AutoConnector.cs @@ -42,11 +42,6 @@ public async void Process(IThreatModel model) { DevOpsManager.Register(connector, model); Connect.ChangeDisconnectButtonStatus(connector, true); - - var configManager = new ExtensionConfigurationManager(model, this.GetExtensionId()); - configManager.Apply(); - - await DevOpsManager.UpdateAsync(model); } } else diff --git a/Studio/ThreatsManager.DevOps.WinForms/Initializers/UpdateNotifier.cs b/Studio/ThreatsManager.DevOps.WinForms/Initializers/UpdateNotifier.cs deleted file mode 100644 index 6b98d8a2..00000000 --- a/Studio/ThreatsManager.DevOps.WinForms/Initializers/UpdateNotifier.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using PostSharp.Patterns.Contracts; -using ThreatsManager.Interfaces; -using ThreatsManager.Interfaces.Extensions; -using ThreatsManager.Interfaces.ObjectModel; -using ThreatsManager.Utilities; - -namespace ThreatsManager.DevOps.Initializers -{ - [Extension("D527CFC8-E594-415A-A993-3FC1175C6487", "DevOps Update Notifier", 100, ExecutionMode.Management)] - public class UpdateNotifier : IExtensionInitializer, IDesktopAlertAwareExtension - { - public void Initialize() - { - DevOpsManager.RefreshDone += DevOpsManagerOnRefreshDone; - } - - private void DevOpsManagerOnRefreshDone([NotNull] IThreatModel model, int count) - { - var configManager = new ExtensionConfigurationManager(model, (new AutoConnector()).GetExtensionId()); - bool show; - switch (configManager.NotificationStrategy) - { - case NotificationType.SuccessOnly: - show = count > 0; - break; - case NotificationType.Full: - show = true; - break; - default: - show = false; - break; - } - - if (show) - ShowMessage?.Invoke($"DevOps Updater has detected {count} update(s)."); - } - - public event Action ShowMessage; - public event Action ShowWarning; - } -} diff --git a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.Designer.cs b/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.Designer.cs deleted file mode 100644 index 80ad01e4..00000000 --- a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.Designer.cs +++ /dev/null @@ -1,228 +0,0 @@ - -namespace ThreatsManager.DevOps.Panels.Configuration -{ - partial class ConfigurationPanel - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.layoutControl1 = new DevComponents.DotNetBar.Layout.LayoutControl(); - this._raiseAllEvents = new System.Windows.Forms.RadioButton(); - this._raiseSomeEvents = new System.Windows.Forms.RadioButton(); - this._raiseNoEvents = new System.Windows.Forms.RadioButton(); - this._interval = new DevComponents.Editors.IntegerInput(); - this._scheduledRefresh = new System.Windows.Forms.CheckBox(); - this.layoutControlItem1 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.layoutControlItem2 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.layoutControlItem3 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.layoutControlItem4 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.layoutControlItem5 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this._tooltip = new System.Windows.Forms.ToolTip(this.components); - this.layoutControl1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this._interval)).BeginInit(); - this.SuspendLayout(); - // - // layoutControl1 - // - this.layoutControl1.BackColor = System.Drawing.Color.White; - this.layoutControl1.Controls.Add(this._raiseAllEvents); - this.layoutControl1.Controls.Add(this._raiseSomeEvents); - this.layoutControl1.Controls.Add(this._raiseNoEvents); - this.layoutControl1.Controls.Add(this._interval); - this.layoutControl1.Controls.Add(this._scheduledRefresh); - this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Fill; - this.layoutControl1.Location = new System.Drawing.Point(0, 0); - this.layoutControl1.Name = "layoutControl1"; - // - // - // - this.layoutControl1.RootGroup.Items.AddRange(new DevComponents.DotNetBar.Layout.LayoutItemBase[] { - this.layoutControlItem1, - this.layoutControlItem2, - this.layoutControlItem3, - this.layoutControlItem4, - this.layoutControlItem5}); - this.layoutControl1.Size = new System.Drawing.Size(683, 466); - this.layoutControl1.TabIndex = 0; - // - // _raiseAllEvents - // - this._raiseAllEvents.AutoSize = true; - this._raiseAllEvents.Enabled = false; - this._raiseAllEvents.Location = new System.Drawing.Point(21, 107); - this._raiseAllEvents.Margin = new System.Windows.Forms.Padding(0); - this._raiseAllEvents.Name = "_raiseAllEvents"; - this._raiseAllEvents.Size = new System.Drawing.Size(658, 17); - this._raiseAllEvents.TabIndex = 4; - this._raiseAllEvents.Text = "Raise a notification every time a Refresh is performed"; - this._raiseAllEvents.UseVisualStyleBackColor = true; - this._raiseAllEvents.CheckedChanged += new System.EventHandler(this._raiseAllEvents_CheckedChanged); - // - // _raiseSomeEvents - // - this._raiseSomeEvents.AutoSize = true; - this._raiseSomeEvents.Enabled = false; - this._raiseSomeEvents.Location = new System.Drawing.Point(21, 82); - this._raiseSomeEvents.Margin = new System.Windows.Forms.Padding(0); - this._raiseSomeEvents.Name = "_raiseSomeEvents"; - this._raiseSomeEvents.Size = new System.Drawing.Size(658, 17); - this._raiseSomeEvents.TabIndex = 3; - this._raiseSomeEvents.Text = "Raise a notification only if one or more updates are found\r\n"; - this._raiseSomeEvents.UseVisualStyleBackColor = true; - this._raiseSomeEvents.CheckedChanged += new System.EventHandler(this._raiseSomeEvents_CheckedChanged); - // - // _raiseNoEvents - // - this._raiseNoEvents.AutoSize = true; - this._raiseNoEvents.Checked = true; - this._raiseNoEvents.Enabled = false; - this._raiseNoEvents.Location = new System.Drawing.Point(21, 57); - this._raiseNoEvents.Margin = new System.Windows.Forms.Padding(0); - this._raiseNoEvents.Name = "_raiseNoEvents"; - this._raiseNoEvents.Size = new System.Drawing.Size(658, 17); - this._raiseNoEvents.TabIndex = 2; - this._raiseNoEvents.TabStop = true; - this._raiseNoEvents.Text = "Do not raise any notification as a result of a Refresh"; - this._raiseNoEvents.UseVisualStyleBackColor = true; - this._raiseNoEvents.CheckedChanged += new System.EventHandler(this._raiseNoEvents_CheckedChanged); - // - // _interval - // - // - // - // - this._interval.BackgroundStyle.Class = "DateTimeInputBackground"; - this._interval.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this._interval.ButtonFreeText.Shortcut = DevComponents.DotNetBar.eShortcut.F2; - this._interval.Enabled = false; - this._interval.Location = new System.Drawing.Point(100, 29); - this._interval.Margin = new System.Windows.Forms.Padding(0); - this._interval.MaxValue = 120; - this._interval.MinValue = 1; - this._interval.Name = "_interval"; - this._interval.ShowUpDown = true; - this._interval.Size = new System.Drawing.Size(96, 20); - this._interval.TabIndex = 1; - this._tooltip.SetToolTip(this._interval, "Interval between two repeated refreshes of the Mitigation statuses.\r\nIt is recomm" + - "ended to avoid refreshing too frequently, to limit resource consumption.\r\nAllowe" + - "d values are between 1 and 120."); - this._interval.Value = 1; - this._interval.ValueChanged += new System.EventHandler(this._interval_ValueChanged); - // - // _scheduledRefresh - // - this._scheduledRefresh.AutoSize = true; - this._scheduledRefresh.Location = new System.Drawing.Point(4, 4); - this._scheduledRefresh.Margin = new System.Windows.Forms.Padding(0); - this._scheduledRefresh.Name = "_scheduledRefresh"; - this._scheduledRefresh.Size = new System.Drawing.Size(675, 17); - this._scheduledRefresh.TabIndex = 0; - this._scheduledRefresh.Text = "Enable scheduled status refreshes\r\n"; - this._tooltip.SetToolTip(this._scheduledRefresh, "Scheduled refresh of the status of the Mitigations.\r\nIt is recommended to avoid r" + - "efreshing too frequently, to limit resource consumption."); - this._scheduledRefresh.UseVisualStyleBackColor = true; - this._scheduledRefresh.CheckedChanged += new System.EventHandler(this._scheduledRefresh_CheckedChanged); - // - // layoutControlItem1 - // - this.layoutControlItem1.Control = this._scheduledRefresh; - this.layoutControlItem1.Height = 25; - this.layoutControlItem1.MinSize = new System.Drawing.Size(32, 20); - this.layoutControlItem1.Name = "layoutControlItem1"; - this.layoutControlItem1.Width = 100; - this.layoutControlItem1.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; - // - // layoutControlItem2 - // - this.layoutControlItem2.Control = this._interval; - this.layoutControlItem2.Height = 28; - this.layoutControlItem2.MinSize = new System.Drawing.Size(64, 18); - this.layoutControlItem2.Name = "layoutControlItem2"; - this.layoutControlItem2.Padding = new System.Windows.Forms.Padding(21, 4, 4, 4); - this.layoutControlItem2.Text = "Interval (mins)"; - this.layoutControlItem2.Width = 200; - // - // layoutControlItem3 - // - this.layoutControlItem3.Control = this._raiseNoEvents; - this.layoutControlItem3.Height = 25; - this.layoutControlItem3.MinSize = new System.Drawing.Size(32, 20); - this.layoutControlItem3.Name = "layoutControlItem3"; - this.layoutControlItem3.Padding = new System.Windows.Forms.Padding(21, 4, 4, 4); - this.layoutControlItem3.Width = 101; - this.layoutControlItem3.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; - // - // layoutControlItem4 - // - this.layoutControlItem4.Control = this._raiseSomeEvents; - this.layoutControlItem4.Height = 25; - this.layoutControlItem4.MinSize = new System.Drawing.Size(32, 20); - this.layoutControlItem4.Name = "layoutControlItem4"; - this.layoutControlItem4.Padding = new System.Windows.Forms.Padding(21, 4, 4, 4); - this.layoutControlItem4.Width = 101; - this.layoutControlItem4.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; - // - // layoutControlItem5 - // - this.layoutControlItem5.Control = this._raiseAllEvents; - this.layoutControlItem5.Height = 25; - this.layoutControlItem5.MinSize = new System.Drawing.Size(32, 20); - this.layoutControlItem5.Name = "layoutControlItem5"; - this.layoutControlItem5.Padding = new System.Windows.Forms.Padding(21, 4, 4, 4); - this.layoutControlItem5.Width = 101; - this.layoutControlItem5.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; - // - // ConfigurationPanel - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.layoutControl1); - this.Name = "ConfigurationPanel"; - this.Size = new System.Drawing.Size(683, 466); - this.layoutControl1.ResumeLayout(false); - this.layoutControl1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this._interval)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private DevComponents.DotNetBar.Layout.LayoutControl layoutControl1; - private System.Windows.Forms.CheckBox _scheduledRefresh; - private System.Windows.Forms.ToolTip _tooltip; - private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem1; - private DevComponents.Editors.IntegerInput _interval; - private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem2; - private System.Windows.Forms.RadioButton _raiseAllEvents; - private System.Windows.Forms.RadioButton _raiseSomeEvents; - private System.Windows.Forms.RadioButton _raiseNoEvents; - private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem3; - private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem4; - private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem5; - } -} diff --git a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.cs b/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.cs deleted file mode 100644 index 793deb25..00000000 --- a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; -using PostSharp.Patterns.Contracts; -using ThreatsManager.DevOps.Initializers; -using ThreatsManager.Interfaces.Extensions; -using ThreatsManager.Interfaces.Extensions.Panels; -using ThreatsManager.Interfaces.ObjectModel; -using ThreatsManager.Utilities; - -namespace ThreatsManager.DevOps.Panels.Configuration -{ - public partial class ConfigurationPanel : UserControl, IConfigurationPanel
- { - private ExtensionConfigurationManager _configuration; - - public ConfigurationPanel() - { - InitializeComponent(); - } - - private readonly Guid _id = Guid.NewGuid(); - public Guid Id => _id; - - public Form PanelContainer { get; set; } - - public void Initialize([NotNull] IThreatModel model) - { - _configuration = new ExtensionConfigurationManager(model, (new AutoConnector()).GetExtensionId()); - - _scheduledRefresh.Checked = _configuration.ScheduledRefreshes; - _interval.Value = _configuration.RefreshInterval; - switch (_configuration.NotificationStrategy) - { - case NotificationType.SuccessOnly: - _raiseSomeEvents.Checked = true; - break; - case NotificationType.Full: - _raiseAllEvents.Checked = true; - break; - default: - _raiseNoEvents.Checked = true; - break; - } - } - - public void Apply() - { - _configuration.Apply(); - } - - public string Label => "DevOps"; - public Bitmap Icon => Properties.Resources.devops_white; - public Bitmap SelectedIcon => Properties.Resources.devops_black; - - public IEnumerable Configuration => _configuration?.Data; - - private void _scheduledRefresh_CheckedChanged(object sender, EventArgs e) - { - _configuration.ScheduledRefreshes = _interval.Enabled = - _raiseAllEvents.Enabled = _raiseSomeEvents.Enabled = _raiseNoEvents.Enabled = - _scheduledRefresh.Checked; - } - - private void _interval_ValueChanged(object sender, EventArgs e) - { - _configuration.RefreshInterval = _interval.Value; - } - - private void _raiseNoEvents_CheckedChanged(object sender, EventArgs e) - { - _configuration.NotificationStrategy = NotificationType.None; - } - - private void _raiseSomeEvents_CheckedChanged(object sender, EventArgs e) - { - _configuration.NotificationStrategy = NotificationType.SuccessOnly; - } - - private void _raiseAllEvents_CheckedChanged(object sender, EventArgs e) - { - _configuration.NotificationStrategy = NotificationType.Full; - } - } -} diff --git a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanelFactory.cs b/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanelFactory.cs deleted file mode 100644 index e540fcee..00000000 --- a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanelFactory.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Windows.Forms; -using ThreatsManager.Interfaces; -using ThreatsManager.Interfaces.Extensions.Panels; - -namespace ThreatsManager.DevOps.Panels.Configuration -{ - [Extension("7F507E55-E545-409F-9BE8-C8EBE280B2AC", "DevOps Configuration Panel", 200, ExecutionMode.Management)] - public class ConfigurationPanelFactory : IConfigurationPanelFactory - { - public IConfigurationPanel Create() - { - return new ConfigurationPanel(); - } - } -} diff --git a/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.CustomRibbonExtension.cs index eb838e50..15fa0009 100644 --- a/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.CustomRibbonExtension.cs @@ -79,7 +79,7 @@ public async void ExecuteCustomAction([NotNull] IActionDefinition action) switch (action.Name) { case "Sync": - if ((await DevOpsManager.UpdateAsync(_model)) > 0) + if (DevOpsManager.Update(_model) > 0) { LoadModel(); } @@ -96,11 +96,15 @@ public async void ExecuteCustomAction([NotNull] IActionDefinition action) var connector = DevOpsManager.GetConnector(_model); var devOpsSchemaManager = new DevOpsPropertySchemaManager(_model); _countdown = new CountdownEvent(mitigations.Length); + ChangeCustomActionStatus?.Invoke("Auto", false); + + ShowMessage?.Invoke("Automatic Load in progress..."); + + var scope = UndoRedoManager.OpenScope("DevOps Auto Retrieval"); foreach (var mitigation in mitigations) AutoLoad(mitigation, connector, devOpsSchemaManager); - ShowMessage?.Invoke("Automatic Load in progress..."); - AutomaticLoadCompletion(); + AutomaticLoadCompletion(scope); } else { @@ -138,6 +142,10 @@ public async void ExecuteCustomAction([NotNull] IActionDefinition action) //ShowWarning?.Invoke($"An error occurred during the execution of the action."); throw; } + finally + { + ChangeCustomActionStatus?.Invoke("Auto", true); + } } private async void AutoLoad([NotNull] IMitigation mitigation, [NotNull] IDevOpsConnector connector, @@ -167,13 +175,16 @@ private async void AutoLoad([NotNull] IMitigation mitigation, [NotNull] IDevOpsC } [Background] - private void AutomaticLoadCompletion() + private void AutomaticLoadCompletion(UndoRedoScope scope) { if (_countdown.Wait(10000)) ShowMessage?.Invoke("Automatic Load done successfully."); else ShowMessage?.Invoke("Automatic Load is taking more than expected."); + scope?.Complete(); + scope?.Dispose(); + LoadModel(); } } diff --git a/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.cs b/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.cs index c371a3a2..33b2f381 100644 --- a/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.cs +++ b/Studio/ThreatsManager.DevOps.WinForms/Panels/MitigationsKanban/MitigationsKanbanPanel.cs @@ -209,7 +209,7 @@ private bool Set(IMitigation mitigation, int pos) try { _loading = true; - DevOpsManager.SetMitigationsStatusAsync(mitigation, status); + DevOpsManager.SetMitigationsStatus(mitigation, status); result = true; } catch (WorkItemCreationException) diff --git a/Studio/ThreatsManager.DevOps.WinForms/ThreatsManager.DevOps.WinForms.csproj b/Studio/ThreatsManager.DevOps.WinForms/ThreatsManager.DevOps.WinForms.csproj index d3ab6d95..8eeefd18 100644 --- a/Studio/ThreatsManager.DevOps.WinForms/ThreatsManager.DevOps.WinForms.csproj +++ b/Studio/ThreatsManager.DevOps.WinForms/ThreatsManager.DevOps.WinForms.csproj @@ -170,20 +170,12 @@ - UserControl CommentsPanel.cs - - UserControl - - - ConfigurationPanel.cs - - Component @@ -219,7 +211,6 @@ - True True @@ -253,9 +244,6 @@ CommentsPanel.cs - - ConfigurationPanel.cs - KanbanPanel.cs diff --git a/Studio/ThreatsManager.Extensions.WinForms/Actions/AddMissingFlows.cs b/Studio/ThreatsManager.Extensions.WinForms/Actions/AddMissingFlows.cs new file mode 100644 index 00000000..67432268 --- /dev/null +++ b/Studio/ThreatsManager.Extensions.WinForms/Actions/AddMissingFlows.cs @@ -0,0 +1,85 @@ +using PostSharp.Patterns.Contracts; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using ThreatsManager.Interfaces; +using ThreatsManager.Interfaces.Extensions; +using ThreatsManager.Interfaces.Extensions.Actions; +using ThreatsManager.Interfaces.ObjectModel; +using ThreatsManager.Interfaces.ObjectModel.Diagrams; +using ThreatsManager.Interfaces.ObjectModel.Entities; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Extensions.Actions +{ + [Extension("8B35C893-C304-418A-BD30-7C9CE88317AB", "Add Missing Flows Context Aware Action", 28, ExecutionMode.Simplified)] + public class AddMissingFlows : IShapeContextAwareAction + { + public Scope Scope => Scope.Entity; + public string Label => "Add Missing Flows"; + public string Group => "ItemActions"; + public Bitmap Icon => Properties.Resources.graph_star_big; + public Bitmap SmallIcon => Properties.Resources.graph_star; + public Shortcut Shortcut => Shortcut.None; + + public bool Execute([NotNull] object item) + { + return false; + } + + public bool IsVisible(object item) + { + return true; + } + + public bool Execute([NotNull] IShape shape) + { + var result = false; + + if (shape is IEntityShape entityShape && shape is IThreatModelChild child) + { + var diagram = child.Model?.Diagrams? + .FirstOrDefault(x => x.Entities.Contains(entityShape)); + if (diagram != null) + { + using (var scope = UndoRedoManager.OpenScope("Add missing Flows")) + { + var outFlows = child.Model?.DataFlows? + .Where(x => x.SourceId == entityShape.AssociatedId && + !(diagram.Links?.Any(y => x.Id == y.AssociatedId) ?? false)); + result = AddFlows(diagram, outFlows); + + var inFlows = child.Model?.DataFlows? + .Where(x => x.TargetId == entityShape.AssociatedId && + !(diagram.Links?.Any(y => x.Id == y.AssociatedId) ?? false)); + result |= AddFlows(diagram, inFlows); + + if (result) + { + scope?.Complete(); + } + } + } + } + + return result; + } + + private bool AddFlows([NotNull] IDiagram diagram, IEnumerable flows) + { + bool result = false; + + if (flows?.Any() ?? false) + { + result = true; + foreach (var flow in flows) + { + diagram.AddLink(flow); + } + } + + return result; + } + } +} diff --git a/Studio/ThreatsManager.Extensions.WinForms/Actions/DuplicateEntity.cs b/Studio/ThreatsManager.Extensions.WinForms/Actions/DuplicateEntity.cs new file mode 100644 index 00000000..04cff1e4 --- /dev/null +++ b/Studio/ThreatsManager.Extensions.WinForms/Actions/DuplicateEntity.cs @@ -0,0 +1,92 @@ +using PostSharp.Patterns.Contracts; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Forms = System.Windows.Forms; +using ThreatsManager.Extensions.Dialogs; +using ThreatsManager.Interfaces; +using ThreatsManager.Interfaces.Extensions; +using ThreatsManager.Interfaces.Extensions.Actions; +using ThreatsManager.Interfaces.ObjectModel; +using ThreatsManager.Interfaces.ObjectModel.Diagrams; +using ThreatsManager.Interfaces.ObjectModel.Entities; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Extensions.Actions +{ + [Extension("F5EDBF05-5A70-4844-BF52-C3B6193D0386", "Duplicate and Convert Context Aware Action", 35, ExecutionMode.Simplified)] + public class DuplicateEntity: IShapeContextAwareAction, IIdentityContextAwareAction + { + public Scope Scope => Scope.Entity; + public string Label => "Duplicate and Convert"; + public string Group => "ItemActions"; + public Bitmap Icon => Properties.Resources.objects_cube_to_cone_big; + public Bitmap SmallIcon => Properties.Resources.objects_cube_to_cone; + public Shortcut Shortcut => Shortcut.None; + + public bool Execute([NotNull] object item) + { + return false; + } + + public bool IsVisible(object item) + { + return true; + } + + public bool Execute([NotNull] IShape shape) + { + var result = false; + + if (shape is IEntityShape entityShape) + { + var identity = entityShape.Identity; + if (identity != null) + { + result = Execute(identity); + } + } + + return result; + } + + public bool Execute([NotNull] IIdentity identity) + { + var result = false; + + if (identity is IEntity entity) + { + var dialog = new DuplicateConvertDialog(); + dialog.Initialize(entity); + if (dialog.ShowDialog(Forms.Form.ActiveForm) == Forms.DialogResult.OK) + { + IEntity newEntity; + + using (var scope = UndoRedoManager.OpenScope("Duplicate Entity")) + { + if (dialog.Convert) + { + newEntity = entity.CopyAndConvert(dialog.EntityType, dialog.EntityTemplate); + } + else + { + newEntity = entity.CopyAndConvert(); + } + + if (newEntity != null) + { + if (!string.IsNullOrWhiteSpace(dialog.NewEntityName)) + newEntity.Name = dialog.NewEntityName; + + result = true; + scope?.Complete(); + } + } + } + } + + return result; + } + } +} diff --git a/Studio/ThreatsManager.Extensions.WinForms/Actions/PasteThreatEvents.cs b/Studio/ThreatsManager.Extensions.WinForms/Actions/PasteThreatEvents.cs index 04008667..86074f35 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Actions/PasteThreatEvents.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Actions/PasteThreatEvents.cs @@ -87,34 +87,16 @@ public bool Execute(IIdentity identity) private void AddThreatEvent([NotNull] IThreatEvent source, [NotNull] IThreatEventsContainer container) { - var threatEvent = container.AddThreatEvent(source.ThreatType); - threatEvent.Name = source.Name; - threatEvent.Description = source.Description; - threatEvent.Severity = source.Severity; - source.CloneProperties(threatEvent); - - var scenarios = source.Scenarios?.ToArray(); - if (scenarios?.Any() ?? false) - { - foreach (var scenario in scenarios) - { - var newScenario = - threatEvent.AddScenario(scenario.Actor, scenario.Severity, scenario.Name); - newScenario.Description = scenario.Description; - newScenario.Motivation = scenario.Motivation; - scenario.CloneProperties(newScenario); - } - } - - var mitigations = source.Mitigations?.ToArray(); - if (mitigations?.Any() ?? false) + var target = container.AddThreatEvent(source.ThreatType); + if (target != null) { - foreach (var mitigation in mitigations) - { - var newMitigation = threatEvent.AddMitigation(mitigation.Mitigation, mitigation.Strength, - mitigation.Status, mitigation.Directives); - mitigation.CloneProperties(newMitigation); - } + target.Name = source.Name; + target.Description = source.Description; + target.Severity = source.Severity; + source.CopyProperties(target); + source.CopyThreatEventMitigations(target); + source.CopyThreatEventScenarios(target); + source.CopyVulnerabilities(target); } } } diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.Designer.cs b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.Designer.cs new file mode 100644 index 00000000..72f3b0fd --- /dev/null +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.Designer.cs @@ -0,0 +1,428 @@ +namespace ThreatsManager.Extensions.Dialogs +{ + partial class DuplicateConvertDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this._cancel = new System.Windows.Forms.Button(); + this._ok = new System.Windows.Forms.Button(); + this.layoutControl1 = new DevComponents.DotNetBar.Layout.LayoutControl(); + this._entityTemplate = new DevComponents.DotNetBar.LabelX(); + this.label1 = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this._newEntityTemplate = new System.Windows.Forms.ComboBox(); + this._newEntityType = new System.Windows.Forms.ComboBox(); + this._convert = new System.Windows.Forms.RadioButton(); + this._duplicate = new System.Windows.Forms.RadioButton(); + this.label3 = new System.Windows.Forms.Label(); + this._entityType = new DevComponents.DotNetBar.LabelX(); + this._entityName = new DevComponents.DotNetBar.LabelX(); + this.layoutControlItem1 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem2 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem10 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem3 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem4 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem5 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem6 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem7 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem8 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem9 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this._newEntityName = new System.Windows.Forms.TextBox(); + this.layoutControlItem11 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.panel1.SuspendLayout(); + this.layoutControl1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.BackColor = System.Drawing.Color.White; + this.panel1.Controls.Add(this._cancel); + this.panel1.Controls.Add(this._ok); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 259); + this.panel1.Margin = new System.Windows.Forms.Padding(6); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(513, 63); + this.panel1.TabIndex = 3; + this.panel1.TabStop = true; + // + // _cancel + // + this._cancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this._cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this._cancel.Location = new System.Drawing.Point(262, 25); + this._cancel.Margin = new System.Windows.Forms.Padding(6); + this._cancel.Name = "_cancel"; + this._cancel.Size = new System.Drawing.Size(75, 23); + this._cancel.TabIndex = 2; + this._cancel.Text = "Cancel"; + this._cancel.UseVisualStyleBackColor = true; + // + // _ok + // + this._ok.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this._ok.DialogResult = System.Windows.Forms.DialogResult.OK; + this._ok.Location = new System.Drawing.Point(175, 25); + this._ok.Margin = new System.Windows.Forms.Padding(6); + this._ok.Name = "_ok"; + this._ok.Size = new System.Drawing.Size(75, 23); + this._ok.TabIndex = 0; + this._ok.Text = "OK"; + this._ok.UseVisualStyleBackColor = true; + this._ok.Click += new System.EventHandler(this._ok_Click); + // + // layoutControl1 + // + this.layoutControl1.BackColor = System.Drawing.Color.White; + this.layoutControl1.Controls.Add(this._newEntityName); + this.layoutControl1.Controls.Add(this._entityTemplate); + this.layoutControl1.Controls.Add(this.label1); + this.layoutControl1.Controls.Add(this.pictureBox1); + this.layoutControl1.Controls.Add(this._newEntityTemplate); + this.layoutControl1.Controls.Add(this._newEntityType); + this.layoutControl1.Controls.Add(this._convert); + this.layoutControl1.Controls.Add(this._duplicate); + this.layoutControl1.Controls.Add(this.label3); + this.layoutControl1.Controls.Add(this._entityType); + this.layoutControl1.Controls.Add(this._entityName); + this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.layoutControl1.Location = new System.Drawing.Point(0, 0); + this.layoutControl1.Name = "layoutControl1"; + // + // + // + this.layoutControl1.RootGroup.Items.AddRange(new DevComponents.DotNetBar.Layout.LayoutItemBase[] { + this.layoutControlItem1, + this.layoutControlItem2, + this.layoutControlItem10, + this.layoutControlItem3, + this.layoutControlItem11, + this.layoutControlItem4, + this.layoutControlItem5, + this.layoutControlItem6, + this.layoutControlItem7, + this.layoutControlItem8, + this.layoutControlItem9}); + this.layoutControl1.Size = new System.Drawing.Size(513, 259); + this.layoutControl1.TabIndex = 4; + // + // _entityTemplate + // + this._entityTemplate.AutoSize = true; + // + // + // + this._entityTemplate.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this._entityTemplate.Location = new System.Drawing.Point(116, 46); + this._entityTemplate.Margin = new System.Windows.Forms.Padding(0); + this._entityTemplate.Name = "_entityTemplate"; + this._entityTemplate.Size = new System.Drawing.Size(32, 15); + this._entityTemplate.TabIndex = 2; + this._entityTemplate.Text = "label3"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(44, 224); + this.label1.Margin = new System.Windows.Forms.Padding(0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(465, 32); + this.label1.TabIndex = 10; + this.label1.Text = "The new Entity is created, but it is not included in any Diagram.\r\nYou must inser" + + "t it yourself, using the Diagram panel."; + // + // pictureBox1 + // + this.pictureBox1.Image = global::ThreatsManager.Extensions.Properties.Resources.report_problem_big; + this.pictureBox1.Location = new System.Drawing.Point(4, 224); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(0); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(32, 32); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox1.TabIndex = 9; + this.pictureBox1.TabStop = false; + // + // _newEntityTemplate + // + this._newEntityTemplate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this._newEntityTemplate.Enabled = false; + this._newEntityTemplate.FormattingEnabled = true; + this._newEntityTemplate.Location = new System.Drawing.Point(134, 195); + this._newEntityTemplate.Margin = new System.Windows.Forms.Padding(0); + this._newEntityTemplate.Name = "_newEntityTemplate"; + this._newEntityTemplate.Size = new System.Drawing.Size(375, 21); + this._newEntityTemplate.TabIndex = 8; + // + // _newEntityType + // + this._newEntityType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this._newEntityType.Enabled = false; + this._newEntityType.FormattingEnabled = true; + this._newEntityType.Location = new System.Drawing.Point(134, 166); + this._newEntityType.Margin = new System.Windows.Forms.Padding(0); + this._newEntityType.Name = "_newEntityType"; + this._newEntityType.Size = new System.Drawing.Size(375, 21); + this._newEntityType.TabIndex = 7; + this._newEntityType.SelectedIndexChanged += new System.EventHandler(this._newEntityType_SelectedIndexChanged); + // + // _convert + // + this._convert.AutoSize = true; + this._convert.Location = new System.Drawing.Point(4, 141); + this._convert.Margin = new System.Windows.Forms.Padding(0); + this._convert.Name = "_convert"; + this._convert.Size = new System.Drawing.Size(505, 17); + this._convert.TabIndex = 6; + this._convert.Text = "Duplicate and convert the source Entity"; + this._convert.UseVisualStyleBackColor = true; + // + // _duplicate + // + this._duplicate.AutoSize = true; + this._duplicate.Checked = true; + this._duplicate.Location = new System.Drawing.Point(4, 116); + this._duplicate.Margin = new System.Windows.Forms.Padding(0); + this._duplicate.Name = "_duplicate"; + this._duplicate.Size = new System.Drawing.Size(505, 17); + this._duplicate.TabIndex = 5; + this._duplicate.TabStop = true; + this._duplicate.Text = "Duplicate the source Entity"; + this._duplicate.UseVisualStyleBackColor = true; + this._duplicate.CheckedChanged += new System.EventHandler(this._duplicate_CheckedChanged); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(4, 67); + this.label3.Margin = new System.Windows.Forms.Padding(0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(505, 13); + this.label3.TabIndex = 3; + this.label3.Text = "Perform the following actions on the Entity."; + // + // _entityType + // + this._entityType.AutoSize = true; + // + // + // + this._entityType.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this._entityType.Location = new System.Drawing.Point(116, 25); + this._entityType.Margin = new System.Windows.Forms.Padding(0); + this._entityType.Name = "_entityType"; + this._entityType.Size = new System.Drawing.Size(32, 15); + this._entityType.TabIndex = 1; + this._entityType.Text = "label2"; + // + // _entityName + // + this._entityName.AutoSize = true; + // + // + // + this._entityName.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this._entityName.Location = new System.Drawing.Point(116, 4); + this._entityName.Margin = new System.Windows.Forms.Padding(0); + this._entityName.Name = "_entityName"; + this._entityName.Size = new System.Drawing.Size(32, 15); + this._entityName.TabIndex = 0; + this._entityName.Text = "label1"; + // + // layoutControlItem1 + // + this.layoutControlItem1.Control = this._entityName; + this.layoutControlItem1.Height = 21; + this.layoutControlItem1.MinSize = new System.Drawing.Size(64, 18); + this.layoutControlItem1.Name = "layoutControlItem1"; + this.layoutControlItem1.Text = "Entity Name"; + this.layoutControlItem1.Width = 100; + this.layoutControlItem1.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem2 + // + this.layoutControlItem2.Control = this._entityType; + this.layoutControlItem2.Height = 21; + this.layoutControlItem2.MinSize = new System.Drawing.Size(64, 18); + this.layoutControlItem2.Name = "layoutControlItem2"; + this.layoutControlItem2.Text = "Entity Type"; + this.layoutControlItem2.Width = 100; + this.layoutControlItem2.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem10 + // + this.layoutControlItem10.Control = this._entityTemplate; + this.layoutControlItem10.Height = 21; + this.layoutControlItem10.MinSize = new System.Drawing.Size(64, 18); + this.layoutControlItem10.Name = "layoutControlItem10"; + this.layoutControlItem10.Text = "Entity Template"; + this.layoutControlItem10.Width = 100; + this.layoutControlItem10.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem3 + // + this.layoutControlItem3.Control = this.label3; + this.layoutControlItem3.Height = 21; + this.layoutControlItem3.MinSize = new System.Drawing.Size(64, 18); + this.layoutControlItem3.Name = "layoutControlItem3"; + this.layoutControlItem3.Text = "Label:"; + this.layoutControlItem3.TextVisible = false; + this.layoutControlItem3.Width = 100; + this.layoutControlItem3.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem4 + // + this.layoutControlItem4.Control = this._duplicate; + this.layoutControlItem4.Height = 25; + this.layoutControlItem4.MinSize = new System.Drawing.Size(32, 20); + this.layoutControlItem4.Name = "layoutControlItem4"; + this.layoutControlItem4.Width = 100; + this.layoutControlItem4.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem5 + // + this.layoutControlItem5.Control = this._convert; + this.layoutControlItem5.Height = 25; + this.layoutControlItem5.MinSize = new System.Drawing.Size(32, 20); + this.layoutControlItem5.Name = "layoutControlItem5"; + this.layoutControlItem5.Width = 100; + this.layoutControlItem5.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem6 + // + this.layoutControlItem6.Control = this._newEntityType; + this.layoutControlItem6.Height = 29; + this.layoutControlItem6.MinSize = new System.Drawing.Size(64, 18); + this.layoutControlItem6.Name = "layoutControlItem6"; + this.layoutControlItem6.Padding = new System.Windows.Forms.Padding(22, 4, 4, 4); + this.layoutControlItem6.Text = "New Entity Type"; + this.layoutControlItem6.Width = 100; + this.layoutControlItem6.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem7 + // + this.layoutControlItem7.Control = this._newEntityTemplate; + this.layoutControlItem7.Height = 29; + this.layoutControlItem7.MinSize = new System.Drawing.Size(64, 18); + this.layoutControlItem7.Name = "layoutControlItem7"; + this.layoutControlItem7.Padding = new System.Windows.Forms.Padding(22, 4, 4, 4); + this.layoutControlItem7.Text = "New Entity Template"; + this.layoutControlItem7.Width = 100; + this.layoutControlItem7.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem8 + // + this.layoutControlItem8.Control = this.pictureBox1; + this.layoutControlItem8.Height = 40; + this.layoutControlItem8.MinSize = new System.Drawing.Size(40, 40); + this.layoutControlItem8.Name = "layoutControlItem8"; + this.layoutControlItem8.Text = "Label:"; + this.layoutControlItem8.TextVisible = false; + this.layoutControlItem8.Width = 40; + // + // layoutControlItem9 + // + this.layoutControlItem9.Control = this.label1; + this.layoutControlItem9.Height = 21; + this.layoutControlItem9.MinSize = new System.Drawing.Size(64, 18); + this.layoutControlItem9.Name = "layoutControlItem9"; + this.layoutControlItem9.Text = "Label:"; + this.layoutControlItem9.TextVisible = false; + this.layoutControlItem9.Width = 99; + this.layoutControlItem9.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // _newEntityName + // + this._newEntityName.Location = new System.Drawing.Point(116, 88); + this._newEntityName.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); + this._newEntityName.Name = "_newEntityName"; + this._newEntityName.Size = new System.Drawing.Size(393, 20); + this._newEntityName.TabIndex = 4; + // + // layoutControlItem11 + // + this.layoutControlItem11.Control = this._newEntityName; + this.layoutControlItem11.Height = 28; + this.layoutControlItem11.MinSize = new System.Drawing.Size(120, 0); + this.layoutControlItem11.Name = "layoutControlItem11"; + this.layoutControlItem11.Text = "New Entity Name"; + this.layoutControlItem11.Width = 100; + this.layoutControlItem11.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // DuplicateConvertDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this._cancel; + this.ClientSize = new System.Drawing.Size(513, 322); + this.Controls.Add(this.layoutControl1); + this.Controls.Add(this.panel1); + this.MinimizeBox = false; + this.Name = "DuplicateConvertDialog"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Duplicate and Convert an Entity"; + this.panel1.ResumeLayout(false); + this.layoutControl1.ResumeLayout(false); + this.layoutControl1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button _ok; + private DevComponents.DotNetBar.Layout.LayoutControl layoutControl1; + private DevComponents.DotNetBar.LabelX _entityType; + private DevComponents.DotNetBar.LabelX _entityName; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem1; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem2; + private System.Windows.Forms.Label label3; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem3; + private System.Windows.Forms.RadioButton _convert; + private System.Windows.Forms.RadioButton _duplicate; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem4; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem5; + private System.Windows.Forms.ComboBox _newEntityTemplate; + private System.Windows.Forms.ComboBox _newEntityType; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem6; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem7; + private System.Windows.Forms.Button _cancel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.PictureBox pictureBox1; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem8; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem9; + private DevComponents.DotNetBar.LabelX _entityTemplate; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem10; + private System.Windows.Forms.TextBox _newEntityName; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem11; + } +} \ No newline at end of file diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.cs b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.cs new file mode 100644 index 00000000..99d2098f --- /dev/null +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.cs @@ -0,0 +1,102 @@ +using PostSharp.Patterns.Contracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ThreatsManager.Interfaces; +using ThreatsManager.Interfaces.ObjectModel; +using ThreatsManager.Interfaces.ObjectModel.Entities; +using ThreatsManager.Utilities; +using ThreatsManager.Utilities.Aspects; + +namespace ThreatsManager.Extensions.Dialogs +{ + public partial class DuplicateConvertDialog : Form + { + private IEntity _entity; + + public DuplicateConvertDialog() + { + InitializeComponent(); + + _newEntityType.Items.AddRange(EnumExtensions.GetEnumLabels().ToArray()); + } + + public void Initialize([NotNull] IEntity entity) + { + _entity = entity; + + _entityName.Text = _entity.Name; + _newEntityName.Text = $"{_entity.Name} (copy)"; + _entityName.Image = _entity.GetImage(ImageSize.Small); + _entityType.Text = _entity.GetEntityType().GetEnumLabel(); + _entityType.Image = _entity.GetEntityType().GetEntityImage(ImageSize.Small); + _newEntityType.SelectedItem = _entity.GetEntityType().GetEnumLabel(); + + var entityTemplate = _entity.Template; + if (entityTemplate != null) + { + _entityTemplate.Text = entityTemplate.Name; + _entityTemplate.Image = entityTemplate.GetImage(ImageSize.Small); + } + else + { + _entityTemplate.Text = null; + _entityTemplate.Image = null; + } + } + + public string NewEntityName => _newEntityName.Text; + + public bool Convert => _convert.Checked; + + public EntityType EntityType + { + get + { + EntityType result = _entity.GetEntityType(); + if (EnumExtensions.TryGetEnumValue(_newEntityType.SelectedItem.ToString(), out var entityType)) + { + result = entityType; + } + + return result; + } + } + + public IEntityTemplate EntityTemplate => _newEntityTemplate.SelectedItem as IEntityTemplate; + + private void _duplicate_CheckedChanged(object sender, EventArgs e) + { + _newEntityType.Enabled = _convert.Checked; + _newEntityTemplate.Enabled = _convert.Checked; + } + + private void _newEntityType_SelectedIndexChanged(object sender, EventArgs e) + { + _newEntityTemplate.Items.Clear(); + _newEntityTemplate.Items.Add(""); + _newEntityTemplate.SelectedIndex = 0; + if (EnumExtensions.TryGetEnumValue(_newEntityType.SelectedItem.ToString(), out var entityType)) + { + var templates = _entity.Model?.GetEntityTemplates(entityType)? + .OrderBy(x => x.Name) + .ToArray(); + if (templates?.Any() ?? false) + { + _newEntityTemplate.Items.AddRange(templates); + } + } + } + + private void _ok_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.resx b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.resx similarity index 96% rename from Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.resx rename to Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.resx index 2aff7171..1af7de15 100644 --- a/Studio/ThreatsManager.DevOps.WinForms/Panels/Configuration/ConfigurationPanel.resx +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/DuplicateConvertDialog.resx @@ -117,7 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.Designer.cs b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.Designer.cs index ce4c988f..e6c1508f 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.Designer.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.Designer.cs @@ -36,7 +36,6 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExportKnowledgeBaseDialog)); this._saveFile = new System.Windows.Forms.SaveFileDialog(); this._wizard = new DevComponents.DotNetBar.Wizard(); @@ -58,9 +57,11 @@ private void InitializeComponent() this._fullyThreatTypes = new System.Windows.Forms.CheckBox(); this._fullyMitigations = new System.Windows.Forms.CheckBox(); this._fullyThreatActors = new System.Windows.Forms.CheckBox(); + this._fullyWeaknesses = new System.Windows.Forms.CheckBox(); this.layoutControlItem8 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem9 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem10 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem1 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem6 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem5 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this._pageSchemas = new DevComponents.DotNetBar.WizardPage(); @@ -75,6 +76,10 @@ private void InitializeComponent() this._uncheckAllThreatTypes = new System.Windows.Forms.Button(); this._checkAllThreatTypes = new System.Windows.Forms.Button(); this._threatTypes = new System.Windows.Forms.CheckedListBox(); + this._pageWeaknesses = new DevComponents.DotNetBar.WizardPage(); + this._uncheckAllWeaknesses = new System.Windows.Forms.Button(); + this._checkAllWeaknesses = new System.Windows.Forms.Button(); + this._weaknesses = new System.Windows.Forms.CheckedListBox(); this._pageMitigations = new DevComponents.DotNetBar.WizardPage(); this._uncheckAllMitigations = new System.Windows.Forms.Button(); this._checkAllMitigations = new System.Windows.Forms.Button(); @@ -99,6 +104,7 @@ private void InitializeComponent() this._pageSchemas.SuspendLayout(); this._pageItemTemplates.SuspendLayout(); this._pageThreatTypes.SuspendLayout(); + this._pageWeaknesses.SuspendLayout(); this._pageMitigations.SuspendLayout(); this._pageThreatActors.SuspendLayout(); this._pageFile.SuspendLayout(); @@ -166,6 +172,7 @@ private void InitializeComponent() this._pageSchemas, this._pageItemTemplates, this._pageThreatTypes, + this._pageWeaknesses, this._pageMitigations, this._pageThreatActors, this._pageFile, @@ -214,7 +221,7 @@ private void InitializeComponent() this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(429, 66); this.label1.TabIndex = 0; - this.label1.Text = "Welcome to the Template Export Wizard"; + this.label1.Text = "Welcome to the Knowledge Base Export Wizard"; // // label2 // @@ -249,7 +256,7 @@ private void InitializeComponent() this._pageTMProperties.Controls.Add(this._layoutDetails); this._pageTMProperties.Location = new System.Drawing.Point(7, 72); this._pageTMProperties.Name = "_pageTMProperties"; - this._pageTMProperties.PageDescription = "Select the Threat Model Details to be included in the Template."; + this._pageTMProperties.PageDescription = "Select the Threat Model Details to be included in the Knowledge Base."; this._pageTMProperties.PageTitle = "Select Threat Model Details"; this._pageTMProperties.Size = new System.Drawing.Size(639, 282); // @@ -340,7 +347,7 @@ private void InitializeComponent() this._pageFullyInclude.Controls.Add(this._layoutFullyCopy); this._pageFullyInclude.Location = new System.Drawing.Point(7, 72); this._pageFullyInclude.Name = "_pageFullyInclude"; - this._pageFullyInclude.PageDescription = "Select the categories that you want to fully include in the Template."; + this._pageFullyInclude.PageDescription = "Select the categories that you want to fully include in the Knowledge Base."; this._pageFullyInclude.PageTitle = "Select what to fully include"; this._pageFullyInclude.Size = new System.Drawing.Size(639, 282); // @@ -383,6 +390,7 @@ private void InitializeComponent() this._layoutFullyCopy.Controls.Add(this._fullyThreatTypes); this._layoutFullyCopy.Controls.Add(this._fullyMitigations); this._layoutFullyCopy.Controls.Add(this._fullyThreatActors); + this._layoutFullyCopy.Controls.Add(this._fullyWeaknesses); this._layoutFullyCopy.ForeColor = System.Drawing.Color.Black; this._layoutFullyCopy.Location = new System.Drawing.Point(55, 0); this._layoutFullyCopy.Name = "_layoutFullyCopy"; @@ -393,6 +401,7 @@ private void InitializeComponent() this.layoutControlItem8, this.layoutControlItem9, this.layoutControlItem10, + this.layoutControlItem1, this.layoutControlItem6, this.layoutControlItem5}); this._layoutFullyCopy.Size = new System.Drawing.Size(529, 253); @@ -445,11 +454,11 @@ private void InitializeComponent() this._fullyMitigations.AutoSize = true; this._fullyMitigations.Checked = true; this._fullyMitigations.CheckState = System.Windows.Forms.CheckState.Checked; - this._fullyMitigations.Location = new System.Drawing.Point(4, 79); + this._fullyMitigations.Location = new System.Drawing.Point(4, 104); this._fullyMitigations.Margin = new System.Windows.Forms.Padding(0); this._fullyMitigations.Name = "_fullyMitigations"; this._fullyMitigations.Size = new System.Drawing.Size(521, 17); - this._fullyMitigations.TabIndex = 3; + this._fullyMitigations.TabIndex = 4; this._fullyMitigations.Text = "Mitigations"; this._fullyMitigations.UseVisualStyleBackColor = true; this._fullyMitigations.CheckedChanged += new System.EventHandler(this._fullyMitigations_CheckedChanged); @@ -459,15 +468,29 @@ private void InitializeComponent() this._fullyThreatActors.AutoSize = true; this._fullyThreatActors.Checked = true; this._fullyThreatActors.CheckState = System.Windows.Forms.CheckState.Checked; - this._fullyThreatActors.Location = new System.Drawing.Point(4, 104); + this._fullyThreatActors.Location = new System.Drawing.Point(4, 129); this._fullyThreatActors.Margin = new System.Windows.Forms.Padding(0); this._fullyThreatActors.Name = "_fullyThreatActors"; this._fullyThreatActors.Size = new System.Drawing.Size(521, 17); - this._fullyThreatActors.TabIndex = 4; + this._fullyThreatActors.TabIndex = 5; this._fullyThreatActors.Text = "Threat Actors"; this._fullyThreatActors.UseVisualStyleBackColor = true; this._fullyThreatActors.CheckedChanged += new System.EventHandler(this._fullyThreatActors_CheckedChanged); // + // _fullyWeaknesses + // + this._fullyWeaknesses.AutoSize = true; + this._fullyWeaknesses.Checked = true; + this._fullyWeaknesses.CheckState = System.Windows.Forms.CheckState.Checked; + this._fullyWeaknesses.Location = new System.Drawing.Point(4, 79); + this._fullyWeaknesses.Margin = new System.Windows.Forms.Padding(0); + this._fullyWeaknesses.Name = "_fullyWeaknesses"; + this._fullyWeaknesses.Size = new System.Drawing.Size(521, 17); + this._fullyWeaknesses.TabIndex = 3; + this._fullyWeaknesses.Text = "Weaknesses"; + this._fullyWeaknesses.UseVisualStyleBackColor = true; + this._fullyWeaknesses.CheckedChanged += new System.EventHandler(this._fullyWeaknesses_CheckedChanged); + // // layoutControlItem8 // this.layoutControlItem8.Control = this._fullySchemas; @@ -495,6 +518,14 @@ private void InitializeComponent() this.layoutControlItem10.Width = 100; this.layoutControlItem10.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; // + // layoutControlItem1 + // + this.layoutControlItem1.Control = this._fullyWeaknesses; + this.layoutControlItem1.Height = 25; + this.layoutControlItem1.MinSize = new System.Drawing.Size(32, 20); + this.layoutControlItem1.Name = "layoutControlItem1"; + this.layoutControlItem1.Width = 529; + // // layoutControlItem6 // this.layoutControlItem6.Control = this._fullyMitigations; @@ -524,7 +555,7 @@ private void InitializeComponent() this._pageSchemas.Controls.Add(this._schemas); this._pageSchemas.Location = new System.Drawing.Point(7, 72); this._pageSchemas.Name = "_pageSchemas"; - this._pageSchemas.PageDescription = "Select the Schemas to be included in the Template."; + this._pageSchemas.PageDescription = "Select the Schemas to be included in the Knowledge Base."; this._pageSchemas.PageTitle = "Select Schemas"; this._pageSchemas.Size = new System.Drawing.Size(639, 282); // @@ -588,7 +619,7 @@ private void InitializeComponent() this._pageItemTemplates.Controls.Add(this._itemTemplates); this._pageItemTemplates.Location = new System.Drawing.Point(7, 72); this._pageItemTemplates.Name = "_pageItemTemplates"; - this._pageItemTemplates.PageDescription = "Select the Item Templates to be included in the Template."; + this._pageItemTemplates.PageDescription = "Select the Item Templates to be included in the Knowledge Base."; this._pageItemTemplates.PageTitle = "Select Item Templates"; this._pageItemTemplates.Size = new System.Drawing.Size(639, 282); // @@ -653,7 +684,7 @@ private void InitializeComponent() this._pageThreatTypes.Controls.Add(this._threatTypes); this._pageThreatTypes.Location = new System.Drawing.Point(7, 72); this._pageThreatTypes.Name = "_pageThreatTypes"; - this._pageThreatTypes.PageDescription = "Select the Threat Types to be included in the Template."; + this._pageThreatTypes.PageDescription = "Select the Threat Types to be included in the Knowledge Base."; this._pageThreatTypes.PageTitle = "Select Threat Types"; this._pageThreatTypes.Size = new System.Drawing.Size(639, 282); // @@ -705,6 +736,71 @@ private void InitializeComponent() this._threatTypes.TabIndex = 11; this._threatTypes.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this._threatTypes_ItemCheck); // + // _pageWeaknesses + // + this._pageWeaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._pageWeaknesses.AntiAlias = false; + this._pageWeaknesses.BackColor = System.Drawing.Color.White; + this._pageWeaknesses.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this._pageWeaknesses.Controls.Add(this._uncheckAllWeaknesses); + this._pageWeaknesses.Controls.Add(this._checkAllWeaknesses); + this._pageWeaknesses.Controls.Add(this._weaknesses); + this._pageWeaknesses.Location = new System.Drawing.Point(7, 72); + this._pageWeaknesses.Name = "_pageWeaknesses"; + this._pageWeaknesses.PageDescription = "Select the Weaknesses to be included in the Knowledge Base."; + this._pageWeaknesses.PageTitle = "Select Weaknesses"; + this._pageWeaknesses.Size = new System.Drawing.Size(639, 282); + // + // + // + this._pageWeaknesses.Style.CornerType = DevComponents.DotNetBar.eCornerType.Square; + // + // + // + this._pageWeaknesses.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; + // + // + // + this._pageWeaknesses.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this._pageWeaknesses.TabIndex = 23; + // + // _uncheckAllWeaknesses + // + this._uncheckAllWeaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this._uncheckAllWeaknesses.Location = new System.Drawing.Point(138, 256); + this._uncheckAllWeaknesses.Name = "_uncheckAllWeaknesses"; + this._uncheckAllWeaknesses.Size = new System.Drawing.Size(75, 23); + this._uncheckAllWeaknesses.TabIndex = 16; + this._uncheckAllWeaknesses.Text = "Uncheck All"; + this._uncheckAllWeaknesses.UseVisualStyleBackColor = true; + this._uncheckAllWeaknesses.Click += new System.EventHandler(this._uncheckAllWeaknesses_Click); + // + // _checkAllWeaknesses + // + this._checkAllWeaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this._checkAllWeaknesses.Location = new System.Drawing.Point(57, 256); + this._checkAllWeaknesses.Name = "_checkAllWeaknesses"; + this._checkAllWeaknesses.Size = new System.Drawing.Size(75, 23); + this._checkAllWeaknesses.TabIndex = 15; + this._checkAllWeaknesses.Text = "Check All"; + this._checkAllWeaknesses.UseVisualStyleBackColor = true; + this._checkAllWeaknesses.Click += new System.EventHandler(this._checkAllWeaknesses_Click); + // + // _weaknesses + // + this._weaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._weaknesses.FormattingEnabled = true; + this._weaknesses.Location = new System.Drawing.Point(57, 0); + this._weaknesses.Margin = new System.Windows.Forms.Padding(0); + this._weaknesses.Name = "_weaknesses"; + this._weaknesses.Size = new System.Drawing.Size(526, 244); + this._weaknesses.TabIndex = 14; + this._weaknesses.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this._weaknesses_ItemCheck); + // // _pageMitigations // this._pageMitigations.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -718,7 +814,7 @@ private void InitializeComponent() this._pageMitigations.Controls.Add(this._mitigations); this._pageMitigations.Location = new System.Drawing.Point(7, 72); this._pageMitigations.Name = "_pageMitigations"; - this._pageMitigations.PageDescription = "Select the Mitigations to be included in the Template."; + this._pageMitigations.PageDescription = "Select the Mitigations to be included in the Knowledge Base."; this._pageMitigations.PageTitle = "Select Mitigations"; this._pageMitigations.Size = new System.Drawing.Size(639, 282); // @@ -783,7 +879,7 @@ private void InitializeComponent() this._pageThreatActors.Controls.Add(this._threatActors); this._pageThreatActors.Location = new System.Drawing.Point(7, 72); this._pageThreatActors.Name = "_pageThreatActors"; - this._pageThreatActors.PageDescription = "Select the Threat Actors to be included in the Template."; + this._pageThreatActors.PageDescription = "Select the Threat Actors to be included in the Knowledge Base."; this._pageThreatActors.PageTitle = "Select Threat Actors"; this._pageThreatActors.Size = new System.Drawing.Size(639, 282); // @@ -848,8 +944,9 @@ private void InitializeComponent() this._pageFile.Location = new System.Drawing.Point(7, 72); this._pageFile.Name = "_pageFile"; this._pageFile.NextButtonEnabled = DevComponents.DotNetBar.eWizardButtonState.False; - this._pageFile.PageDescription = "Select where to create the Template and the name of the file to be created."; - this._pageFile.PageTitle = "Select Template file"; + this._pageFile.PageDescription = "Select where to create the Knowledge Base and the name of the file to be created." + + ""; + this._pageFile.PageTitle = "Select Knowledge Base file"; this._pageFile.Size = new System.Drawing.Size(639, 282); // // @@ -923,7 +1020,7 @@ private void InitializeComponent() this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(429, 66); this.label4.TabIndex = 3; - this.label4.Text = "Template Export Creation"; + this.label4.Text = "Knowledge Base Export\r\n"; // // label5 // @@ -936,7 +1033,7 @@ private void InitializeComponent() this.label5.Size = new System.Drawing.Size(428, 234); this.label5.TabIndex = 4; this.label5.Text = "The required information has been collected.\r\n\r\nYou may click Finish to confirm t" + - "he creation of the new Template, or Cancel to abort it."; + "he creation of the new Knowledge Base, or Cancel to abort it."; // // _spellAsYouType // @@ -984,7 +1081,7 @@ private void InitializeComponent() this._spellAsYouType.V2Parser = true; this._spellAsYouType.WarnDuplicates = true; // - // ExportTemplateDialog + // ExportKnowledgeBaseDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; @@ -993,11 +1090,11 @@ private void InitializeComponent() this.Controls.Add(this._wizard); this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "ExportTemplateDialog"; + this.Name = "ExportKnowledgeBaseDialog"; this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Template Export Wizard"; + this.Text = "Knowledge Base Export Wizard"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ExportTemplateDialog_FormClosed); this._wizard.ResumeLayout(false); this._pageIntro.ResumeLayout(false); @@ -1011,6 +1108,7 @@ private void InitializeComponent() this._pageSchemas.ResumeLayout(false); this._pageItemTemplates.ResumeLayout(false); this._pageThreatTypes.ResumeLayout(false); + this._pageWeaknesses.ResumeLayout(false); this._pageMitigations.ResumeLayout(false); this._pageThreatActors.ResumeLayout(false); this._pageFile.ResumeLayout(false); @@ -1073,5 +1171,11 @@ private void InitializeComponent() private System.Windows.Forms.TextBox _fileName; private System.Windows.Forms.CheckBox _skipGranularSteps; private Keyoti.RapidSpell.RapidSpellAsYouType _spellAsYouType; + private System.Windows.Forms.CheckBox _fullyWeaknesses; + private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem1; + private DevComponents.DotNetBar.WizardPage _pageWeaknesses; + private System.Windows.Forms.Button _uncheckAllWeaknesses; + private System.Windows.Forms.Button _checkAllWeaknesses; + private System.Windows.Forms.CheckedListBox _weaknesses; } } \ No newline at end of file diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.cs b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.cs index 3eeb64ac..32d5d9e2 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.cs @@ -116,6 +116,17 @@ public ExportKnowledgeBaseDialog([NotNull] IThreatModel model) : this() _fullyThreatTypes.CheckState = CheckState.Indeterminate; } + var weaknesses = _model.Weaknesses?.OrderBy(x => x.Name).ToArray(); + if (weaknesses?.Any() ?? false) + { + _weaknesses.Items.AddRange(weaknesses); + } + else + { + _fullyWeaknesses.Enabled = false; + _fullyWeaknesses.CheckState = CheckState.Indeterminate; + } + var mitigations = _model.Mitigations?.OrderBy(x => x.Name).ToArray(); if (mitigations?.Any() ?? false) { @@ -187,6 +198,20 @@ private void _uncheckAllThreatTypes_Click(object sender, EventArgs e) eWizardButtonState.True : eWizardButtonState.False; } + private void _checkAllWeaknesses_Click(object sender, EventArgs e) + { + CheckAll(_weaknesses); + _pageWeaknesses.NextButtonEnabled = AnythingSelected(true) ? + eWizardButtonState.True : eWizardButtonState.False; + } + + private void _uncheckAllWeaknesses_Click(object sender, EventArgs e) + { + UncheckAll(_weaknesses); + _pageWeaknesses.NextButtonEnabled = AnythingSelected(true) ? + eWizardButtonState.True : eWizardButtonState.False; + } + private void _checkAllMitigations_Click(object sender, EventArgs e) { CheckAll(_mitigations); @@ -259,11 +284,13 @@ private DuplicationDefinition GetDuplicationDefinition() DuplicationDefinition result = new DuplicationDefinition(); List schemas = new List(); List mitigations = new List(); + List weaknesses = new List(); List severities = new List(); List strengths = new List(); AddThreatActors(result, schemas); - AddThreatTypes(result, schemas, mitigations, severities, strengths); + AddThreatTypes(result, schemas, mitigations, weaknesses, severities, strengths); + AddWeaknesses(result, schemas, mitigations, weaknesses, severities, strengths); AddMitigations(result, mitigations, schemas); AddItemTemplates(result, schemas); AddStrengths(result, strengths, schemas); @@ -312,12 +339,14 @@ private void AddSeverities([NotNull] DuplicationDefinition definition, } private void AddThreatTypes([NotNull] DuplicationDefinition definition, [NotNull] List schemas, - [NotNull] List mitigations, [NotNull] List severities, [NotNull] List strengths) + [NotNull] List mitigations, [NotNull] List weaknesses, + [NotNull] List severities, [NotNull] List strengths) { if (_fullyThreatTypes.Checked) { definition.AllThreatTypes = true; AddMitigations(mitigations, _model.ThreatTypes); + AddWeaknesses(weaknesses, _model.ThreatTypes); AddSeverities(severities, _model.ThreatTypes); AddStrengths(strengths, _model.ThreatTypes); AddSchemas(schemas, _model.ThreatTypes?.Select(x => x.Properties)); @@ -330,6 +359,7 @@ private void AddThreatTypes([NotNull] DuplicationDefinition definition, [NotNull definition.ThreatTypes = threatTypes.Select(x => x.Id).ToArray(); AddMitigations(mitigations, threatTypes); + AddWeaknesses(weaknesses, threatTypes); AddSeverities(severities, threatTypes); AddStrengths(strengths, threatTypes); AddSchemas(schemas, threatTypes.Select(x => x.Properties)); @@ -337,6 +367,48 @@ private void AddThreatTypes([NotNull] DuplicationDefinition definition, [NotNull } } + private void AddWeaknesses([NotNull] DuplicationDefinition definition, [NotNull] List schemas, + [NotNull] List mitigations, [NotNull] List weaknesses, + [NotNull] List severities, [NotNull] List strengths) + { + if (_fullyWeaknesses.Checked) + { + definition.AllWeaknesses = true; + AddMitigations(mitigations, _model.Weaknesses); + AddSeverities(severities, _model.Weaknesses); + AddStrengths(strengths, _model.Weaknesses); + AddSchemas(schemas, _model.Weaknesses?.Select(x => x.Properties)); + } + else + { + var w = _weaknesses.CheckedItems.OfType().Select(x => x.Id).ToArray(); + IEnumerable weaknessesId = null; + if (w.Any()) + { + if (weaknesses.Any()) + weaknessesId = weaknesses.Union(w).ToArray(); + else + weaknessesId = w; + } + else + { + if (weaknesses.Any()) + weaknessesId = weaknesses; + } + + definition.Weaknesses = weaknessesId; + + var w2 = _model.Weaknesses?.Where(x => weaknessesId?.Contains(x.Id) ?? false).ToArray(); + if (w2?.Any() ?? false) + { + AddMitigations(mitigations, w2); + AddSeverities(severities, w2); + AddStrengths(strengths, w2); + AddSchemas(schemas, w2.Select(x => x.Properties)); + } + } + } + [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] private void AddMitigations([NotNull] DuplicationDefinition definition, [NotNull] List mitigations, [NotNull] List schemas) @@ -442,6 +514,50 @@ private void AddMitigations(List mitigations, IEnumerable thr } } + private void AddMitigations(List mitigations, IEnumerable weaknesses) + { + var w = weaknesses?.ToArray(); + if (w?.Any() ?? false) + { + foreach (var weakness in w) + { + var mm = weakness.Mitigations?.ToArray(); + if (mm?.Any() ?? false) + { + foreach (var mitigation in mm) + { + if (!mitigations.Contains(mitigation.MitigationId)) + { + mitigations.Add(mitigation.MitigationId); + } + } + } + } + } + } + + private void AddWeaknesses(List weaknesses, IEnumerable threatTypes) + { + var tt = threatTypes?.ToArray(); + if (tt?.Any() ?? false) + { + foreach (var threatType in tt) + { + var w = threatType.Weaknesses?.ToArray(); + if (w?.Any() ?? false) + { + foreach (var weakness in w) + { + if (!weaknesses.Contains(weakness.WeaknessId)) + { + weaknesses.Add(weakness.WeaknessId); + } + } + } + } + } + } + private void AddSeverities([NotNull] List severities, IEnumerable threatTypes) { var tt = threatTypes?.ToArray(); @@ -456,6 +572,20 @@ private void AddSeverities([NotNull] List severities, IEnumerable severities, IEnumerable weaknesses) + { + var w = weaknesses?.ToArray(); + if (w?.Any() ?? false) + { + var sevs = w.Select(x => x.SeverityId); + foreach (var sev in sevs) + { + if (!severities.Contains(sev)) + severities.Add(sev); + } + } + } + private void AddStrengths(List strengths, IEnumerable threatTypes) { var tt = threatTypes?.ToArray(); @@ -478,6 +608,28 @@ private void AddStrengths(List strengths, IEnumerable threatTy } } + private void AddStrengths(List strengths, IEnumerable weaknesses) + { + var w = weaknesses?.ToArray(); + if (w?.Any() ?? false) + { + foreach (var weakness in w) + { + var mitigations = weakness.Mitigations?.ToArray(); + if (mitigations?.Any() ?? false) + { + foreach (var mitigation in mitigations) + { + if (mitigation.Strength != null && !strengths.Contains(mitigation.StrengthId)) + { + strengths.Add(mitigation.StrengthId); + } + } + } + } + } + } + private void AddSchemas([NotNull] List schemas, IEnumerable> listProps) { var listPropsArray = listProps?.ToArray(); @@ -569,6 +721,14 @@ private WizardPage GetNextPage([NotNull] WizardPage current) else result.NextButtonEnabled = eWizardButtonState.True; } else if (current == _pageThreatTypes) + { + result = !_fullyWeaknesses.Checked ? _pageWeaknesses : GetNextPage(_pageWeaknesses); + if (GetNextPage(result) == _pageFile) + result.NextButtonEnabled = AnythingSelected(true) ? + eWizardButtonState.True : eWizardButtonState.False; + else + result.NextButtonEnabled = eWizardButtonState.True; + } else if (current == _pageWeaknesses) { result = !_fullyMitigations.Checked ? _pageMitigations : GetNextPage(_pageMitigations); if (GetNextPage(result) == _pageFile) @@ -576,7 +736,8 @@ private WizardPage GetNextPage([NotNull] WizardPage current) eWizardButtonState.True : eWizardButtonState.False; else result.NextButtonEnabled = eWizardButtonState.True; - } else if (current == _pageMitigations) + } + else if (current == _pageMitigations) { result = !_fullyThreatActors.Checked ? _pageThreatActors : GetNextPage(_pageThreatActors); if (GetNextPage(result) == _pageFile) @@ -615,9 +776,14 @@ private WizardPage GetPreviousPage([NotNull] WizardPage current) } else if (current == _pageThreatTypes) { result = !_fullyItemTemplates.Checked ? _pageItemTemplates : GetPreviousPage(_pageItemTemplates); - } else if (current == _pageMitigations) + } + else if (current == _pageWeaknesses) { result = !_fullyThreatTypes.Checked ? _pageThreatTypes : GetPreviousPage(_pageThreatTypes); + } + else if (current == _pageMitigations) + { + result = !_fullyWeaknesses.Checked ? _pageWeaknesses : GetPreviousPage(_pageWeaknesses); } else if (current == _pageThreatActors) { result = !_fullyMitigations.Checked ? _pageMitigations : GetPreviousPage(_pageMitigations); @@ -653,6 +819,12 @@ private void _fullyThreatTypes_CheckedChanged(object sender, EventArgs e) eWizardButtonState.True : eWizardButtonState.False; } + private void _fullyWeaknesses_CheckedChanged(object sender, EventArgs e) + { + _pageFullyInclude.NextButtonEnabled = AnythingSelected(false) ? + eWizardButtonState.True : eWizardButtonState.False; + } + private void _fullyMitigations_CheckedChanged(object sender, EventArgs e) { _pageFullyInclude.NextButtonEnabled = AnythingSelected(false) ? @@ -677,11 +849,12 @@ private bool AnythingSelected(bool full) _fullySchemas.CheckState == CheckState.Checked || _fullyItemTemplates.CheckState == CheckState.Checked || _fullyThreatTypes.CheckState == CheckState.Checked || + _fullyWeaknesses.CheckState == CheckState.Checked || _fullyMitigations.CheckState == CheckState.Checked || _fullyThreatActors.CheckState == CheckState.Checked || _schemas.CheckedItems.Count > 0 || _itemTemplates.CheckedItems.Count > 0 || - _threatTypes.CheckedItems.Count > 0 || _mitigations.CheckedItems.Count > 0 || - _threatActors.CheckedItems.Count > 0; + _threatTypes.CheckedItems.Count > 0 || _weaknesses.CheckedItems.Count > 0 || + _mitigations.CheckedItems.Count > 0 || _threatActors.CheckedItems.Count > 0; } private void _schemas_ItemCheck(object sender, ItemCheckEventArgs e) @@ -690,11 +863,14 @@ private void _schemas_ItemCheck(object sender, ItemCheckEventArgs e) _fullySchemas.CheckState == CheckState.Checked || _fullyItemTemplates.CheckState == CheckState.Checked || _fullyThreatTypes.CheckState == CheckState.Checked || + _fullyWeaknesses.CheckState == CheckState.Checked || _fullyMitigations.CheckState == CheckState.Checked || _fullyThreatActors.CheckState == CheckState.Checked || (e.NewValue == CheckState.Checked || _schemas.CheckedItems.Count > 1) || _itemTemplates.CheckedItems.Count > 0 || - _threatTypes.CheckedItems.Count > 0 || _mitigations.CheckedItems.Count > 0 || + _threatTypes.CheckedItems.Count > 0 || + _weaknesses.CheckedItems.Count > 0 || + _mitigations.CheckedItems.Count > 0 || _threatActors.CheckedItems.Count > 0) ? eWizardButtonState.True : eWizardButtonState.False; } @@ -705,11 +881,14 @@ private void _entityTemplates_ItemCheck(object sender, ItemCheckEventArgs e) _fullySchemas.CheckState == CheckState.Checked || _fullyItemTemplates.CheckState == CheckState.Checked || _fullyThreatTypes.CheckState == CheckState.Checked || + _fullyWeaknesses.CheckState == CheckState.Checked || _fullyMitigations.CheckState == CheckState.Checked || _fullyThreatActors.CheckState == CheckState.Checked || _schemas.CheckedItems.Count > 0 || (e.NewValue == CheckState.Checked || _itemTemplates.CheckedItems.Count > 1) || - _threatTypes.CheckedItems.Count > 0 || _mitigations.CheckedItems.Count > 0 || + _threatTypes.CheckedItems.Count > 0 || + _weaknesses.CheckedItems.Count > 0 || + _mitigations.CheckedItems.Count > 0 || _threatActors.CheckedItems.Count > 0) ? eWizardButtonState.True : eWizardButtonState.False; } @@ -720,10 +899,14 @@ private void _threatActors_ItemCheck(object sender, ItemCheckEventArgs e) _fullySchemas.CheckState == CheckState.Checked || _fullyItemTemplates.CheckState == CheckState.Checked || _fullyThreatTypes.CheckState == CheckState.Checked || + _fullyWeaknesses.CheckState == CheckState.Checked || _fullyMitigations.CheckState == CheckState.Checked || _fullyThreatActors.CheckState == CheckState.Checked || - _schemas.CheckedItems.Count > 0 || _itemTemplates.CheckedItems.Count > 0 || - _threatTypes.CheckedItems.Count > 0 || _mitigations.CheckedItems.Count > 0 || + _schemas.CheckedItems.Count > 0 || + _itemTemplates.CheckedItems.Count > 0 || + _threatTypes.CheckedItems.Count > 0 || + _weaknesses.CheckedItems.Count > 0 || + _mitigations.CheckedItems.Count > 0 || (e.NewValue == CheckState.Checked || _threatActors.CheckedItems.Count > 1)) ? eWizardButtonState.True : eWizardButtonState.False; } @@ -734,11 +917,31 @@ private void _threatTypes_ItemCheck(object sender, ItemCheckEventArgs e) _fullySchemas.CheckState == CheckState.Checked || _fullyItemTemplates.CheckState == CheckState.Checked || _fullyThreatTypes.CheckState == CheckState.Checked || + _fullyWeaknesses.CheckState == CheckState.Checked || _fullyMitigations.CheckState == CheckState.Checked || _fullyThreatActors.CheckState == CheckState.Checked || _schemas.CheckedItems.Count > 0 || _itemTemplates.CheckedItems.Count > 0 || - (e.NewValue == CheckState.Checked || _threatTypes.CheckedItems.Count > 1 ) || - _mitigations.CheckedItems.Count > 0 || _threatActors.CheckedItems.Count > 0) ? + (e.NewValue == CheckState.Checked || _threatTypes.CheckedItems.Count > 1 ) || + _weaknesses.CheckedItems.Count > 0 || + _mitigations.CheckedItems.Count > 0 || + _threatActors.CheckedItems.Count > 0) ? + eWizardButtonState.True : eWizardButtonState.False; + } + + private void _weaknesses_ItemCheck(object sender, ItemCheckEventArgs e) + { + _pageWeaknesses.NextButtonEnabled = (_wizard.GetNextPage() != _pageFinish || + _fullySchemas.CheckState == CheckState.Checked || + _fullyItemTemplates.CheckState == CheckState.Checked || + _fullyThreatTypes.CheckState == CheckState.Checked || + _fullyWeaknesses.CheckState == CheckState.Checked || + _fullyMitigations.CheckState == CheckState.Checked || + _fullyThreatActors.CheckState == CheckState.Checked || + _schemas.CheckedItems.Count > 0 || _itemTemplates.CheckedItems.Count > 0 || + _threatTypes.CheckedItems.Count > 0 || + (e.NewValue == CheckState.Checked || _weaknesses.CheckedItems.Count > 1) || + _mitigations.CheckedItems.Count > 0 || + _threatActors.CheckedItems.Count > 0) ? eWizardButtonState.True : eWizardButtonState.False; } @@ -748,10 +951,14 @@ private void _mitigations_ItemCheck(object sender, ItemCheckEventArgs e) _fullySchemas.CheckState == CheckState.Checked || _fullyItemTemplates.CheckState == CheckState.Checked || _fullyThreatTypes.CheckState == CheckState.Checked || + _fullyWeaknesses.CheckState == CheckState.Checked || _fullyMitigations.CheckState == CheckState.Checked || _fullyThreatActors.CheckState == CheckState.Checked || - _schemas.CheckedItems.Count > 0 || _itemTemplates.CheckedItems.Count > 0 || - _threatTypes.CheckedItems.Count > 0 || _mitigations.CheckedItems.Count > 0 || + _schemas.CheckedItems.Count > 0 || + _itemTemplates.CheckedItems.Count > 0 || + _threatTypes.CheckedItems.Count > 0 || + _weaknesses.CheckedItems.Count > 0 || + (e.NewValue == CheckState.Checked || _mitigations.CheckedItems.Count > 1) || _threatActors.CheckedItems.Count > 0) ? eWizardButtonState.True : eWizardButtonState.False; } diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.resx b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.resx index a8f959e1..3f7ebd26 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.resx +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ExportTemplateDialog.resx @@ -121,13 +121,10 @@ 17, 17 - This wizard will guide you through the process to export part of the current Threat Model as a Template. + This wizard will guide you through the process to export part of the current Threat Model as a Knowledge Base. -You will be requested to select which items you want to export, and where to save the new Template. +You will be requested to select which items you want to export, and where to save the new Knowledge Base. -The current Threat Model will not be affected by the Template Export process. +The current Threat Model will not be affected by the Knowledge Base Export process. - - 232, 19 - \ No newline at end of file diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.Designer.cs b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.Designer.cs index d1bc7a43..c256bcc1 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.Designer.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.Designer.cs @@ -28,6 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportTemplateDialog)); this._wizard = new DevComponents.DotNetBar.Wizard(); this._pageIntro = new DevComponents.DotNetBar.WizardPage(); this.label1 = new System.Windows.Forms.Label(); @@ -66,12 +67,12 @@ private void InitializeComponent() this._checkAllEntityTemplates = new System.Windows.Forms.Button(); this._itemTemplates = new System.Windows.Forms.CheckedListBox(); this._pageThreatTypes = new DevComponents.DotNetBar.WizardPage(); - this._pageWeaknesses = new DevComponents.DotNetBar.WizardPage(); this._uncheckAllThreatTypes = new System.Windows.Forms.Button(); this._checkAllThreatTypes = new System.Windows.Forms.Button(); + this._threatTypes = new System.Windows.Forms.CheckedListBox(); + this._pageWeaknesses = new DevComponents.DotNetBar.WizardPage(); this._uncheckAllWeaknesses = new System.Windows.Forms.Button(); this._checkAllWeaknesses = new System.Windows.Forms.Button(); - this._threatTypes = new System.Windows.Forms.CheckedListBox(); this._weaknesses = new System.Windows.Forms.CheckedListBox(); this._pageMitigations = new DevComponents.DotNetBar.WizardPage(); this._uncheckAllMitigations = new System.Windows.Forms.Button(); @@ -205,7 +206,7 @@ private void InitializeComponent() this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(429, 66); this.label1.TabIndex = 0; - this.label1.Text = "Welcome to the Template Import Wizard"; + this.label1.Text = "Welcome to the Knowledge Base Import Wizard"; // // label2 // @@ -217,9 +218,7 @@ private void InitializeComponent() this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(428, 234); this.label2.TabIndex = 1; - this.label2.Text = "This wizard will guide you through the process to import an existing Template int" + - "o the current Threat Model.\r\n\r\nYou will be given the option of selecting the par" + - "t of the Template you want to import."; + this.label2.Text = resources.GetString("label2.Text"); // // label3 // @@ -244,8 +243,8 @@ private void InitializeComponent() this._pageFile.Location = new System.Drawing.Point(7, 72); this._pageFile.Name = "_pageFile"; this._pageFile.NextButtonEnabled = DevComponents.DotNetBar.eWizardButtonState.False; - this._pageFile.PageDescription = "Select the Template file to be imported."; - this._pageFile.PageTitle = "Select Template file"; + this._pageFile.PageDescription = "Select the Knowledge Base file to be imported."; + this._pageFile.PageTitle = "Select Knowledge Base file"; this._pageFile.Size = new System.Drawing.Size(639, 282); // // @@ -293,8 +292,8 @@ private void InitializeComponent() this._pageTMProperties.Controls.Add(this._layoutDetails); this._pageTMProperties.Location = new System.Drawing.Point(7, 72); this._pageTMProperties.Name = "_pageTMProperties"; - this._pageTMProperties.PageDescription = "Select the Threat Model Details to be included in the Template."; - this._pageTMProperties.PageTitle = "Select Threat Model Details"; + this._pageTMProperties.PageDescription = "Show the details of the Knowledge Base being imported."; + this._pageTMProperties.PageTitle = "Show Threat Model Details"; this._pageTMProperties.Size = new System.Drawing.Size(639, 282); // // @@ -383,7 +382,7 @@ private void InitializeComponent() this._pageFullyInclude.Controls.Add(this._layoutFullyCopy); this._pageFullyInclude.Location = new System.Drawing.Point(7, 72); this._pageFullyInclude.Name = "_pageFullyInclude"; - this._pageFullyInclude.PageDescription = "Select the categories that you want to fully include in the Template."; + this._pageFullyInclude.PageDescription = "Select the categories that you want to fully include in the Knowledge Base."; this._pageFullyInclude.PageTitle = "Select what to fully include"; this._pageFullyInclude.Size = new System.Drawing.Size(639, 282); // @@ -494,7 +493,7 @@ private void InitializeComponent() this._fullyWeaknesses.Margin = new System.Windows.Forms.Padding(0); this._fullyWeaknesses.Name = "_fullyWeaknesses"; this._fullyWeaknesses.Size = new System.Drawing.Size(521, 17); - this._fullyWeaknesses.TabIndex = 2; + this._fullyWeaknesses.TabIndex = 3; this._fullyWeaknesses.Text = "Weaknesses"; this._fullyWeaknesses.UseVisualStyleBackColor = true; this._fullyWeaknesses.CheckedChanged += new System.EventHandler(this._fullyWeaknesses_CheckedChanged); @@ -508,7 +507,7 @@ private void InitializeComponent() this._fullyMitigations.Margin = new System.Windows.Forms.Padding(0); this._fullyMitigations.Name = "_fullyMitigations"; this._fullyMitigations.Size = new System.Drawing.Size(521, 17); - this._fullyMitigations.TabIndex = 3; + this._fullyMitigations.TabIndex = 4; this._fullyMitigations.Text = "Mitigations"; this._fullyMitigations.UseVisualStyleBackColor = true; this._fullyMitigations.CheckedChanged += new System.EventHandler(this._fullyMitigations_CheckedChanged); @@ -522,7 +521,7 @@ private void InitializeComponent() this._fullyThreatActors.Margin = new System.Windows.Forms.Padding(0); this._fullyThreatActors.Name = "_fullyThreatActors"; this._fullyThreatActors.Size = new System.Drawing.Size(521, 17); - this._fullyThreatActors.TabIndex = 4; + this._fullyThreatActors.TabIndex = 5; this._fullyThreatActors.Text = "Threat Actors"; this._fullyThreatActors.UseVisualStyleBackColor = true; this._fullyThreatActors.CheckedChanged += new System.EventHandler(this._fullyThreatActors_CheckedChanged); @@ -592,7 +591,7 @@ private void InitializeComponent() this._pageSchemas.Controls.Add(this._schemas); this._pageSchemas.Location = new System.Drawing.Point(7, 72); this._pageSchemas.Name = "_pageSchemas"; - this._pageSchemas.PageDescription = "Select the Schemas to be included in the Template."; + this._pageSchemas.PageDescription = "Select the Schemas to be included in the Knowledge Base."; this._pageSchemas.PageTitle = "Select Schemas"; this._pageSchemas.Size = new System.Drawing.Size(639, 282); // @@ -656,7 +655,7 @@ private void InitializeComponent() this._pageItemTemplates.Controls.Add(this._itemTemplates); this._pageItemTemplates.Location = new System.Drawing.Point(7, 72); this._pageItemTemplates.Name = "_pageItemTemplates"; - this._pageItemTemplates.PageDescription = "Select the Item Templates to be included in the Template."; + this._pageItemTemplates.PageDescription = "Select the Item Templates to be included in the Knowledge Base."; this._pageItemTemplates.PageTitle = "Select Item Templates"; this._pageItemTemplates.Size = new System.Drawing.Size(639, 282); // @@ -721,7 +720,7 @@ private void InitializeComponent() this._pageThreatTypes.Controls.Add(this._threatTypes); this._pageThreatTypes.Location = new System.Drawing.Point(7, 72); this._pageThreatTypes.Name = "_pageThreatTypes"; - this._pageThreatTypes.PageDescription = "Select the Threat Types to be included in the Template."; + this._pageThreatTypes.PageDescription = "Select the Threat Types to be included in the Knowledge Base."; this._pageThreatTypes.PageTitle = "Select Threat Types"; this._pageThreatTypes.Size = new System.Drawing.Size(639, 282); // @@ -775,8 +774,8 @@ private void InitializeComponent() // // _pageWeaknesses // - this._pageWeaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this._pageWeaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this._pageWeaknesses.AntiAlias = false; this._pageWeaknesses.BackColor = System.Drawing.Color.White; @@ -827,8 +826,8 @@ private void InitializeComponent() // // _weaknesses // - this._weaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this._weaknesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this._weaknesses.FormattingEnabled = true; this._weaknesses.Location = new System.Drawing.Point(57, 0); @@ -851,7 +850,7 @@ private void InitializeComponent() this._pageMitigations.Controls.Add(this._mitigations); this._pageMitigations.Location = new System.Drawing.Point(7, 72); this._pageMitigations.Name = "_pageMitigations"; - this._pageMitigations.PageDescription = "Select the Mitigations to be included in the Template."; + this._pageMitigations.PageDescription = "Select the Mitigations to be included in the Knowledge Base."; this._pageMitigations.PageTitle = "Select Mitigations"; this._pageMitigations.Size = new System.Drawing.Size(639, 282); // @@ -916,7 +915,7 @@ private void InitializeComponent() this._pageThreatActors.Controls.Add(this._threatActors); this._pageThreatActors.Location = new System.Drawing.Point(7, 72); this._pageThreatActors.Name = "_pageThreatActors"; - this._pageThreatActors.PageDescription = "Select the Threat Actors to be included in the Template."; + this._pageThreatActors.PageDescription = "Select the Threat Actors to be included in the Knowledge Base."; this._pageThreatActors.PageTitle = "Select Threat Actors"; this._pageThreatActors.Size = new System.Drawing.Size(639, 282); // @@ -1005,7 +1004,7 @@ private void InitializeComponent() this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(429, 66); this.label4.TabIndex = 3; - this.label4.Text = "Template Import"; + this.label4.Text = "Knowledge Base Import"; // // label5 // @@ -1018,14 +1017,14 @@ private void InitializeComponent() this.label5.Size = new System.Drawing.Size(428, 234); this.label5.TabIndex = 4; this.label5.Text = "The required information has been collected.\r\n\r\nYou may click Finish to confirm i" + - "mporting the Template, or Cancel to abort it."; + "mporting the Knowledge Base, or Cancel to abort it."; // // _openFile // this._openFile.DefaultExt = "tmt"; this._openFile.Filter = "Threat Model Template (*.tmt)|*.tmt|Threat Model Json Template (*.tmk)|*.tmk"; - this._openFile.Title = "Select the Template file"; this._openFile.RestoreDirectory = true; + this._openFile.Title = "Select the Template file"; // // ImportTemplateDialog // @@ -1040,7 +1039,7 @@ private void InitializeComponent() this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Template Import Wizard"; + this.Text = "Knowledge Base Import Wizard"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ImportTemplateDialog_FormClosed); this._wizard.ResumeLayout(false); this._pageIntro.ResumeLayout(false); diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.cs b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.cs index 6d4d6e53..604073e5 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.cs @@ -241,8 +241,8 @@ private void LoadTemplate([Required] string fileName) } else { - _fullyThreatTypes.Enabled = false; - _fullyThreatTypes.CheckState = CheckState.Indeterminate; + _fullyWeaknesses.Enabled = false; + _fullyWeaknesses.CheckState = CheckState.Indeterminate; } var mitigations = _template.Mitigations?.OrderBy(x => x.Name).ToArray(); diff --git a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.resx b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.resx index 84c6a1b8..38e9e9d6 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.resx +++ b/Studio/ThreatsManager.Extensions.WinForms/Dialogs/ImportTemplateDialog.resx @@ -117,6 +117,11 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + This wizard will guide you through the process to import an existing Knowledge Base into the current Threat Model. + +You will be given the option of selecting the part of the Knowledge Base you want to import. + 246, 17 diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/DataFlowList/DataFlowListPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/DataFlowList/DataFlowListPanel.CustomRibbonExtension.cs index fd221c1b..b8bb3258 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/DataFlowList/DataFlowListPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/DataFlowList/DataFlowListPanel.CustomRibbonExtension.cs @@ -36,6 +36,9 @@ public IEnumerable CommandBars new ActionDefinition(Id, "RemoveDataFlow", "Remove Flow", Resources.flow_big_delete, Resources.flow_delete, false), + new ActionDefinition(Id, "RemoveNotInDiagrams", "Remove not in Diagrams", + Properties.Resources.flow_big_sponge, + Properties.Resources.flow_sponge), }), new CommandsBarDefinition("Find", "Find", new IActionDefinition[] { @@ -92,76 +95,126 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) case "RemoveDataFlow": if (_currentRow != null) { - if ((selected?.Length ?? 0) > 1) + using (var scope = UndoRedoManager.OpenScope("Remove Flows")) { - var outcome = MessageBox.Show(Form.ActiveForm, - $"You have selected {selected.Length} Flows. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Flows,\nNo to remove only the last one you selected, '{_currentRow?.Tag?.ToString()}'.\nPress Cancel to abort.", - "Remove Flows", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button3); - switch (outcome) + if ((selected?.Length ?? 0) > 1) { - case DialogResult.Yes: - bool removed = true; - foreach (var row in selected) - { - bool r = false; - if (row.Tag is IDataFlow flow) + var outcome = MessageBox.Show(Form.ActiveForm, + $"You have selected {selected.Length} Flows. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Flows,\nNo to remove only the last one you selected, '{_currentRow?.Tag?.ToString()}'.\nPress Cancel to abort.", + "Remove Flows", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button3); + switch (outcome) + { + case DialogResult.Yes: + bool removed = true; + foreach (var row in selected) { - r = _model.RemoveDataFlow(flow.Id); - } + bool r = false; + if (row.Tag is IDataFlow flow) + { + r = _model.RemoveDataFlow(flow.Id); + } - removed &= r; + removed &= r; - if (r && row == _currentRow) - { - _properties.Item = null; - _currentRow = null; + if (r && row == _currentRow) + { + _properties.Item = null; + _currentRow = null; + } } - } - if (removed) - { - text = "Remove Flows"; - } - else - { - warning = true; - text = "One or more Flows cannot be removed."; - } - break; - case DialogResult.No: - if (_currentRow != null && _currentRow.Tag is IDataFlow flow2) - { - if (_model.RemoveDataFlow(flow2.Id)) + scope?.Complete(); + + if (removed) { - _properties.Item = null; - _currentRow = null; - text = "Remove Flow"; + text = "Remove Flows"; } else { warning = true; - text = "The Flow cannot be removed."; + text = "One or more Flows cannot be removed."; } - } - break; + break; + case DialogResult.No: + if (_currentRow != null && _currentRow.Tag is IDataFlow flow2) + { + if (_model.RemoveDataFlow(flow2.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove Flow"; + } + else + { + warning = true; + text = "The Flow cannot be removed."; + } + } + break; + } + } + else if (_currentRow != null && _currentRow.Tag is IDataFlow dataFlow && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove Flow '{dataFlow.Name}'. Are you sure?", + "Remove Flow", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) + { + if (_model.RemoveDataFlow(dataFlow.Id)) + { + scope?.Complete(); + _properties.Item = null; + text = "Remove Flow"; + } + else + { + warning = true; + text = "The Flow cannot be removed."; + } } } - else if (_currentRow != null && _currentRow.Tag is IDataFlow dataFlow && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove Flow '{dataFlow.Name}'. Are you sure?", - "Remove Flow", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) + } + break; + case "RemoveNotInDiagrams": + var diagrams = _model.Diagrams?.ToArray(); + var flows = _model.DataFlows? + .Where(x => !(diagrams?.Any(y => y.Links?.Any(z => x.Id == z.AssociatedId) ?? false) ?? false)) + .ToArray(); + if (flows?.Any() ?? false) + { + if (MessageBox.Show(Form.ActiveForm, + $"You are about to remove {flows.Count()} Flows that are not associated with any Diagram. Are you sure?", + "Remove Flows not in any Diagram", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - if (_model.RemoveDataFlow(dataFlow.Id)) + var currentFlow = _currentRow?.Tag as IDataFlow; + if (currentFlow != null && flows.Any(x => x.Id == currentFlow.Id)) { _properties.Item = null; - text = "Remove Flow"; + _currentRow = null; + } - else + + using (var scope = UndoRedoManager.OpenScope("Remove Flows Not In Any Diagram")) { - warning = true; - text = "The Flow cannot be removed."; + var removed = true; + foreach (var flow in flows) + { + removed &= _model.RemoveDataFlow(flow.Id); + } + + if (removed) + { + text = "Remove Flows Not In Any Diagram "; + } + else + { + warning = true; + text = "One or more Flows cannot be removed."; + } + + scope?.Complete(); } } } @@ -170,10 +223,10 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) bool found = false; if (_currentRow != null && _currentRow.Tag is IDataFlow dataFlow2) { - var diagrams = _model.Diagrams?.ToArray(); - if (diagrams?.Any() ?? false) + var diagrams2 = _model.Diagrams?.ToArray(); + if (diagrams2?.Any() ?? false) { - foreach (var diagram in diagrams) + foreach (var diagram in diagrams2) { var flow = diagram.GetLink(dataFlow2.Id); if (flow != null) diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/DataStoreList/DataStoreListPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/DataStoreList/DataStoreListPanel.CustomRibbonExtension.cs index a350601e..0e0b2109 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/DataStoreList/DataStoreListPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/DataStoreList/DataStoreListPanel.CustomRibbonExtension.cs @@ -39,6 +39,9 @@ public IEnumerable CommandBars new ActionDefinition(Id, "RemoveDataStore", "Remove Data Store", Resources.storage_big_delete, Resources.storage_delete, false), + new ActionDefinition(Id, "RemoveNotInDiagrams", "Remove not in Diagrams", + Properties.Resources.storage_big_sponge, + Properties.Resources.storage_sponge), }), new CommandsBarDefinition("Find", "Find", new IActionDefinition[] { @@ -94,82 +97,137 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) { case "AddDataStore": text = "Add Data Store"; - _model.AddEntity(); + using (var scope = UndoRedoManager.OpenScope("Add Data Store")) + { + _model.AddEntity(); + scope?.Complete(); + } break; case "RemoveDataStore": if (_currentRow != null) { - if ((selected?.Length ?? 0) > 1) + using (var scope = UndoRedoManager.OpenScope("Remove Data Stores")) { - var outcome = MessageBox.Show(Form.ActiveForm, - $"You have selected {selected.Length} Data Stores. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Data Stores,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", - "Remove Data Stores", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button3); - switch (outcome) + if ((selected?.Length ?? 0) > 1) { - case DialogResult.Yes: - bool removed = true; - foreach (var row in selected) - { - bool r = false; - if (row.Tag is IEntity entity) + var outcome = MessageBox.Show(Form.ActiveForm, + $"You have selected {selected.Length} Data Stores. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Data Stores,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", + "Remove Data Stores", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button3); + switch (outcome) + { + case DialogResult.Yes: + bool removed = true; + foreach (var row in selected) { - r = _model.RemoveEntity(entity.Id); - } + bool r = false; + if (row.Tag is IEntity entity) + { + r = _model.RemoveEntity(entity.Id); + } - removed &= r; + removed &= r; - if (r && row == _currentRow) - { - _properties.Item = null; - _currentRow = null; + if (r && row == _currentRow) + { + _properties.Item = null; + _currentRow = null; + } } - } - if (removed) - { - text = "Remove Data Stores"; - } - else - { - warning = true; - text = "One or more Data Stores cannot be removed."; - } - break; - case DialogResult.No: - if (_currentRow != null && _currentRow.Tag is IEntity entity2) - { - if (_model.RemoveEntity(entity2.Id)) + scope?.Complete(); + + if (removed) { - _properties.Item = null; - _currentRow = null; - text = "Remove Data Store"; + text = "Remove Data Stores"; } else { warning = true; - text = "The Data Store cannot be removed."; + text = "One or more Data Stores cannot be removed."; + } + break; + case DialogResult.No: + if (_currentRow != null && _currentRow.Tag is IEntity entity2) + { + if (_model.RemoveEntity(entity2.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove Data Store"; + } + else + { + warning = true; + text = "The Data Store cannot be removed."; + } } - } - break; + break; + } + } + else if (_currentRow != null && _currentRow.Tag is IDataStore dataStore && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove Data Store '{dataStore.Name}'. Are you sure?", + "Remove Data Store", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) + { + if (_model.RemoveEntity(dataStore.Id)) + { + scope?.Complete(); + _properties.Item = null; + text = "Remove Data Store"; + } + else + { + warning = true; + text = "The Data Store cannot be removed."; + } } } - else if (_currentRow != null && _currentRow.Tag is IDataStore dataStore && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove Data Store '{dataStore.Name}'. Are you sure?", - "Remove Data Store", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) + } + break; + case "RemoveNotInDiagrams": + var diagrams = _model.Diagrams?.ToArray(); + var dataStores = _model.Entities? + .OfType() + .Where(x => !(diagrams?.Any(y => y.Entities?.Any(z => x.Id == z.AssociatedId) ?? false) ?? false)) + .ToArray(); + if (dataStores?.Any() ?? false) + { + if (MessageBox.Show(Form.ActiveForm, + $"You are about to remove {dataStores.Count()} Data Stores that are not associated with any Diagram. Are you sure?", + "Remove Data Stores not in any Diagram", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - if (_model.RemoveEntity(dataStore.Id)) + var currentStore = _currentRow?.Tag as IDataStore; + if (currentStore != null && dataStores.Any(x => x.Id == currentStore.Id)) { _properties.Item = null; - text = "Remove Data Store"; + _currentRow = null; + } - else + + using (var scope = UndoRedoManager.OpenScope("Remove Data Stores Not In Any Diagram")) { - warning = true; - text = "The Data Store cannot be removed."; + var removed = true; + foreach (var dataStore in dataStores) + { + removed &= _model.RemoveEntity(dataStore.Id); + } + + if (removed) + { + text = "Remove Data Stores Not In Any Diagram "; + } + else + { + warning = true; + text = "One or more Data Stores cannot be removed."; + } + + scope?.Complete(); } } } @@ -178,10 +236,10 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) bool found = false; if (_currentRow != null && _currentRow.Tag is IDataStore dataStore2) { - var diagrams = _model.Diagrams?.ToArray(); - if (diagrams?.Any() ?? false) + var diagrams2 = _model.Diagrams?.ToArray(); + if (diagrams2?.Any() ?? false) { - foreach (var diagram in diagrams) + foreach (var diagram in diagrams2) { var shape = diagram.GetEntityShape(dataStore2.Id); if (shape != null) diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/AssociatedPanelItemMarker.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/AssociatedPanelItemMarker.cs index de2aebd6..622958ac 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/AssociatedPanelItemMarker.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/AssociatedPanelItemMarker.cs @@ -27,6 +27,7 @@ private AssociatedPanelItemMarker() { Selectable = false; MarkerStatusTrigger.MarkerStatusUpdated += MarkerStatusTriggerOnMarkerStatusUpdated; + PanelItemListFormTrigger.PanelStatusUpdated += PanelItemListFormTrigger_ShowPanels; } public AssociatedPanelItemMarker([NotNull] object referenceObj) : this() @@ -61,6 +62,7 @@ public void Dispose() _markerProvider.StatusUpdated -= MarkerStatusUpdated; _markerProvider.Dispose(); } + PanelItemListFormTrigger.PanelStatusUpdated -= PanelItemListFormTrigger_ShowPanels; } private void MarkerStatusUpdated(IMarkerProvider provider) @@ -77,6 +79,14 @@ private void MarkerStatusTriggerOnMarkerStatusUpdated(MarkerStatus status) Visible = _visible; } + private void PanelItemListFormTrigger_ShowPanels(PanelsStatus status, GoView view) + { + if (status == PanelsStatus.Visible) + { + ShowPanelItemListForm(view, this.Location); + } + } + /// /// Event raised when a panel item is clicked. /// diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.CustomRibbonExtension.cs index 70208b7e..fdafce20 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.CustomRibbonExtension.cs @@ -104,7 +104,9 @@ public IEnumerable CommandBars var viewList = new List() { new ActionDefinition(Id, "MarkerToggle", "Toggle Markers", - Properties.Resources.cubes_big, Properties.Resources.cubes, true) + Properties.Resources.cubes_big, Properties.Resources.cubes, true), + new ActionDefinition(Id, "AllPanelsToggle", "Toggle all Panels", + Properties.Resources.panel_big, Properties.Resources.panel, true) }; if (_commandsBarContextAwareActions?.Any(x => string.CompareOrdinal("View", x.Key) == 0) ?? false) { @@ -397,6 +399,19 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) throw new ArgumentOutOfRangeException(); } break; + case "AllPanelsToggle": + switch (PanelItemListFormTrigger.CurrentStatus) + { + case PanelsStatus.Normal: + PanelItemListFormTrigger.RaiseShowPanels(PanelsStatus.Visible, _graph); + break; + case PanelsStatus.Visible: + PanelItemListFormTrigger.RaiseShowPanels(PanelsStatus.Normal, _graph); + break; + default: + throw new ArgumentOutOfRangeException(); + } + break; case "ZoomIn": _graph.ZoomIn(); break; diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Designer.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Designer.cs index 85427bf6..9a2bddfa 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Designer.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Designer.cs @@ -43,6 +43,9 @@ protected override void Dispose(bool disposing) { _diagram.Model.ChildCreated -= OnModelChildCreated; _diagram.Model.ChildRemoved -= OnModelChildRemoved; + _diagram.LinkAdded -= OnLinkAdded; + _diagram.EntityShapeAdded -= OnEntityShapeAdded; + _diagram.GroupShapeAdded -= OnGroupShapeAdded; } var shapes = _entities.Values.OfType().ToArray(); diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Links.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Links.cs index 8999bce0..62f60fab 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Links.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Links.cs @@ -9,25 +9,28 @@ public partial class ModelPanel { private void AddLink([NotNull] ILink link, float dpiFactor = 1.0f) { - var from = GetEntity(link.DataFlow.Source); - var to = GetEntity(link.DataFlow.Target); - if (from != null && to != null) + if (!_links.ContainsKey(link.AssociatedId)) { - var newLink = new GraphLink(link, dpiFactor, _markerSize) + var from = GetEntity(link.DataFlow.Source); + var to = GetEntity(link.DataFlow.Target); + if (from != null && to != null) { - Loading = true, - FromPort = from.Port, - ToPort = to.Port - }; - if (_actions != null) - newLink.SetContextAwareActions(_actions); - _graph.Doc.Add(newLink); - _links.Add(link.AssociatedId, newLink); - newLink.SelectedLink += OnSelectedLink; - newLink.SelectedThreatEvent += OnSelectedThreatEvent; - - newLink.Loading = false; - newLink.UpdateRoute(); + var newLink = new GraphLink(link, dpiFactor, _markerSize) + { + Loading = true, + FromPort = from.Port, + ToPort = to.Port + }; + if (_actions != null) + newLink.SetContextAwareActions(_actions); + _graph.Doc.Add(newLink); + _links.Add(link.AssociatedId, newLink); + newLink.SelectedLink += OnSelectedLink; + newLink.SelectedThreatEvent += OnSelectedThreatEvent; + + newLink.Loading = false; + newLink.UpdateRoute(); + } } } diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Shapes.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Shapes.cs index aab5a236..0cbf5da4 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Shapes.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.Shapes.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Web.UI.WebControls.WebParts; using Northwoods.Go; using PostSharp.Patterns.Contracts; using ThreatsManager.Interfaces.Extensions.Panels; @@ -51,52 +52,63 @@ private GoNode AddShape([NotNull] IShape shape, float dpiFactor = 1.0f) { GoNode result = null; - GraphGroup parent = null; - - if (shape.Identity is IGroupElement child) + if (_entities.ContainsKey(shape.AssociatedId)) { - _groups.TryGetValue(child.ParentId, out parent); + result = _entities[shape.AssociatedId]; } - - if (shape is IEntityShape entityShape) + else if (_groups.ContainsKey(shape.AssociatedId)) { - var node = new GraphEntity(entityShape, dpiFactor, _iconSize, _iconCenterSize, _imageSize, _markerSize); - if (_actions != null) - node.SetContextAwareActions(_actions); - node.SelectedShape += OnSelectedShape; - node.SelectedThreatEvent += OnSelectedThreatEvent; - node.OpenDiagram += OnOpenDiagram; - if (parent == null) - _graph.Doc.Add(node); - else - parent.Add(node); - _entities.Add(shape.AssociatedId, node); - - node.Validate(); - - result = node; + result = _groups[shape.AssociatedId]; } - else if (shape is IGroupShape groupShape && !_groups.ContainsKey(groupShape.AssociatedId)) + else { - var group = new GraphGroup(groupShape, dpiFactor, _markerSize); - if (_actions != null) - group.SetContextAwareActions(_actions); - group.SelectedShape += OnSelectedShape; - if (parent == null) - _graph.Doc.Add(group); - else - parent.Add(group); - _groups.Add(shape.AssociatedId, group); + GraphGroup parent = null; - group.Validate(); + if (shape.Identity is IGroupElement child) + { + _groups.TryGetValue(child.ParentId, out parent); + } - result = group; - } + if (shape is IEntityShape entityShape) + { + var node = new GraphEntity(entityShape, dpiFactor, _iconSize, _iconCenterSize, _imageSize, _markerSize); + if (_actions != null) + node.SetContextAwareActions(_actions); + node.SelectedShape += OnSelectedShape; + node.SelectedThreatEvent += OnSelectedThreatEvent; + node.OpenDiagram += OnOpenDiagram; + if (parent == null) + _graph.Doc.Add(node); + else + parent.Add(node); + _entities.Add(shape.AssociatedId, node); - if (result != null && shape.Identity is IThreatEventsContainer container) - { - container.ThreatEventAdded += OnThreatEventAddedToShape; - container.ThreatEventRemoved += OnThreatEventRemovedFromShape; + node.Validate(); + + result = node; + } + else if (shape is IGroupShape groupShape && !_groups.ContainsKey(groupShape.AssociatedId)) + { + var group = new GraphGroup(groupShape, dpiFactor, _markerSize); + if (_actions != null) + group.SetContextAwareActions(_actions); + group.SelectedShape += OnSelectedShape; + if (parent == null) + _graph.Doc.Add(group); + else + parent.Add(group); + _groups.Add(shape.AssociatedId, group); + + group.Validate(); + + result = group; + } + + if (result != null && shape.Identity is IThreatEventsContainer container) + { + container.ThreatEventAdded += OnThreatEventAddedToShape; + container.ThreatEventRemoved += OnThreatEventRemovedFromShape; + } } return result; diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.ShowDiagramPanel.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.ShowDiagramPanel.cs index a5566ae8..8d841e46 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.ShowDiagramPanel.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanel.ShowDiagramPanel.cs @@ -34,6 +34,9 @@ public void SetDiagram([NotNull] IDiagram diagram) { _diagram.Model.ChildCreated += OnModelChildCreated; _diagram.Model.ChildRemoved += OnModelChildRemoved; + _diagram.LinkAdded += OnLinkAdded; + _diagram.EntityShapeAdded += OnEntityShapeAdded; + _diagram.GroupShapeAdded += OnGroupShapeAdded; var dpi = GetDiagramDpi(diagram); var factor = Dpi.Factor.Height / dpi; @@ -254,6 +257,21 @@ private void OnModelChildRemoved(IIdentity identity) } } + private void OnGroupShapeAdded(IGroupShapesContainer container, IGroupShape shape) + { + AddShape(shape); + } + + private void OnEntityShapeAdded(IEntityShapesContainer container, IEntityShape shape) + { + AddShape(shape); + } + + private void OnLinkAdded(ILinksContainer container, ILink link) + { + AddLink(link); + } + private void ReparentChildren([NotNull] GraphGroup parent, GraphGroup newParent) { var entities = _entities.Values.Where(x => x.Parent == parent).ToArray(); diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanelFactory.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanelFactory.cs index 47aa216c..1663f4e2 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanelFactory.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/ModelPanelFactory.cs @@ -88,10 +88,14 @@ internal bool Delete([NotNull] ModelPanel panel) if (panel.Diagram is IDiagram diagram && panel.Diagram.Model is IThreatModel model) { - if (model.RemoveDiagram(diagram.Id)) + using (var scope = UndoRedoManager.OpenScope("Remove Diagram")) { - PanelDeletionRequired?.Invoke(this, panel); - result = true; + if (model.RemoveDiagram(diagram.Id)) + { + scope?.Complete(); + PanelDeletionRequired?.Invoke(this, panel); + result = true; + } } } diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelItemListForm.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelItemListForm.cs index b7a449a8..deb11d84 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelItemListForm.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelItemListForm.cs @@ -31,8 +31,15 @@ public PanelItemListForm(object referenceObject) _instances.Add(this); _referenceObject = referenceObject; + PanelItemListFormTrigger.PanelStatusUpdated += PanelItemListFormTrigger_PanelStatusUpdated; } - + + private void PanelItemListFormTrigger_PanelStatusUpdated(PanelsStatus status, Northwoods.Go.GoView view) + { + if (status == PanelsStatus.Normal) + this.Close(); + } + /// /// Event raised when a panel item is clicked. /// @@ -239,6 +246,7 @@ public static void CloseAll() protected override void OnClosed(EventArgs e) { + PanelItemListFormTrigger.PanelStatusUpdated -= PanelItemListFormTrigger_PanelStatusUpdated; _instances.Remove(this); base.OnClosed(e); } @@ -298,7 +306,8 @@ private void ItemClicked(object sender, EventArgs e) private void ThreatEventListForm_Deactivate(object sender, EventArgs e) { - this.Close(); + if (PanelItemListFormTrigger.CurrentStatus == PanelsStatus.Normal) + this.Close(); } private void _panel_Leave(object sender, EventArgs e) diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelItemListFormTrigger.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelItemListFormTrigger.cs new file mode 100644 index 00000000..3a507421 --- /dev/null +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelItemListFormTrigger.cs @@ -0,0 +1,23 @@ +using Northwoods.Go; +using System; + +namespace ThreatsManager.Extensions.Panels.Diagram +{ + public static class PanelItemListFormTrigger + { + static PanelItemListFormTrigger() + { + CurrentStatus = PanelsStatus.Normal; + } + + public static PanelsStatus CurrentStatus { get; private set; } + + public static event Action PanelStatusUpdated; + + public static void RaiseShowPanels(PanelsStatus status, GoView view) + { + CurrentStatus = status; + PanelStatusUpdated?.Invoke(status, view); + } + } +} \ No newline at end of file diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelsStatus.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelsStatus.cs new file mode 100644 index 00000000..80d104f9 --- /dev/null +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Diagram/PanelsStatus.cs @@ -0,0 +1,8 @@ +namespace ThreatsManager.Extensions.Panels.Diagram +{ + public enum PanelsStatus + { + Normal, + Visible + } +} \ No newline at end of file diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/ExternalInteractorList/ExternalInteractorListPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/ExternalInteractorList/ExternalInteractorListPanel.CustomRibbonExtension.cs index 685239fa..cd7c8b93 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/ExternalInteractorList/ExternalInteractorListPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/ExternalInteractorList/ExternalInteractorListPanel.CustomRibbonExtension.cs @@ -40,6 +40,9 @@ public IEnumerable CommandBars new ActionDefinition(Id, "RemoveExternal", "Remove External Interactor", Resources.external_big_delete, Resources.external_delete, false), + new ActionDefinition(Id, "RemoveNotInDiagrams", "Remove not in Diagrams", + Properties.Resources.external_big_sponge, + Properties.Resources.external_sponge), }), new CommandsBarDefinition("Find", "Find", new IActionDefinition[] { @@ -95,82 +98,137 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) { case "AddExternal": text = "Add External Interactor"; - _model.AddEntity(); + using (var scope = UndoRedoManager.OpenScope("Add External Interactor")) + { + _model.AddEntity(); + scope?.Complete(); + } break; case "RemoveExternal": if (_currentRow != null) { - if ((selected?.Length ?? 0) > 1) + using (var scope = UndoRedoManager.OpenScope("Remove External Interactors")) { - var outcome = MessageBox.Show(Form.ActiveForm, - $"You have selected {selected.Length} External Interactors. Do you want to remove them all?\nPlease click 'Yes' to remove all selected External Interactors,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", - "Remove External Interactors", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button3); - switch (outcome) + if ((selected?.Length ?? 0) > 1) { - case DialogResult.Yes: - bool removed = true; - foreach (var row in selected) - { - bool r = false; - if (row.Tag is IEntity entity) + var outcome = MessageBox.Show(Form.ActiveForm, + $"You have selected {selected.Length} External Interactors. Do you want to remove them all?\nPlease click 'Yes' to remove all selected External Interactors,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", + "Remove External Interactors", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button3); + switch (outcome) + { + case DialogResult.Yes: + bool removed = true; + foreach (var row in selected) { - r = _model.RemoveEntity(entity.Id); - } + bool r = false; + if (row.Tag is IEntity entity) + { + r = _model.RemoveEntity(entity.Id); + } - removed &= r; + removed &= r; - if (r && row == _currentRow) - { - _properties.Item = null; - _currentRow = null; + if (r && row == _currentRow) + { + _properties.Item = null; + _currentRow = null; + } } - } - if (removed) - { - text = "Remove External Interactors"; - } - else - { - warning = true; - text = "One or more External Interactors cannot be removed."; - } - break; - case DialogResult.No: - if (_currentRow != null && _currentRow.Tag is IEntity entity2) - { - if (_model.RemoveEntity(entity2.Id)) + scope?.Complete(); + + if (removed) { - _properties.Item = null; - _currentRow = null; - text = "Remove External Interactor"; + text = "Remove External Interactors"; } else { warning = true; - text = "The External Interactor cannot be removed."; + text = "One or more External Interactors cannot be removed."; + } + break; + case DialogResult.No: + if (_currentRow != null && _currentRow.Tag is IEntity entity2) + { + if (_model.RemoveEntity(entity2.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove External Interactor"; + } + else + { + warning = true; + text = "The External Interactor cannot be removed."; + } } - } - break; + break; + } + } + else if (_currentRow != null && _currentRow.Tag is IExternalInteractor externalInteractor && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove External Interactor '{externalInteractor.Name}'. Are you sure?", + "Remove External Interactor", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) + { + if (_model.RemoveEntity(externalInteractor.Id)) + { + scope?.Complete(); + _properties.Item = null; + text = "Remove External Interactor"; + } + else + { + warning = true; + text = "The External Interactor cannot be removed."; + } } } - else if (_currentRow != null && _currentRow.Tag is IExternalInteractor externalInteractor && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove External Interactor '{externalInteractor.Name}'. Are you sure?", - "Remove External Interactor", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) + } + break; + case "RemoveNotInDiagrams": + var diagrams = _model.Diagrams?.ToArray(); + var externalInteractors = _model.Entities? + .OfType() + .Where(x => !(diagrams?.Any(y => y.Entities?.Any(z => x.Id == z.AssociatedId) ?? false) ?? false)) + .ToArray(); + if (externalInteractors?.Any() ?? false) + { + if (MessageBox.Show(Form.ActiveForm, + $"You are about to remove {externalInteractors.Count()} External Interactors that are not associated with any Diagram. Are you sure?", + "Remove External Interactors not in any Diagram", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - if (_model.RemoveEntity(externalInteractor.Id)) + var currentInteractor = _currentRow?.Tag as IExternalInteractor; + if (currentInteractor != null && externalInteractors.Any(x => x.Id == currentInteractor.Id)) { _properties.Item = null; - text = "Remove External Interactor"; + _currentRow = null; + } - else + + using (var scope = UndoRedoManager.OpenScope("Remove External Interactors Not In Any Diagram")) { - warning = true; - text = "The External Interactor cannot be removed."; + var removed = true; + foreach (var externalInteractor in externalInteractors) + { + removed &= _model.RemoveEntity(externalInteractor.Id); + } + + if (removed) + { + text = "Remove External Interactors Not In Any Diagram "; + } + else + { + warning = true; + text = "One or more External Interactors cannot be removed."; + } + + scope?.Complete(); } } } @@ -179,10 +237,10 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) bool found = false; if (_currentRow != null && _currentRow.Tag is IExternalInteractor externalInteractor2) { - var diagrams = _model.Diagrams?.ToArray(); - if (diagrams?.Any() ?? false) + var diagrams2 = _model.Diagrams?.ToArray(); + if (diagrams2?.Any() ?? false) { - foreach (var diagram in diagrams) + foreach (var diagram in diagrams2) { var shape = diagram.GetEntityShape(externalInteractor2.Id); if (shape != null) diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/ItemTemplateList/ItemTemplateListPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/ItemTemplateList/ItemTemplateListPanel.CustomRibbonExtension.cs index 20f5eb30..ea5fe790 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/ItemTemplateList/ItemTemplateListPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/ItemTemplateList/ItemTemplateListPanel.CustomRibbonExtension.cs @@ -99,13 +99,17 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) { if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.OK) { - var entityTemplate = _model.AddEntityTemplate(dialog.EntityName, - dialog.EntityDescription, - dialog.BigImage, - dialog.Image, - dialog.SmallImage, - dialog.EntityType); - _model.AutoApplySchemas(entityTemplate); + using (var scope = UndoRedoManager.OpenScope("Add Entity Tempate")) + { + var entityTemplate = _model.AddEntityTemplate(dialog.EntityName, + dialog.EntityDescription, + dialog.BigImage, + dialog.Image, + dialog.SmallImage, + dialog.EntityType); + _model.AutoApplySchemas(entityTemplate); + scope?.Complete(); + } text = "Add Entity Template"; } } @@ -116,9 +120,13 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) dialog.IdentityTypeName = "Flow Template"; if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.OK) { - var flowTemplate = _model.AddFlowTemplate(dialog.IdentityName, - dialog.IdentityDescription); - _model.AutoApplySchemas(flowTemplate); + using (var scope = UndoRedoManager.OpenScope("Add Flow Template")) + { + var flowTemplate = _model.AddFlowTemplate(dialog.IdentityName, + dialog.IdentityDescription); + _model.AutoApplySchemas(flowTemplate); + scope?.Complete(); + } text = "Add Flow Template"; } } @@ -129,9 +137,13 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) dialog.IdentityTypeName = "Trust Boundary Template"; if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.OK) { - var trustBoundaryTemplate = _model.AddTrustBoundaryTemplate(dialog.IdentityName, - dialog.IdentityDescription); - _model.AutoApplySchemas(trustBoundaryTemplate); + using (var scope = UndoRedoManager.OpenScope("Add Trust Boundary Template")) + { + var trustBoundaryTemplate = _model.AddTrustBoundaryTemplate(dialog.IdentityName, + dialog.IdentityDescription); + _model.AutoApplySchemas(trustBoundaryTemplate); + scope?.Complete(); + } text = "Add Trust Boundary Template"; } } @@ -139,142 +151,159 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) case "RemoveItemTemplates": if (_currentRow != null) { - if ((selected?.Length ?? 0) > 1) + using (var scope = UndoRedoManager.OpenScope("Remove Item Templates")) { - var outcome = MessageBox.Show(Form.ActiveForm, - $"You have selected {selected.Length} Item Templates. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Item Templates,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", - "Remove Item Templates", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button3); - switch (outcome) + if ((selected?.Length ?? 0) > 1) { - case DialogResult.Yes: - bool removed = true; - foreach (var row in selected) - { - bool r = false; - if (row.Tag is IEntityTemplate template) - { - r = _model.RemoveEntityTemplate(template.Id); - } else if (row.Tag is IFlowTemplate flowTemplate) - { - r = _model.RemoveFlowTemplate(flowTemplate.Id); - } else if (row.Tag is ITrustBoundaryTemplate trustBoundaryTemplate) + var outcome = MessageBox.Show(Form.ActiveForm, + $"You have selected {selected.Length} Item Templates. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Item Templates,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", + "Remove Item Templates", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button3); + switch (outcome) + { + case DialogResult.Yes: + bool removed = true; + foreach (var row in selected) { - r = _model.RemoveTrustBoundaryTemplate(trustBoundaryTemplate.Id); - } + bool r = false; + if (row.Tag is IEntityTemplate template) + { + r = _model.RemoveEntityTemplate(template.Id); + } + else if (row.Tag is IFlowTemplate flowTemplate) + { + r = _model.RemoveFlowTemplate(flowTemplate.Id); + } + else if (row.Tag is ITrustBoundaryTemplate trustBoundaryTemplate) + { + r = _model.RemoveTrustBoundaryTemplate(trustBoundaryTemplate.Id); + } - removed &= r; + removed &= r; - if (r && row == _currentRow) - { - _properties.Item = null; - _currentRow = null; + if (r && row == _currentRow) + { + _properties.Item = null; + _currentRow = null; + } } - } - if (removed) - { - text = "Remove Item Templates"; - } - else - { - warning = true; - text = "One or more Item Templates cannot be removed."; - } + scope?.Complete(); - break; - case DialogResult.No: - if (_currentRow?.Tag is IEntityTemplate template2) - { - if (_model.RemoveEntityTemplate(template2.Id)) + if (removed) { - _properties.Item = null; - _currentRow = null; - text = "Remove Entity Template"; + text = "Remove Item Templates"; } else { warning = true; - text = "The Entity Template cannot be removed."; - } - } else if (_currentRow?.Tag is IFlowTemplate template3) - { - if (_model.RemoveFlowTemplate(template3.Id)) - { - _properties.Item = null; - _currentRow = null; - text = "Remove Flow Template"; + text = "One or more Item Templates cannot be removed."; } - else + + break; + case DialogResult.No: + if (_currentRow?.Tag is IEntityTemplate template2) { - warning = true; - text = "The Flow Template cannot be removed."; + if (_model.RemoveEntityTemplate(template2.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove Entity Template"; + } + else + { + warning = true; + text = "The Entity Template cannot be removed."; + } } - } else if (_currentRow?.Tag is ITrustBoundaryTemplate template4) - { - if (_model.RemoveTrustBoundaryTemplate(template4.Id)) + else if (_currentRow?.Tag is IFlowTemplate template3) { - _properties.Item = null; - _currentRow = null; - text = "Remove Trust Boundary Template"; + if (_model.RemoveFlowTemplate(template3.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove Flow Template"; + } + else + { + warning = true; + text = "The Flow Template cannot be removed."; + } } - else + else if (_currentRow?.Tag is ITrustBoundaryTemplate template4) { - warning = true; - text = "The Trust Boundary Template cannot be removed."; + if (_model.RemoveTrustBoundaryTemplate(template4.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove Trust Boundary Template"; + } + else + { + warning = true; + text = "The Trust Boundary Template cannot be removed."; + } } - } - break; - } - } - else if (_currentRow?.Tag is IEntityTemplate template && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove Entity Template '{template.Name}'. Are you sure?", - "Remove Entity Template", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) - { - if (_model.RemoveEntityTemplate(template.Id)) - { - text = "Remove Entity Template"; - _properties.Item = null; - } - else - { - warning = true; - text = "The Entity Template cannot be removed."; - } - } else if (_currentRow?.Tag is IFlowTemplate flowTemplate && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove Flow Template '{flowTemplate.Name}'. Are you sure?", - "Remove Flow Template", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) - { - if (_model.RemoveFlowTemplate(flowTemplate.Id)) - { - text = "Remove Flow Template"; - _properties.Item = null; + break; + } } - else + else if (_currentRow?.Tag is IEntityTemplate template && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove Entity Template '{template.Name}'. Are you sure?", + "Remove Entity Template", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - warning = true; - text = "The Flow Template cannot be removed."; + if (_model.RemoveEntityTemplate(template.Id)) + { + scope?.Complete(); + text = "Remove Entity Template"; + _properties.Item = null; + } + else + { + warning = true; + text = "The Entity Template cannot be removed."; + } } - } else if (_currentRow?.Tag is ITrustBoundaryTemplate trustBoundaryTemplate && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove Trust Boundary Template '{trustBoundaryTemplate.Name}'. Are you sure?", - "Remove Trust Boundary Template", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) - { - if (_model.RemoveTrustBoundaryTemplate(trustBoundaryTemplate.Id)) + else if (_currentRow?.Tag is IFlowTemplate flowTemplate && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove Flow Template '{flowTemplate.Name}'. Are you sure?", + "Remove Flow Template", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - text = "Remove Trust Boundary Template"; - _properties.Item = null; + if (_model.RemoveFlowTemplate(flowTemplate.Id)) + { + scope?.Complete(); + text = "Remove Flow Template"; + _properties.Item = null; + } + else + { + warning = true; + text = "The Flow Template cannot be removed."; + } } - else + else if (_currentRow?.Tag is ITrustBoundaryTemplate trustBoundaryTemplate && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove Trust Boundary Template '{trustBoundaryTemplate.Name}'. Are you sure?", + "Remove Trust Boundary Template", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - warning = true; - text = "The Trust Boundary Template cannot be removed."; + if (_model.RemoveTrustBoundaryTemplate(trustBoundaryTemplate.Id)) + { + scope?.Complete(); + text = "Remove Trust Boundary Template"; + _properties.Item = null; + } + else + { + warning = true; + text = "The Trust Boundary Template cannot be removed."; + } } } } diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Learning/LearningPanelFactory.MainRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Learning/LearningPanelFactory.MainRibbonExtension.cs index 042ad5a9..cd599b87 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Learning/LearningPanelFactory.MainRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Learning/LearningPanelFactory.MainRibbonExtension.cs @@ -6,6 +6,7 @@ using ThreatsManager.Interfaces.ObjectModel; using ThreatsManager.Utilities; using ThreatsManager.Utilities.Aspects; +using ThreatsManager.Utilities.Policies; namespace ThreatsManager.Extensions.Panels.Learning { @@ -38,16 +39,20 @@ public IEnumerable RibbonActions get { IEnumerable result = null; - - var config = ThreatsManager.Engine.ExtensionsConfigurationManager.GetConfigurationSection(); - if (!(config?.DisableHelp ?? false)) + var policy = new HelpTroubleshootPolicy(); + if (policy == null || (policy.HelpTroubleshoot ?? true)) { - result = new List + var config = ThreatsManager.Engine.ExtensionsConfigurationManager.GetConfigurationSection(); + + if (!(config?.DisableHelp ?? false)) + { + result = new List { new ActionDefinition(Id, "CreatePanel", "Learning", Properties.Resources.school_big, Properties.Resources.school) }; + } } return result; diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/ProcessList/ProcessListPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/ProcessList/ProcessListPanel.CustomRibbonExtension.cs index a1790991..44f63d42 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/ProcessList/ProcessListPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/ProcessList/ProcessListPanel.CustomRibbonExtension.cs @@ -40,6 +40,9 @@ public IEnumerable CommandBars new ActionDefinition(Id, "RemoveProcess", "Remove Process", Resources.process_big_delete, Resources.process_delete, false), + new ActionDefinition(Id, "RemoveNotInDiagrams", "Remove not in Diagrams", + Properties.Resources.process_big_sponge, + Properties.Resources.process_sponge), }, false), new CommandsBarDefinition("Find", "Find", new IActionDefinition[] { @@ -96,84 +99,139 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) { case "AddProcess": text = "Add Process"; - _model.AddEntity(); + using (var scope = UndoRedoManager.OpenScope("Add Process")) + { + _model.AddEntity(); + scope?.Complete(); + } break; case "RemoveProcess": if (_currentRow != null) { - if ((selected?.Length ?? 0) > 1) + using (var scope = UndoRedoManager.OpenScope("Remove Processes")) { - var outcome = MessageBox.Show(Form.ActiveForm, - $"You have selected {selected.Length} Processes. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Processes,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", - "Remove Processes", MessageBoxButtons.YesNoCancel, - MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button3); - switch (outcome) + if ((selected?.Length ?? 0) > 1) { - case DialogResult.Yes: - bool removed = true; - foreach (var row in selected) - { - bool r = false; - if (row.Tag is IEntity entity) + var outcome = MessageBox.Show(Form.ActiveForm, + $"You have selected {selected.Length} Processes. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Processes,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", + "Remove Processes", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button3); + switch (outcome) + { + case DialogResult.Yes: + bool removed = true; + foreach (var row in selected) { - r = _model.RemoveEntity(entity.Id); - } + bool r = false; + if (row.Tag is IEntity entity) + { + r = _model.RemoveEntity(entity.Id); + } - removed &= r; + removed &= r; - if (r && row == _currentRow) - { - _properties.Item = null; - _currentRow = null; + if (r && row == _currentRow) + { + _properties.Item = null; + _currentRow = null; + } } - } - if (removed) - { - text = "Remove Processes"; - } - else - { - warning = true; - text = "One or more Processes cannot be removed."; - } + scope?.Complete(); - break; - case DialogResult.No: - if (_currentRow != null && _currentRow.Tag is IEntity entity2) - { - if (_model.RemoveEntity(entity2.Id)) + if (removed) { - _properties.Item = null; - _currentRow = null; - text = "Remove Process"; + text = "Remove Processes"; } else { warning = true; - text = "The Process cannot be removed."; + text = "One or more Processes cannot be removed."; } - } - break; + break; + case DialogResult.No: + if (_currentRow != null && _currentRow.Tag is IEntity entity2) + { + if (_model.RemoveEntity(entity2.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove Process"; + } + else + { + warning = true; + text = "The Process cannot be removed."; + } + } + + break; + } + } + else if (_currentRow != null && _currentRow.Tag is IProcess process && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove Process '{process.Name}'. Are you sure?", + "Remove Process", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) + { + if (_model.RemoveEntity(process.Id)) + { + scope?.Complete(); + text = "Remove Process"; + _properties.Item = null; + } + else + { + warning = true; + text = "The Process cannot be removed."; + } } } - else if (_currentRow != null && _currentRow.Tag is IProcess process && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove Process '{process.Name}'. Are you sure?", - "Remove Process", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) + } + break; + case "RemoveNotInDiagrams": + var diagrams = _model.Diagrams?.ToArray(); + var processes = _model.Entities? + .OfType() + .Where(x => !(diagrams?.Any(y => y.Entities?.Any(z => x.Id == z.AssociatedId) ?? false) ?? false)) + .ToArray(); + if (processes?.Any() ?? false) + { + if (MessageBox.Show(Form.ActiveForm, + $"You are about to remove {processes.Count()} Processes that are not associated with any Diagram. Are you sure?", + "Remove Processes not in any Diagram", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - if (_model.RemoveEntity(process.Id)) + var currentProcess = _currentRow?.Tag as IProcess; + if (currentProcess != null && processes.Any(x => x.Id == currentProcess.Id)) { - text = "Remove Process"; _properties.Item = null; + _currentRow = null; + } - else + + using (var scope = UndoRedoManager.OpenScope("Remove Processes Not In Any Diagram")) { - warning = true; - text = "The Process cannot be removed."; + var removed = true; + foreach (var process in processes) + { + removed &= _model.RemoveEntity(process.Id); + } + + if (removed) + { + text = "Remove Processes Not In Any Diagram "; + } + else + { + warning = true; + text = "One or more Processes cannot be removed."; + } + + scope?.Complete(); } } } @@ -182,10 +240,10 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) bool found = false; if (_currentRow != null && _currentRow.Tag is IProcess process2) { - var diagrams = _model.Diagrams?.ToArray(); - if (diagrams?.Any() ?? false) + var diagrams2 = _model.Diagrams?.ToArray(); + if (diagrams2?.Any() ?? false) { - foreach (var diagram in diagrams) + foreach (var diagram in diagrams2) { var shape = diagram.GetEntityShape(process2.Id); if (shape != null) diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Troubleshooting/TroubleshootingPanelFactory.MainRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Troubleshooting/TroubleshootingPanelFactory.MainRibbonExtension.cs index 67ac667c..2ee3e73f 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Troubleshooting/TroubleshootingPanelFactory.MainRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Troubleshooting/TroubleshootingPanelFactory.MainRibbonExtension.cs @@ -6,6 +6,7 @@ using ThreatsManager.Interfaces.ObjectModel; using ThreatsManager.Utilities; using ThreatsManager.Utilities.Aspects; +using ThreatsManager.Utilities.Policies; namespace ThreatsManager.Extensions.Panels.Troubleshooting { @@ -38,16 +39,20 @@ public IEnumerable RibbonActions get { IEnumerable result = null; - - var config = ThreatsManager.Engine.ExtensionsConfigurationManager.GetConfigurationSection(); - if (!(config?.DisableHelp ?? false)) + var policy = new HelpTroubleshootPolicy(); + if (policy == null || (policy.HelpTroubleshoot ?? true)) { - result = new List + var config = ThreatsManager.Engine.ExtensionsConfigurationManager.GetConfigurationSection(); + + if (!(config?.DisableHelp ?? false)) { - new ActionDefinition(Id, "CreatePanel", "Troubleshooting", Properties.Resources.lifebelt_big, - Properties.Resources.lifebelt) - }; + result = new List + { + new ActionDefinition(Id, "CreatePanel", "Troubleshooting", Properties.Resources.lifebelt_big, + Properties.Resources.lifebelt) + }; + } } return result; diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/TrustBoundaryList/TrustBoundaryListPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/TrustBoundaryList/TrustBoundaryListPanel.CustomRibbonExtension.cs index 953a1e70..789d1e98 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/TrustBoundaryList/TrustBoundaryListPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/TrustBoundaryList/TrustBoundaryListPanel.CustomRibbonExtension.cs @@ -40,6 +40,9 @@ public IEnumerable CommandBars new ActionDefinition(Id, "RemoveTrustBoundary", "Remove Trust Boundary", Resources.trust_boundary_big_delete, Resources.trust_boundary_delete, false), + new ActionDefinition(Id, "RemoveNotInDiagrams", "Remove not in Diagrams", + Resources.trust_boundary_big_delete, + Resources.trust_boundary_delete, false), }), new CommandsBarDefinition("Find", "Find", new IActionDefinition[] { @@ -95,84 +98,138 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) { case "AddTrustBoundary": text = "Add Trust Boundary"; - _model.AddGroup(); + using (var scope = UndoRedoManager.OpenScope("Add Trust Boundary")) + { + _model.AddGroup(); + scope?.Complete(); + } break; case "RemoveTrustBoundary": if (_currentRow != null) { - if ((selected?.Length ?? 0) > 1) + using (var scope = UndoRedoManager.OpenScope("Remove Trust Boundaries")) { - var outcome = MessageBox.Show(Form.ActiveForm, - $"You have selected {selected.Length} Trust Boundaries. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Trust Boundaries,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", - "Remove Trust Boundaries", MessageBoxButtons.YesNoCancel, - MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button3); - switch (outcome) + if ((selected?.Length ?? 0) > 1) { - case DialogResult.Yes: - bool removed = true; - foreach (var row in selected) - { - bool r = false; - if (row.Tag is IGroup group) + var outcome = MessageBox.Show(Form.ActiveForm, + $"You have selected {selected.Length} Trust Boundaries. Do you want to remove them all?\nPlease click 'Yes' to remove all selected Trust Boundaries,\nNo to remove only the last one you selected, '{_currentRow.Tag?.ToString()}'.\nPress Cancel to abort.", + "Remove Trust Boundaries", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button3); + switch (outcome) + { + case DialogResult.Yes: + bool removed = true; + foreach (var row in selected) { - r = _model.RemoveGroup(group.Id); - } + bool r = false; + if (row.Tag is IGroup group) + { + r = _model.RemoveGroup(group.Id); + } - removed &= r; + removed &= r; - if (r && row == _currentRow) - { - _properties.Item = null; - _currentRow = null; + if (r && row == _currentRow) + { + _properties.Item = null; + _currentRow = null; + } } - } - if (removed) - { - text = "Remove Trust Boundaries"; - } - else - { - warning = true; - text = "One or more Trust Boundaries cannot be removed."; - } + scope?.Complete(); - break; - case DialogResult.No: - if (_currentRow != null && _currentRow.Tag is IGroup group2) - { - if (_model.RemoveGroup(group2.Id)) + if (removed) { - _properties.Item = null; - _currentRow = null; - text = "Remove Trust Boundary"; + text = "Remove Trust Boundaries"; } else { warning = true; - text = "The Trust Boundary cannot be removed."; + text = "One or more Trust Boundaries cannot be removed."; } - } - break; + break; + case DialogResult.No: + if (_currentRow != null && _currentRow.Tag is IGroup group2) + { + if (_model.RemoveGroup(group2.Id)) + { + scope?.Complete(); + _properties.Item = null; + _currentRow = null; + text = "Remove Trust Boundary"; + } + else + { + warning = true; + text = "The Trust Boundary cannot be removed."; + } + } + + break; + } + } + else if (_currentRow != null && _currentRow.Tag is ITrustBoundary tb && + MessageBox.Show(Form.ActiveForm, + $"You are about to remove Trust Boundary '{tb.Name}'. Are you sure?", + "Remove Trust Boundary", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) + { + if (_model.RemoveGroup(tb.Id)) + { + scope?.Complete(); + _properties.Item = null; + text = "Remove Trust Boundary"; + } + else + { + warning = true; + text = "The Trust Boundary cannot be removed."; + } } } - else if (_currentRow != null && _currentRow.Tag is ITrustBoundary tb && - MessageBox.Show(Form.ActiveForm, - $"You are about to remove Trust Boundary '{tb.Name}'. Are you sure?", - "Remove Trust Boundary", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) + } + break; + case "RemoveNotInDiagrams": + var diagrams = _model.Diagrams?.ToArray(); + var trustBoundaries = _model.Entities? + .OfType() + .Where(x => !(diagrams?.Any(y => y.Entities?.Any(z => x.Id == z.AssociatedId) ?? false) ?? false)); + if (trustBoundaries?.Any() ?? false) + { + if (MessageBox.Show(Form.ActiveForm, + $"You are about to remove {trustBoundaries.Count()} Trust Boundaries that are not associated with any Diagram. Are you sure?", + "Remove Trust Boundaries not in any Diagram", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) { - if (_model.RemoveGroup(tb.Id)) + var currentTrustBoundary = _currentRow?.Tag as ITrustBoundary; + if (currentTrustBoundary != null && trustBoundaries.Any(x => x.Id == currentTrustBoundary.Id)) { _properties.Item = null; - text = "Remove Trust Boundary"; + _currentRow = null; + } - else + + using (var scope = UndoRedoManager.OpenScope("Remove Trust Boundaries Not In Any Diagram")) { - warning = true; - text = "The Trust Boundary cannot be removed."; + var removed = true; + foreach (var trustBoundary in trustBoundaries) + { + removed &= _model.RemoveEntity(trustBoundary.Id); + } + + if (removed) + { + text = "Remove Trust Boundaries Not In Any Diagram "; + } + else + { + warning = true; + text = "One or more Trust Boundaries cannot be removed."; + } + + scope?.Complete(); } } } @@ -181,10 +238,10 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) bool found = false; if (_currentRow != null && _currentRow.Tag is ITrustBoundary trustBoundary2) { - var diagrams = _model.Diagrams?.ToArray(); - if (diagrams?.Any() ?? false) + var diagrams2 = _model.Diagrams?.ToArray(); + if (diagrams2?.Any() ?? false) { - foreach (var diagram in diagrams) + foreach (var diagram in diagrams2) { var shape = diagram.GetGroupShape(trustBoundary2.Id); if (shape != null) diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.CustomRibbonExtension.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.CustomRibbonExtension.cs index 97765277..6b906322 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.CustomRibbonExtension.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.CustomRibbonExtension.cs @@ -85,6 +85,10 @@ public void ExecuteCustomAction([NotNull] IActionDefinition action) { LoadDocStructure(file); } + else + { + ShowWarning?.Invoke("The Reference Word File does not exist."); + } } else { @@ -113,29 +117,36 @@ private bool SaveFull() if (!string.IsNullOrWhiteSpace(_wordFile.Text)) { var originalPath = GetDocumentPath(_model, _wordFile.Text); - var fileName = Path.Combine(Path.GetDirectoryName(originalPath), - $"{Path.GetFileNameWithoutExtension(originalPath)}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx"); - - try + if (File.Exists(originalPath)) { - ShowProgress(); + var fileName = Path.Combine(Path.GetDirectoryName(originalPath), + $"{Path.GetFileNameWithoutExtension(originalPath)}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx"); try { - var ignoredDictionary = GetPlaceholdersWithIgnoredFields()? - .ToDictionary(x => x, GetIgnoredFields); - result = _reportGenerator.Generate(originalPath, fileName, ignoredDictionary); + ShowProgress(); + + try + { + var ignoredDictionary = GetPlaceholdersWithIgnoredFields()? + .ToDictionary(x => x, GetIgnoredFields); + result = _reportGenerator.Generate(originalPath, fileName, ignoredDictionary); - _lastDocument = fileName; + _lastDocument = fileName; + } + catch + { + ShowWarning?.Invoke("Report generation failed."); + } } - catch + finally { - ShowWarning?.Invoke("Report generation failed."); + CloseProgress(); } } - finally + else { - CloseProgress(); + ShowWarning?.Invoke("The Reference Word File does not exist."); } } else diff --git a/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.cs b/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.cs index 30b53e51..af7e008c 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Panels/Word/WordReportingPanel.cs @@ -66,6 +66,10 @@ public void SetThreatModel([NotNull] IThreatModel threatModel) _wordFile.Text = wordFile; LoadDocStructure(file); } + else + { + ShowWarning?.Invoke("The Reference Word File does not exist."); + } } } @@ -130,22 +134,25 @@ private static string GetDocumentPath([NotNull] IThreatModel model, [Required] s return result; } - private static string GetAbsolutePath([Required] string reference, [Required] string relativePath) + private static string GetAbsolutePath(string reference, string relativePath) { - string result; + string result = null; - if (relativePath.StartsWith(@"..\")) - { - relativePath = relativePath.Substring(3); - reference = Directory.GetParent(reference).FullName; - result = GetAbsolutePath(reference, relativePath); - } - else + if (!string.IsNullOrWhiteSpace(reference) && !string.IsNullOrWhiteSpace(relativePath)) { - if (!reference.EndsWith(@"\") && (!relativePath.StartsWith(@"\") || !relativePath.StartsWith(@".\"))) - reference = reference + @"\"; + if (relativePath.StartsWith(@"..\")) + { + relativePath = relativePath.Substring(3); + reference = Directory.GetParent(reference)?.FullName; + result = GetAbsolutePath(reference, relativePath); + } + else + { + if (!reference.EndsWith(@"\") && (!relativePath.StartsWith(@"\") || !relativePath.StartsWith(@".\"))) + reference = reference + @"\"; - result = Path.GetFullPath(reference + relativePath); + result = Path.GetFullPath(reference + relativePath); + } } return result; diff --git a/Studio/ThreatsManager.Extensions.WinForms/Policies/RiskNormalizationPolicy.cs b/Studio/ThreatsManager.Extensions.WinForms/Policies/RiskNormalizationPolicy.cs new file mode 100644 index 00000000..57a72981 --- /dev/null +++ b/Studio/ThreatsManager.Extensions.WinForms/Policies/RiskNormalizationPolicy.cs @@ -0,0 +1,13 @@ +using ThreatsManager.Interfaces; +using ThreatsManager.Utilities; + +namespace ThreatsManager.Extensions.Policies +{ + [Extension("58583B10-BFF1-40D3-B927-3DFC4E013246", "Risk Normalization Policy", 100, ExecutionMode.Business)] + public class RiskNormalizationPolicy : Policy + { + protected override string PolicyName => "RiskNormalization"; + + public int? RiskNormalization => (int?)Value; + } +} diff --git a/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.Designer.cs b/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.Designer.cs index d7bb8491..1f99e90d 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.Designer.cs +++ b/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.Designer.cs @@ -1457,6 +1457,36 @@ internal static System.Drawing.Bitmap export_template_small { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap external_big_sponge { + get { + object obj = ResourceManager.GetObject("external_big_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap external_huge_sponge_big { + get { + object obj = ResourceManager.GetObject("external_huge_sponge_big", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap external_sponge { + get { + object obj = ResourceManager.GetObject("external_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1537,6 +1567,36 @@ internal static System.Drawing.Bitmap floppy_disk_small { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap flow_big_sponge { + get { + object obj = ResourceManager.GetObject("flow_big_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap flow_huge_sponge_big { + get { + object obj = ResourceManager.GetObject("flow_huge_sponge_big", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap flow_sponge { + get { + object obj = ResourceManager.GetObject("flow_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -2479,6 +2539,46 @@ internal static System.Drawing.Bitmap note_text_small { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap objects_cube_to_cone { + get { + object obj = ResourceManager.GetObject("objects_cube_to_cone", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap objects_cube_to_cone_big { + get { + object obj = ResourceManager.GetObject("objects_cube_to_cone_big", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap objects_cube_to_cone_huge { + get { + object obj = ResourceManager.GetObject("objects_cube_to_cone_huge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap objects_cube_to_cone_small { + get { + object obj = ResourceManager.GetObject("objects_cube_to_cone_small", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -2519,6 +2619,46 @@ internal static System.Drawing.Bitmap odometer_small { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap panel { + get { + object obj = ResourceManager.GetObject("panel", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap panel_big { + get { + object obj = ResourceManager.GetObject("panel_big", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap panel_huge { + get { + object obj = ResourceManager.GetObject("panel_huge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap panel_small { + get { + object obj = ResourceManager.GetObject("panel_small", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized string similar to Parent is not aligned. Please move the shape to the correct parent.. /// @@ -2648,6 +2788,36 @@ internal static System.Drawing.Bitmap presentation_pie_chart_small { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap process_big_sponge { + get { + object obj = ResourceManager.GetObject("process_big_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap process_huge_sponge_big { + get { + object obj = ResourceManager.GetObject("process_huge_sponge_big", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap process_sponge { + get { + object obj = ResourceManager.GetObject("process_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -3539,6 +3709,36 @@ internal static System.Drawing.Bitmap signpost_two_small { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap storage_big_sponge { + get { + object obj = ResourceManager.GetObject("storage_big_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap storage_huge_sponge_big { + get { + object obj = ResourceManager.GetObject("storage_huge_sponge_big", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap storage_sponge { + get { + object obj = ResourceManager.GetObject("storage_sponge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.resx b/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.resx index 30a94796..3003e30a 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.resx +++ b/Studio/ThreatsManager.Extensions.WinForms/Properties/Resources.resx @@ -1359,4 +1359,64 @@ Are you sure you want still to get full access rights? ..\Resources\magic_wand_small_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\panel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\panel_big.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\panel_huge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\panel_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\objects_cube_to_cone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\objects_cube_to_cone_big.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\objects_cube_to_cone_huge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\objects_cube_to_cone_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\external_big_sponge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\external_huge_sponge_big.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\external_sponge_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\flow_big_sponge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\flow_huge_sponge_big.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\flow_sponge_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\process_big_sponge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\process_huge_sponge_big.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\process_sponge_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\storage_big_sponge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\storage_huge_sponge_big.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\storage_sponge_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Studio/ThreatsManager.Extensions.WinForms/Properties/licenses.licx b/Studio/ThreatsManager.Extensions.WinForms/Properties/licenses.licx index 0b97a6b2..196ac1ea 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/Properties/licenses.licx +++ b/Studio/ThreatsManager.Extensions.WinForms/Properties/licenses.licx @@ -1 +1 @@ -Keyoti.RapidSpell.RapidSpellAsYouType, Keyoti.RapidSpell.NET4, Version=6.2.21.412, Culture=neutral, PublicKeyToken=58d9fd2e9ec4dc0e \ No newline at end of file +Keyoti.RapidSpell.RapidSpellAsYouType, Keyoti.RapidSpell.NET4, Version=6.2.22.214, Culture=neutral, PublicKeyToken=58d9fd2e9ec4dc0e diff --git a/Studio/ThreatsManager.Extensions.WinForms/ThreatsManager.Extensions.WinForms.csproj b/Studio/ThreatsManager.Extensions.WinForms/ThreatsManager.Extensions.WinForms.csproj index fc56358c..7e22d6b2 100644 --- a/Studio/ThreatsManager.Extensions.WinForms/ThreatsManager.Extensions.WinForms.csproj +++ b/Studio/ThreatsManager.Extensions.WinForms/ThreatsManager.Extensions.WinForms.csproj @@ -131,6 +131,7 @@ SolutionInfo.cs + @@ -142,6 +143,7 @@ + @@ -163,6 +165,12 @@ ChangeTemplateMultipleDialog.cs + + Form + + + DuplicateConvertDialog.cs + Form @@ -347,6 +355,8 @@ + + @@ -763,6 +773,7 @@ + True True @@ -794,6 +805,9 @@ ChangeTemplateMultipleDialog.cs + + DuplicateConvertDialog.cs + RemoveSchemaMultipleDialog.cs @@ -1400,6 +1414,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Studio/ThreatsManager.MsTmt.WinForms/ExtensionLibrary.cs b/Studio/ThreatsManager.MsTmt.WinForms/ExtensionLibrary.cs index 0afe5834..bb003cc5 100644 --- a/Studio/ThreatsManager.MsTmt.WinForms/ExtensionLibrary.cs +++ b/Studio/ThreatsManager.MsTmt.WinForms/ExtensionLibrary.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Studio/ThreatsManager.MsTmt.WinForms/ExtensionsContainer.cs b/Studio/ThreatsManager.MsTmt.WinForms/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Studio/ThreatsManager.MsTmt.WinForms/ExtensionsContainer.cs +++ b/Studio/ThreatsManager.MsTmt.WinForms/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Studio/ThreatsManager.Quality.WinForms/Annotations/AnnotationPropertyViewerBlock.cs b/Studio/ThreatsManager.Quality.WinForms/Annotations/AnnotationPropertyViewerBlock.cs index 30d24fc4..0a75907e 100644 --- a/Studio/ThreatsManager.Quality.WinForms/Annotations/AnnotationPropertyViewerBlock.cs +++ b/Studio/ThreatsManager.Quality.WinForms/Annotations/AnnotationPropertyViewerBlock.cs @@ -66,9 +66,9 @@ public bool Execute() { var schemaManager = new AnnotationsPropertySchemaManager(_model); schemaManager.RemoveAnnotation(_container, topicToBeClarified); - scope?.Complete(); } + scope?.Complete(); result = true; } else if (_annotation is Highlight highlight) @@ -78,9 +78,9 @@ public bool Execute() { var schemaManager = new AnnotationsPropertySchemaManager(_model); schemaManager.RemoveAnnotation(_container, highlight); - scope?.Complete(); } + scope?.Complete(); result = true; } else if (_annotation is ReviewNote reviewNote) @@ -90,9 +90,9 @@ public bool Execute() { var schemaManager = new AnnotationsPropertySchemaManager(_model); schemaManager.RemoveAnnotation(_container, reviewNote); - scope?.Complete(); } + scope?.Complete(); result = true; } } diff --git a/Studio/ThreatsManager.Quality.WinForms/ExtensionsContainer.cs b/Studio/ThreatsManager.Quality.WinForms/ExtensionsContainer.cs index ade27606..f810ed4c 100644 --- a/Studio/ThreatsManager.Quality.WinForms/ExtensionsContainer.cs +++ b/Studio/ThreatsManager.Quality.WinForms/ExtensionsContainer.cs @@ -1,3 +1,3 @@ using ThreatsManager.Interfaces; -[assembly: ExtensionsContainer("2.1.1")] \ No newline at end of file +[assembly: ExtensionsContainer("2.1.2")] \ No newline at end of file diff --git a/Studio/ThreatsManager.Quality.WinForms/Schemas/AnnotationsPropertySchemaManager.cs b/Studio/ThreatsManager.Quality.WinForms/Schemas/AnnotationsPropertySchemaManager.cs index 8ff0fc79..a2f671eb 100644 --- a/Studio/ThreatsManager.Quality.WinForms/Schemas/AnnotationsPropertySchemaManager.cs +++ b/Studio/ThreatsManager.Quality.WinForms/Schemas/AnnotationsPropertySchemaManager.cs @@ -218,7 +218,9 @@ public bool HasNotes([NotNull] IPropertiesContainer container) if (container.GetProperty(propertyType) is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is Annotations.Annotations annotations) { - result = annotations.Items.Any(x => !(x is Highlight) && !(x is TopicToBeClarified) && !(x is ReviewNote) && !(x is AnnotationAnswer)); + result = annotations.Items? + .Any(x => !(x is Highlight) && !(x is TopicToBeClarified) && !(x is ReviewNote) && !(x is AnnotationAnswer)) + ?? false; } return result; @@ -232,7 +234,7 @@ public bool HasTopics([NotNull] IPropertiesContainer container) if (container.GetProperty(propertyType) is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is Annotations.Annotations annotations) { - result = annotations.Items.OfType().Any(); + result = annotations.Items?.OfType().Any() ?? false; } return result; @@ -246,7 +248,7 @@ public bool HasOpenTopics([NotNull] IPropertiesContainer container) if (container.GetProperty(propertyType) is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is Annotations.Annotations annotations) { - result = annotations.Items.OfType().Any(x => !x.Answered); + result = annotations.Items?.OfType().Any(x => !x.Answered) ?? false; } return result; @@ -260,7 +262,7 @@ public bool HasClosedTopics([NotNull] IPropertiesContainer container) if (container.GetProperty(propertyType) is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is Annotations.Annotations annotations) { - result = annotations.Items.OfType().Any(x => x.Answered); + result = annotations.Items?.OfType().Any(x => x.Answered) ?? false; } return result; @@ -274,7 +276,7 @@ public bool HasHighlights([NotNull] IPropertiesContainer container) if (container.GetProperty(propertyType) is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is Annotations.Annotations annotations) { - result = annotations.Items.OfType().Any(); + result = annotations.Items?.OfType().Any() ?? false; } return result; @@ -288,7 +290,7 @@ public bool HasReviewNotes([NotNull] IPropertiesContainer container) if (container.GetProperty(propertyType) is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is Annotations.Annotations annotations) { - result = annotations.Items.OfType().Any(); + result = annotations.Items?.OfType().Any() ?? false; } return result; diff --git a/Studio/ThreatsManager.Utilities.WinForms/ItemEditor.cs b/Studio/ThreatsManager.Utilities.WinForms/ItemEditor.cs index f3790175..ec1f15dd 100644 --- a/Studio/ThreatsManager.Utilities.WinForms/ItemEditor.cs +++ b/Studio/ThreatsManager.Utilities.WinForms/ItemEditor.cs @@ -431,7 +431,8 @@ private void DeregisterCurrentEventHandlers() { if (dataFlow.Source is IEntity source) { - ((INotifyPropertyChanged)source).PropertyChanged -= OnSourcePropertyChanged; + if (source is INotifyPropertyChanged sourceNotifyPropertyChanged) + sourceNotifyPropertyChanged.PropertyChanged -= OnSourcePropertyChanged; source.ImageChanged -= OnSourceImageChanged; } var labelSource = GetControl("Flow", "Source"); @@ -440,7 +441,8 @@ private void DeregisterCurrentEventHandlers() if (dataFlow.Target is IEntity target) { - ((INotifyPropertyChanged)target).PropertyChanged -= OnTargetPropertyChanged; + if (target is INotifyPropertyChanged targetNotifyPropertyChanged) + targetNotifyPropertyChanged.PropertyChanged -= OnTargetPropertyChanged; target.ImageChanged -= OnTargetImageChanged; } var labelTarget = GetControl("Flow", "Target"); @@ -466,7 +468,8 @@ private void DeregisterCurrentEventHandlers() } threatEvent.ThreatEventMitigationAdded -= ThreatEventMitigationAdded; threatEvent.ThreatEventMitigationRemoved -= ThreatEventMitigationRemoved; - ((INotifyPropertyChanged)threatEvent.Parent).PropertyChanged -= OnThreatEventParentPropertyChanged; + if (threatEvent.Parent is INotifyPropertyChanged threatEventParentNotifyPropertyChanged) + threatEventParentNotifyPropertyChanged.PropertyChanged -= OnThreatEventParentPropertyChanged; var labetThreatEvent = GetControl("Threat Event", "Associated To"); if (labetThreatEvent != null) _superTooltip.SetSuperTooltip(labetThreatEvent, null); @@ -484,7 +487,8 @@ private void DeregisterCurrentEventHandlers() { mitigationEntity.ImageChanged -= OnThreatEventMitigationImageChanged; } - ((INotifyPropertyChanged)mitigation.ThreatEvent.Parent).PropertyChanged -= OnThreatEventParentPropertyChanged; + if (mitigation.ThreatEvent.Parent is INotifyPropertyChanged mtpNotifyPropertyChanged) + mtpNotifyPropertyChanged.PropertyChanged -= OnThreatEventParentPropertyChanged; var labelThreatEventMitigation = GetControl("Threat Event Mitigation", "Associated To"); if (labelThreatEventMitigation != null) _superTooltip.SetSuperTooltip(labelThreatEventMitigation, null); diff --git a/Studio/ThreatsManager.Utilities.WinForms/Properties/AssemblyInfo.cs b/Studio/ThreatsManager.Utilities.WinForms/Properties/AssemblyInfo.cs index afd5da82..116e0f3c 100644 --- a/Studio/ThreatsManager.Utilities.WinForms/Properties/AssemblyInfo.cs +++ b/Studio/ThreatsManager.Utilities.WinForms/Properties/AssemblyInfo.cs @@ -27,8 +27,8 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.1.1.0")] -[assembly: AssemblyFileVersion("2.1.1.0")] +[assembly: AssemblyVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.1.2.0")] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("8da52fe7-e3e4-44bb-85e5-e81a26108155")] \ No newline at end of file diff --git a/Studio/ThreatsManager/App.config b/Studio/ThreatsManager/App.config index 7ef6afd9..08e3410b 100644 --- a/Studio/ThreatsManager/App.config +++ b/Studio/ThreatsManager/App.config @@ -1,7 +1,7 @@  -
+
@@ -66,7 +66,7 @@ - + @@ -74,15 +74,15 @@ - + - + - + diff --git a/Studio/ThreatsManager/Dialogs/AboutBox.Designer.cs b/Studio/ThreatsManager/Dialogs/AboutBox.Designer.cs index 6e4f3f6d..7dc3ac76 100644 --- a/Studio/ThreatsManager/Dialogs/AboutBox.Designer.cs +++ b/Studio/ThreatsManager/Dialogs/AboutBox.Designer.cs @@ -43,9 +43,9 @@ private void InitializeComponent() // tableLayoutPanel // this.tableLayoutPanel.ColumnCount = 3; - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 28.25112F)); - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 44.84305F)); - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.90583F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 400F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 66.66666F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.tableLayoutPanel.Controls.Add(this._links, 0, 3); this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0); this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0); @@ -66,8 +66,7 @@ private void InitializeComponent() this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5F)); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 65F)); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel.Size = new System.Drawing.Size(753, 412); + this.tableLayoutPanel.Size = new System.Drawing.Size(912, 359); this.tableLayoutPanel.TabIndex = 0; // // _links @@ -78,12 +77,12 @@ private void InitializeComponent() this._links.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; this.tableLayoutPanel.SetColumnSpan(this._links, 2); this._links.Dock = System.Windows.Forms.DockStyle.Fill; - this._links.Location = new System.Drawing.Point(222, 60); + this._links.Location = new System.Drawing.Point(410, 51); this._links.Margin = new System.Windows.Forms.Padding(10, 0, 4, 0); this._links.MaximumSize = new System.Drawing.Size(0, 28); this._links.Name = "_links"; this._links.PaddingLeft = 3; - this._links.Size = new System.Drawing.Size(527, 20); + this._links.Size = new System.Drawing.Size(498, 17); this._links.Style = DevComponents.DotNetBar.eDotNetBarStyle.OfficeXP; this._links.TabIndex = 29; this._links.Text = "Some resources to learn more on Threats Mana" + @@ -93,12 +92,12 @@ private void InitializeComponent() // logoPictureBox // this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.logoPictureBox.Image = global::ThreatsManager.Properties.Resources.Background; + this.logoPictureBox.Image = global::ThreatsManager.Properties.Resources.ThreatModeling; this.logoPictureBox.Location = new System.Drawing.Point(4, 4); this.logoPictureBox.Margin = new System.Windows.Forms.Padding(4); this.logoPictureBox.Name = "logoPictureBox"; this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 7); - this.logoPictureBox.Size = new System.Drawing.Size(204, 404); + this.logoPictureBox.Size = new System.Drawing.Size(392, 351); this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.logoPictureBox.TabIndex = 12; this.logoPictureBox.TabStop = false; @@ -106,11 +105,11 @@ private void InitializeComponent() // labelProductName // this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelProductName.Location = new System.Drawing.Point(222, 0); + this.labelProductName.Location = new System.Drawing.Point(410, 0); this.labelProductName.Margin = new System.Windows.Forms.Padding(10, 0, 4, 0); this.labelProductName.MaximumSize = new System.Drawing.Size(0, 28); this.labelProductName.Name = "labelProductName"; - this.labelProductName.Size = new System.Drawing.Size(323, 20); + this.labelProductName.Size = new System.Drawing.Size(327, 17); this.labelProductName.TabIndex = 19; this.labelProductName.Text = "Product Name"; this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -118,11 +117,11 @@ private void InitializeComponent() // labelVersion // this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelVersion.Location = new System.Drawing.Point(559, 0); + this.labelVersion.Location = new System.Drawing.Point(751, 0); this.labelVersion.Margin = new System.Windows.Forms.Padding(10, 0, 4, 0); this.labelVersion.MaximumSize = new System.Drawing.Size(0, 28); this.labelVersion.Name = "labelVersion"; - this.labelVersion.Size = new System.Drawing.Size(190, 20); + this.labelVersion.Size = new System.Drawing.Size(157, 17); this.labelVersion.TabIndex = 0; this.labelVersion.Text = "Version"; this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -130,11 +129,11 @@ private void InitializeComponent() // labelCopyright // this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelCopyright.Location = new System.Drawing.Point(222, 20); + this.labelCopyright.Location = new System.Drawing.Point(410, 17); this.labelCopyright.Margin = new System.Windows.Forms.Padding(10, 0, 4, 0); this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 28); this.labelCopyright.Name = "labelCopyright"; - this.labelCopyright.Size = new System.Drawing.Size(323, 20); + this.labelCopyright.Size = new System.Drawing.Size(327, 17); this.labelCopyright.TabIndex = 21; this.labelCopyright.Text = "Copyright"; this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -147,12 +146,12 @@ private void InitializeComponent() this._moreInformation.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; this.tableLayoutPanel.SetColumnSpan(this._moreInformation, 2); this._moreInformation.Dock = System.Windows.Forms.DockStyle.Fill; - this._moreInformation.Location = new System.Drawing.Point(222, 40); + this._moreInformation.Location = new System.Drawing.Point(410, 34); this._moreInformation.Margin = new System.Windows.Forms.Padding(10, 0, 4, 0); this._moreInformation.MaximumSize = new System.Drawing.Size(0, 28); this._moreInformation.Name = "_moreInformation"; this._moreInformation.PaddingLeft = 3; - this._moreInformation.Size = new System.Drawing.Size(527, 20); + this._moreInformation.Size = new System.Drawing.Size(498, 17); this._moreInformation.Style = DevComponents.DotNetBar.eDotNetBarStyle.OfficeXP; this._moreInformation.TabIndex = 25; this._moreInformation.Text = "Based on Threats Manager Platform SDK v{ENGINE_VERSION}, available under M" + @@ -163,7 +162,7 @@ private void InitializeComponent() // this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.okButton.Location = new System.Drawing.Point(629, 381); + this.okButton.Location = new System.Drawing.Point(788, 328); this.okButton.Margin = new System.Windows.Forms.Padding(4); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(120, 27); @@ -179,7 +178,7 @@ private void InitializeComponent() this._thirdParty.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; this.tableLayoutPanel.SetColumnSpan(this._thirdParty, 2); this._thirdParty.Dock = System.Windows.Forms.DockStyle.Fill; - this._thirdParty.Location = new System.Drawing.Point(218, 86); + this._thirdParty.Location = new System.Drawing.Point(406, 74); this._thirdParty.Margin = new System.Windows.Forms.Padding(6); this._thirdParty.Name = "_thirdParty"; this._thirdParty.ReadOnly = true; @@ -187,7 +186,7 @@ private void InitializeComponent() this._thirdParty.Rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\nouicompat\\deflang1040{\\fonttbl{\\f0\\fnil\\fcharset0 " + "Microsoft Sans Serif;}}\r\n{\\*\\generator Riched20 10.0.22621}\\viewkind4\\uc1 \r\n\\par" + "d\\f0\\fs17\\par\r\n}\r\n"; - this._thirdParty.Size = new System.Drawing.Size(529, 275); + this._thirdParty.Size = new System.Drawing.Size(500, 238); this._thirdParty.TabIndex = 27; this._thirdParty.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this._thirdParty_LinkClicked); // @@ -196,7 +195,7 @@ private void InitializeComponent() this.AcceptButton = this.okButton; this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(781, 440); + this.ClientSize = new System.Drawing.Size(940, 387); this.Controls.Add(this.tableLayoutPanel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Margin = new System.Windows.Forms.Padding(4); @@ -208,6 +207,7 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "About..."; + this.Load += new System.EventHandler(this.AboutBox_Load); this.tableLayoutPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit(); this.ResumeLayout(false); diff --git a/Studio/ThreatsManager/Dialogs/AboutBox.cs b/Studio/ThreatsManager/Dialogs/AboutBox.cs index f8513db2..705b756e 100644 --- a/Studio/ThreatsManager/Dialogs/AboutBox.cs +++ b/Studio/ThreatsManager/Dialogs/AboutBox.cs @@ -120,5 +120,10 @@ private void _links_MarkupLinkClick(object sender, DevComponents.DotNetBar.Marku Process.Start(sInfo); #pragma warning restore SCS0001 // Command injection possible in {1} argument passed to '{0}' } + + private void AboutBox_Load(object sender, EventArgs e) + { + + } } } diff --git a/Studio/ThreatsManager/Dialogs/OptionsForm.Designer.cs b/Studio/ThreatsManager/Dialogs/OptionsForm.Designer.cs index 11a19461..16c4de9c 100644 --- a/Studio/ThreatsManager/Dialogs/OptionsForm.Designer.cs +++ b/Studio/ThreatsManager/Dialogs/OptionsForm.Designer.cs @@ -31,8 +31,21 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OptionsForm)); this._sideNav = new DevComponents.DotNetBar.Controls.SideNav(); + this.sideNavPanel1 = new DevComponents.DotNetBar.Controls.SideNavPanel(); + this._panelOtherSettings = new DevComponents.DotNetBar.Layout.LayoutControl(); + this._disableHelp = new System.Windows.Forms.CheckBox(); + this._disableTelemetry = new System.Windows.Forms.CheckBox(); + this._browseUserDictionary = new System.Windows.Forms.Button(); + this._userDictionary = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.layoutControlItem24 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem25 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem26 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this._layoutTelemetryPolicy = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this.layoutControlItem27 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this._panelExtensions = new DevComponents.DotNetBar.Controls.SideNavPanel(); this._layoutExtensions = new DevComponents.DotNetBar.Layout.LayoutControl(); + this.label5 = new System.Windows.Forms.Label(); this._executionMode = new System.Windows.Forms.ComboBox(); this._addStandardCertificate = new System.Windows.Forms.Button(); this._addStandardPrefix = new System.Windows.Forms.Button(); @@ -50,11 +63,15 @@ private void InitializeComponent() this._removeCertificate = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this._addStandardFolder = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); this.layoutControlItem1 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutGroup1 = new DevComponents.DotNetBar.Layout.LayoutGroup(); this.layoutControlItem3 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem15 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem2 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this._layoutFoldersPolicy = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem4 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem5 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem6 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); @@ -62,24 +79,17 @@ private void InitializeComponent() this.layoutControlItem7 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem16 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem8 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this._layoutPrefixesPolicy = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem9 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem10 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutGroup3 = new DevComponents.DotNetBar.Layout.LayoutGroup(); this.layoutControlItem11 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem17 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem12 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this._layoutCertificatesPolicy = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem28 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); + this._layoutExecutionModePolicy = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem13 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.sideNavPanel1 = new DevComponents.DotNetBar.Controls.SideNavPanel(); - this._panelOtherSettings = new DevComponents.DotNetBar.Layout.LayoutControl(); - this._disableHelp = new System.Windows.Forms.CheckBox(); - this._disableTelemetry = new System.Windows.Forms.CheckBox(); - this._browseUserDictionary = new System.Windows.Forms.Button(); - this._userDictionary = new System.Windows.Forms.TextBox(); - this.layoutControlItem24 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.layoutControlItem25 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.layoutControlItem26 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); - this.layoutControlItem27 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this._panelSmartSave = new DevComponents.DotNetBar.Controls.SideNavPanel(); this._layoutSmartSave = new DevComponents.DotNetBar.Layout.LayoutControl(); this.label4 = new System.Windows.Forms.Label(); @@ -106,11 +116,13 @@ private void InitializeComponent() this.layoutControlItem14 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this.layoutControlItem21 = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this._userDictFile = new System.Windows.Forms.SaveFileDialog(); + this.label10 = new System.Windows.Forms.Label(); + this._layoutHelpPolicy = new DevComponents.DotNetBar.Layout.LayoutControlItem(); this._sideNav.SuspendLayout(); - this._panelExtensions.SuspendLayout(); - this._layoutExtensions.SuspendLayout(); this.sideNavPanel1.SuspendLayout(); this._panelOtherSettings.SuspendLayout(); + this._panelExtensions.SuspendLayout(); + this._layoutExtensions.SuspendLayout(); this._panelSmartSave.SuspendLayout(); this._layoutSmartSave.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this._smartSaveInstances)).BeginInit(); @@ -121,8 +133,8 @@ private void InitializeComponent() // _sideNav // this._sideNav.Controls.Add(this._panelExtensions); - this._sideNav.Controls.Add(this._panelSmartSave); this._sideNav.Controls.Add(this.sideNavPanel1); + this._sideNav.Controls.Add(this._panelSmartSave); this._sideNav.Dock = System.Windows.Forms.DockStyle.Fill; this._sideNav.EnableClose = false; this._sideNav.EnableMaximize = false; @@ -140,18 +152,158 @@ private void InitializeComponent() this._sideNav.Size = new System.Drawing.Size(868, 516); this._sideNav.TabIndex = 0; // + // sideNavPanel1 + // + this.sideNavPanel1.Controls.Add(this._panelOtherSettings); + this.sideNavPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.sideNavPanel1.Location = new System.Drawing.Point(122, 31); + this.sideNavPanel1.Name = "sideNavPanel1"; + this.sideNavPanel1.Size = new System.Drawing.Size(745, 484); + this.sideNavPanel1.TabIndex = 32; + this.sideNavPanel1.Visible = false; + // + // _panelOtherSettings + // + this._panelOtherSettings.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this._panelOtherSettings.Controls.Add(this._disableHelp); + this._panelOtherSettings.Controls.Add(this._disableTelemetry); + this._panelOtherSettings.Controls.Add(this._browseUserDictionary); + this._panelOtherSettings.Controls.Add(this._userDictionary); + this._panelOtherSettings.Controls.Add(this.label9); + this._panelOtherSettings.Controls.Add(this.label10); + this._panelOtherSettings.Dock = System.Windows.Forms.DockStyle.Fill; + this._panelOtherSettings.ForeColor = System.Drawing.Color.Black; + this._panelOtherSettings.Location = new System.Drawing.Point(0, 0); + this._panelOtherSettings.Name = "_panelOtherSettings"; + // + // + // + this._panelOtherSettings.RootGroup.Items.AddRange(new DevComponents.DotNetBar.Layout.LayoutItemBase[] { + this.layoutControlItem24, + this.layoutControlItem25, + this.layoutControlItem26, + this._layoutTelemetryPolicy, + this.layoutControlItem27, + this._layoutHelpPolicy}); + this._panelOtherSettings.Size = new System.Drawing.Size(745, 484); + this._panelOtherSettings.TabIndex = 0; + // + // _disableHelp + // + this._disableHelp.AutoSize = true; + this._disableHelp.Location = new System.Drawing.Point(4, 64); + this._disableHelp.Margin = new System.Windows.Forms.Padding(0); + this._disableHelp.Name = "_disableHelp"; + this._disableHelp.Size = new System.Drawing.Size(646, 21); + this._disableHelp.TabIndex = 4; + this._disableHelp.Text = "Disable Help and Troubleshooting pages (requires restart)"; + this._tooltip.SetToolTip(this._disableHelp, resources.GetString("_disableHelp.ToolTip")); + this._disableHelp.UseVisualStyleBackColor = true; + // + // _disableTelemetry + // + this._disableTelemetry.AutoSize = true; + this._disableTelemetry.Location = new System.Drawing.Point(4, 35); + this._disableTelemetry.Margin = new System.Windows.Forms.Padding(0); + this._disableTelemetry.Name = "_disableTelemetry"; + this._disableTelemetry.Size = new System.Drawing.Size(646, 21); + this._disableTelemetry.TabIndex = 2; + this._disableTelemetry.Text = "Disable Telemetry (requires restart)"; + this._disableTelemetry.UseVisualStyleBackColor = true; + this._disableTelemetry.CheckedChanged += new System.EventHandler(this._disableTelemetry_CheckedChanged); + // + // _browseUserDictionary + // + this._browseUserDictionary.Location = new System.Drawing.Point(666, 4); + this._browseUserDictionary.Margin = new System.Windows.Forms.Padding(0); + this._browseUserDictionary.Name = "_browseUserDictionary"; + this._browseUserDictionary.Size = new System.Drawing.Size(75, 23); + this._browseUserDictionary.TabIndex = 1; + this._browseUserDictionary.Text = "Browse"; + this._browseUserDictionary.UseVisualStyleBackColor = true; + this._browseUserDictionary.Click += new System.EventHandler(this._browseUserDictionary_Click); + // + // _userDictionary + // + this._userDictionary.Location = new System.Drawing.Point(89, 4); + this._userDictionary.Margin = new System.Windows.Forms.Padding(0); + this._userDictionary.Name = "_userDictionary"; + this._userDictionary.ReadOnly = true; + this._userDictionary.Size = new System.Drawing.Size(569, 20); + this._userDictionary.TabIndex = 0; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.ForeColor = System.Drawing.Color.Red; + this.label9.Location = new System.Drawing.Point(658, 35); + this.label9.Margin = new System.Windows.Forms.Padding(0); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(83, 21); + this.label9.TabIndex = 3; + this.label9.Text = "Policy Applied"; + this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // layoutControlItem24 + // + this.layoutControlItem24.Control = this._userDictionary; + this.layoutControlItem24.Height = 28; + this.layoutControlItem24.MinSize = new System.Drawing.Size(120, 0); + this.layoutControlItem24.Name = "layoutControlItem24"; + this.layoutControlItem24.Text = "User Dictionary"; + this.layoutControlItem24.Width = 99; + this.layoutControlItem24.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // layoutControlItem25 + // + this.layoutControlItem25.Control = this._browseUserDictionary; + this.layoutControlItem25.Height = 31; + this.layoutControlItem25.MinSize = new System.Drawing.Size(32, 20); + this.layoutControlItem25.Name = "layoutControlItem25"; + this.layoutControlItem25.Width = 83; + // + // layoutControlItem26 + // + this.layoutControlItem26.Control = this._disableTelemetry; + this.layoutControlItem26.Height = 25; + this.layoutControlItem26.MinSize = new System.Drawing.Size(32, 20); + this.layoutControlItem26.Name = "layoutControlItem26"; + this.layoutControlItem26.Width = 99; + this.layoutControlItem26.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // + // _layoutTelemetryPolicy + // + this._layoutTelemetryPolicy.Control = this.label9; + this._layoutTelemetryPolicy.Height = 29; + this._layoutTelemetryPolicy.MinSize = new System.Drawing.Size(64, 18); + this._layoutTelemetryPolicy.Name = "_layoutTelemetryPolicy"; + this._layoutTelemetryPolicy.Text = "Label:"; + this._layoutTelemetryPolicy.TextVisible = false; + this._layoutTelemetryPolicy.Visible = false; + this._layoutTelemetryPolicy.Width = 91; + // + // layoutControlItem27 + // + this.layoutControlItem27.Control = this._disableHelp; + this.layoutControlItem27.Height = 25; + this.layoutControlItem27.MinSize = new System.Drawing.Size(32, 20); + this.layoutControlItem27.Name = "layoutControlItem27"; + this.layoutControlItem27.Width = 99; + this.layoutControlItem27.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; + // // _panelExtensions // this._panelExtensions.Controls.Add(this._layoutExtensions); this._panelExtensions.Dock = System.Windows.Forms.DockStyle.Fill; - this._panelExtensions.Location = new System.Drawing.Point(118, 31); + this._panelExtensions.Location = new System.Drawing.Point(122, 31); this._panelExtensions.Name = "_panelExtensions"; - this._panelExtensions.Size = new System.Drawing.Size(749, 484); + this._panelExtensions.Size = new System.Drawing.Size(745, 484); this._panelExtensions.TabIndex = 24; // // _layoutExtensions // this._layoutExtensions.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this._layoutExtensions.Controls.Add(this.label5); this._layoutExtensions.Controls.Add(this._executionMode); this._layoutExtensions.Controls.Add(this._addStandardCertificate); this._layoutExtensions.Controls.Add(this._addStandardPrefix); @@ -169,6 +321,9 @@ private void InitializeComponent() this._layoutExtensions.Controls.Add(this._removeCertificate); this._layoutExtensions.Controls.Add(this.label3); this._layoutExtensions.Controls.Add(this._addStandardFolder); + this._layoutExtensions.Controls.Add(this.label6); + this._layoutExtensions.Controls.Add(this.label7); + this._layoutExtensions.Controls.Add(this.label8); this._layoutExtensions.Dock = System.Windows.Forms.DockStyle.Fill; this._layoutExtensions.ForeColor = System.Drawing.Color.Black; this._layoutExtensions.Location = new System.Drawing.Point(0, 0); @@ -187,10 +342,23 @@ private void InitializeComponent() this.layoutControlItem10, this.layoutGroup3, this.layoutControlItem28, + this._layoutExecutionModePolicy, this.layoutControlItem13}); - this._layoutExtensions.Size = new System.Drawing.Size(749, 484); + this._layoutExtensions.Size = new System.Drawing.Size(745, 484); this._layoutExtensions.TabIndex = 0; // + // label5 + // + this.label5.AutoSize = true; + this.label5.ForeColor = System.Drawing.Color.Red; + this.label5.Location = new System.Drawing.Point(659, 97); + this.label5.Margin = new System.Windows.Forms.Padding(0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(81, 21); + this.label5.TabIndex = 4; + this.label5.Text = "Policy Applied"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // _executionMode // this._executionMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -198,18 +366,18 @@ private void InitializeComponent() this._executionMode.Location = new System.Drawing.Point(104, 429); this._executionMode.Margin = new System.Windows.Forms.Padding(0); this._executionMode.Name = "_executionMode"; - this._executionMode.Size = new System.Drawing.Size(641, 21); - this._executionMode.TabIndex = 18; + this._executionMode.Size = new System.Drawing.Size(546, 21); + this._executionMode.TabIndex = 21; this._executionMode.SelectedIndexChanged += new System.EventHandler(this._executionMode_SelectedIndexChanged); // // _addStandardCertificate // this._addStandardCertificate.Enabled = false; - this._addStandardCertificate.Location = new System.Drawing.Point(667, 346); + this._addStandardCertificate.Location = new System.Drawing.Point(663, 346); this._addStandardCertificate.Margin = new System.Windows.Forms.Padding(0); this._addStandardCertificate.Name = "_addStandardCertificate"; this._addStandardCertificate.Size = new System.Drawing.Size(75, 23); - this._addStandardCertificate.TabIndex = 15; + this._addStandardCertificate.TabIndex = 17; this._addStandardCertificate.Text = "Add Default"; this._addStandardCertificate.UseVisualStyleBackColor = true; this._addStandardCertificate.Click += new System.EventHandler(this._addStandardCertificate_Click); @@ -217,11 +385,11 @@ private void InitializeComponent() // _addStandardPrefix // this._addStandardPrefix.Enabled = false; - this._addStandardPrefix.Location = new System.Drawing.Point(667, 203); + this._addStandardPrefix.Location = new System.Drawing.Point(663, 203); this._addStandardPrefix.Margin = new System.Windows.Forms.Padding(0); this._addStandardPrefix.Name = "_addStandardPrefix"; this._addStandardPrefix.Size = new System.Drawing.Size(75, 23); - this._addStandardPrefix.TabIndex = 9; + this._addStandardPrefix.TabIndex = 10; this._addStandardPrefix.Text = "Add Default"; this._addStandardPrefix.UseVisualStyleBackColor = true; this._addStandardPrefix.Click += new System.EventHandler(this._addStandardPrefix_Click); @@ -235,12 +403,12 @@ private void InitializeComponent() this._folders.Margin = new System.Windows.Forms.Padding(0); this._folders.Name = "_folders"; this._folders.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this._folders.Size = new System.Drawing.Size(551, 108); + this._folders.Size = new System.Drawing.Size(547, 108); this._folders.TabIndex = 0; // // _removeFolder // - this._removeFolder.Location = new System.Drawing.Point(667, 70); + this._removeFolder.Location = new System.Drawing.Point(663, 70); this._removeFolder.Margin = new System.Windows.Forms.Padding(0); this._removeFolder.Name = "_removeFolder"; this._removeFolder.Size = new System.Drawing.Size(75, 23); @@ -251,7 +419,7 @@ private void InitializeComponent() // // _addFolder // - this._addFolder.Location = new System.Drawing.Point(667, 8); + this._addFolder.Location = new System.Drawing.Point(663, 8); this._addFolder.Margin = new System.Windows.Forms.Padding(0); this._addFolder.Name = "_addFolder"; this._addFolder.Size = new System.Drawing.Size(75, 23); @@ -267,8 +435,8 @@ private void InitializeComponent() this.label2.Location = new System.Drawing.Point(4, 122); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(741, 13); - this.label2.TabIndex = 5; + this.label2.Size = new System.Drawing.Size(737, 13); + this.label2.TabIndex = 6; this.label2.Text = "Validation Rules"; // // _validationPrefix @@ -278,8 +446,8 @@ private void InitializeComponent() this._validationPrefix.Location = new System.Drawing.Point(4, 143); this._validationPrefix.Margin = new System.Windows.Forms.Padding(0); this._validationPrefix.Name = "_validationPrefix"; - this._validationPrefix.Size = new System.Drawing.Size(741, 17); - this._validationPrefix.TabIndex = 6; + this._validationPrefix.Size = new System.Drawing.Size(737, 17); + this._validationPrefix.TabIndex = 7; this._validationPrefix.Text = "Assembly must start with one of those prefixes"; this._validationPrefix.UseVisualStyleBackColor = false; this._validationPrefix.CheckedChanged += new System.EventHandler(this._validationPrefix_CheckedChanged); @@ -294,17 +462,17 @@ private void InitializeComponent() this._prefixes.Margin = new System.Windows.Forms.Padding(0); this._prefixes.Name = "_prefixes"; this._prefixes.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this._prefixes.Size = new System.Drawing.Size(630, 108); - this._prefixes.TabIndex = 7; + this._prefixes.Size = new System.Drawing.Size(626, 108); + this._prefixes.TabIndex = 8; // // _addPrefix // this._addPrefix.Enabled = false; - this._addPrefix.Location = new System.Drawing.Point(667, 172); + this._addPrefix.Location = new System.Drawing.Point(663, 172); this._addPrefix.Margin = new System.Windows.Forms.Padding(0); this._addPrefix.Name = "_addPrefix"; this._addPrefix.Size = new System.Drawing.Size(75, 23); - this._addPrefix.TabIndex = 8; + this._addPrefix.TabIndex = 9; this._addPrefix.Text = "Add"; this._addPrefix.UseVisualStyleBackColor = true; this._addPrefix.Click += new System.EventHandler(this._addPrefix_Click); @@ -312,11 +480,11 @@ private void InitializeComponent() // _removePrefix // this._removePrefix.Enabled = false; - this._removePrefix.Location = new System.Drawing.Point(667, 234); + this._removePrefix.Location = new System.Drawing.Point(663, 234); this._removePrefix.Margin = new System.Windows.Forms.Padding(0); this._removePrefix.Name = "_removePrefix"; this._removePrefix.Size = new System.Drawing.Size(75, 23); - this._removePrefix.TabIndex = 10; + this._removePrefix.TabIndex = 11; this._removePrefix.Text = "Remove"; this._removePrefix.UseVisualStyleBackColor = true; this._removePrefix.Click += new System.EventHandler(this._removePrefix_Click); @@ -328,8 +496,8 @@ private void InitializeComponent() this._validationCertificates.Location = new System.Drawing.Point(4, 286); this._validationCertificates.Margin = new System.Windows.Forms.Padding(0); this._validationCertificates.Name = "_validationCertificates"; - this._validationCertificates.Size = new System.Drawing.Size(741, 17); - this._validationCertificates.TabIndex = 12; + this._validationCertificates.Size = new System.Drawing.Size(737, 17); + this._validationCertificates.TabIndex = 14; this._validationCertificates.Text = "Assembly must be signed with one of those certificates"; this._validationCertificates.UseVisualStyleBackColor = false; this._validationCertificates.CheckedChanged += new System.EventHandler(this._validationCertificates_CheckedChanged); @@ -344,17 +512,17 @@ private void InitializeComponent() this._certificates.Margin = new System.Windows.Forms.Padding(0); this._certificates.Name = "_certificates"; this._certificates.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this._certificates.Size = new System.Drawing.Size(630, 108); - this._certificates.TabIndex = 13; + this._certificates.Size = new System.Drawing.Size(626, 108); + this._certificates.TabIndex = 15; // // _addCertificate // this._addCertificate.Enabled = false; - this._addCertificate.Location = new System.Drawing.Point(667, 315); + this._addCertificate.Location = new System.Drawing.Point(663, 315); this._addCertificate.Margin = new System.Windows.Forms.Padding(0); this._addCertificate.Name = "_addCertificate"; this._addCertificate.Size = new System.Drawing.Size(75, 23); - this._addCertificate.TabIndex = 14; + this._addCertificate.TabIndex = 16; this._addCertificate.Text = "Add"; this._addCertificate.UseVisualStyleBackColor = true; this._addCertificate.Click += new System.EventHandler(this._addCertificate_Click); @@ -362,11 +530,11 @@ private void InitializeComponent() // _removeCertificate // this._removeCertificate.Enabled = false; - this._removeCertificate.Location = new System.Drawing.Point(667, 377); + this._removeCertificate.Location = new System.Drawing.Point(663, 377); this._removeCertificate.Margin = new System.Windows.Forms.Padding(0); this._removeCertificate.Name = "_removeCertificate"; this._removeCertificate.Size = new System.Drawing.Size(75, 23); - this._removeCertificate.TabIndex = 16; + this._removeCertificate.TabIndex = 18; this._removeCertificate.Text = "Remove"; this._removeCertificate.UseVisualStyleBackColor = true; this._removeCertificate.Click += new System.EventHandler(this._removeCertificate_Click); @@ -379,14 +547,14 @@ private void InitializeComponent() this.label3.Location = new System.Drawing.Point(4, 458); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(741, 16); - this.label3.TabIndex = 19; + this.label3.Size = new System.Drawing.Size(737, 16); + this.label3.TabIndex = 23; this.label3.Text = "Please note that the changes to the Extensions configuration will be applied only" + " after a restart of Threats Manager Studio."; // // _addStandardFolder // - this._addStandardFolder.Location = new System.Drawing.Point(667, 39); + this._addStandardFolder.Location = new System.Drawing.Point(663, 39); this._addStandardFolder.Margin = new System.Windows.Forms.Padding(0); this._addStandardFolder.Name = "_addStandardFolder"; this._addStandardFolder.Size = new System.Drawing.Size(75, 23); @@ -395,6 +563,42 @@ private void InitializeComponent() this._addStandardFolder.UseVisualStyleBackColor = true; this._addStandardFolder.Click += new System.EventHandler(this._addStandardFolder_Click); // + // label6 + // + this.label6.AutoSize = true; + this.label6.ForeColor = System.Drawing.Color.Red; + this.label6.Location = new System.Drawing.Point(663, 265); + this.label6.Margin = new System.Windows.Forms.Padding(0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(73, 13); + this.label6.TabIndex = 12; + this.label6.Text = "Policy Applied"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.ForeColor = System.Drawing.Color.Red; + this.label7.Location = new System.Drawing.Point(663, 408); + this.label7.Margin = new System.Windows.Forms.Padding(0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(73, 13); + this.label7.TabIndex = 19; + this.label7.Text = "Policy Applied"; + this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.ForeColor = System.Drawing.Color.Red; + this.label8.Location = new System.Drawing.Point(658, 429); + this.label8.Margin = new System.Windows.Forms.Padding(0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(83, 21); + this.label8.TabIndex = 22; + this.label8.Text = "Policy Applied"; + this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // layoutControlItem1 // this.layoutControlItem1.Control = this._folders; @@ -413,7 +617,8 @@ private void InitializeComponent() this.layoutGroup1.Items.AddRange(new DevComponents.DotNetBar.Layout.LayoutItemBase[] { this.layoutControlItem3, this.layoutControlItem15, - this.layoutControlItem2}); + this.layoutControlItem2, + this._layoutFoldersPolicy}); this.layoutGroup1.MinSize = new System.Drawing.Size(90, 32); this.layoutGroup1.Name = "layoutGroup1"; this.layoutGroup1.TextPosition = DevComponents.DotNetBar.Layout.eLayoutPosition.Top; @@ -443,6 +648,18 @@ private void InitializeComponent() this.layoutControlItem2.Name = "layoutControlItem2"; this.layoutControlItem2.Width = 83; // + // _layoutFoldersPolicy + // + this._layoutFoldersPolicy.Control = this.label5; + this._layoutFoldersPolicy.Height = 21; + this._layoutFoldersPolicy.MinSize = new System.Drawing.Size(64, 18); + this._layoutFoldersPolicy.Name = "_layoutFoldersPolicy"; + this._layoutFoldersPolicy.Padding = new System.Windows.Forms.Padding(0); + this._layoutFoldersPolicy.Text = "Label:"; + this._layoutFoldersPolicy.TextVisible = false; + this._layoutFoldersPolicy.Visible = false; + this._layoutFoldersPolicy.Width = 81; + // // layoutControlItem4 // this.layoutControlItem4.Control = this.label2; @@ -482,7 +699,8 @@ private void InitializeComponent() this.layoutGroup2.Items.AddRange(new DevComponents.DotNetBar.Layout.LayoutItemBase[] { this.layoutControlItem7, this.layoutControlItem16, - this.layoutControlItem8}); + this.layoutControlItem8, + this._layoutPrefixesPolicy}); this.layoutGroup2.MinSize = new System.Drawing.Size(90, 32); this.layoutGroup2.Name = "layoutGroup2"; this.layoutGroup2.TextPosition = DevComponents.DotNetBar.Layout.eLayoutPosition.Top; @@ -512,6 +730,17 @@ private void InitializeComponent() this.layoutControlItem8.Name = "layoutControlItem8"; this.layoutControlItem8.Width = 83; // + // _layoutPrefixesPolicy + // + this._layoutPrefixesPolicy.Control = this.label6; + this._layoutPrefixesPolicy.Height = 21; + this._layoutPrefixesPolicy.MinSize = new System.Drawing.Size(64, 18); + this._layoutPrefixesPolicy.Name = "_layoutPrefixesPolicy"; + this._layoutPrefixesPolicy.Text = "Label:"; + this._layoutPrefixesPolicy.TextVisible = false; + this._layoutPrefixesPolicy.Visible = false; + this._layoutPrefixesPolicy.Width = 81; + // // layoutControlItem9 // this.layoutControlItem9.Control = this._validationCertificates; @@ -541,7 +770,8 @@ private void InitializeComponent() this.layoutGroup3.Items.AddRange(new DevComponents.DotNetBar.Layout.LayoutItemBase[] { this.layoutControlItem11, this.layoutControlItem17, - this.layoutControlItem12}); + this.layoutControlItem12, + this._layoutCertificatesPolicy}); this.layoutGroup3.MinSize = new System.Drawing.Size(90, 32); this.layoutGroup3.Name = "layoutGroup3"; this.layoutGroup3.TextPosition = DevComponents.DotNetBar.Layout.eLayoutPosition.Top; @@ -571,6 +801,17 @@ private void InitializeComponent() this.layoutControlItem12.Name = "layoutControlItem12"; this.layoutControlItem12.Width = 83; // + // _layoutCertificatesPolicy + // + this._layoutCertificatesPolicy.Control = this.label7; + this._layoutCertificatesPolicy.Height = 21; + this._layoutCertificatesPolicy.MinSize = new System.Drawing.Size(64, 18); + this._layoutCertificatesPolicy.Name = "_layoutCertificatesPolicy"; + this._layoutCertificatesPolicy.Text = "Label:"; + this._layoutCertificatesPolicy.TextVisible = false; + this._layoutCertificatesPolicy.Visible = false; + this._layoutCertificatesPolicy.Width = 81; + // // layoutControlItem28 // this.layoutControlItem28.Control = this._executionMode; @@ -578,9 +819,20 @@ private void InitializeComponent() this.layoutControlItem28.MinSize = new System.Drawing.Size(64, 18); this.layoutControlItem28.Name = "layoutControlItem28"; this.layoutControlItem28.Text = "Execution Mode"; - this.layoutControlItem28.Width = 100; + this.layoutControlItem28.Width = 99; this.layoutControlItem28.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; // + // _layoutExecutionModePolicy + // + this._layoutExecutionModePolicy.Control = this.label8; + this._layoutExecutionModePolicy.Height = 21; + this._layoutExecutionModePolicy.MinSize = new System.Drawing.Size(64, 18); + this._layoutExecutionModePolicy.Name = "_layoutExecutionModePolicy"; + this._layoutExecutionModePolicy.Text = "Label:"; + this._layoutExecutionModePolicy.TextVisible = false; + this._layoutExecutionModePolicy.Visible = false; + this._layoutExecutionModePolicy.Width = 91; + // // layoutControlItem13 // this.layoutControlItem13.Control = this.label3; @@ -592,118 +844,6 @@ private void InitializeComponent() this.layoutControlItem13.Width = 100; this.layoutControlItem13.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; // - // sideNavPanel1 - // - this.sideNavPanel1.Controls.Add(this._panelOtherSettings); - this.sideNavPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.sideNavPanel1.Location = new System.Drawing.Point(118, 31); - this.sideNavPanel1.Name = "sideNavPanel1"; - this.sideNavPanel1.Size = new System.Drawing.Size(749, 484); - this.sideNavPanel1.TabIndex = 32; - this.sideNavPanel1.Visible = false; - // - // _panelOtherSettings - // - this._panelOtherSettings.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this._panelOtherSettings.Controls.Add(this._disableHelp); - this._panelOtherSettings.Controls.Add(this._disableTelemetry); - this._panelOtherSettings.Controls.Add(this._browseUserDictionary); - this._panelOtherSettings.Controls.Add(this._userDictionary); - this._panelOtherSettings.Dock = System.Windows.Forms.DockStyle.Fill; - this._panelOtherSettings.ForeColor = System.Drawing.Color.Black; - this._panelOtherSettings.Location = new System.Drawing.Point(0, 0); - this._panelOtherSettings.Name = "_panelOtherSettings"; - // - // - // - this._panelOtherSettings.RootGroup.Items.AddRange(new DevComponents.DotNetBar.Layout.LayoutItemBase[] { - this.layoutControlItem24, - this.layoutControlItem25, - this.layoutControlItem26, - this.layoutControlItem27}); - this._panelOtherSettings.Size = new System.Drawing.Size(749, 484); - this._panelOtherSettings.TabIndex = 0; - // - // _disableHelp - // - this._disableHelp.AutoSize = true; - this._disableHelp.Location = new System.Drawing.Point(4, 60); - this._disableHelp.Margin = new System.Windows.Forms.Padding(0); - this._disableHelp.Name = "_disableHelp"; - this._disableHelp.Size = new System.Drawing.Size(741, 17); - this._disableHelp.TabIndex = 3; - this._disableHelp.Text = "Disable Help and Troubleshooting pages (requires restart)"; - this._tooltip.SetToolTip(this._disableHelp, resources.GetString("_disableHelp.ToolTip")); - this._disableHelp.UseVisualStyleBackColor = true; - // - // _disableTelemetry - // - this._disableTelemetry.AutoSize = true; - this._disableTelemetry.Location = new System.Drawing.Point(4, 35); - this._disableTelemetry.Margin = new System.Windows.Forms.Padding(0); - this._disableTelemetry.Name = "_disableTelemetry"; - this._disableTelemetry.Size = new System.Drawing.Size(741, 17); - this._disableTelemetry.TabIndex = 2; - this._disableTelemetry.Text = "Disable Telemetry (requires restart)"; - this._disableTelemetry.UseVisualStyleBackColor = true; - this._disableTelemetry.CheckedChanged += new System.EventHandler(this._disableTelemetry_CheckedChanged); - // - // _browseUserDictionary - // - this._browseUserDictionary.Location = new System.Drawing.Point(670, 4); - this._browseUserDictionary.Margin = new System.Windows.Forms.Padding(0); - this._browseUserDictionary.Name = "_browseUserDictionary"; - this._browseUserDictionary.Size = new System.Drawing.Size(75, 23); - this._browseUserDictionary.TabIndex = 1; - this._browseUserDictionary.Text = "Browse"; - this._browseUserDictionary.UseVisualStyleBackColor = true; - this._browseUserDictionary.Click += new System.EventHandler(this._browseUserDictionary_Click); - // - // _userDictionary - // - this._userDictionary.Location = new System.Drawing.Point(89, 4); - this._userDictionary.Margin = new System.Windows.Forms.Padding(0); - this._userDictionary.Name = "_userDictionary"; - this._userDictionary.ReadOnly = true; - this._userDictionary.Size = new System.Drawing.Size(573, 20); - this._userDictionary.TabIndex = 0; - // - // layoutControlItem24 - // - this.layoutControlItem24.Control = this._userDictionary; - this.layoutControlItem24.Height = 28; - this.layoutControlItem24.MinSize = new System.Drawing.Size(120, 0); - this.layoutControlItem24.Name = "layoutControlItem24"; - this.layoutControlItem24.Text = "User Dictionary"; - this.layoutControlItem24.Width = 99; - this.layoutControlItem24.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; - // - // layoutControlItem25 - // - this.layoutControlItem25.Control = this._browseUserDictionary; - this.layoutControlItem25.Height = 31; - this.layoutControlItem25.MinSize = new System.Drawing.Size(32, 20); - this.layoutControlItem25.Name = "layoutControlItem25"; - this.layoutControlItem25.Width = 83; - // - // layoutControlItem26 - // - this.layoutControlItem26.Control = this._disableTelemetry; - this.layoutControlItem26.Height = 25; - this.layoutControlItem26.MinSize = new System.Drawing.Size(32, 20); - this.layoutControlItem26.Name = "layoutControlItem26"; - this.layoutControlItem26.Width = 100; - this.layoutControlItem26.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; - // - // layoutControlItem27 - // - this.layoutControlItem27.Control = this._disableHelp; - this.layoutControlItem27.Height = 25; - this.layoutControlItem27.MinSize = new System.Drawing.Size(32, 20); - this.layoutControlItem27.Name = "layoutControlItem27"; - this.layoutControlItem27.Width = 100; - this.layoutControlItem27.WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent; - // // _panelSmartSave // this._panelSmartSave.Controls.Add(this._layoutSmartSave); @@ -955,8 +1095,31 @@ private void InitializeComponent() // this._userDictFile.DefaultExt = "txt"; this._userDictFile.Filter = "Text file (*.txt)|*.txt"; - this._userDictFile.Title = "User Dictionary File"; this._userDictFile.RestoreDirectory = true; + this._userDictFile.Title = "User Dictionary File"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.ForeColor = System.Drawing.Color.Red; + this.label10.Location = new System.Drawing.Point(658, 64); + this.label10.Margin = new System.Windows.Forms.Padding(0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(83, 21); + this.label10.TabIndex = 6; + this.label10.Text = "Policy Applied"; + this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // _layoutHelpPolicy + // + this._layoutHelpPolicy.Control = this.label10; + this._layoutHelpPolicy.Height = 29; + this._layoutHelpPolicy.MinSize = new System.Drawing.Size(64, 18); + this._layoutHelpPolicy.Name = "_layoutHelpPolicy"; + this._layoutHelpPolicy.Text = "Label:"; + this._layoutHelpPolicy.TextVisible = false; + this._layoutHelpPolicy.Visible = false; + this._layoutHelpPolicy.Width = 91; // // OptionsForm // @@ -975,16 +1138,16 @@ private void InitializeComponent() this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Options"; + this.Text = "Settings"; this.Load += new System.EventHandler(this.OptionsForm_Load); this._sideNav.ResumeLayout(false); this._sideNav.PerformLayout(); - this._panelExtensions.ResumeLayout(false); - this._layoutExtensions.ResumeLayout(false); - this._layoutExtensions.PerformLayout(); this.sideNavPanel1.ResumeLayout(false); this._panelOtherSettings.ResumeLayout(false); this._panelOtherSettings.PerformLayout(); + this._panelExtensions.ResumeLayout(false); + this._layoutExtensions.ResumeLayout(false); + this._layoutExtensions.PerformLayout(); this._panelSmartSave.ResumeLayout(false); this._layoutSmartSave.ResumeLayout(false); this._layoutSmartSave.PerformLayout(); @@ -1073,5 +1236,17 @@ private void InitializeComponent() private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem28; private System.Windows.Forms.CheckBox _disableHelp; private DevComponents.DotNetBar.Layout.LayoutControlItem layoutControlItem27; + private System.Windows.Forms.Label label5; + private DevComponents.DotNetBar.Layout.LayoutControlItem _layoutFoldersPolicy; + private System.Windows.Forms.Label label6; + private DevComponents.DotNetBar.Layout.LayoutControlItem _layoutPrefixesPolicy; + private System.Windows.Forms.Label label7; + private DevComponents.DotNetBar.Layout.LayoutControlItem _layoutCertificatesPolicy; + private System.Windows.Forms.Label label8; + private DevComponents.DotNetBar.Layout.LayoutControlItem _layoutExecutionModePolicy; + private System.Windows.Forms.Label label9; + private DevComponents.DotNetBar.Layout.LayoutControlItem _layoutTelemetryPolicy; + private System.Windows.Forms.Label label10; + private DevComponents.DotNetBar.Layout.LayoutControlItem _layoutHelpPolicy; } } \ No newline at end of file diff --git a/Studio/ThreatsManager/Dialogs/OptionsForm.cs b/Studio/ThreatsManager/Dialogs/OptionsForm.cs index ca27377d..1268ee72 100644 --- a/Studio/ThreatsManager/Dialogs/OptionsForm.cs +++ b/Studio/ThreatsManager/Dialogs/OptionsForm.cs @@ -8,11 +8,14 @@ using PostSharp.Patterns.Contracts; using ThreatsManager.Engine; using ThreatsManager.Engine.Config; +using ThreatsManager.Engine.Policies; using ThreatsManager.Interfaces; using ThreatsManager.Interfaces.Extensions.Panels; using ThreatsManager.Interfaces.ObjectModel; +using ThreatsManager.Policies; using ThreatsManager.Properties; using ThreatsManager.Utilities; +using ThreatsManager.Utilities.Policies; namespace ThreatsManager.Dialogs { @@ -31,6 +34,10 @@ public OptionsForm() if (folders?.Any() ?? false) _folders.Items.AddRange(folders); + var foldersPolicy = new FoldersPolicy(); + if (foldersPolicy.IsDefined) + _layoutFoldersPolicy.Visible = true; + var prefixes = Manager.Instance.Configuration.Prefixes?.ToArray(); if (prefixes?.Any() ?? false) { @@ -38,6 +45,14 @@ public OptionsForm() _validationPrefix.Checked = true; } + var prefixesPolicy = new PrefixesPolicy(); + if (prefixesPolicy.IsDefined) + { + _layoutPrefixesPolicy.Visible = true; + _validationPrefix.Checked = true; + _validationPrefix.Enabled = false; + } + var certificates = Manager.Instance.Configuration.Certificates?.ToArray(); if (certificates?.Any() ?? false) { @@ -45,23 +60,68 @@ public OptionsForm() _validationCertificates.Checked = true; } - var executionModes = EnumExtensions.GetEnumLabels()?.ToArray(); + var certificatesPolicy = new CertificatesPolicy(); + if (certificatesPolicy.IsDefined) + { + _layoutCertificatesPolicy.Visible = true; + _validationCertificates.Checked = true; + _validationCertificates.Enabled = false; + } + + var executionModePolicy = new MaxExecutionModePolicy(); + var maxExecutionMode = executionModePolicy.MaxExecutionMode ?? ExecutionMode.Pioneer; + if (executionModePolicy.IsDefined) + _layoutExecutionModePolicy.Visible = true; + var executionModes = Enum.GetValues(typeof(ExecutionMode)).Cast() + .Where(x => x >= maxExecutionMode) + .Select(x => EnumExtensions.GetEnumLabel(x)) + .ToArray(); if (executionModes?.Any() ?? false) _executionMode.Items.AddRange(executionModes); var config = ExtensionsConfigurationManager.GetConfigurationSection(); - _executionMode.SelectedItem = config.Mode.GetEnumLabel(); - _tooltip.SetToolTip(_executionMode, config.Mode.GetEnumDescription()); + if (!executionModePolicy.IsDefined || config.Mode < maxExecutionMode) + { + _executionMode.SelectedItem = maxExecutionMode.GetEnumLabel(); + _tooltip.SetToolTip(_executionMode, maxExecutionMode.GetEnumDescription()); + } + else + { + _executionMode.SelectedItem = config.Mode.GetEnumLabel(); + _tooltip.SetToolTip(_executionMode, config.Mode.GetEnumDescription()); + } _enableSmartSave.Checked = config.SmartSave; _smartSaveInstances.Value = config.SmartSaveCount; _smartSaveAutosave.Value = config.SmartSaveInterval; _userDictionary.Text = config.UserDictionary; - if ((Application.UserAppDataRegistry?.GetValue("Consent", false) is string consentString) && - bool.TryParse(consentString, out var consent)) - _disableTelemetry.Checked = !consent; - else + + var telemetryPolicy = new TelemetryPolicy(); + if (telemetryPolicy.IsDefined && !(telemetryPolicy.Telemetry ?? false)) + { _disableTelemetry.Checked = true; - _disableHelp.Checked = config.DisableHelp; + _disableTelemetry.Enabled = false; + _layoutTelemetryPolicy.Visible = true; + } + else + { + if ((Application.UserAppDataRegistry?.GetValue("Consent", false) is string consentString) && + bool.TryParse(consentString, out var consent)) + _disableTelemetry.Checked = !consent; + else + _disableTelemetry.Checked = true; + } + + var helpPolicy = new HelpTroubleshootPolicy(); + if (helpPolicy.IsDefined && !(helpPolicy.HelpTroubleshoot ?? false)) + { + _disableHelp.Checked = true; + _disableHelp.Enabled = false; + _layoutHelpPolicy.Visible = true; + } + else + { + _disableHelp.Checked = config.DisableHelp; + } _loading = false; } diff --git a/Studio/ThreatsManager/Dialogs/OptionsForm.resx b/Studio/ThreatsManager/Dialogs/OptionsForm.resx index e93a5856..0ad19a74 100644 --- a/Studio/ThreatsManager/Dialogs/OptionsForm.resx +++ b/Studio/ThreatsManager/Dialogs/OptionsForm.resx @@ -117,6 +117,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 453, 26 + + + Help and Troubleshooting requires to contact external systems to retrieve the indexes +and then to contact the documentation pages under https://threatsmanager.com. +Therefore, to avoid all contact with external systems, you have to disable both Telemetry +and Help and Troubleshooting. + Please select the interval in minutes for automatic saves. For example, if the number above is 3, then the file is automatically saved every 3 minutes, provided that there is a pending change to be saved. @@ -130,22 +139,10 @@ Each save will have the name of the original file, with suffix ending with "_YYY Please note that removal will consider only the files with name ending with the suffix. The original file without suffix will be replaced every time with the latest version. Smart Save operates only with the standard Save: Save As is not affected by it. - - - 453, 26 - - - Help and Troubleshooting requires to contact external systems to retrieve the indexes -and then to contact the documentation pages under https://threatsmanager.com. -Therefore, to avoid all contact with external systems, you have to disable both Telemetry -and Help and Troubleshooting. 256, 26 - - 453, 26 - 546, 26 diff --git a/Studio/ThreatsManager/MainForm.Designer.cs b/Studio/ThreatsManager/MainForm.Designer.cs index 2f48fde2..347978af 100644 --- a/Studio/ThreatsManager/MainForm.Designer.cs +++ b/Studio/ThreatsManager/MainForm.Designer.cs @@ -42,9 +42,9 @@ private void InitializeComponent() this._windows = new DevComponents.DotNetBar.ButtonItem(); this._closeWindows = new DevComponents.DotNetBar.ButtonItem(); this._closeWindow = new DevComponents.DotNetBar.ButtonItem(); + this._ribbonPanelAnalyze = new DevComponents.DotNetBar.RibbonPanel(); this._ribbonPanelKnowledgeBase = new DevComponents.DotNetBar.RibbonPanel(); this._ribbonPanelHome = new DevComponents.DotNetBar.RibbonPanel(); - this._ribbonPanelAnalyze = new DevComponents.DotNetBar.RibbonPanel(); this._fileButton = new DevComponents.DotNetBar.ApplicationButton(); this.itemContainer1 = new DevComponents.DotNetBar.ItemContainer(); this.itemContainer2 = new DevComponents.DotNetBar.ItemContainer(); @@ -101,6 +101,7 @@ private void InitializeComponent() // // this._ribbon.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this._ribbon.Controls.Add(this._ribbonPanelHome); this._ribbon.Controls.Add(this._ribbonPanelHelp); this._ribbon.Controls.Add(this._ribbonPanelConfigure); this._ribbon.Controls.Add(this._ribbonPanelReview); @@ -110,7 +111,6 @@ private void InitializeComponent() this._ribbon.Controls.Add(this._ribbonPanelView); this._ribbon.Controls.Add(this._ribbonPanelAnalyze); this._ribbon.Controls.Add(this._ribbonPanelKnowledgeBase); - this._ribbon.Controls.Add(this._ribbonPanelHome); this._ribbon.Dock = System.Windows.Forms.DockStyle.Top; this._ribbon.ForeColor = System.Drawing.Color.Black; this._ribbon.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] { @@ -183,6 +183,7 @@ private void InitializeComponent() // this._ribbonPanelHelp.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; this._ribbonPanelHelp.TabIndex = 10; + this._ribbonPanelHelp.Visible = false; // // _ribbonPanelConfigure // @@ -395,6 +396,29 @@ private void InitializeComponent() this._closeWindow.Text = "Close Window"; this._closeWindow.Click += new System.EventHandler(this._closeCurrentWindow_Click); // + // _ribbonPanelAnalyze + // + this._ribbonPanelAnalyze.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this._ribbonPanelAnalyze.Dock = System.Windows.Forms.DockStyle.Fill; + this._ribbonPanelAnalyze.Location = new System.Drawing.Point(0, 43); + this._ribbonPanelAnalyze.Name = "_ribbonPanelAnalyze"; + this._ribbonPanelAnalyze.Padding = new System.Windows.Forms.Padding(3, 0, 3, 2); + this._ribbonPanelAnalyze.Size = new System.Drawing.Size(1048, 97); + // + // + // + this._ribbonPanelAnalyze.Style.CornerType = DevComponents.DotNetBar.eCornerType.Square; + // + // + // + this._ribbonPanelAnalyze.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; + // + // + // + this._ribbonPanelAnalyze.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this._ribbonPanelAnalyze.TabIndex = 7; + this._ribbonPanelAnalyze.Visible = false; + // // _ribbonPanelKnowledgeBase // this._ribbonPanelKnowledgeBase.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; @@ -439,30 +463,6 @@ private void InitializeComponent() // this._ribbonPanelHome.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; this._ribbonPanelHome.TabIndex = 4; - this._ribbonPanelHome.Visible = false; - // - // _ribbonPanelAnalyze - // - this._ribbonPanelAnalyze.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; - this._ribbonPanelAnalyze.Dock = System.Windows.Forms.DockStyle.Fill; - this._ribbonPanelAnalyze.Location = new System.Drawing.Point(0, 43); - this._ribbonPanelAnalyze.Name = "_ribbonPanelAnalyze"; - this._ribbonPanelAnalyze.Padding = new System.Windows.Forms.Padding(3, 0, 3, 2); - this._ribbonPanelAnalyze.Size = new System.Drawing.Size(1048, 97); - // - // - // - this._ribbonPanelAnalyze.Style.CornerType = DevComponents.DotNetBar.eCornerType.Square; - // - // - // - this._ribbonPanelAnalyze.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; - // - // - // - this._ribbonPanelAnalyze.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this._ribbonPanelAnalyze.TabIndex = 7; - this._ribbonPanelAnalyze.Visible = false; // // _fileButton // @@ -694,6 +694,7 @@ private void InitializeComponent() // // _ribbonTabHome // + this._ribbonTabHome.Checked = true; this._ribbonTabHome.FixedSize = new System.Drawing.Size(50, 0); this._ribbonTabHome.Name = "_ribbonTabHome"; this._ribbonTabHome.Panel = this._ribbonPanelHome; @@ -766,7 +767,6 @@ private void InitializeComponent() // // _ribbonTabHelp // - this._ribbonTabHelp.Checked = true; this._ribbonTabHelp.FixedSize = new System.Drawing.Size(50, 0); this._ribbonTabHelp.Name = "_ribbonTabHelp"; this._ribbonTabHelp.Panel = this._ribbonPanelHelp; diff --git a/Studio/ThreatsManager/MainForm.cs b/Studio/ThreatsManager/MainForm.cs index 7086afdf..d5356372 100644 --- a/Studio/ThreatsManager/MainForm.cs +++ b/Studio/ThreatsManager/MainForm.cs @@ -24,6 +24,7 @@ using ThreatsManager.Interfaces; using ThreatsManager.Utilities.WinForms; using PostSharp.Patterns.Recording; +using ThreatsManager.Policies; namespace ThreatsManager { @@ -212,25 +213,34 @@ private void UndoRedoManager_DirtyChanged(bool obj) private void InitializeTelemetry() { bool disableTelemetry = true; - var consentString = Application.UserAppDataRegistry?.GetValue("Consent") as string; - if (consentString == null) + + var policy = new TelemetryPolicy(); + if (!policy.IsDefined) { - if (MessageBox.Show(this, Resources.ConsentMessage, - Resources.ConsentCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, - MessageBoxDefaultButton.Button2) == DialogResult.Yes) + var consentString = Application.UserAppDataRegistry?.GetValue("Consent") as string; + if (consentString == null) { - Application.UserAppDataRegistry?.SetValue("Consent", true); - disableTelemetry = false; + if (MessageBox.Show(this, Resources.ConsentMessage, + Resources.ConsentCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, + MessageBoxDefaultButton.Button2) == DialogResult.Yes) + { + Application.UserAppDataRegistry?.SetValue("Consent", true); + disableTelemetry = false; + } + else + { + Application.UserAppDataRegistry?.SetValue("Consent", false); + disableTelemetry = true; + } } - else + else if (bool.TryParse(consentString, out var consent)) { - Application.UserAppDataRegistry?.SetValue("Consent", false); - disableTelemetry = true; + disableTelemetry = !consent; } } - else if (bool.TryParse(consentString, out var consent)) + else { - disableTelemetry = !consent; + disableTelemetry = !(policy.Telemetry ?? false); } if (disableTelemetry) @@ -244,10 +254,10 @@ private void InitializeTelemetry() ExceptionlessClient.Default.Configuration.ReadFromAttributes(); #if LOGGING #pragma warning disable SecurityIntelliSenseCS // MS Security rules violation - var logFile = Path.Combine(Program.Folder, "tms_exceptionless.log"); + var logFile = Path.Combine(Program.Folder, "tms_exceptionless.log"); #pragma warning restore SecurityIntelliSenseCS // MS Security rules violation - ExceptionlessClient.Default.Configuration.UseFileLogger(logFile); + ExceptionlessClient.Default.Configuration.UseFileLogger(logFile); #endif ExceptionlessClient.Default.Register(false); ExceptionlessClient.Default.SubmittingEvent += OnSubmittingEvent; diff --git a/Studio/ThreatsManager/Policies/TelemetryPolicy.cs b/Studio/ThreatsManager/Policies/TelemetryPolicy.cs new file mode 100644 index 00000000..2eab7d20 --- /dev/null +++ b/Studio/ThreatsManager/Policies/TelemetryPolicy.cs @@ -0,0 +1,11 @@ +using ThreatsManager.Utilities; + +namespace ThreatsManager.Policies +{ + internal class TelemetryPolicy : Policy + { + protected override string PolicyName => "Telemetry"; + + public bool? Telemetry => BoolValue; + } +} diff --git a/Studio/ThreatsManager/Portable.config b/Studio/ThreatsManager/Portable.config index d7e683d1..b834992a 100644 --- a/Studio/ThreatsManager/Portable.config +++ b/Studio/ThreatsManager/Portable.config @@ -1,7 +1,7 @@  -
+
@@ -66,7 +66,7 @@ - + @@ -74,15 +74,15 @@ - + - + - + diff --git a/Studio/ThreatsManager/Properties/Resources.Designer.cs b/Studio/ThreatsManager/Properties/Resources.Designer.cs index 4d250cac..21a1ec9a 100644 --- a/Studio/ThreatsManager/Properties/Resources.Designer.cs +++ b/Studio/ThreatsManager/Properties/Resources.Designer.cs @@ -643,6 +643,16 @@ internal static string ThirdParties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThreatModeling { + get { + object obj = ResourceManager.GetObject("ThreatModeling", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized string similar to Threats Manager Studio. /// diff --git a/Studio/ThreatsManager/Properties/Resources.resx b/Studio/ThreatsManager/Properties/Resources.resx index 90d2eab1..30689bc4 100644 --- a/Studio/ThreatsManager/Properties/Resources.resx +++ b/Studio/ThreatsManager/Properties/Resources.resx @@ -145,9 +145,6 @@ You can change your mind at any time, by change the related setting in the Setti Edit Exiting Component - - ..\Resources\Background.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\door_exit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -485,4 +482,10 @@ and this is even more true for constructive criticism. ..\Resources\control_panel_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Background.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ThreatModeling.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Studio/ThreatsManager/SolutionInfo.cs b/Studio/ThreatsManager/SolutionInfo.cs index 10dbae4a..4c302527 100644 --- a/Studio/ThreatsManager/SolutionInfo.cs +++ b/Studio/ThreatsManager/SolutionInfo.cs @@ -18,5 +18,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.1.0")] -[assembly: AssemblyFileVersion("2.1.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.1.2.0")] \ No newline at end of file diff --git a/Studio/ThreatsManager/ThreatsManager.csproj b/Studio/ThreatsManager/ThreatsManager.csproj index 1bf3dd6e..e1e4fd8b 100644 --- a/Studio/ThreatsManager/ThreatsManager.csproj +++ b/Studio/ThreatsManager/ThreatsManager.csproj @@ -312,6 +312,7 @@ Form + @@ -410,6 +411,7 @@ +