Skip to content

Commit 5e0dd01

Browse files
DYN-9862 UnTrusted Paths Notifications (#16752)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c70e506 commit 5e0dd01

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

src/Notifications/NotificationsViewExtension.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Dynamo.ViewModels;
1010
using Dynamo.Wpf.Extensions;
1111
using Dynamo.Utilities;
12+
using System.IO;
1213

1314
namespace Dynamo.Notifications
1415
{
@@ -112,6 +113,28 @@ public void Loaded(ViewLoadedParams viewStartupParams)
112113
viewStartupParams.dynamoMenu.Items.Add(notificationsMenuItem.MenuItem);
113114

114115
LoadNotificationCenter();
116+
117+
//If TrustedLocations contain paths pointing to ProgramData, log a warning notification.
118+
string programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
119+
var unsafeLocations = new System.Collections.Generic.List<string>();
120+
foreach (var location in viewModel.Model.PreferenceSettings.TrustedLocations)
121+
{
122+
var fullChildPath = Path.GetFullPath(location);
123+
if (fullChildPath.StartsWith(programDataPath, StringComparison.OrdinalIgnoreCase))
124+
{
125+
unsafeLocations.Add(location);
126+
}
127+
}
128+
if (unsafeLocations.Count > 0)
129+
{
130+
foreach (var unsafePath in unsafeLocations)
131+
{
132+
string detail = Properties.Resources.UnsafePathDetectedDetail + "\n" + unsafePath;
133+
Notifications.Add(new NotificationMessage("Preference Settings", Properties.Resources.UnsafePathDetectedTitle, detail));
134+
}
135+
136+
notificationsMenuItem.NotificationsChangeHandler.Invoke(this, null);
137+
}
115138
}
116139

117140
private void LoadNotificationCenter()

src/Notifications/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Notifications/Properties/Resources.en-US.resx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -150,4 +150,10 @@
150150
<data name="NotificationsCenterTitle" xml:space="preserve">
151151
<value>Notifications</value>
152152
</data>
153+
<data name="UnsafePathDetectedDetail" xml:space="preserve">
154+
<value>An unsafe path has been detected in Trusted Locations:</value>
155+
</data>
156+
<data name="UnsafePathDetectedTitle" xml:space="preserve">
157+
<value>Unsafe path detected</value>
158+
</data>
153159
</root>

src/Notifications/Properties/Resources.resx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -135,6 +135,12 @@
135135
<data name="ExtensionName" xml:space="preserve">
136136
<value>Notifications</value>
137137
</data>
138+
<data name="NoNotificationsMsg" xml:space="preserve">
139+
<value>You currently have no notifications. New notifications will appear above</value>
140+
</data>
141+
<data name="NoNotificationsTitle" xml:space="preserve">
142+
<value>No notifications</value>
143+
</data>
138144
<data name="NotificationCenterDisabledMsg" xml:space="preserve">
139145
<value>Notification Center feature is disabled. Enable it in preference panel to see latest news.</value>
140146
</data>
@@ -144,4 +150,10 @@
144150
<data name="NotificationsCenterTitle" xml:space="preserve">
145151
<value>Notifications</value>
146152
</data>
153+
<data name="UnsafePathDetectedDetail" xml:space="preserve">
154+
<value>An unsafe path has been detected in Trusted Locations:</value>
155+
</data>
156+
<data name="UnsafePathDetectedTitle" xml:space="preserve">
157+
<value>Unsafe path detected</value>
158+
</data>
147159
</root>

0 commit comments

Comments
 (0)