diff --git a/src/Notifications/NotificationsViewExtension.cs b/src/Notifications/NotificationsViewExtension.cs index d3e19b5b0ce..743375dd92c 100644 --- a/src/Notifications/NotificationsViewExtension.cs +++ b/src/Notifications/NotificationsViewExtension.cs @@ -9,6 +9,7 @@ using Dynamo.ViewModels; using Dynamo.Wpf.Extensions; using Dynamo.Utilities; +using System.IO; namespace Dynamo.Notifications { @@ -112,6 +113,28 @@ public void Loaded(ViewLoadedParams viewStartupParams) viewStartupParams.dynamoMenu.Items.Add(notificationsMenuItem.MenuItem); LoadNotificationCenter(); + + //If TrustedLocations contain paths pointing to ProgramData, log a warning notification. + string programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); + var unsafeLocations = new System.Collections.Generic.List(); + foreach (var location in viewModel.Model.PreferenceSettings.TrustedLocations) + { + var fullChildPath = Path.GetFullPath(location); + if (fullChildPath.StartsWith(programDataPath, StringComparison.OrdinalIgnoreCase)) + { + unsafeLocations.Add(location); + } + } + if (unsafeLocations.Count > 0) + { + foreach (var unsafePath in unsafeLocations) + { + string detail = Properties.Resources.UnsafePathDetectedDetail + "\n" + unsafePath; + Notifications.Add(new NotificationMessage("Preference Settings", Properties.Resources.UnsafePathDetectedTitle, detail)); + } + + notificationsMenuItem.NotificationsChangeHandler.Invoke(this, null); + } } private void LoadNotificationCenter() diff --git a/src/Notifications/Properties/Resources.Designer.cs b/src/Notifications/Properties/Resources.Designer.cs index ce76085d545..368d75a36c5 100644 --- a/src/Notifications/Properties/Resources.Designer.cs +++ b/src/Notifications/Properties/Resources.Designer.cs @@ -158,5 +158,23 @@ public static string NotificationsCenterTitle { return ResourceManager.GetString("NotificationsCenterTitle", resourceCulture); } } + + /// + /// Looks up a localized string similar to An unsafe path has been detected in Trusted Locations:. + /// + public static string UnsafePathDetectedDetail { + get { + return ResourceManager.GetString("UnsafePathDetectedDetail", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unsafe path detected. + /// + public static string UnsafePathDetectedTitle { + get { + return ResourceManager.GetString("UnsafePathDetectedTitle", resourceCulture); + } + } } } diff --git a/src/Notifications/Properties/Resources.en-US.resx b/src/Notifications/Properties/Resources.en-US.resx index 54c101db48b..3e878e0a490 100644 --- a/src/Notifications/Properties/Resources.en-US.resx +++ b/src/Notifications/Properties/Resources.en-US.resx @@ -1,4 +1,4 @@ - +